- type: entityTable
  id: BasicCalmEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: AnomalySpawn
    - id: BluespaceArtifact
    - id: BluespaceLocker
    - id: BreakerFlip
    - id: BureaucraticError
    - id: ClericalError
    - id: CockroachMigration
    - id: GasLeak
    - id: GreytideVirus
    - id: IonStorm # its calm like 90% of the time smh
    - id: KudzuGrowth
    - id: MassHallucinations
    - id: MimicVendorRule
    - id: MouseMigration
    - id: PowerGridCheck
    - id: RandomSentience
    - id: SlimesSpawn
    - id: SolarFlare
    - id: SnakeSpawn
    - id: SpiderClownSpawn
    - id: SpiderSpawn
    - id: VentClog
    - id: VentFleshWorms # Sunrise-Edit
    - id: VentbullMigration # Sunrise-Edit

- type: entityTable
  id: BasicAntagEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: ClosetSkeleton
    - id: KingRatMigration
    - id: RevenantSpawn
    - !type:NestedSelector
      tableId: DerelictBorgEventTable

- type: entityTable
  id: ModerateAntagEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: DragonSpawn
    - id: NinjaSpawn
    - id: ParadoxCloneSpawn
    - id: SleeperAgents
    - id: ZombieOutbreak
    - id: LoneOpsSpawn
    - id: WizardSpawn
    - id: AbductorsSpawn # Sunrise-Edit
    - !type:NestedSelector
      tableId: DerelictBorgEventTable

#Sunrise-start
- type: entityTable
  id: DerelictBorgEventTable #For Derelict Borg spawns
  table: !type:GroupSelector
    children:
    - !type:GroupSelector # Standard NT Borgs
      weight: 85
      children:
        - id: DerelictEngineerCyborgSpawn
        - id: DerelictGenericCyborgSpawn
        - id: DerelictJanitorCyborgSpawn
        - id: DerelictMedicalCyborgSpawn
        - id: DerelictMiningCyborgSpawn
    - !type:GroupSelector # Other Borgs
      weight: 15
      children:
        - id: DerelictSyndicateAssaultCyborgSpawn
        - id: DerelictSyndicateReaperCyborgSpawn
        - id: DerelictSyndicateSaboteurCyborgSpawn
        - id: DerelictSyndicateMedicalCyborgSpawn
#Sunrise-End

- type: entity
  id: BaseStationEvent
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  10
      max:  20

- type: entity
  id: BaseStationEventShortDelay
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  10
      max:  20

- type: entity
  id: BaseStationEventLongDelay
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  40
      max:  60

- type: entity
  id: AnomalySpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncementColor: "#18abf5"
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    weight: 8
    duration: 35
  - type: AnomalySpawnRule

- type: entity
  id: BluespaceArtifact
  parent: BaseStationEventShortDelay
  components:
  - type: GameRule
    delay:
      min:  30
      max:  30
  - type: StationEvent
    startAnnouncementColor: "#18abf5"
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    weight: 8
    duration: 35
  - type: BluespaceArtifactRule

- type: entity
  id: BluespaceLocker
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 2
    reoccurrenceDelay: 5
    earliestStart: 1
    duration: 1
  - type: BluespaceLockerRule

- type: entity
  id: BreakerFlip
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 7
    duration: 1
    minimumPlayers: 15
  - type: BreakerFlipRule

- type: entity
  id: BureaucraticError
  parent: BaseGameRule
  components:
  - type: StationEvent
    startAnnouncement: station-event-bureaucratic-error-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    minimumPlayers: 25
    weight: 3
    duration: 1
  - type: BureaucraticErrorRule
    ignoredJobs:
    - StationAi
    - ResearchAssistant
    - MedicalIntern
    - SecurityCadet
    - TechnicalAssistant

- type: entity
  id: ClericalError
  parent: BaseGameRule
  components:
  - type: StationEvent
    startAnnouncement: station-event-clerical-error-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    minimumPlayers: 15
    weight: 5
    duration: 1
  - type: ClericalErrorRule

- type: entity
  parent: BaseGameRule
  id: ClosetSkeleton
  components:
  - type: StationEvent
    weight: 5
    duration: 1
    minimumPlayers: 10
  - type: RandomEntityStorageSpawnRule
    prototype: MobSkeletonCloset

- type: entity
  parent: BaseGameRule
  id: DragonSpawn
  components:
  # Sunrise-start
  - type: GameRule
    delay:
      min: 900
      max: 900
  # Sunrise-end
  - type: StationEvent
    weight: 6.5
    earliestStart: 40
    reoccurrenceDelay: 20
    minimumPlayers: 60 #Sunrise-edit
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: MobDragon
  - type: DragonRule
  - type: AntagObjectives
    objectives:
    - CarpRiftsObjective
    - DragonSurviveObjective
  - type: AntagSelection
    agentName: dragon-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostDragon
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleDragon
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseGameRule
  id: NinjaSpawn
  components:
  # Sunrise-start
  - type: GameRule
    delay:
      min: 60
      max: 600
  # Sunrise-end
  - type: StationEvent
    weight: 6
    duration: null
    earliestStart: 30
    reoccurrenceDelay: 20
    minimumPlayers: 30
  - type: SpaceSpawnRule
  - type: AntagLoadProfileRule
  - type: AntagObjectives
    objectives:
    - StealResearchObjective
    - DoorjackObjective
    - SpiderChargeObjective
    - TerrorObjective
    - MassArrestObjective
    - NinjaSurviveObjective
  - type: AntagSelection
    agentName: ninja-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostSpaceNinja
      min: 1
      max: 1
      pickPlayer: false
      startingGear: SpaceNinjaGear
      roleLoadout:
      - RoleSurvivalEVA
      briefing:
        text: ninja-role-greeting
        color: Green
        sound: /Audio/Misc/ninja_greeting.ogg
      components:
      # Sunrise edit start
      - type: GhostPanelAntagonistMarker
        name: ghost-panel-antagonist-ninja-name
        description: ghost-panel-antagonist-ninja-description
        priority: 40
      # Sunrise edit end
      - type: SpaceNinja
      - type: NpcFactionMember
        factions:
        - SpiderClan
      - type: AutoImplant
        implants:
        # Sunrise-Start
        #- DeathAcidifierImplant
        - RedspaceImplant
        - MicroBombImplant
        - StimpackImplant
        - ReviverImplant
        - NutrimentImplant
        # Sunrise-End
      - type: RandomMetadata
        nameSegments:
        - NamesNinjaTitle
        - NamesNinja
        nameFormat: name-format-ninja
      mindRoles:
      - MindRoleNinja
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseGameRule
  id: ParadoxCloneSpawn
  components:
  - type: StationEvent
    weight: 5
    duration: null
    earliestStart: 20
    reoccurrenceDelay: 20
    minimumPlayers: 15
  - type: ParadoxCloneRule
    objectiveBlacklist:
      tags:
      - ParadoxCloneObjectiveBlacklist
  - type: AntagObjectives
    objectives:
    - ParadoxCloneKillObjective
    - ParadoxCloneLivingObjective
  - type: AntagRandomSpawn # TODO: improve spawning so they only start in maints
  - type: AntagSelection
    agentName: paradox-clone-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostParadoxClone
      min: 1
      max: 1
      pickPlayer: false
      startingGear: ParadoxCloneGear
      roleLoadout:
      - RoleSurvivalVoxTank # give vox something to breath in case they don't get a copy
      briefing:
        text: paradox-clone-role-greeting
        color: lightblue
        sound: /Audio/Misc/paradox_clone_greeting.ogg
      mindRoles:
      - MindRoleParadoxClone
  - type: DynamicRuleCost
    cost: 50

- type: entity
  parent: BaseGameRule
  id: RevenantSpawn
  components:
  - type: StationEvent
    weight: 7.5
    duration: 1
    earliestStart: 45
    minimumPlayers: 20
  - type: RandomSpawnRule
    prototype: MobRevenant

- type: entity
  parent: BaseWizardRule
  id: WizardSpawn
  components:
  - type: StationEvent
    weight: 1 # rare
    duration: 1
    earliestStart: 30
    reoccurrenceDelay: 60
    minimumPlayers: 30
  - type: AntagSelection
    agentName: wizard-round-end-name
    definitions:
    - spawnerPrototype: SpawnPointGhostWizard
      min: 1
      max: 1
      playerRatio: 1
      pickPlayer: false
      startingGear: WizardBlueGear
      roleLoadout:
      - RoleSurvivalExtended
      briefing:
        text: wizard-role-greeting
        color: Turquoise
        # TODO: Need Wizard Start sound
        #sound: "/Audio/Ambience/Antag/wizard_start.ogg"
      # TODO: WizardComp as needed
      components:
      - type: NpcFactionMember
        factions:
        - Wizard
      - type: RandomMetadata
        nameSegments:
        - NamesWizardFirst
        - NamesWizardLast
        nameFormat: name-format-wizard
      mindRoles:
      - MindRoleWizard

# disabled until event is rewritten to be more interesting
#- type: entity
#  id: FalseAlarm
#  parent: BaseGameRule
#  components:
#  - type: StationEvent
#    weight: 15
#    duration: 1
#  - type: FalseAlarmRule

- type: entity
  id: GasLeak
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-gas-leak-start-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    endAnnouncement: station-event-gas-leak-end-announcement
    weight: 8
    endAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
  - type: GasLeakRule

- type: entity
  id: KudzuGrowth
  parent: BaseStationEventLongDelay
  components:
  - type: StationEvent
    earliestStart: 15
    minimumPlayers: 15
    weight: 7
    duration: 240
  - type: KudzuGrowthRule

- type: entity
  id: PowerGridCheck
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    weight: 5
    startAnnouncement: station-event-power-grid-check-start-announcement
    endAnnouncement: station-event-power-grid-check-end-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    duration: 60
    maxDuration: 120
  - type: PowerGridCheckRule

- type: entity
  parent: BaseGameRule
  id: SolarFlare
  components:
  - type: StationEvent
    weight: 8
    startAnnouncement: station-event-solar-flare-start-announcement
    endAnnouncement: station-event-solar-flare-end-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    duration: 120
    maxDuration: 240
  - type: SolarFlareRule
    onlyJamHeadsets: true
    affectedChannels:
    - Common
    extraChannels:
    - Command
    - Engineering
    - Medical
    - Science
    - Security
    - Service
    - Supply
    extraCount: 2
    lightBreakChancePerSecond: 0.0003
    doorToggleChancePerSecond: 0.001

- type: entity
  id: VentClog
  parent: BaseStationEventLongDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-clog-start-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    earliestStart: 15
    minimumPlayers: 15
    weight: 5
    duration: 60
  - type: VentClogRule

- type: entity
  id: SlimesSpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 60
  - type: VentCrittersRule
    entries:
    - id: MobAdultSlimesBlueAngry
      prob: 0.02
    - id: MobAdultSlimesGreenAngry
      prob: 0.02
    - id: MobAdultSlimesYellowAngry
      prob: 0.02

- type: entity
  id: SnakeSpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 60
  - type: VentCrittersRule
    entries:
    - id: MobPurpleSnake
      prob: 0.02
    - id: MobSmallPurpleSnake
      prob: 0.02
    - id: MobCobraSpace
      prob: 0.02

- type: entity
  id: SpiderSpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 60
  - type: VentCrittersRule
    entries:
    - id: MobGiantSpiderAngry
      prob: 0.05

- type: entity
  id: SpiderClownSpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-announcement
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    earliestStart: 20
    minimumPlayers: 20
    weight: 1.5
    duration: 60
  - type: VentCrittersRule
    entries:
    - id: MobClownSpider
      prob: 0.05

- type: entity
  id: ZombieOutbreak
  parent: BaseGameRule
  components:
  - type: StationEvent
    earliestStart: 90
    minimumPlayers: 40
    weight: 0 # Sunrise-edit: Нахуя оно блядь вообще надо
    duration: 1
    occursDuringRoundEnd: false
  - type: ZombieRule
  - type: AntagSelection
    definitions:
    - prefRoles: [ InitialInfected ]
      max: 3
      ignoreCanBeAntag: true # Sunrise-Edit
      playerRatio: 10
      blacklist:
        components:
        - ZombieImmune
        - AntagImmune
      briefing:
        text: zombie-patientzero-role-greeting
        color: Plum
        sound: "/Audio/Ambience/Antag/zombie_start.ogg"
      components:
      - type: PendingZombie #less time to prepare than normal
        minInitialInfectedGrace: 300
        maxInitialInfectedGrace: 450
      - type: ZombifyOnDeath
      - type: IncurableZombie
      - type: InitialInfected
      mindRoles:
      - MindRoleInitialInfected
  - type: DynamicRuleCost
    cost: 200

- type: entity
  parent: BaseNukeopsRule
  id: LoneOpsSpawn
  components:
  - type: StationEvent
    earliestStart: 35
    weight: 5.5
    minimumPlayers: 20
    duration: null # LoneOpsSpawn needs an infinite duration so that it inherits the NukeOpsRule things of an actually appropriate end screen (not always "Neutral outcome!") and... ending the game if the station is nuked.
  - type: RuleGrids
  - type: LoadMapRule
    gridPath: /Maps/_Fish/Shuttles/ShuttleEvent/striker.yml #Fish-edit
  - type: NukeopsRule
    roundEndBehavior: Nothing
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointLoneNukeOperative
      min: 1
      max: 1
      pickPlayer: false
      startingGear: SyndicateLoneOperativeGearFull
      roleLoadout:
      - RoleSurvivalNukie
      components:
      # Sunrise edit start
      - type: GhostPanelAntagonistMarker
        name: ghost-panel-antagonist-loneops-name
        description: ghost-panel-antagonist-loneops-description
        priority: 20
      # Sunrise edit end
      - type: NukeOperative
      - type: RandomMetadata
        nameSegments:
        - NamesSyndicatePrefix
        - NamesSyndicateNormal
        nameFormat: name-format-nukie-generic
      - type: NpcFactionMember
        factions:
        - Syndicate
      mindRoles:
      - MindRoleLoneops
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseTraitorRule
  id: SleeperAgents
  components:
  - type: StationEvent
    earliestStart: 30
    weight: 8
    minimumPlayers: 15
    maxOccurrences: 1 # can only happen once per round
    startAnnouncement: station-event-communication-interception
    startAudio:
      path: /Audio/Announcements/announce.ogg # Fish-edit
    duration: null # the rule has to last the whole round not 1 second
    occursDuringRoundEnd: false
  - type: AlertLevelInterceptionRule
  - type: AntagSelection
    definitions:
    - prefRoles: [ TraitorSleeper ]
      fallbackRoles: [ Traitor ]
      min: 5 # Sunrise-Edit
      max: 10 # Sunrise-Edit
      playerRatio: 10
      blacklist:
        components:
        - AntagImmune
      mindRoles:
      - MindRoleTraitorSleeper

- type: entity
  id: MassHallucinations
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 7
    duration: 150
    maxDuration: 300
    reoccurrenceDelay: 30
  - type: MassHallucinationsRule
    minTimeBetweenIncidents: 0.1
    maxTimeBetweenIncidents: 300
    maxSoundDistance: 7
    sounds:
      collection: Paracusia

- type: entity
  parent: BaseGameRule
  id: IonStorm
  components:
  - type: StationEvent
    startAudio:
      path: /Audio/_Sunrise/Announcements/ionstorm.ogg
      params:
        volume: -10
    weight: 8
    reoccurrenceDelay: 20
    duration: 1
  - type: IonStormRule

- type: entity
  id: MimicVendorRule
  parent: BaseGameRule
  components:
  - type: StationEvent
    earliestStart: 0
    minimumPlayers: 20
    maxOccurrences: 1 # this event has diminishing returns on interesting-ness, so we cap it
    weight: 5
  - type: MobReplacementRule

- type: entity
  id: GreytideVirus
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAudio:
      path: /Audio/Announcements/attention.ogg
    weight: 5
    minimumPlayers: 25
    reoccurrenceDelay: 20
  - type: GreytideVirusRule
    accessGroups:
    - Cargo
    - Command
    - Engineering
    - Research
    - Security
    - Service
    blacklist:
    - External # don't space everything

- type: entity
  parent: BaseGameRule
  id: SmugglerStashVariationPass
  components:
  - type: StationEvent
    earliestStart: 0
    duration: 1
    minimumPlayers: 1
    maxOccurrences: 2
    weight: 10
  - type: RandomSpawnRule
    prototype: RandomSatchelSpawner

- type: entity
  parent: BaseGameRule
  id: DerelictEngineerCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerEngineeringBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictEngineeringCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictGenericCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictJanitorCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerJanitorBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictJanitorCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictMedicalCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerMedicalBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictMedicalCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictMiningCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerMiningBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictMiningCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictSyndicateAssaultCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 25
    reoccurrenceDelay: 20
    minimumPlayers: 15
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerBorgSyndicateDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictSyndicateAssaultCyborg
      min: 1
      max: 1
      pickPlayer: false
