Better inventory window, inventory buttons on game HUD.

Part of #272
This commit is contained in:
Pieter-Jan Briers
2019-07-23 23:24:47 +02:00
parent 4d202a7678
commit 1fbb5915aa
12 changed files with 431 additions and 252 deletions

View File

@@ -1,17 +1,53 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using System;
using System;
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
namespace Content.Shared.GameObjects
{
public abstract class SharedInventoryComponent : Component
{
// ReSharper disable UnassignedReadonlyField
[Dependency] protected readonly IReflectionManager ReflectionManager;
[Dependency] protected readonly IDynamicTypeFactory DynamicTypeFactory;
// ReSharper restore UnassignedReadonlyField
public sealed override string Name => "Inventory";
public sealed override uint? NetID => ContentNetIDs.STORAGE;
public sealed override Type StateType => typeof(InventoryComponentState);
[ViewVariables]
protected Inventory InventoryInstance { get; private set; }
[ViewVariables]
private string _templateName = "HumanInventory"; //stored for serialization purposes
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _templateName, "Template", "HumanInventory");
}
public override void Initialize()
{
base.Initialize();
CreateInventory();
}
private void CreateInventory()
{
var type = ReflectionManager.LooseGetType(_templateName);
DebugTools.Assert(type != null);
InventoryInstance = DynamicTypeFactory.CreateInstance<Inventory>(type);
}
[Serializable, NetSerializable]
protected class InventoryComponentState : ComponentState
{