# These are the action buttons, actions, and mobs, to represent burrowing, all packed together for convenience.
# This works by using the polymorph system to polymorh the mob into a burrowed mob, either Large or small.

# Actions that go on the BurrowAbility component
- type: entity
  parent: [BaseActionPolymorph, BaseDoAfterAction]
  id: ActionBurrowSmall
  name: Burrow
  description: Burrows into the ground.
  components:
  - type: Action
    useDelay: 2
    icon:
      sprite: _starcup/Interface/Actions/actions_general.rsi
      state: burrow
  - type: InstantAction
    event: !type:PolymorphActionEvent
      protoId: BurrowedSmall
  - type: DoAfterArgs
    delay: 2
    breakOnMove: true

- type: entity
  parent: [BaseActionPolymorph, BaseDoAfterAction]
  id: ActionBurrowLarge
  name: Burrow
  description: Burrows into the ground.
  components:
  - type: Action
    useDelay: 3
    icon:
      sprite: _starcup/Interface/Actions/actions_general.rsi
      state: burrow
  - type: InstantAction
    event: !type:PolymorphActionEvent
      protoId: BurrowedLarge
  - type: DoAfterArgs
    delay: 3
    breakOnMove: true

# Action events/protoIDs
- type: polymorph
  id: BurrowedSmall
  configuration:
    entity: BurrowedCreatureSmall
    transferName: false
    inventory: None
    revertOnDeath: true
    revertOnCrit: true
    polymorphPopup: "burrowing-popup-generic"
    exitPolymorphPopup: "burrowing-revert-popup-generic"
    polymorphSound:
      path: /Audio/_starcup/Effects/Burrowing/burrow_on_small.ogg
      params:
        volume: 0.1
    exitPolymorphSound:
      path: /Audio/_starcup/Effects/Burrowing/burrow_off_small.ogg

- type: polymorph
  id: BurrowedLarge
  configuration:
    entity: BurrowedCreatureLarge
    transferName: false
    inventory: None
    revertOnDeath: true
    revertOnCrit: true
    polymorphPopup: "burrowing-popup-generic"
    exitPolymorphPopup: "burrowing-revert-popup-generic"
    polymorphSound:
      path: /Audio/_starcup/Effects/Burrowing/burrow_on_large.ogg
      params:
        volume: 0.1
    exitPolymorphSound:
      path: /Audio/_starcup/Effects/Burrowing/burrow_off_large.ogg

# Entities resulting from the protoIDs
- type: entity
  id: BurrowedCreatureSmall
  name: burrowed creature
  suffix: small
  parent:
    - BaseMob
  description: Something hides underground.
  components:
  - type: Sprite
    noRot: true
    sprite: _starcup/Mobs/Special/burrowed_small.rsi
    drawdepth: FloorObjects
    layers:
    - state: burrowed1
      map: ["random"]
  - type: RandomSprite
    available:
    - random:
        burrowed1: ""
        burrowed2: ""
        burrowed3: ""
        burrowed4: ""
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeCircle
          radius: 0.25
        mask:
        - Impassable
  - type: Insulated
  - type: Temperature
    currentTemperature: 310.15
  - type: TemperatureDamage
    heatDamageThreshold: 360
    coldDamageThreshold: -150
  - type: Tag
    tags:
    - CannotSuicide
  - type: MovementSpeedModifier
    baseWalkSpeed : 0
    baseSprintSpeed : 0
  - type: NoSlip
  - type: Damageable
    damageContainer: Biological
    damageModifierSet: burrowed
    # the components below were copied from MobDamageable, and maybe tweaked a little.
    # the burrowed creature was not parented to it because MobDamageable has the pullable component.
    # we don't want burrowed creatures to be pullable.
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTypeTrigger
        damageType: Blunt
        damage: 400
      behaviors:
      - !type:GibBehavior { }
    - trigger:
        !type:DamageTypeTrigger
        damageType: Radiation
        damage: 15
      behaviors:
      - !type:PopupBehavior
        popup: mouth-taste-metal
        popupType: LargeCaution
        targetOnly: true
    - trigger:
        !type:DamageTypeTrigger
        damageType: Radiation
        damage: 40
      behaviors:
      - !type:VomitBehavior
  - type: RadiationReceiver
  - type: Stamina
  - type: StunVisuals
  - type: MobState
  - type: MobThresholds
    thresholds:
      0: Alive
      45: Critical
      50: Dead
  - type: MobStateActions
    actions:
      Critical:
      - ActionCritSuccumb
      - ActionCritFakeDeath
      - ActionCritLastWords
  - type: Deathgasp
  - type: HealthExaminable
    examinableTypes:
    - Blunt
    - Slash
    - Piercing
    - Heat
    - Shock
    - Cold
    - Caustic
    - Asphyxiation
    - Radiation
  - type: DamageOnHighSpeedImpact
    damage:
      types:
        Blunt: 5
    soundHit:
      path: /Audio/Effects/hit_kick.ogg
  - type: LightningTarget
    priority: 2
    lightningExplode: false

- type: entity
  id: BurrowedCreatureLarge
  name: burrowed creature
  suffix: large
  parent: BurrowedCreatureSmall
  description: Something hides underground.
  components:
  - type: Sprite
    noRot: true
    sprite: _starcup/Mobs/Special/burrowed_large.rsi
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeCircle
          radius: 0.5
        mask:
        - Impassable
  - type: MobThresholds
    thresholds:
      0: Alive
      95: Critical
      100: Dead
