# Be careful with these as they get removed on shutdown too!
- type: entity
  id: AiHeld
  description: Components added / removed from an entity that gets inserted into an AI core.
  categories: [ HideSpawnMenu ]
  components:
  - type: IntrinsicRadioReceiver
  - type: IntrinsicRadioTransmitter
    channels:
    - Binary
    - Common
    - Command
    - Engineering
    - Medical
    - Science
    - Security
    - Service
    - Supply
  - type: ActiveRadio
    channels:
    - Binary
    - Common
    - Command
    - Engineering
    - Medical
    - Science
    - Security
    - Service
    - Supply
  - type: IgnoreUIRange
  - type: StationAiHeld
  - type: StationAiOverlay
  - type: ShowElectrocutionHUD
  - type: ActionGrant
    actions:
    - ActionJumpToCore
    - ActionSurvCameraLights
    - ActionAIViewLaws
  - type: UserInterface
    interfaces:
      enum.RadarConsoleUiKey.Key:
        type: RadarConsoleBoundUserInterface
      enum.CrewMonitoringUIKey.Key:
        type: CrewMonitoringBoundUserInterface
      enum.GeneralStationRecordConsoleKey.Key:
        type: GeneralStationRecordConsoleBoundUserInterface
      enum.SiliconLawsUiKey.Key:
        type: SiliconLawBoundUserInterface
      enum.CommunicationsConsoleUiKey.Key:
        type: CommunicationsConsoleBoundUserInterface
  - type: IntrinsicUI
    uis:
      enum.RadarConsoleUiKey.Key:
        toggleAction: ActionAGhostShowRadar
      enum.CrewMonitoringUIKey.Key:
        toggleAction: ActionAGhostShowCrewMonitoring
      enum.GeneralStationRecordConsoleKey.Key:
        toggleAction: ActionAGhostShowStationRecords
      enum.CommunicationsConsoleUiKey.Key:
        toggleAction: ActionAGhostShowCommunications
  - type: CrewMonitoringConsole
  - type: GeneralStationRecordConsole
  - type: DeviceNetwork
    deviceNetId: Wireless
    receiveFrequencyId: CrewMonitor
    transmitFrequencyId: ShuttleTimer
  - type: RadarConsole
    followEntity: false
  - type: CommunicationsConsole
    canShuttle: false
    title: comms-console-announcement-title-station-ai
    color: "#5ed7aa"
  - type: ShowJobIcons

- type: entity
  id: AiHeldIntellicard
  description: Components added / removed from an entity that gets inserted into an Intellicard.
  categories: [ HideSpawnMenu ]
  components:
  - type: IntrinsicRadioReceiver
  - type: IntrinsicRadioTransmitter
    channels:
    - Binary
  - type: ActiveRadio
    channels:
    - Binary
    - Common
  - type: ActionGrant
    actions:
    - ActionAIViewLaws
  - type: UserInterface
    interfaces:
      enum.SiliconLawsUiKey.Key:
        type: SiliconLawBoundUserInterface
  - type: ShowJobIcons

# Ai
- type: entity
  id: AiHolder
  abstract: true
  description: Handles AI interactions across holocards + AI cores
  components:
  - type: ItemSlots
  - type: Tag
    tags:
    - GhostOnlyWarp
  - type: StationAiHolder
    slot:
      name: station-ai-mind-slot
      locked: false
      disableEject: true
      whitelist:
        tags:
        - StationAi
  - type: ContainerContainer
    containers:
      station_ai_mind_slot: !type:ContainerSlot
        # Load-bearing.
        # The issue is verbs check for same transparent container.
        # The alternative is you add a bunch of events trying to override it; we don't even really need the container functionality
        # anyway it's just a quality of life thing.
        showEnts: True

# Items
- type: entity
  id: Intellicard
  name: intellicard
  description: A storage device for AIs.
  parent:
  - BaseItem
  - AiHolder
  suffix: Empty
  components:
  - type: ContainerComp
    proto: AiHeldIntellicard
    container: station_ai_mind_slot
  - type: Sprite
    sprite: Objects/Devices/ai_card.rsi
    layers:
    - state: base
    - state: full
      map: ["unshaded"]
      shader: unshaded
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.StationAiVisualState.Key:
        unshaded:
          Empty: { state: empty }
          Occupied: { state: full }
  - type: Intellicard

- type: entity
  id: PlayerStationAiPreview
  categories: [ HideSpawnMenu ]
  components:
  - type: Sprite
    sprite: Mobs/Silicon/station_ai.rsi
    layers:
    - state: base
    - state: ai
      shader: unshaded

- type: entity
  id: PlayerStationAiEmpty
  name: AI Core
  description: The latest in Artificial Intelligences.
  parent:
  - BaseStructure
  - AiHolder
  suffix: Empty
  components:
  - type: Anchorable
    flags: 
    - Anchorable
  - type: Rotatable
  - type: WarpPoint
    blacklist:
      tags:
      - GhostOnlyWarp
  - type: ContainerComp
    proto: AiHeld
    container: station_ai_mind_slot
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: ApcPowerReceiver
    powerLoad: 1000
    needsPower: false
  - type: StationAiCore
  - type: StationAiVision
  - type: InteractionOutline
  - type: Sprite
    snapCardinals: true
    sprite: Mobs/Silicon/station_ai.rsi
    layers:
    - state: base
    - state: ai_empty
      shader: unshaded
    - state: ai
      map: ["enum.StationAiVisualState.Key"]
      shader: unshaded
      visible: false
  - type: Appearance
  - type: InteractionPopup
    interactSuccessString: petting-success-station-ai
    interactFailureString: petting-failure-station-ai
    messagePerceivedByOthers: petting-success-station-ai-others # Otherwise AI cannot tell its being pet as It's just a brain inside of the core, not the core itself.
    interactSuccessSound:
      path: /Audio/Ambience/Objects/periodic_beep.ogg
  - type: Telephone
    compatibleRanges:
    - Grid
    - Map
    - Unlimited
    listeningRange: 0
    speakerVolume: Speak
    unlistedNumber: true
  - type: Holopad
  - type: StationAiWhitelist
  - type: UserInterface
    interfaces:
      enum.HolopadUiKey.AiRequestWindow:
        type: HolopadBoundUserInterface
      enum.HolopadUiKey.AiActionWindow:
        type: HolopadBoundUserInterface
      enum.StationAiCustomizationUiKey.Key:
        type: StationAiCustomizationBoundUserInterface

# The job-ready version of an AI spawn.
- type: entity
  id: PlayerStationAi
  parent: PlayerStationAiEmpty
  suffix: Job spawn
  components:
  - type: ContainerSpawnPoint
    containerId: station_ai_mind_slot
    job: StationAi

# The actual brain inside the core
- type: entity
  id: StationAiBrain
  parent: PositronicBrain
  categories: [ HideSpawnMenu, DoNotMap ]
  components:
  - type: Sprite
    # Once it's in a core it's pretty much an abstract entity at that point.
    visible: false
  - type: BlockMovement
    blockInteraction: false
  - type: SiliconLawProvider
    laws: Crewsimov
  - type: SiliconLawBound
  - type: ActionGrant
    actions:
    - ActionViewLaws
  - type: UserInterface
    interfaces:
      enum.SiliconLawsUiKey.Key:
        type: SiliconLawBoundUserInterface
        requireInputValidation: false
  - type: ComplexInteraction
  - type: Actions
  - type: Access
    groups:
    - AllAccess
    - Silicon
  - type: Eye
    drawFov: false
  - type: Examiner
  - type: InputMover
  - type: Speech
    speechVerb: Robotic
    speechSounds: Borg
  - type: Tag
    tags:
    - HideContextMenu
    - StationAi
    - NoConsoleSound
  - type: StartingMindRole
    mindRole: "MindRoleSiliconBrain"
    silent: true
  - type: StationAiCustomization
    protoIds:
      StationAiCoreIconography: StationAiIconAi
      StationAiHolograms: StationAiHologramFemale
  - type: HolographicAvatar
    layerData:
    - sprite: Mobs/Silicon/holograms.rsi
      state: ai_female
  - type: NameIdentifier
    group: StationAi

# Hologram projection that the AI's eye tracks.
- type: entity
  parent:
  - Incorporeal
  - BaseMob
  id: StationAiHolo
  name: AI eye
  description: The AI's viewer.
  categories: [ HideSpawnMenu, DoNotMap ]
  components:
  - type: NoFTL
  - type: Tag
    tags:
    - GhostOnlyWarp
  - type: WarpPoint
    follow: true
    blacklist:
      tags:
      - GhostOnlyWarp
  - type: Eye
    pvsScale: 1.5
  - type: Visibility
    layer: 2
  - type: Sprite
    sprite: Mobs/Silicon/station_ai.rsi
    layers:
    - state: ai_camera
      shader: unshaded
      map: ["base"]

# The holographic representation of the AI that is projected from a holopad.
- type: entity
  id: StationAiHoloLocal
  name: AI hologram
  description: A holographic representation of an AI.
  categories: [ HideSpawnMenu, DoNotMap ]
  components:
  - type: Transform
    anchored: true
  - type: Tag
    tags:
    - GhostOnlyWarp
  - type: WarpPoint
    follow: true
    blacklist:
      tags:
      - GhostOnlyWarp
  - type: Eye
  - type: ContentEye
  - type: Examiner
  - type: Actions
  - type: Alerts
  - type: FTLSmashImmune
  - type: CargoSellBlacklist
  - type: StationAiVision
    range: 20

# Borgs
- type: entity
  id: PlayerBorgBattery
  parent: BorgChassisSelectable
  suffix: Battery
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellMedium
  - type: StartingMindRole
    mindRole: "MindRoleSiliconBrain"
    silent: true

- type: entity
  id: PlayerBorgSyndicateAssaultBattery
  parent: BorgChassisSyndicateAssault
  suffix: Battery, Module, Operative
  components:
  - type: NukeOperative
  - type: ContainerFill
    containers:
      borg_brain:
        - PositronicBrain
      borg_module:
        - BorgModuleOperative
        - BorgModuleL6C
        - BorgModuleDoubleEsword
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHyper

- type: entity
  id: PlayerBorgSyndicateAssaultGhostRole
  parent: PlayerBorgSyndicateAssaultBattery
  suffix: Ghost role
  components:
    - type: GhostRole
      name: ghost-role-information-syndicate-cyborg-assault-name
      description: ghost-role-information-syndicate-cyborg-description
      rules: ghost-role-information-silicon-rules
      raffle:
        settings: default
    - type: GhostTakeoverAvailable

- type: entity
  id: PlayerBorgSyndicateSaboteurBattery
  parent: BorgChassisSyndicateSaboteur
  suffix: Battery, Module, Operative
  components:
  - type: NukeOperative
  - type: ContainerFill
    containers:
      borg_brain:
        - PositronicBrain
      borg_module:
        - BorgModuleTool
        - BorgModuleOperative
        - BorgModuleSyndicateWeapon
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHyper

- type: entity
  id: PlayerBorgSyndicateSaboteurGhostRole
  parent: PlayerBorgSyndicateSaboteurBattery
  suffix: Ghost role
  components:
    - type: GhostRole
      name: ghost-role-information-syndicate-cyborg-saboteur-name
      description: ghost-role-information-syndicate-cyborg-description
      rules: ghost-role-information-silicon-rules
      raffle:
        settings: default
    - type: GhostTakeoverAvailable

- type: entity
  name: syndicate invasion borg spawner
  id: PlayerBorgSyndicateInvasionGhostRoleSpawner
  parent: MarkerBase
  components:
  - type: Sprite
    layers:
      - state: red
      - sprite: Structures/Decoration/banner.rsi
        state: banner_syndicate
  - type: RandomSpawner
    prototypes:
    - PlayerBorgSyndicateAssaultGhostRole
    - PlayerBorgSyndicateAssaultGhostRole # Saboteurs are kinda like cyborg medics, we want less.
    - PlayerBorgSyndicateSaboteurGhostRole

- type: entity
  parent: EngineeringBorgChassisDerelict
  id: PlayerEngineeringBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
      borg_module:
      - BorgModuleTool
      - BorgModuleFireExtinguisher
      - BorgModuleConstruction
      - BorgModuleRCD
      - BorgModuleCable
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHigh
  - type: RandomMetadata
    nameSegments: [NamesBorg]

- type: entity
  parent: PlayerEngineeringBorgDerelict
  id: PlayerEngineeringBorgDerelictGhostRole
  suffix: Ghost role
  components:
  - type: GhostRole
    name: ghost-role-information-derelict-engineering-cyborg-name
    description: ghost-role-information-derelict-engineering-cyborg-description
    rules: ghost-role-information-silicon-rules
    raffle:
      settings: default
    reregister: false
  - type: GhostTakeoverAvailable

- type: entity
  parent: BorgChassisDerelict
  id: PlayerBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
        - PositronicBrain
      borg_module:
        - BorgModuleTool
        # - BorgModuleFireExtinguisher # Frontier: jetpack is superior
        - BorgModuleJetpack # Frontier
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHigh
  - type: RandomMetadata
    nameSegments: [NFNamesBorg] # Frontier: NamesBorg<NFNamesBorg

- type: entity
  parent: PlayerBorgDerelict
  id: PlayerBorgDerelictGhostRole
  suffix: Ghost role
  components:
    - type: GhostRole
      name: ghost-role-information-derelict-cyborg-name
      description: nf-ghost-role-information-derelict-cyborg-description # Frontier
      rules: ghost-role-information-silicon-rules
      raffle:
        settings: default
      reregister: false
    - type: GhostTakeoverAvailable

- type: entity
  parent: JanitorBorgChassisDerelict
  id: PlayerJanitorBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
      borg_module:
      - BorgModuleTool
      - BorgModuleFireExtinguisher
      - BorgModuleCleaning
      - BorgModuleCustodial
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHigh
  - type: RandomMetadata
    nameSegments: [NamesBorg]

- type: entity
  parent: PlayerJanitorBorgDerelict
  id: PlayerJanitorBorgDerelictGhostRole
  suffix: Ghost role
  components:
  - type: GhostRole
    name: ghost-role-information-derelict-janitor-cyborg-name
    description: ghost-role-information-derelict-janitor-cyborg-description
    rules: ghost-role-information-silicon-rules
    raffle:
      settings: default
    reregister: false
  - type: GhostTakeoverAvailable

- type: entity
  parent: MedicalBorgChassisDerelict
  id: PlayerMedicalBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
      borg_module:
      - BorgModuleTool
      - BorgModuleFireExtinguisher
      - BorgModuleChemical
      - BorgModuleTopicals
      - BorgModuleRescue
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHigh
  - type: RandomMetadata
    nameSegments: [NamesBorg]

- type: entity
  parent: PlayerMedicalBorgDerelict
  id: PlayerMedicalBorgDerelictGhostRole
  suffix: Ghost role
  components:
  - type: GhostRole
    name: ghost-role-information-derelict-medical-cyborg-name
    description: ghost-role-information-derelict-medical-cyborg-description
    rules: ghost-role-information-silicon-rules
    raffle:
      settings: default
    reregister: false
  - type: GhostTakeoverAvailable

- type: entity
  parent: MiningBorgChassisDerelict
  id: PlayerMiningBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
      borg_module:
      - BorgModuleTool #No fire extinguisher, traversal is better
      - BorgModuleMining
      - BorgModuleTraversal
      - BorgModuleAppraisal
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHigh
  - type: RandomMetadata
    nameSegments: [NamesBorg]

- type: entity
  parent: PlayerMiningBorgDerelict
  id: PlayerMiningBorgDerelictGhostRole
  suffix: Ghost role
  components:
  - type: GhostRole
    name: ghost-role-information-derelict-mining-cyborg-name
    description: ghost-role-information-derelict-mining-cyborg-description
    rules: ghost-role-information-silicon-rules
    raffle:
      settings: default
    reregister: false
  - type: GhostTakeoverAvailable

- type: entity
  parent: SyndicateAssaultBorgChassisDerelict
  id: PlayerSyndicateAssaultBorgDerelict
  suffix: Battery, Module
  components:
  - type: ContainerFill
    containers:
      borg_brain:
      - PositronicBrain
      borg_module:
      - BorgModuleOperative
      - BorgModuleC20r
      - BorgModuleEsword
  - type: ItemSlots
    slots:
      cell_slot:
        name: power-cell-slot-component-slot-name-default
        startingItem: PowerCellHyper
  - type: RandomMetadata
    nameSegments: [NamesDeathCommando]

- type: entity
  parent: PlayerSyndicateAssaultBorgDerelict
  id: PlayerBorgSyndicateDerelictGhostRole
  suffix: Ghost role
  components:
  - type: GhostRole
    name: ghost-role-information-derelict-syndicate-assault-cyborg-name
    description: ghost-role-information-derelict-syndicate-assault-cyborg-description
    rules: ghost-role-information-silicon-rules
    raffle:
      settings: default
    reregister: false
  - type: GhostTakeoverAvailable
