if (ev.Cancelled)
return;
+ var afterEvent = new AfterFullyEatenEvent(user);
+ RaiseLocalEvent(food, ref afterEvent);
+
var dev = new DestructionEventArgs();
RaiseLocalEvent(food, dev);
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
+using Content.Shared.Destructible;
namespace Content.Server.Nutrition.EntitySystems;
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)
{
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;
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.
using Robust.Shared.Serialization;
using Robust.Shared.Audio;
using Content.Shared.Whitelist;
+using Content.Shared.Damage;
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>
using Content.Shared.Construction.EntitySystems;
+using Content.Shared.Damage;
using Content.Shared.Destructible;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
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;
[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()
{
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);
}
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))
[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.
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))
secret-stash-plant = plant
secret-stash-toilet = toilet cistern
secret-stash-plushie = plushie
+secret-stash-cake = cake
- 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