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,

View File

@@ -1,3 +1,4 @@
using Content.Shared.Containers.ItemSlots;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
@@ -25,7 +26,7 @@ namespace Content.Server.Nutrition.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<UtensilComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<UtensilComponent, AfterInteractEvent>(OnAfterInteract, after: new[] { typeof(ItemSlotsSystem) });
}
/// <summary>
@@ -33,6 +34,9 @@ namespace Content.Server.Nutrition.EntitySystems
/// </summary>
private void OnAfterInteract(EntityUid uid, UtensilComponent component, AfterInteractEvent ev)
{
if (ev.Handled)
return;
if (ev.Target == null || !ev.CanReach)
return;

View File

@@ -1 +1 @@
clothing-military-boots-sidearm = Sidearm
clothing-boots-sidearm = Sidearm

View File

@@ -45,7 +45,7 @@
- type: ItemSlots
slots:
item:
name: clothing-military-boots-sidearm
name: clothing-boots-sidearm
whitelist:
tags:
- Knife

View File

@@ -9,8 +9,26 @@
- type: Clothing
sprite: Clothing/Shoes/Specific/chef.rsi
# stuff common to all clown & jester shoes
- type: entity
parent: ClothingShoesBaseButcherable
abstract: true
parent: [ClothingShoesBaseButcherable, ClothingSlotBase]
id: ClothingShoesClownBase
components:
- type: ItemSlots
slots:
item:
name: clothing-boots-sidearm
whitelist:
tags:
- Knife
- ToySidearm
blacklist:
components:
- Sharp
- type: entity
parent: ClothingShoesClownBase
id: ClothingShoesClown
name: clown shoes
description: "The prankster's standard-issue clowning shoes. Damn they're huge!"
@@ -49,7 +67,7 @@
acceleration: 5
- type: entity
parent: ClothingShoesBaseButcherable
parent: ClothingShoesClownBase
id: ClothingShoesBling
name: bling clown shoes
description: Made of refined bananium and shined with the pulp of a fresh banana peel. These make a flashy statement.

View File

@@ -400,6 +400,9 @@
Quantity: 3
- ReagentId: Fat
Quantity: 3
- type: SliceableFood
count: 3
slice: FoodMeatCutlet
- type: entity
name: raw lizard meat

View File

@@ -893,6 +893,7 @@
- type: Tag
tags:
- Sidearm
- ToySidearm
- type: Gun
selectedMode: SemiAuto
availableModes:
@@ -925,14 +926,14 @@
suffix: Fake
description: Looks almost like the real thing! Ages 8 and up.
components:
- type: RevolverAmmoProvider
whitelist:
tags:
- CartridgeCap
- SpeedLoaderCap
- CartridgeMagnum
- SpeedLoaderMagnum
proto: CartridgeMagnumAP
- type: RevolverAmmoProvider
whitelist:
tags:
- CartridgeCap
- SpeedLoaderCap
- CartridgeMagnum
- SpeedLoaderMagnum
proto: CartridgeMagnumAP
- type: entity
parent: BaseItem

View File

@@ -7,9 +7,6 @@
sprite: Objects/Misc/utensils.rsi
- type: Item # TODO add inhand sprites for all utensils
sprite: Objects/Misc/utensils.rsi
- type: Tag
tags:
- Metal
- type: SpaceGarbage
- type: entity
@@ -23,8 +20,14 @@
price: 0
- type: Tag
tags:
- Plastic
- Trash
- Plastic
- Trash
- type: MeleeWeapon
wideAnimationRotation: 180
attackRate: 1.5
damage:
types:
Blunt: 0
- type: entity
parent: UtensilBase
@@ -66,6 +69,9 @@
name: spoon
description: There is no spoon.
components:
- type: Tag
tags:
- Metal
- type: Sprite
state: spoon
- type: Item
@@ -99,7 +105,7 @@
speedModifier: 0.1 # you can try
- type: entity
parent: UtensilBase
parent: UtensilBasePlastic
id: KnifePlastic
name: plastic knife
description: That's not a knife. This is a knife.
@@ -109,3 +115,8 @@
- type: Utensil
types:
- Knife
- type: Tag
tags:
- Plastic
- Trash
- Knife

View File

@@ -1181,6 +1181,9 @@
- type: Tag
id: Torch
- type: Tag
id: ToySidearm
- type: Tag
id: Trash