get that crap outta here (completely rewrites inventorysystem) (#5807)
* some work * equip: done unequip: todo * unequipping done & refactored events * workin * movin * reee namespaces * stun * mobstate * fixes * some work on events * removes serverside itemcomp & misc fixes * work * smol merge fix * ports template to prototype & finishes ui * moves relay & adds containerenumerator * actions & cuffs * my god what is actioncode * more fixes * im loosing my grasp on reality * more fixes * more work * explosions * yes * more work * more fixes * merge master & misc fixed because i forgot to commit before merging master * more fixes * fixes * moar * more work * moar fixes * suffixmap * more work on client * motivation low * no. no containers * mirroring client to server * fixes * move serverinvcomp * serverinventorycomponent is dead * gaming * only strippable & ai left... * only ai and richtext left * fixes ai * fixes * fixes sprite layers * more fixes * resolves optional * yes * stable™️ * fixes * moar fixes * moar * fix some tests * lmao * no comment * good to merge™️ * fixes build but for real * adresses some reviews * adresses some more reviews * nullables, yo * fixes lobbyscreen * timid refactor to differentiate actor & target * adresses more reviews * more * my god what a mess * removed the rest of duplicates * removed duplicate slotflags and renamed shoes to feet * removes another unused one * yes * fixes lobby & makes tryunequip return unequipped item * fixes * some funny renames * fixes * misc improvements to attemptevents * fixes * merge fixes Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Shared.Inventory;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using static Content.Shared.Inventory.EquipmentSlotDefines;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
// Tests the behavior of HumanInventoryControllerComponent.
|
||||
// Tests the behavior of InventoryComponent.
|
||||
// i.e. the interaction between uniforms and the pocket/ID slots.
|
||||
// and also how big items don't fit in pockets.
|
||||
[TestFixture]
|
||||
[TestOf(typeof(HumanInventoryControllerComponent))]
|
||||
public class HumanInventoryUniformSlotsTest : ContentIntegrationTest
|
||||
{
|
||||
private const string Prototypes = @"
|
||||
@@ -21,7 +20,7 @@ namespace Content.IntegrationTests.Tests
|
||||
id: HumanDummy
|
||||
components:
|
||||
- type: Inventory
|
||||
- type: HumanInventoryController
|
||||
- type: ContainerContainer
|
||||
|
||||
- type: entity
|
||||
name: UniformDummy
|
||||
@@ -67,8 +66,11 @@ namespace Content.IntegrationTests.Tests
|
||||
EntityUid pocketItem = default;
|
||||
InventoryComponent inventory = null;
|
||||
|
||||
InventorySystem invSystem = default!;
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
invSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InventorySystem>();
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
||||
@@ -81,26 +83,25 @@ namespace Content.IntegrationTests.Tests
|
||||
pocketItem = entityMan.SpawnEntity("FlashlightDummy", MapCoordinates.Nullspace);
|
||||
var tooBigItem = entityMan.SpawnEntity("ToolboxDummy", MapCoordinates.Nullspace);
|
||||
|
||||
inventory = entityMan.GetComponent<InventoryComponent>(human);
|
||||
|
||||
Assert.That(inventory.CanEquip(Slots.INNERCLOTHING, uniform));
|
||||
Assert.That(invSystem.CanEquip(human, uniform, "jumpsuit", out _));
|
||||
|
||||
// Can't equip any of these since no uniform!
|
||||
Assert.That(inventory.CanEquip(Slots.IDCARD, idCard), Is.False);
|
||||
Assert.That(inventory.CanEquip(Slots.POCKET1, pocketItem), Is.False);
|
||||
Assert.That(inventory.CanEquip(Slots.POCKET1, tooBigItem), Is.False); // This one fails either way.
|
||||
Assert.That(invSystem.CanEquip(human, idCard, "id", out _), Is.False);
|
||||
Assert.That(invSystem.CanEquip(human, pocketItem, "pocket1", out _), Is.False);
|
||||
Assert.That(invSystem.CanEquip(human, tooBigItem, "pocket2", out _), Is.False); // This one fails either way.
|
||||
|
||||
inventory.Equip(Slots.INNERCLOTHING, uniform);
|
||||
Assert.That(invSystem.TryEquip(human, uniform, "jumpsuit"));
|
||||
|
||||
Assert.That(inventory.Equip(Slots.IDCARD, idCard));
|
||||
Assert.That(inventory.Equip(Slots.POCKET1, pocketItem));
|
||||
Assert.That(inventory.CanEquip(Slots.POCKET1, tooBigItem), Is.False); // Still failing!
|
||||
Assert.That(invSystem.TryEquip(human, idCard, "id"));
|
||||
Assert.That(invSystem.CanEquip(human, tooBigItem, "pocket1", out _), Is.False); // Still failing!
|
||||
Assert.That(invSystem.TryEquip(human, pocketItem, "pocket1"));
|
||||
|
||||
Assert.That(IsDescendant(idCard, human));
|
||||
Assert.That(IsDescendant(pocketItem, human));
|
||||
|
||||
// Now drop the jumpsuit.
|
||||
inventory.Unequip(Slots.INNERCLOTHING);
|
||||
Assert.That(invSystem.TryUnequip(human, "jumpsuit"));
|
||||
});
|
||||
|
||||
server.RunTicks(2);
|
||||
@@ -113,9 +114,9 @@ namespace Content.IntegrationTests.Tests
|
||||
Assert.That(IsDescendant(pocketItem, human), Is.False);
|
||||
|
||||
// Ensure everything null here.
|
||||
Assert.That(inventory.GetSlotItem(Slots.INNERCLOTHING), Is.Null);
|
||||
Assert.That(inventory.GetSlotItem(Slots.IDCARD), Is.Null);
|
||||
Assert.That(inventory.GetSlotItem(Slots.POCKET1), Is.Null);
|
||||
Assert.That(!invSystem.TryGetSlotEntity(human, "jumpsuit", out _));
|
||||
Assert.That(!invSystem.TryGetSlotEntity(human, "id", out _));
|
||||
Assert.That(!invSystem.TryGetSlotEntity(human, "pocket1", out _));
|
||||
});
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
Reference in New Issue
Block a user