Fix Butcherable handling, ItemSlots for clown shoes (#25661)

* Fix butcherable handling

* ItemSlots for clown shoes

* Return if handled

* Handle if popup

* Whitespace, spoons are metal

* Zero damage plastic utensils, blacklist by metal+melee

* Hmmm truthy

* Plastic knives are knives too, just use that

* Delete unused tag

* Always true if doAfter

* Raw rat meat should be sliceable too
This commit is contained in:
Krunklehorn
2024-03-13 06:03:14 -04:00
committed by GitHub
parent 3981173a15
commit 674b42b3a0
9 changed files with 75 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Body.Components;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Verbs;
@@ -34,7 +35,7 @@ public sealed class SharpSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract, before: new[] { typeof(UtensilSystem) });
SubscribeLocalEvent<SharpComponent, SharpDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<ButcherableComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
@@ -42,31 +43,34 @@ public sealed class SharpSystem : EntitySystem
private void OnAfterInteract(EntityUid uid, SharpComponent component, AfterInteractEvent args)
{
if (args.Handled)
return;
if (args.Target is null || !args.CanReach)
return;
TryStartButcherDoafter(uid, args.Target.Value, args.User);
args.Handled = TryStartButcherDoAfter(uid, args.Target.Value, args.User);
}
private void TryStartButcherDoafter(EntityUid knife, EntityUid target, EntityUid user)
private bool TryStartButcherDoAfter(EntityUid knife, EntityUid target, EntityUid user)
{
if (!TryComp<ButcherableComponent>(target, out var butcher))
return;
return false;
if (!TryComp<SharpComponent>(knife, out var sharp))
return;
return false;
if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
return false;
if (butcher.Type != ButcheringType.Knife && target != user)
{
_popupSystem.PopupEntity(Loc.GetString("butcherable-different-tool", ("target", target)), knife, user);
return;
return true;
}
if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
return;
if (!sharp.Butchering.Add(target))
return;
return true;
var doAfter =
new DoAfterArgs(EntityManager, user, sharp.ButcherDelayModifier * butcher.ButcherDelay, new SharpDoAfterEvent(), knife, target: target, used: knife)
@@ -77,6 +81,7 @@ public sealed class SharpSystem : EntitySystem
NeedHand = true
};
_doAfterSystem.TryStartDoAfter(doAfter);
return true;
}
private void OnDoAfter(EntityUid uid, SharpComponent component, DoAfterEvent args)
@@ -161,7 +166,7 @@ public sealed class SharpSystem : EntitySystem
Act = () =>
{
if (!disabled)
TryStartButcherDoafter(args.Using!.Value, args.Target, args.User);
TryStartButcherDoAfter(args.Using!.Value, args.Target, args.User);
},
Message = message,
Disabled = disabled,