# SPDX-FileCopyrightText: 2024 BombasterDS <115770678+BombasterDS@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  categories: [ HideSpawnMenu ] # mail isnt meant to be spawned manually
  parent: BaseItem
  abstract: true
  id: BaseMail
  name: mail
  components:
  - type: Item
#    size: Normal # Frontier
    storedRotation: -90
  - type: Mail
  - type: Tag # Goobstation - Moth food
    tags:
    - Mail
    - Paper # Goobstation
  - type: AccessReader
  - type: Sprite
    scale: 0.7, 0.7 # Frontier
    sprite: Nyanotrasen/Objects/Specific/Mail/mail.rsi
    layers:
    - state: icon
      map: ["enum.MailVisualLayers.Icon"]
    - state: postmark
    - state: fragile
      map: ["enum.MailVisualLayers.FragileStamp"]
      visible: false
    - map: ["enum.MailVisualLayers.JobStamp"]
      scale: 0.8, 0.8 # Frontier 0.5<0.8
      offset: 0.225, 0.165 # Frontier (0.275, 0.2)<(0.225, 0.165)
    - state: locked
      map: ["enum.MailVisualLayers.Lock"]
    - state: priority
      map: ["enum.MailVisualLayers.PriorityTape"]
      visible: false
      shader: unshaded
    - state: broken
      map: ["enum.MailVisualLayers.Breakage"]
      visible: false
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.MailVisuals.IsTrash:
        enum.MailVisualLayers.Icon:
          True:
            state: trash
          False:
            state: icon
      enum.MailVisuals.IsLocked:
        enum.MailVisualLayers.Lock:
          True:
            visible: true
          False:
            visible: false
      enum.MailVisuals.IsFragile:
        enum.MailVisualLayers.FragileStamp:
          True:
            visible: true
          False:
            visible: false
      enum.MailVisuals.IsPriority:
        enum.MailVisualLayers.PriorityTape:
          True:
            visible: true
          False:
            visible: false
      enum.MailVisuals.IsPriorityInactive:
        enum.MailVisualLayers.PriorityTape:
          True:
            shader: shaded
            state: priority_inactive
          False:
            shader: unshaded
            state: priority
      enum.MailVisuals.IsBroken:
        enum.MailVisualLayers.Breakage:
          True:
            visible: true
          False:
            visible: false
  - type: Damageable
    damageContainer: Inorganic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 5
        #triggersOnce: true
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Breakage" ]
    - trigger:
        !type:DamageTrigger
        damage: 40
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Speech
  - type: DamageOnLand
    damage:
      types:
        Blunt: 10
  - type: CargoSellBlacklist # Frontier
  - type: Food # Frontier - Moth food
    delay: 7 # Goobstation - Mail should take as long as paper to eat
    forceFeedDelay: 7
    requiresSpecialDigestion: true
  - type: SolutionContainerManager
    solutions:
      food:
        maxVol: 1
        reagents:
        - ReagentId: Nothing
          Quantity: 1
  - type: FlavorProfile # Goobstation - Moth food
    flavors:
    - paper
    ignoreReagents:
    - Fiber
  - type: LanguageSpeaker # Einstein Engines - Language
  - type: LanguageKnowledge # Einstein Engines - Language
    speaks:
    - TauCetiBasic # So that them foreigners can't understand what the broken mail is saying
    understands: []

# This empty parcel is allowed to exist and evade the tests for the admin
# mailto command.
- type: entity
  parent: BaseMail
  id: MailAdminFun
  suffix: adminfun
