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 <milonpl.git@proton.me>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user