Can't butcher objects inside containers. (this time, the pr contains the code 🙃) (#11685)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
using Content.Server.Kitchen.Components;
|
using Content.Server.Kitchen.Components;
|
||||||
|
using Content.Server.MobState;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
@@ -7,6 +8,7 @@ using Content.Shared.Nutrition.Components;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
|
using Robust.Server.Containers;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ public sealed class SharpSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
|
[Dependency] private readonly ContainerSystem _containerSystem = default!;
|
||||||
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -48,7 +52,7 @@ public sealed class SharpSystem : EntitySystem
|
|||||||
if (butcher.Type != ButcheringType.Knife)
|
if (butcher.Type != ButcheringType.Knife)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TryComp<MobStateComponent>(target, out var mobState) && !mobState.IsDead())
|
if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!sharp.Butchering.Add(target))
|
if (!sharp.Butchering.Add(target))
|
||||||
@@ -77,6 +81,9 @@ public sealed class SharpSystem : EntitySystem
|
|||||||
if (!TryComp<SharpComponent>(ev.Sharp, out var sharp))
|
if (!TryComp<SharpComponent>(ev.Sharp, out var sharp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_containerSystem.IsEntityInContainer(ev.Entity))
|
||||||
|
return;
|
||||||
|
|
||||||
sharp.Butchering.Remove(ev.Entity);
|
sharp.Butchering.Remove(ev.Entity);
|
||||||
|
|
||||||
var spawnEntities = EntitySpawnCollection.GetSpawns(butcher.SpawnedEntities, _robustRandom);
|
var spawnEntities = EntitySpawnCollection.GetSpawns(butcher.SpawnedEntities, _robustRandom);
|
||||||
@@ -124,18 +131,23 @@ public sealed class SharpSystem : EntitySystem
|
|||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
string? message = null;
|
string? message = null;
|
||||||
|
|
||||||
if (TryComp<MobStateComponent>(uid, out var state) && !state.IsDead())
|
|
||||||
{
|
|
||||||
disabled = true;
|
|
||||||
message = Loc.GetString("butcherable-mob-isnt-dead");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Using is null || !HasComp<SharpComponent>(args.Using))
|
if (args.Using is null || !HasComp<SharpComponent>(args.Using))
|
||||||
{
|
{
|
||||||
disabled = true;
|
disabled = true;
|
||||||
message = Loc.GetString("butcherable-need-knife",
|
message = Loc.GetString("butcherable-need-knife",
|
||||||
("target", uid));
|
("target", uid));
|
||||||
}
|
}
|
||||||
|
else if (_containerSystem.IsEntityInContainer(uid))
|
||||||
|
{
|
||||||
|
message = Loc.GetString("butcherable-not-in-container",
|
||||||
|
("target", uid));
|
||||||
|
disabled = true;
|
||||||
|
}
|
||||||
|
else if (TryComp<MobStateComponent>(uid, out var state) && !_mobStateSystem.IsDead(uid, state))
|
||||||
|
{
|
||||||
|
disabled = true;
|
||||||
|
message = Loc.GetString("butcherable-mob-isnt-dead");
|
||||||
|
}
|
||||||
|
|
||||||
InteractionVerb verb = new()
|
InteractionVerb verb = new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
butcherable-knife-butchered-success = You butcher { THE($target) } with { THE($knife) }.
|
butcherable-knife-butchered-success = You butcher { THE($target) } with { THE($knife) }.
|
||||||
butcherable-need-knife = Use a sharp object to butcher { THE($target) }.
|
butcherable-need-knife = Use a sharp object to butcher { THE($target) }.
|
||||||
|
butcherable-not-in-container = { CAPITALIZE(THE($target)) } can't be in a container.
|
||||||
butcherable-mob-isnt-dead = Needs to be dead.
|
butcherable-mob-isnt-dead = Needs to be dead.
|
||||||
butcherable-verb-name = Butcher
|
butcherable-verb-name = Butcher
|
||||||
|
|||||||
Reference in New Issue
Block a user