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:
Paul Ritter
2021-12-30 22:56:10 +01:00
committed by GitHub
parent 7a5adb47a1
commit 512d6a38c3
199 changed files with 2493 additions and 3300 deletions

View File

@@ -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"
});