]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Put items inside cakes! (#31015)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Thu, 24 Apr 2025 03:00:50 +0000 (20:00 -0700)
committerGitHub <noreply@github.com>
Thu, 24 Apr 2025 03:00:50 +0000 (05:00 +0200)
* First commit

* I'm silly

* Please be it

* Some more fixes

* Cleanup

* fine!

* removed = false

* review

---------

Co-authored-by: Milon <milonpl.git@proton.me>
Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs
Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Shared/Nutrition/IngestionEvents.cs
Content.Shared/Storage/Components/SecretStashComponent.cs
Content.Shared/Storage/EntitySystems/SecretStashSystem.cs
Content.Shared/Tools/Components/ToolOpenableComponent.cs
Content.Shared/Tools/Systems/ToolOpenableSystem.cs
Resources/Locale/en-US/storage/components/secret-stash-component.ftl
Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/cake.yml

index fd68f611c1920fe02a5a9aca5e3b002b248db697..e294edf15bc007bc493937afe59c9fbe62ba9363 100644 (file)
@@ -336,6 +336,9 @@ public sealed class FoodSystem : EntitySystem
         if (ev.Cancelled)
             return;
 
+        var afterEvent = new AfterFullyEatenEvent(user);
+        RaiseLocalEvent(food, ref afterEvent);
+
         var dev = new DestructionEventArgs();
         RaiseLocalEvent(food, dev);
 
index 5684cef3f42d523ec6f1c09792cf37714cf3ff86..5335a9b02bd9d114dcadef95f0a3c44b348f5961 100644 (file)
@@ -14,6 +14,7 @@ using Robust.Shared.Random;
 using Robust.Shared.Containers;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Systems;
+using Content.Shared.Destructible;
 
 namespace Content.Server.Nutrition.EntitySystems;
 
@@ -140,6 +141,9 @@ public sealed class SliceableFoodSystem : EntitySystem
         if (ev.Cancelled)
             return;
 
+        var dev = new DestructionEventArgs();
+        RaiseLocalEvent(uid, dev);
+
         // Locate the sliced food and spawn its trash
         foreach (var trash in foodComp.Trash)
         {
index 64dbcec54707ec52123876e938fbe99925dcfaf8..b9d4afc88932da0c1967d4bba009e2460ab36688 100644 (file)
@@ -2,6 +2,7 @@ using Content.Server.Actions;
 using Content.Server.Humanoid;
 using Content.Server.Inventory;
 using Content.Server.Mind.Commands;
+using Content.Shared.Nutrition;
 using Content.Server.Polymorph.Components;
 using Content.Shared.Actions;
 using Content.Shared.Buckle;
index 488605522ac766d8b543d3dc4842b39cd8fb3d0f..685b08b1bd3973f34be631613366973b2181a803 100644 (file)
@@ -23,6 +23,18 @@ public sealed class BeforeFullyEatenEvent : CancellableEntityEventArgs
     public EntityUid User;
 }
 
+/// <summary>
+/// Raised directed at the food after finishing eating it and before it's deleted.
+/// </summary>
+[ByRefEvent]
+public readonly record struct AfterFullyEatenEvent(EntityUid User)
+{
+    /// <summary>
+    /// The entity that ate the food.
+    /// </summary>
+    public readonly EntityUid User = User;
+}
+
 /// <summary>
 /// Raised directed at the food being sliced before it's deleted.
 /// Cancel this if you want to do something special before a food is deleted.
index f8fff4c19498a8a1b58452e9e5162a3e74b55c66..54350952a81dd477df221ed41b218b0e3ae2ec81 100644 (file)
@@ -9,6 +9,7 @@ using Content.Shared.DoAfter;
 using Robust.Shared.Serialization;
 using Robust.Shared.Audio;
 using Content.Shared.Whitelist;
+using Content.Shared.Damage;
 
 namespace Content.Shared.Storage.Components
 {
@@ -60,6 +61,12 @@ namespace Content.Shared.Storage.Components
         [DataField]
         public string? SecretStashName;
 
+        /// <summary>
+        /// How much damage is delt to something after eating a secret stash that contains an item.
+        /// </summary>
+        [DataField]
+        public DamageSpecifier? DamageEatenItemInside;
+
         /// <summary>
         ///     Container used to keep secret stash item.
         /// </summary>
index f13303d733868242fd7d37db01eb3dc42cb10ddd..51615c5afaf440b15cf672c33ad3697297a6e329 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Shared.Construction.EntitySystems;
+using Content.Shared.Damage;
 using Content.Shared.Destructible;
 using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
@@ -6,6 +7,7 @@ using Content.Shared.IdentityManagement;
 using Content.Shared.Interaction;
 using Content.Shared.Item;
 using Content.Shared.Materials;
+using Content.Shared.Nutrition;
 using Content.Shared.Popups;
 using Content.Shared.Storage.Components;
 using Content.Shared.Tools.EntitySystems;
@@ -30,6 +32,7 @@ public sealed class SecretStashSystem : EntitySystem
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly ToolOpenableSystem _toolOpenableSystem = default!;
     [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+    [Dependency] private readonly DamageableSystem _damageableSystem = default!;
 
     public override void Initialize()
     {
@@ -38,6 +41,7 @@ public sealed class SecretStashSystem : EntitySystem
         SubscribeLocalEvent<SecretStashComponent, DestructionEventArgs>(OnDestroyed);
         SubscribeLocalEvent<SecretStashComponent, GotReclaimedEvent>(OnReclaimed);
         SubscribeLocalEvent<SecretStashComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem), typeof(AnchorableSystem) });
+        SubscribeLocalEvent<SecretStashComponent, AfterFullyEatenEvent>(OnEaten);
         SubscribeLocalEvent<SecretStashComponent, InteractHandEvent>(OnInteractHand);
         SubscribeLocalEvent<SecretStashComponent, GetVerbsEvent<InteractionVerb>>(OnGetVerb);
     }
@@ -57,6 +61,14 @@ public sealed class SecretStashSystem : EntitySystem
         DropContentsAndAlert(entity, args.ReclaimerCoordinates);
     }
 
+    private void OnEaten(Entity<SecretStashComponent> entity, ref AfterFullyEatenEvent args)
+    {
+        // TODO: When newmed is finished should do damage to teeth (Or something like that!)
+        var damage = entity.Comp.DamageEatenItemInside;
+        if (HasItemInside(entity) && damage != null)
+            _damageableSystem.TryChangeDamage(args.User, damage, true);
+    }
+
     private void OnInteractUsing(Entity<SecretStashComponent> entity, ref InteractUsingEvent args)
     {
         if (args.Handled || !IsStashOpen(entity))
index 82cdf611da9abdd0b058d3224b245e4144b37d69..e48ba421c4c269fb5c186a37e94cd27fcb190f8c 100644 (file)
@@ -49,6 +49,12 @@ namespace Content.Shared.Tools.Components
         [DataField, AutoNetworkedField]
         public bool HasVerbs = true;
 
+        /// <summary>
+        /// If true, the only way to interact is with verbs. Clicking on the entity will not do anything.
+        /// </summary>
+        [DataField, AutoNetworkedField]
+        public bool VerbOnly;
+
         /// <summary>
         ///     The name of what is being open and closed.
         ///     E.g toilet lid, pannel, compartment.
index 4951040350af85b1ef5693d923cb5c4ba30a12e4..10e0dd6869fad807895678de0e98b34c8b339942 100644 (file)
@@ -30,7 +30,7 @@ public sealed class ToolOpenableSystem : EntitySystem
 
     private void OnInteractUsing(Entity<ToolOpenableComponent> entity, ref InteractUsingEvent args)
     {
-        if (args.Handled)
+        if (args.Handled || entity.Comp.VerbOnly)
             return;
 
         if (TryOpenClose(entity, args.Used, args.User))
index 16e575c0f13fcd4620e6a95776691fe2469cdcfc..c7f92fb91f700f9fa8398b7e8b82c7f57b6a72a7 100644 (file)
@@ -23,3 +23,4 @@ comp-secret-stash-verb-open = Open
 secret-stash-plant = plant
 secret-stash-toilet = toilet cistern
 secret-stash-plushie = plushie
+secret-stash-cake = cake
index d5bf403d2ef034eb3082c4f99c0cdb838ec33279..3b9ae17b6a3ad6a0619143655e1c4c27c48df543 100644 (file)
   - type: Tag
     tags:
     - Cake
+  - type: SecretStash
+    maxItemSize: "Normal"
+    secretStashName: secret-stash-cake
+    damageEatenItemInside:
+      types:
+        Slash: 7.5
+  - type: ToolOpenable
+    openToolQualityNeeded: Slicing
+    closeToolQualityNeeded: Slicing
+    verbOnly: true
+  - type: ContainerContainer
+    containers:
+      stash: !type:ContainerSlot {}
 
 - type: entity
   parent: FoodCakeBase