Fix body bags not taking humans (#6125)

This commit is contained in:
Leon Friedrich
2022-01-11 17:55:27 +13:00
committed by GitHub
parent 552e04d7ea
commit 05df798f11
2 changed files with 19 additions and 4 deletions

View File

@@ -48,9 +48,13 @@ namespace Content.Server.Foldable
if (TryComp(uid, out StrapComponent? strap) && strap.BuckledEntities.Any()) if (TryComp(uid, out StrapComponent? strap) && strap.BuckledEntities.Any())
return false; return false;
// Also check if this entity is "open" (e.g., body bags) if (!TryComp(uid, out EntityStorageComponent? storage))
return !TryComp(uid, out EntityStorageComponent? storage) || !storage.Open; return true;
if (storage.Open)
return false;
return !storage.Contents.ContainedEntities.Any();
} }
/// <summary> /// <summary>

View File

@@ -8,6 +8,7 @@ using Content.Server.Ghost.Components;
using Content.Server.Tools; using Content.Server.Tools;
using Content.Shared.Acts; using Content.Shared.Acts;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Foldable;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Physics; using Content.Shared.Physics;
@@ -233,11 +234,13 @@ namespace Content.Server.Storage.Components
continue; continue;
// conditions are complicated because of pizzabox-related issues, so follow this guide // conditions are complicated because of pizzabox-related issues, so follow this guide
// 0. Accomplish your goals at all costs.
// 1. AddToContents can block anything // 1. AddToContents can block anything
// 2. maximum item count can block anything // 2. maximum item count can block anything
// 3. ghosts can NEVER be eaten // 3. ghosts can NEVER be eaten
// 4. items can always be eaten unless a previous law prevents it // 4. items can always be eaten unless a previous law prevents it
// 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it // 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it
// 6. if this is an item, then mobs must only be eaten if some other component prevents pick-up interactions while a mob is inside (e.g. foldable)
// Let's not insert admin ghosts, yeah? This is really a a hack and should be replaced by attempt events // Let's not insert admin ghosts, yeah? This is really a a hack and should be replaced by attempt events
if (_entMan.HasComponent<GhostComponent>(entity)) if (_entMan.HasComponent<GhostComponent>(entity))
@@ -259,8 +262,16 @@ namespace Content.Server.Storage.Components
// Seriously, it is insanely hacky and weird to get someone out of a backpack once they end up in there. // Seriously, it is insanely hacky and weird to get someone out of a backpack once they end up in there.
// And to be clear, they should NOT be in there. // And to be clear, they should NOT be in there.
// For the record, what you need to do is empty the backpack onto a PlacableSurface (table, rack) // For the record, what you need to do is empty the backpack onto a PlacableSurface (table, rack)
if (targetIsMob && !storageIsItem) if (targetIsMob)
allowedToEat = true; {
if (!storageIsItem)
allowedToEat = true;
else
{
// make an exception if this is a foldable-item that is currently un-folded (e.g., body bags).
allowedToEat = _entMan.TryGetComponent(Owner, out FoldableComponent? foldable) && !foldable.IsFolded;
}
}
if (!allowedToEat) if (!allowedToEat)
continue; continue;