]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
make tinned foods use openable (#19884)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sat, 7 Oct 2023 00:35:32 +0000 (01:35 +0100)
committerGitHub <noreply@github.com>
Sat, 7 Oct 2023 00:35:32 +0000 (17:35 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
23 files changed:
Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/tin.yml
Resources/Prototypes/Entities/Objects/Consumable/Food/food_base.yml
Resources/Prototypes/Entities/Objects/Consumable/Food/meat.yml
Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/icon-open.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/beans-open.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/icon.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/beans.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/trash.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/beans-empty.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/icon-open.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtinmaint-open.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/icon.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtinmaint.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/trash.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtinmaint-empty.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/icon-hot.png [moved from Resources/Textures/Objects/Consumable/Food/mre.rsi/tin-hot.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/icon-open.png [moved from Resources/Textures/Objects/Consumable/Food/mre.rsi/tin-open.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/icon.png [moved from Resources/Textures/Objects/Consumable/Food/mre.rsi/tin-closed.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/trash.png [moved from Resources/Textures/Objects/Consumable/Food/mre.rsi/tin-trash.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/icon-open.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtin-open.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/icon.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtin.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/trash.png [moved from Resources/Textures/Objects/Consumable/Food/snacks.rsi/peachtin-empty.png with 100% similarity]
Resources/Textures/Objects/Consumable/Food/mre.rsi/meta.json
Resources/Textures/Objects/Consumable/Food/snacks.rsi/meta.json

diff --git a/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs
new file mode 100644 (file)
index 0000000..f01e4f7
--- /dev/null
@@ -0,0 +1,17 @@
+using Content.Server.Nutrition.EntitySystems;
+
+namespace Content.Server.Destructible.Thresholds.Behaviors;
+
+/// <summary>
+/// Causes the drink/food to open when the destruction threshold is reached.
+/// If it is already open nothing happens.
+/// </summary>
+[DataDefinition]
+public sealed partial class OpenBehavior : IThresholdBehavior
+{
+    public void Execute(EntityUid uid, DestructibleSystem system, EntityUid? cause = null)
+    {
+        var openable = EntitySystem.Get<OpenableSystem>();
+        openable.TryOpen(uid);
+    }
+}
index d7de1d234b03b82ff1d9a25c4346ad7325a1fb21..764356ad687f4b9f8d440a0ff8aa91bfcf8736cb 100644 (file)
@@ -1,8 +1,10 @@
 # Base
 
+# uses "icon" and "icon-open" states for the main item.
+# trash prototypes use "trash" state
 - type: entity
   abstract: true
-  parent: BaseItem
+  parent: [FoodBase, FoodOpenableBase]
   id: FoodTinBase
   name: tin
   description: A tin of something, sealed tight.
     solutions:
       food:
         maxVol: 20
-  - type: Sprite
-    sprite: Objects/Consumable/Food/snacks.rsi
+        reagents:
+        - ReagentId: Nutriment
+          Quantity: 15
+  - type: Openable
+    openableByHand: false
+    sound:
+      path: /Audio/Items/can_open3.ogg
+  - type: Destructible
+    thresholds:
+    # if tinned food is nuked just delete it, no sound
+    - trigger:
+        !type:DamageTrigger
+        damage: 50
+      behaviors:
+      - !type:DoActsBehavior
+        acts: [ "Destruction" ]
+    - trigger:
+        !type:DamageTrigger
+        damage: 6
+      behaviors:
+      - !type:OpenBehavior
   - type: Item
     sprite: Objects/Consumable/Food/snacks.rsi
     heldPrefix: packet
@@ -27,9 +48,8 @@
         Blunt: 3
   - type: Damageable
     damageContainer: Inorganic
-  - type: PhysicalComposition
-    materialComposition:
-      Steel: 100
+  - type: StaticPrice
+    price: 50
 
 - type: entity
   abstract: true
   description: An empty tin. Could get a bit of metal from this.
   components:
   - type: Sprite
-    sprite: Objects/Consumable/Food/snacks.rsi
+    state: trash
   - type: Item
     sprite: Objects/Consumable/Food/snacks.rsi
     heldPrefix: packet
     size: 3
-  - type: Tag
-    tags:
-      - Trash
   - type: PhysicalComposition
     materialComposition:
       Steel: 100
+  - type: Tag
+    tags:
+    - Trash
+
 # Tins
 
 # Need something that you can open these tins with. I suggest a prying or cutting tool.
   description: Just a nice can of ripe peaches swimming in their own juices.
   components:
   - type: Sprite
-    state: peachtin
-  - type: Destructible
-    thresholds:
-    - trigger:
-        !type:DamageTrigger
-        damage: 6
-      behaviors:
-      - !type:PlaySoundBehavior
-        sound:
-          path: /Audio/Items/can_open3.ogg
-      - !type:SpawnEntitiesBehavior
-        spawn:
-          FoodTinPeachesOpen:
-            min: 1
-            max: 1
-      - !type:DoActsBehavior
-        acts: [ "Destruction" ]
-  - type: StaticPrice
-    price: 50
-
-- type: entity
-  parent: FoodTinBase
-  id: FoodTinPeachesOpen
-  name: tinned peaches
-  description: Just a nice can of ripe peaches swimming in their own juices.
-  components:
-  - type: Sprite
-    state: peachtin-open
-  - type: SolutionContainerManager
-    solutions:
-      food:
-        maxVol: 20
-        reagents:
-        - ReagentId: Nutriment
-          Quantity: 15
+    sprite: Objects/Consumable/Food/Tins/peaches.rsi
   - type: FlavorProfile
     flavors:
-      - sweet
-      - funny
+    - sweet
+    - funny
   - type: Food
     trash: FoodTinPeachesTrash
 
   name: tinned peaches
   components:
   - type: Sprite
-    state: peachtin-empty
+    sprite: Objects/Consumable/Food/Tins/peaches.rsi
 
+# slightly run down texture and different name
 - type: entity
-  parent: FoodTinBase
+  parent: FoodTinPeaches
   id: FoodTinPeachesMaint
   name: Maintenance Peaches
-  description: Just a nice can of ripe peaches swimming in their own juices.
   components:
   - type: Sprite
-    state: peachtinmaint
-  - type: Destructible
-    thresholds:
-    - trigger:
-        !type:DamageTrigger
-        damage: 6
-      behaviors:
-      - !type:PlaySoundBehavior
-        sound:
-          path: /Audio/Items/can_open3.ogg
-      - !type:SpawnEntitiesBehavior
-        spawn:
-          FoodTinPeachesMaintOpen:
-            min: 1
-            max: 1
-      - !type:DoActsBehavior
-        acts: [ "Destruction" ]
-  - type: StaticPrice
-    price: 50
+    sprite: Objects/Consumable/Food/Tins/maint_peaches.rsi
+  - type: Food
+    trash: FoodTinPeachesMaintTrash
 
+# only exists for backwards compatibility with a few maps, nothing else uses it
 - type: entity
-  parent: FoodTinBase
+  parent: FoodTinPeachesMaint
   id: FoodTinPeachesMaintOpen
-  name: Maintenance Peaches
-  description: Just a nice can of ripe peaches swimming in their own juices.
+  suffix: Open
   components:
   - type: Sprite
-    state: peachtinmaint-open
-  - type: SolutionContainerManager
-    solutions:
-      food:
-        reagents:
-        - ReagentId: Nutriment
-          Quantity: 15
-  - type: Food
-    trash: FoodTinPeachesMaintTrash
+    layers:
+    - state: icon-open
+      map: ["icon"]
+  - type: Openable
+    opened: true
 
 - type: entity
   parent: FoodTinBaseTrash
   name: Maintenance Peaches
   components:
   - type: Sprite
-    state: peachtinmaint-empty
+    sprite: Objects/Consumable/Food/Tins/maint_peaches.rsi
 
 - type: entity
   parent: FoodTinBase
   description: Musical fruit in a slightly less musical container.
   components:
   - type: Sprite
-    state: beans
-  - type: Destructible
-    thresholds:
-    - trigger:
-        !type:DamageTrigger
-        damage: 6
-      behaviors:
-      - !type:PlaySoundBehavior
-        sound:
-          path: /Audio/Items/can_open3.ogg
-      - !type:SpawnEntitiesBehavior
-        spawn:
-          FoodTinBeansOpen:
-            min: 1
-            max: 1
-      - !type:DoActsBehavior
-        acts: [ "Destruction" ]
-  - type: StaticPrice
-    price: 50
-
-- type: entity
-  parent: FoodTinBase
-  id: FoodTinBeansOpen
-  name: tin of beans
-  description: Musical fruit in a slightly less musical container.
-  components:
-  - type: Sprite
-    state: beans-open
-  - type: SolutionContainerManager
-    solutions:
-      food:
-        reagents:
-        - ReagentId: Nutriment
-          Quantity: 15
+    sprite: Objects/Consumable/Food/Tins/beans.rsi
   - type: FlavorProfile
     flavors:
-      - savory
-      - salty
-      - cheap
+    - savory
+    - salty
+    - cheap
   - type: Food
     trash: FoodTinBeansTrash
 
   name: tin of beans
   components:
   - type: Sprite
-    state: beans-empty
+    sprite: Objects/Consumable/Food/Tins/beans.rsi
+
 # MRE can
 
 - type: entity
   description: A standard issue tin of meat with a convenient pull tab.
   components:
   - type: Sprite
-    sprite: Objects/Consumable/Food/mre.rsi
-    state: tin-closed
-  - type: Destructible
-    thresholds:
-    - trigger:
-        !type:DamageTrigger
-        damage: 6
-      behaviors:
-      - !type:PlaySoundBehavior
-        sound:
-          path: /Audio/Items/can_open3.ogg
-      - !type:SpawnEntitiesBehavior
-        spawn:
-          FoodTinMREOpen:
-            min: 1
-            max: 1
-      - !type:DoActsBehavior
-        acts: [ "Destruction" ]
-  - type: SpawnItemsOnUse
-    items:
-      - id: FoodTinMREOpen
-    sound:
-      path: /Audio/Items/can_open3.ogg
-
-
-- type: entity
-  parent: FoodTinBase
-  id: FoodTinMREOpen
-  name: tinned meat
-  description: A standard issue tin of meat.
-  components:
-  - type: Sprite
-    sprite: Objects/Consumable/Food/mre.rsi
-    state: tin-open
-  - type: SolutionContainerManager
-    solutions:
-      food:
-        reagents:
-        - ReagentId: Nutriment
-          Quantity: 15
+    sprite: Objects/Consumable/Food/Tins/meat.rsi
+  # the convenient pull tab
+  - type: Openable
+    openableByHand: true
   - type: FlavorProfile
     flavors:
-      - meaty
-      - salty
-      - cheap
+    - meaty
+    - salty
+    - cheap
   - type: Food
     trash: FoodTinMRETrash
 
   name: tinned meat
   components:
   - type: Sprite
-    sprite: Objects/Consumable/Food/mre.rsi
-    state: tin-trash
+    sprite: Objects/Consumable/Food/Tins/meat.rsi
index be65bc29b0d00acd4516c510dc57b8951cdb5f65..0d942ebf96c21a92812eb439d964c93895ece4a3 100644 (file)
     solution: food
   - type: RefillableSolution
     solution: food
+
+# usable by any food that can be opened
+# handles appearance with states "icon" and "icon-open"
+- type: entity
+  id: FoodOpenableBase
+  abstract: true
+  components:
+  - type: Appearance
+  - type: Sprite
+    layers:
+    - state: icon
+      map: ["icon"]
+  - type: GenericVisualizer
+    visuals:
+      enum.OpenableVisuals.Opened:
+        icon:
+          True: {state: "icon-open"}
+          False: {state: "icon"}
+  - type: Openable
index 30306ddff300030a159cef9168fffec52024debd..21a100841dbb170c664eec33e28f1b8d9a1ea87d 100644 (file)
@@ -8,7 +8,6 @@
   - type: FlavorProfile
     flavors:
       - meaty
-  - type: Food
   - type: Sprite
     sprite: Objects/Consumable/Food/meat.rsi
   - type: Extractable
   - type: Tag
     tags:
     - Raw
+    - Meat
   - type: Sprite
     state: rouny
   - type: SolutionContainerManager
 # Cooked
 
 - type: entity
-  parent: BaseItem
+  parent: FoodBase
   id: MaterialSmileExtract
   name: smile extract
   description: It's a real panacea. But at what cost?
   components:
-  - type: Food
   - type: Extractable
     grindableSolutionName: food
   - type: FlavorProfile
           Quantity: 10
         - ReagentId: Iron
           Quantity: 10
-  - type: Item
-    size: 5
   - type: StaticPrice
     price: 3000 #It has so much Omnizin in it
   - type: Tag
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: bacon-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: product-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: bird-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: bird-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: bird-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: crab-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: goliath-cooked
   - type: Tag
     tags:
     - Cooked
+    - Meat
   - type: Sprite
     layers:
     - state: rouny-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: lizard-cooked
     tags:
     - Cooked
     - Meat
-  - type: Food
   - type: Sprite
     layers:
     - state: spiderleg-cooked
diff --git a/Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/meta.json b/Resources/Textures/Objects/Consumable/Food/Tins/beans.rsi/meta.json
new file mode 100644 (file)
index 0000000..fbd3219
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/c6e3401f2e7e1e55c57060cdf956a98ef1fefc24",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "icon"
+    },
+    {
+      "name": "icon-open"
+    },
+    {
+      "name": "trash"
+    }
+  ]
+}
diff --git a/Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/meta.json b/Resources/Textures/Objects/Consumable/Food/Tins/maint_peaches.rsi/meta.json
new file mode 100644 (file)
index 0000000..fbd3219
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/c6e3401f2e7e1e55c57060cdf956a98ef1fefc24",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "icon"
+    },
+    {
+      "name": "icon-open"
+    },
+    {
+      "name": "trash"
+    }
+  ]
+}
diff --git a/Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/meta.json b/Resources/Textures/Objects/Consumable/Food/Tins/meat.rsi/meta.json
new file mode 100644 (file)
index 0000000..0f14d21
--- /dev/null
@@ -0,0 +1,31 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from cev-eris at https://github.com/discordia-space/CEV-Eris/raw/9c980cb9bc84d07b1c210c5447798af525185f80/icons/obj/food.dmi",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "icon"
+    },
+    {
+      "name": "icon-hot",
+      "delays": [
+        [
+          0.5,
+          0.5,
+          0.5,
+          0.5
+        ]
+      ]
+    },
+    {
+      "name": "icon-open"
+    },
+    {
+      "name": "trash"
+    }
+  ]
+}
diff --git a/Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/meta.json b/Resources/Textures/Objects/Consumable/Food/Tins/peaches.rsi/meta.json
new file mode 100644 (file)
index 0000000..fbd3219
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/c6e3401f2e7e1e55c57060cdf956a98ef1fefc24",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "icon"
+    },
+    {
+      "name": "icon-open"
+    },
+    {
+      "name": "trash"
+    }
+  ]
+}
index 5aca929f9831c6677919b0f8a7727b27e1a28eb6..d4669293cda3ca8b024f614b845fac229f9c9870 100644 (file)
     {
       "name": "box-closed"
     },
-    {
-      "name": "tin-closed"
-    },
-    {
-      "name": "tin-hot",
-      "delays": [
-        [
-          0.5,
-          0.5,
-          0.5,
-          0.5
-        ]
-      ]
-    },
-    {
-      "name": "tin-open"
-    },
-    {
-      "name": "tin-trash"
-    },
     {
       "name": "candy"
     },
index 116e05d18f3017ef8fc57c00a32f7ec7aa6f40b9..6f699103840ac07027bc5da88dd14741ed480277 100644 (file)
@@ -7,15 +7,6 @@
     "y": 32
   },
   "states": [
-    {
-      "name": "beans"
-    },
-    {
-      "name": "beans-empty"
-    },
-    {
-      "name": "beans-open"
-    },
     {
       "name": "boritos"
     },
       "name": "packet-inhand-left",
       "directions": 4
     },
-    {
-      "name": "peachtin"
-    },
-    {
-      "name": "peachtin-empty"
-    },
-    {
-      "name": "peachtin-open"
-    },
-    {
-      "name": "peachtinmaint"
-    },
-    {
-      "name": "peachtinmaint-empty"
-    },
-    {
-      "name": "peachtinmaint-open"
-    },
     {
       "name": "pistachio"
     },