From 186cef25ca39ac233914c2b4b5c1bedcdbbe4243 Mon Sep 17 00:00:00 2001 From: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Date: Wed, 23 Apr 2025 20:00:50 -0700 Subject: [PATCH] Put items inside cakes! (#31015) * First commit * I'm silly * Please be it * Some more fixes * Cleanup * fine! * removed = false * review --------- Co-authored-by: Milon --- .../Nutrition/EntitySystems/FoodSystem.cs | 3 +++ .../Nutrition/EntitySystems/SliceableFoodSystem.cs | 4 ++++ Content.Server/Polymorph/Systems/PolymorphSystem.cs | 1 + Content.Shared/Nutrition/IngestionEvents.cs | 12 ++++++++++++ .../Storage/Components/SecretStashComponent.cs | 7 +++++++ .../Storage/EntitySystems/SecretStashSystem.cs | 12 ++++++++++++ .../Tools/Components/ToolOpenableComponent.cs | 6 ++++++ Content.Shared/Tools/Systems/ToolOpenableSystem.cs | 2 +- .../storage/components/secret-stash-component.ftl | 1 + .../Entities/Objects/Consumable/Food/Baked/cake.yml | 13 +++++++++++++ 10 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index fd68f611c1..e294edf15b 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -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); diff --git a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs index 5684cef3f4..5335a9b02b 100644 --- a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs @@ -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) { diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index 64dbcec547..b9d4afc889 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -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; diff --git a/Content.Shared/Nutrition/IngestionEvents.cs b/Content.Shared/Nutrition/IngestionEvents.cs index 488605522a..685b08b1bd 100644 --- a/Content.Shared/Nutrition/IngestionEvents.cs +++ b/Content.Shared/Nutrition/IngestionEvents.cs @@ -23,6 +23,18 @@ public sealed class BeforeFullyEatenEvent : CancellableEntityEventArgs public EntityUid User; } +/// +/// Raised directed at the food after finishing eating it and before it's deleted. +/// +[ByRefEvent] +public readonly record struct AfterFullyEatenEvent(EntityUid User) +{ + /// + /// The entity that ate the food. + /// + public readonly EntityUid User = User; +} + /// /// 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. diff --git a/Content.Shared/Storage/Components/SecretStashComponent.cs b/Content.Shared/Storage/Components/SecretStashComponent.cs index f8fff4c194..54350952a8 100644 --- a/Content.Shared/Storage/Components/SecretStashComponent.cs +++ b/Content.Shared/Storage/Components/SecretStashComponent.cs @@ -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; + /// + /// How much damage is delt to something after eating a secret stash that contains an item. + /// + [DataField] + public DamageSpecifier? DamageEatenItemInside; + /// /// Container used to keep secret stash item. /// diff --git a/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs b/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs index f13303d733..51615c5afa 100644 --- a/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SecretStashSystem.cs @@ -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(OnDestroyed); SubscribeLocalEvent(OnReclaimed); SubscribeLocalEvent(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem), typeof(AnchorableSystem) }); + SubscribeLocalEvent(OnEaten); SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent>(OnGetVerb); } @@ -57,6 +61,14 @@ public sealed class SecretStashSystem : EntitySystem DropContentsAndAlert(entity, args.ReclaimerCoordinates); } + private void OnEaten(Entity 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 entity, ref InteractUsingEvent args) { if (args.Handled || !IsStashOpen(entity)) diff --git a/Content.Shared/Tools/Components/ToolOpenableComponent.cs b/Content.Shared/Tools/Components/ToolOpenableComponent.cs index 82cdf611da..e48ba421c4 100644 --- a/Content.Shared/Tools/Components/ToolOpenableComponent.cs +++ b/Content.Shared/Tools/Components/ToolOpenableComponent.cs @@ -49,6 +49,12 @@ namespace Content.Shared.Tools.Components [DataField, AutoNetworkedField] public bool HasVerbs = true; + /// + /// If true, the only way to interact is with verbs. Clicking on the entity will not do anything. + /// + [DataField, AutoNetworkedField] + public bool VerbOnly; + /// /// The name of what is being open and closed. /// E.g toilet lid, pannel, compartment. diff --git a/Content.Shared/Tools/Systems/ToolOpenableSystem.cs b/Content.Shared/Tools/Systems/ToolOpenableSystem.cs index 4951040350..10e0dd6869 100644 --- a/Content.Shared/Tools/Systems/ToolOpenableSystem.cs +++ b/Content.Shared/Tools/Systems/ToolOpenableSystem.cs @@ -30,7 +30,7 @@ public sealed class ToolOpenableSystem : EntitySystem private void OnInteractUsing(Entity entity, ref InteractUsingEvent args) { - if (args.Handled) + if (args.Handled || entity.Comp.VerbOnly) return; if (TryOpenClose(entity, args.Used, args.User)) diff --git a/Resources/Locale/en-US/storage/components/secret-stash-component.ftl b/Resources/Locale/en-US/storage/components/secret-stash-component.ftl index 16e575c0f1..c7f92fb91f 100644 --- a/Resources/Locale/en-US/storage/components/secret-stash-component.ftl +++ b/Resources/Locale/en-US/storage/components/secret-stash-component.ftl @@ -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 diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/cake.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/cake.yml index d5bf403d2e..3b9ae17b6a 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/cake.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/cake.yml @@ -26,6 +26,19 @@ - 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 -- 2.51.2