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,11 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Standing;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -252,7 +252,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
var akms = entityManager.SpawnEntity(ItemDummyId, coordinates);
|
||||
|
||||
// Equip items
|
||||
Assert.True(entityManager.TryGetComponent(akms, out ItemComponent item));
|
||||
Assert.True(entityManager.TryGetComponent(akms, out SharedItemComponent item));
|
||||
Assert.True(hands.PutInHand(item));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Clothing.Components;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Item;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using static Content.Shared.Inventory.EquipmentSlotDefines;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -19,23 +21,25 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
// Spawn everything.
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
var invSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InventorySystem>();
|
||||
|
||||
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
||||
|
||||
var entMgr = IoCManager.Resolve<IEntityManager>();
|
||||
var container = entMgr.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
var inv = entMgr.AddComponent<InventoryComponent>(container);
|
||||
entMgr.AddComponent<ServerInventoryComponent>(container);
|
||||
entMgr.AddComponent<ContainerManagerComponent>(container);
|
||||
|
||||
var child = entMgr.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
var item = entMgr.AddComponent<ClothingComponent>(child);
|
||||
var item = entMgr.AddComponent<ItemComponent>(child);
|
||||
item.SlotFlags = SlotFlags.HEAD;
|
||||
|
||||
// Equip item.
|
||||
Assert.That(inv.Equip(Slots.HEAD, item, false), Is.True);
|
||||
Assert.That(invSystem.TryEquip(container, child, "head"), Is.True);
|
||||
|
||||
// Delete parent.
|
||||
entMgr.DeleteEntity(container);
|
||||
@@ -43,8 +47,6 @@ namespace Content.IntegrationTests.Tests
|
||||
// Assert that child item was also deleted.
|
||||
Assert.That(item.Deleted, Is.True);
|
||||
});
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Actions;
|
||||
using Content.Client.Actions.UI;
|
||||
using Content.Client.Items.Components;
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Actions.Prototypes;
|
||||
using Content.Shared.Cooldown;
|
||||
using Content.Shared.Item;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -268,7 +268,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
|
||||
// grant an extra item action, before pickup, initially disabled
|
||||
itemActions.GrantOrUpdate(ItemActionType.DebugToggle, false);
|
||||
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<ItemComponent>(serverFlashlight), false);
|
||||
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<SharedItemComponent>(serverFlashlight), false);
|
||||
// grant an extra item action, after pickup, with a cooldown
|
||||
itemActions.GrantOrUpdate(ItemActionType.DebugInstant, cooldown: cooldown);
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
{
|
||||
// pick the item up again, the states should be back to what they were when dropped,
|
||||
// as the states "stick" with the item
|
||||
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<ItemComponent>(serverFlashlight), false);
|
||||
serverEntManager.GetComponent<HandsComponent>(serverPlayerEnt).PutInHand(serverEntManager.GetComponent<SharedItemComponent>(serverFlashlight), false);
|
||||
Assert.That(serverActionsComponent.ItemActionStates().TryGetValue(serverFlashlight, out var lightStates));
|
||||
Assert.That(lightStates.TryGetValue(ItemActionType.ToggleLight, out var lightState));
|
||||
Assert.That(lightState.Equals(new ActionState(true, toggledOn: true)));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#nullable enable annotations
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Items.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -13,6 +14,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Reflection;
|
||||
using ItemComponent = Content.Server.Clothing.Components.ItemComponent;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
{
|
||||
@@ -97,7 +99,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
Assert.That(interactHand);
|
||||
|
||||
Assert.That(sEntities.TryGetComponent<HandsComponent>(user, out var hands));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<ItemComponent>(item)));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<SharedItemComponent>(item)));
|
||||
|
||||
interactionSystem.UserInteraction(user, sEntities.GetComponent<TransformComponent>(target).Coordinates, target);
|
||||
Assert.That(interactUsing);
|
||||
@@ -169,7 +171,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
Assert.That(interactHand, Is.False);
|
||||
|
||||
Assert.That(sEntities.TryGetComponent<HandsComponent?>(user, out var hands));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<ItemComponent>(item)));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<SharedItemComponent>(item)));
|
||||
|
||||
interactionSystem.UserInteraction(user, sEntities.GetComponent<TransformComponent>(target).Coordinates, target);
|
||||
Assert.That(interactUsing, Is.False);
|
||||
@@ -238,7 +240,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
Assert.That(interactHand);
|
||||
|
||||
Assert.That(sEntities.TryGetComponent<HandsComponent>(user, out var hands));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<ItemComponent>(item)));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<SharedItemComponent>(item)));
|
||||
|
||||
interactionSystem.UserInteraction(user, sEntities.GetComponent<TransformComponent>(target).Coordinates, target);
|
||||
Assert.That(interactUsing);
|
||||
@@ -308,7 +310,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
Assert.That(interactHand, Is.False);
|
||||
|
||||
Assert.That(sEntities.TryGetComponent<HandsComponent?>(user, out var hands));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<ItemComponent>(item)));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<SharedItemComponent>(item)));
|
||||
|
||||
interactionSystem.UserInteraction(user, sEntities.GetComponent<TransformComponent>(target).Coordinates, target);
|
||||
Assert.That(interactUsing, Is.False);
|
||||
@@ -393,7 +395,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
Assert.That(interactHand);
|
||||
|
||||
Assert.That(sEntities.TryGetComponent<HandsComponent?>(user, out var hands));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<ItemComponent>(item)));
|
||||
Assert.That(hands.PutInHand(sEntities.GetComponent<SharedItemComponent>(item)));
|
||||
|
||||
interactionSystem.UserInteraction(user, sEntities.GetComponent<TransformComponent>(target).Coordinates, target);
|
||||
Assert.That(interactUsing, Is.False);
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Stunnable;
|
||||
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
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(InventoryHelpers))]
|
||||
public class InventoryHelpersTest : ContentIntegrationTest
|
||||
{
|
||||
private const string Prototypes = @"
|
||||
@@ -22,6 +19,7 @@ namespace Content.IntegrationTests.Tests
|
||||
id: InventoryStunnableDummy
|
||||
components:
|
||||
- type: Inventory
|
||||
- type: ContainerContainer
|
||||
- type: StatusEffects
|
||||
allowed:
|
||||
- Stun
|
||||
@@ -53,43 +51,41 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
var sEntities = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
EntityUid human = default;
|
||||
InventoryComponent inventory = null;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
var systemMan = IoCManager.Resolve<IEntitySystemManager>();
|
||||
|
||||
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
||||
|
||||
human = sEntities.SpawnEntity("InventoryStunnableDummy", MapCoordinates.Nullspace);
|
||||
inventory = sEntities.GetComponent<InventoryComponent>(human);
|
||||
var human = sEntities.SpawnEntity("InventoryStunnableDummy", MapCoordinates.Nullspace);
|
||||
var invSystem = systemMan.GetEntitySystem<InventorySystem>();
|
||||
|
||||
// Can't do the test if this human doesn't have the slots for it.
|
||||
Assert.That(inventory.HasSlot(Slots.INNERCLOTHING));
|
||||
Assert.That(inventory.HasSlot(Slots.IDCARD));
|
||||
Assert.That(invSystem.HasSlot(human, "jumpsuit"));
|
||||
Assert.That(invSystem.HasSlot(human, "id"));
|
||||
|
||||
Assert.That(inventory.SpawnItemInSlot(Slots.INNERCLOTHING, "InventoryJumpsuitJanitorDummy", true));
|
||||
Assert.That(invSystem.SpawnItemInSlot(human, "jumpsuit", "InventoryJumpsuitJanitorDummy", true));
|
||||
|
||||
// Do we actually have the uniform equipped?
|
||||
Assert.That(inventory.TryGetSlotItem(Slots.INNERCLOTHING, out ItemComponent uniform));
|
||||
Assert.That(sEntities.GetComponent<MetaDataComponent>(uniform.Owner).EntityPrototype is
|
||||
Assert.That(invSystem.TryGetSlotEntity(human, "jumpsuit", out var uniform));
|
||||
Assert.That(sEntities.GetComponent<MetaDataComponent>(uniform.Value).EntityPrototype is
|
||||
{
|
||||
ID: "InventoryJumpsuitJanitorDummy"
|
||||
});
|
||||
|
||||
EntitySystem.Get<StunSystem>().TryStun(human, TimeSpan.FromSeconds(1f), true);
|
||||
systemMan.GetEntitySystem<StunSystem>().TryStun(human, TimeSpan.FromSeconds(1f), true);
|
||||
|
||||
// Since the mob is stunned, they can't equip this.
|
||||
Assert.That(inventory.SpawnItemInSlot(Slots.IDCARD, "InventoryIDCardDummy", true), Is.False);
|
||||
Assert.That(invSystem.SpawnItemInSlot(human, "id", "InventoryIDCardDummy", true), Is.False);
|
||||
|
||||
// Make sure we don't have the ID card equipped.
|
||||
Assert.That(inventory.TryGetSlotItem(Slots.IDCARD, out ItemComponent _), Is.False);
|
||||
Assert.That(invSystem.TryGetSlotEntity(human, "item", out _), Is.False);
|
||||
|
||||
// Let's try skipping the interaction check and see if it equips it!
|
||||
Assert.That(inventory.SpawnItemInSlot(Slots.IDCARD, "InventoryIDCardDummy"));
|
||||
Assert.That(inventory.TryGetSlotItem(Slots.IDCARD, out ItemComponent id));
|
||||
Assert.That(sEntities.GetComponent<MetaDataComponent>(id.Owner).EntityPrototype is
|
||||
Assert.That(invSystem.SpawnItemInSlot(human, "id", "InventoryIDCardDummy", true, true));
|
||||
Assert.That(invSystem.TryGetSlotEntity(human, "id", out var idUid));
|
||||
Assert.That(sEntities.GetComponent<MetaDataComponent>(idUid.Value).EntityPrototype is
|
||||
{
|
||||
ID: "InventoryIDCardDummy"
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.PDA;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.PDA;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Player;
|
||||
@@ -58,6 +58,8 @@ namespace Content.IntegrationTests.Tests.PDA
|
||||
var sPlayerManager = server.ResolveDependency<IPlayerManager>();
|
||||
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
var invSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<InventorySystem>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var player = sPlayerManager.Sessions.Single().AttachedEntity.GetValueOrDefault();
|
||||
@@ -71,7 +73,7 @@ namespace Content.IntegrationTests.Tests.PDA
|
||||
|
||||
// Put PDA in hand
|
||||
var dummyPda = sEntityManager.SpawnEntity(PdaDummy, sEntityManager.GetComponent<TransformComponent>(player).MapPosition);
|
||||
var pdaItemComponent = sEntityManager.GetComponent<ItemComponent>(dummyPda);
|
||||
var pdaItemComponent = sEntityManager.GetComponent<SharedItemComponent>(dummyPda);
|
||||
sEntityManager.GetComponent<HandsComponent>(player).PutInHand(pdaItemComponent);
|
||||
|
||||
var pdaComponent = sEntityManager.GetComponent<PDAComponent>(dummyPda);
|
||||
@@ -91,7 +93,7 @@ namespace Content.IntegrationTests.Tests.PDA
|
||||
|
||||
// Put ID card in hand
|
||||
var idDummy = sEntityManager.SpawnEntity(IdCardDummy, sEntityManager.GetComponent<TransformComponent>(player).MapPosition);
|
||||
var idItemComponent = sEntityManager.GetComponent<ItemComponent>(idDummy);
|
||||
var idItemComponent = sEntityManager.GetComponent<SharedItemComponent>(idDummy);
|
||||
sEntityManager.GetComponent<HandsComponent>(player).PutInHand(idItemComponent);
|
||||
|
||||
var idCardComponent = sEntityManager.GetComponent<IdCardComponent>(idDummy);
|
||||
@@ -103,20 +105,16 @@ namespace Content.IntegrationTests.Tests.PDA
|
||||
Assert.That(id, Is.EqualTo(idCardComponent));
|
||||
|
||||
// Remove all IDs and PDAs
|
||||
var inventory = sEntityManager.GetComponent<InventoryComponent>(player);
|
||||
Assert.That(invSystem.TryGetSlots(player, out var slots));
|
||||
|
||||
foreach (var slot in inventory.Slots)
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
var item = inventory.GetSlotItem(slot);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
if(!invSystem.TryGetSlotEntity(player, slot.Name, out var item))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sEntityManager.HasComponent<PDAComponent>(item.Owner))
|
||||
if (sEntityManager.HasComponent<PDAComponent>(item))
|
||||
{
|
||||
inventory.ForceUnequip(slot);
|
||||
invSystem.TryUnequip(player, slot.Name, force: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user