@@ -1,11 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
||||
|
||||
namespace Content.Shared.GameObjects
|
||||
{
|
||||
public abstract class Inventory
|
||||
{
|
||||
public abstract int Columns { get; }
|
||||
public abstract string InterfaceControllerTypeName { get; }
|
||||
|
||||
public abstract IReadOnlyList<Slots> SlotMasks { get; }
|
||||
|
||||
@@ -19,11 +20,13 @@ namespace Content.Shared.GameObjects
|
||||
public abstract int SlotDrawingOrder(Slots slot);
|
||||
}
|
||||
|
||||
// Dynamically created by SharedInventoryComponent.
|
||||
[UsedImplicitly]
|
||||
public class HumanInventory : Inventory
|
||||
{
|
||||
public override int Columns => 3;
|
||||
public override string InterfaceControllerTypeName => "HumanInventoryInterfaceController";
|
||||
|
||||
private static Dictionary<Slots, int> _slotDrawingOrder = new Dictionary<Slots, int>
|
||||
private static readonly Dictionary<Slots, int> _slotDrawingOrder = new Dictionary<Slots, int>
|
||||
{
|
||||
{Slots.HEAD, 10},
|
||||
{Slots.MASK, 9},
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user