Rejigging Item slots (#4933)

* itemslot overhaul

* remove "shared" prefix

* handle component shutdown

* comments, cleanup, tests

* comments and minor tweak

* rename ItemSlotManagerState

* fix swapping

* fix merge

* Add ItemSlot verb text override

* fix merge  (IEntity -> entityUid)

* Fix merge (LabelSystem)

* Fix merge (nuke disk)

* fix test
This commit is contained in:
Leon Friedrich
2021-11-20 18:26:01 +13:00
committed by GitHub
parent 19c5fed53a
commit 91b185e3c2
28 changed files with 805 additions and 554 deletions

View File

@@ -42,7 +42,6 @@ namespace Content.IntegrationTests.Tests
Slots:
- idcard
- type: PDA
idCard: AssistantIDCard
";
[Test]
public async Task SpawnItemInSlotTest()

View File

@@ -29,13 +29,12 @@ namespace Content.IntegrationTests.Tests.PDA
id: {PdaDummy}
name: {PdaDummy}
components:
- type: ItemSlots
slots:
pdaIdSlot:
whitelist:
components:
- IdCard
- type: PDA
idSlot:
name: ID Card
whitelist:
components:
- IdCard
- type: Item";
[Test]
@@ -77,9 +76,9 @@ namespace Content.IntegrationTests.Tests.PDA
var pdaComponent = dummyPda.GetComponent<PDAComponent>();
var pdaIdCard = sEntityManager.SpawnEntity(IdCardDummy, player.Transform.MapPosition);
var itemSlots = dummyPda.GetComponent<SharedItemSlotsComponent>();
sEntityManager.EntitySysManager.GetEntitySystem<SharedItemSlotsSystem>()
.TryInsertContent(itemSlots, pdaIdCard, pdaComponent.IdSlot);
var itemSlots = dummyPda.GetComponent<ItemSlotsComponent>();
sEntityManager.EntitySysManager.GetEntitySystem<ItemSlotsSystem>()
.TryInsert(dummyPda.Uid, pdaComponent.IdSlot, pdaIdCard);
var pdaContainedId = pdaComponent.ContainedID;
// The PDA in the hand should be found first

View File

@@ -98,7 +98,7 @@ namespace Content.IntegrationTests.Tests.Utility
// Test from serialized
var dummy = entityManager.SpawnEntity("WhitelistDummy", mapCoordinates);
var whitelistSer = dummy.GetComponent<SharedItemSlotsComponent>().Slots.Values.First().Whitelist;
var whitelistSer = dummy.GetComponent<ItemSlotsComponent>().Slots.Values.First().Whitelist;
Assert.That(whitelistSer, Is.Not.Null);
Assert.That(whitelistSer.Components, Is.Not.Null);