diff --git a/SEConfigTool/SEConfigTool.csproj b/SEConfigTool/SEConfigTool.csproj
index f059a15e..df4f6e1d 100644
--- a/SEConfigTool/SEConfigTool.csproj
+++ b/SEConfigTool/SEConfigTool.csproj
@@ -46,6 +46,10 @@
False
..\GameLibraries\Sandbox.Common.XmlSerializers.dll
+
+ False
+ ..\GameLibraries\Sandbox.Game.dll
+
diff --git a/SEModAPI/API/TypeConverters.cs b/SEModAPI/API/TypeConverters.cs
index 4f4927bc..4e9d0eb7 100644
--- a/SEModAPI/API/TypeConverters.cs
+++ b/SEModAPI/API/TypeConverters.cs
@@ -103,160 +103,4 @@ public override object CreateInstance(ITypeDescriptorContext context, System.Col
return new Vector3I((int)propertyValues["X"], (int)propertyValues["Y"], (int)propertyValues["Z"]);
}
}
-
- public class ItemSerializableDefinitionIdTypeConverter : TypeConverter
- {
- private static PhysicalItemDefinitionsManager m_physicalItemsManager;
- private static ComponentDefinitionsManager m_componentsManager;
- private static AmmoMagazinesDefinitionsManager m_ammoManager;
-
- private static List m_idList;
-
- public ItemSerializableDefinitionIdTypeConverter()
- {
- //Load up the static item managers
- if (m_physicalItemsManager == null)
- {
- m_physicalItemsManager = new PhysicalItemDefinitionsManager();
- m_physicalItemsManager.Load(PhysicalItemDefinitionsManager.GetContentDataFile("PhysicalItems.sbc"));
- }
- if (m_componentsManager == null)
- {
- m_componentsManager = new ComponentDefinitionsManager();
- m_componentsManager.Load(ComponentDefinitionsManager.GetContentDataFile("Components.sbc"));
- }
- if (m_ammoManager == null)
- {
- m_ammoManager = new AmmoMagazinesDefinitionsManager();
- m_ammoManager.Load(AmmoMagazinesDefinitionsManager.GetContentDataFile("AmmoMagazines.sbc"));
- }
-
- //Populate the static list with the ids from the items
- if (m_idList == null)
- {
- m_idList = new List();
- foreach (var def in m_physicalItemsManager.Definitions)
- {
- m_idList.Add(def.Id);
- }
- foreach (var def in m_componentsManager.Definitions)
- {
- m_idList.Add(def.Id);
- }
- foreach (var def in m_ammoManager.Definitions)
- {
- m_idList.Add(def.Id);
- }
- }
- }
-
- public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
- {
- return true;
- }
-
- public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
- {
- return new StandardValuesCollection(m_idList);
- }
-
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
- else
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
- {/*
- if (value.GetType() == typeof(string))
- {
- string source = (string)value;
- source = source.Replace(" ", "");
- string[] sourceParts = source.Split('/');
- if (sourceParts.Length == 2)
- {
- MyObjectBuilderTypeEnum typeId;
- if (Enum.TryParse(sourceParts[0], out typeId))
- {
- SerializableDefinitionId result = new SerializableDefinitionId(typeId, sourceParts[1]);
- return result;
- }
- }
- }
- */
- return base.ConvertFrom(context, culture, value);
- }
- }
-
- public class ObjectSerializableDefinitionIdTypeConverter : TypeConverter
- {
- private static CubeBlockDefinitionsManager m_blocksManager;
- private static List m_idList;
-
- public ObjectSerializableDefinitionIdTypeConverter()
- {
- //Load up the static item managers
- if (m_blocksManager == null)
- {
- m_blocksManager = new CubeBlockDefinitionsManager();
- m_blocksManager.Load(CubeBlockDefinitionsManager.GetContentDataFile("CubeBlocks.sbc"));
- }
-
- //Populate the static list with the ids from the items
- if (m_idList == null)
- {
- m_idList = new List();
- foreach (var def in m_blocksManager.Definitions)
- {
- m_idList.Add(def.Id);
- }
-
- //m_idList.Add(new SerializableDefinitionId(MyObjectBuilderTypeEnum.CubeGrid, ""));
- //m_idList.Add(new SerializableDefinitionId(MyObjectBuilderTypeEnum.VoxelMap, ""));
- //m_idList.Add(new SerializableDefinitionId(MyObjectBuilderTypeEnum.FloatingObject, ""));
- //m_idList.Add(new SerializableDefinitionId(MyObjectBuilderTypeEnum.Meteor, ""));
- }
- }
-
- public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
- {
- return true;
- }
-
- public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
- {
- return new StandardValuesCollection(m_idList);
- }
-
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
- else
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
- {/*
- if (value.GetType() == typeof(string))
- {
- string source = (string)value;
- source = source.Replace(" ", "");
- string[] sourceParts = source.Split('/');
- if (sourceParts.Length == 2)
- {
- MyObjectBuilderTypeEnum typeId;
- if (Enum.TryParse(sourceParts[0], out typeId))
- {
- SerializableDefinitionId result = new SerializableDefinitionId(typeId, sourceParts[1]);
- return result;
- }
- }
- }
- */
- return base.ConvertFrom(context, culture, value);
- }
- }
}
diff --git a/SEModAPIExtensions/API/ChatManager.cs b/SEModAPIExtensions/API/ChatManager.cs
index 30ac3b08..32f6a6f4 100644
--- a/SEModAPIExtensions/API/ChatManager.cs
+++ b/SEModAPIExtensions/API/ChatManager.cs
@@ -3,34 +3,26 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
using System.ServiceModel;
-using System.ServiceModel.Description;
-using System.Text;
using System.Text.RegularExpressions;
+using System.Threading;
using System.Xml;
using Sandbox.Common.ObjectBuilders;
-using SEModAPI.API.Definitions;
-
-using SEModAPIExtensions.API.IPC;
-
using SEModAPIInternal.API.Server;
using SEModAPIInternal.API.Common;
using SEModAPIInternal.API.Entity;
using SEModAPIInternal.API.Entity.Sector.SectorObject;
using SEModAPIInternal.API.Entity.Sector.SectorObject.CubeGrid;
using SEModAPIInternal.API.Entity.Sector.SectorObject.CubeGrid.CubeBlock;
-using SEModAPIInternal.API.Utility;
using SEModAPIInternal.Support;
-using VRageMath;
+using VRage;
using VRage.Common.Utils;
-using System.Threading;
+using VRageMath;
namespace SEModAPIExtensions.API
{
@@ -102,6 +94,7 @@ public struct ChatEvent
private static List m_chatMessages;
private static List m_chatHistory;
private static bool m_chatHandlerSetup;
+ private static FastResourceLock m_resourceLock;
private List m_chatEvents;
private Dictionary m_chatCommands;
@@ -124,6 +117,7 @@ protected ChatManager()
m_chatMessages = new List();
m_chatHistory = new List();
m_chatHandlerSetup = false;
+ m_resourceLock = new FastResourceLock();
m_chatEvents = new List();
m_chatCommands = new Dictionary();
@@ -289,7 +283,13 @@ public List ChatHistory
}
}
- return m_chatHistory;
+ m_resourceLock.AcquireShared();
+
+ List history = new List(m_chatHistory);
+
+ m_resourceLock.ReleaseShared();
+
+ return history;
}
}
@@ -390,7 +390,9 @@ protected void ReceiveChatMessage(ulong remoteUserId, string message, ChatEntryT
chatEvent.priority = 0;
ChatManager.Instance.AddEvent(chatEvent);
+ m_resourceLock.AcquireExclusive();
m_chatHistory.Add(chatEvent);
+ m_resourceLock.ReleaseExclusive();
}
public void SendPrivateChatMessage(ulong remoteUserId, string message)
@@ -421,7 +423,9 @@ public void SendPrivateChatMessage(ulong remoteUserId, string message)
chatEvent.priority = 0;
ChatManager.Instance.AddEvent(chatEvent);
+ m_resourceLock.AcquireExclusive();
m_chatHistory.Add(chatEvent);
+ m_resourceLock.ReleaseExclusive();
}
catch (Exception ex)
{
@@ -471,7 +475,9 @@ public void SendPublicChatMessage(string message)
selfChatEvent.priority = 0;
ChatManager.Instance.AddEvent(selfChatEvent);
+ m_resourceLock.AcquireExclusive();
m_chatHistory.Add(selfChatEvent);
+ m_resourceLock.ReleaseExclusive();
}
catch (Exception ex)
{
diff --git a/SEModAPIInternal/API/Common/GameEntityManager.cs b/SEModAPIInternal/API/Common/GameEntityManager.cs
index 80f1230a..39452fce 100644
--- a/SEModAPIInternal/API/Common/GameEntityManager.cs
+++ b/SEModAPIInternal/API/Common/GameEntityManager.cs
@@ -76,26 +76,26 @@ public static BaseObject GetEntity(long entityId)
internal static void AddEntity(long entityId, BaseObject entity)
{
- m_resourceLock.AcquireExclusive();
+ //m_resourceLock.AcquireExclusive();
if (m_entityMap.ContainsKey(entityId))
return;
m_entityMap.Add(entityId, entity);
- m_resourceLock.ReleaseExclusive();
+ //m_resourceLock.ReleaseExclusive();
}
internal static void RemoveEntity(long entityId)
{
- m_resourceLock.AcquireExclusive();
+ //m_resourceLock.AcquireExclusive();
if (!m_entityMap.ContainsKey(entityId))
return;
m_entityMap.Remove(entityId);
- m_resourceLock.ReleaseExclusive();
+ //m_resourceLock.ReleaseExclusive();
}
internal static Object GetGameEntity(long entityId, Type entityType)
diff --git a/SEModAPIInternal/API/Entity/BaseObject.cs b/SEModAPIInternal/API/Entity/BaseObject.cs
index 417e7a2a..8f30b815 100644
--- a/SEModAPIInternal/API/Entity/BaseObject.cs
+++ b/SEModAPIInternal/API/Entity/BaseObject.cs
@@ -21,6 +21,7 @@
using SEModAPIInternal.Support;
using VRage;
+using Sandbox.Definitions;
namespace SEModAPIInternal.API.Entity
{
@@ -36,6 +37,8 @@ public class BaseObject : IDisposable
#region "Attributes"
protected MyObjectBuilder_Base m_objectBuilder;
+ protected MyDefinitionId m_definitionId;
+ protected MyDefinitionBase m_definition;
protected Object m_backingObject;
protected bool m_isDisposed = false;
@@ -47,12 +50,38 @@ public class BaseObject : IDisposable
public BaseObject(MyObjectBuilder_Base baseEntity)
{
m_objectBuilder = baseEntity;
+
+ m_definitionId = new MyDefinitionId(m_objectBuilder.TypeId, m_objectBuilder.SubtypeId.ToString());
+ if (!string.IsNullOrEmpty(m_objectBuilder.SubtypeName))
+ {
+ try
+ {
+ m_definition = MyDefinitionManager.Static.GetDefinition(m_definitionId);
+ }
+ catch (Exception)
+ {
+ //Do nothing!
+ }
+ }
}
public BaseObject(MyObjectBuilder_Base baseEntity, Object backingObject)
{
m_objectBuilder = baseEntity;
m_backingObject = backingObject;
+
+ m_definitionId = new MyDefinitionId(m_objectBuilder.TypeId, m_objectBuilder.SubtypeId.ToString());
+ if (!string.IsNullOrEmpty(m_objectBuilder.SubtypeName))
+ {
+ try
+ {
+ m_definition = MyDefinitionManager.Static.GetDefinition(m_definitionId);
+ }
+ catch (Exception)
+ {
+ //Do nothing!
+ }
+ }
}
#endregion
@@ -123,13 +152,29 @@ public Object BackingObject
[Category("Object")]
[Browsable(true)]
[ReadOnly(true)]
- [TypeConverter(typeof(ObjectSerializableDefinitionIdTypeConverter))]
- public SerializableDefinitionId Id
+ [Description("The ID representing the definition type of the object")]
+ public MyDefinitionId Id
+ {
+ get
+ {
+ return m_definitionId;
+ }
+ private set
+ {
+ //Do nothing!
+ }
+ }
+
+ [IgnoreDataMember]
+ [Category("Object")]
+ [Browsable(true)]
+ [ReadOnly(true)]
+ [Description("The definition type of the object")]
+ public MyDefinitionBase Definition
{
get
{
- SerializableDefinitionId newId = new SerializableDefinitionId(m_objectBuilder.TypeId, m_objectBuilder.SubtypeName);
- return newId;
+ return m_definition;
}
private set
{
@@ -142,6 +187,7 @@ private set
[Browsable(false)]
[ReadOnly(true)]
[Description("The value ID representing the type of the object")]
+ [Obsolete]
public MyObjectBuilderType TypeId
{
get { return m_objectBuilder.TypeId; }
@@ -156,6 +202,7 @@ private set
[Browsable(false)]
[ReadOnly(true)]
[Description("The value ID representing the sub-type of the object")]
+ [Obsolete]
public string Subtype
{
get { return m_objectBuilder.SubtypeName; }
@@ -1311,8 +1358,6 @@ public List GetTypedInternalData() where T : BaseObject
{
try
{
- Refresh();
-
m_resourceLock.AcquireShared();
List newList = new List();
@@ -1326,6 +1371,8 @@ public List GetTypedInternalData() where T : BaseObject
m_resourceLock.ReleaseShared();
+ Refresh();
+
return newList;
}
catch (Exception ex)
diff --git a/SEModAPIInternal/API/Entity/InventoryEntity.cs b/SEModAPIInternal/API/Entity/InventoryEntity.cs
index 65b6be7f..307c3c75 100644
--- a/SEModAPIInternal/API/Entity/InventoryEntity.cs
+++ b/SEModAPIInternal/API/Entity/InventoryEntity.cs
@@ -13,6 +13,7 @@
using SEModAPIInternal.Support;
using VRage;
+using Sandbox.Definitions;
namespace SEModAPIInternal.API.Entity
{
@@ -340,14 +341,6 @@ public class InventoryItemEntity : BaseObject
private InventoryEntity m_parentContainer;
- private static PhysicalItemDefinitionsManager m_physicalItemsManager;
- private static ComponentDefinitionsManager m_componentsManager;
- private static AmmoMagazinesDefinitionsManager m_ammoManager;
-
- private SerializableDefinitionId m_itemId;
- private float m_itemMass = -1;
- private float m_itemVolume = -1;
-
public static string InventoryItemNamespace = "33FB6E717989660631E6772B99F502AD";
public static string InventoryItemClass = "555069178719BB1B546FB026B906CE00";
@@ -362,45 +355,15 @@ public class InventoryItemEntity : BaseObject
public InventoryItemEntity(MyObjectBuilder_InventoryItem definition)
: base(definition)
{
- if (m_physicalItemsManager == null)
- {
- m_physicalItemsManager = new PhysicalItemDefinitionsManager();
- m_physicalItemsManager.Load(PhysicalItemDefinitionsManager.GetContentDataFile("PhysicalItems.sbc"));
- }
- if (m_componentsManager == null)
- {
- m_componentsManager = new ComponentDefinitionsManager();
- m_componentsManager.Load(ComponentDefinitionsManager.GetContentDataFile("Components.sbc"));
- }
- if (m_ammoManager == null)
- {
- m_ammoManager = new AmmoMagazinesDefinitionsManager();
- m_ammoManager.Load(AmmoMagazinesDefinitionsManager.GetContentDataFile("AmmoMagazines.sbc"));
- }
-
- FindMatchingItem();
+ m_definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(PhysicalContent);
+ m_definitionId = m_definition.Id;
}
public InventoryItemEntity(MyObjectBuilder_InventoryItem definition, Object backingObject)
: base(definition, backingObject)
{
- if (m_physicalItemsManager == null)
- {
- m_physicalItemsManager = new PhysicalItemDefinitionsManager();
- m_physicalItemsManager.Load(PhysicalItemDefinitionsManager.GetContentDataFile("PhysicalItems.sbc"));
- }
- if (m_componentsManager == null)
- {
- m_componentsManager = new ComponentDefinitionsManager();
- m_componentsManager.Load(ComponentDefinitionsManager.GetContentDataFile("Components.sbc"));
- }
- if (m_ammoManager == null)
- {
- m_ammoManager = new AmmoMagazinesDefinitionsManager();
- m_ammoManager.Load(AmmoMagazinesDefinitionsManager.GetContentDataFile("AmmoMagazines.sbc"));
- }
-
- FindMatchingItem();
+ m_definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(PhysicalContent);
+ m_definitionId = m_definition.Id;
}
#endregion
@@ -424,7 +387,14 @@ internal static Type InternalType
[ReadOnly(true)]
public override string Name
{
- get { return Id.SubtypeName; }
+ get
+ {
+ MyPhysicalItemDefinition def = Definition;
+ if (def == null)
+ return base.Name;
+
+ return def.Id.SubtypeName;
+ }
}
[IgnoreDataMember]
@@ -445,34 +415,22 @@ public override string Name
[IgnoreDataMember]
[Category("Container Item")]
- [Browsable(false)]
- public InventoryEntity Container
+ [ReadOnly(true)]
+ new public MyPhysicalItemDefinition Definition
{
- get { return m_parentContainer; }
- set { m_parentContainer = value; }
+ get
+ {
+ return (MyPhysicalItemDefinition)base.Definition;
+ }
}
- [DataMember]
+ [IgnoreDataMember]
[Category("Container Item")]
- [ReadOnly(false)]
- [TypeConverter(typeof(ItemSerializableDefinitionIdTypeConverter))]
- new public SerializableDefinitionId Id
+ [Browsable(false)]
+ public InventoryEntity Container
{
- get { return m_itemId; }
- set
- {
- if (m_itemId.Equals(value)) return;
-
- ObjectBuilder.PhysicalContent = (MyObjectBuilder_PhysicalObject)MyObjectBuilder_PhysicalObject.CreateNewObject(value);
- bool result = FindMatchingItem();
- if (!result)
- {
- ObjectBuilder.PhysicalContent = (MyObjectBuilder_PhysicalObject)MyObjectBuilder_PhysicalObject.CreateNewObject(m_itemId);
- return;
- }
-
- Changed = true;
- }
+ get { return m_parentContainer; }
+ set { m_parentContainer = value; }
}
[DataMember]
@@ -527,7 +485,10 @@ public MyObjectBuilder_PhysicalObject PhysicalContent
[ReadOnly(true)]
public float TotalMass
{
- get { return (float)ObjectBuilder.Amount * m_itemMass; }
+ get
+ {
+ return (float)ObjectBuilder.Amount * Mass;
+ }
}
[IgnoreDataMember]
@@ -535,7 +496,7 @@ public float TotalMass
[ReadOnly(true)]
public float TotalVolume
{
- get { return (float)ObjectBuilder.Amount * m_itemVolume; }
+ get { return (float)ObjectBuilder.Amount * Volume; }
}
[DataMember]
@@ -543,12 +504,15 @@ public float TotalVolume
[ReadOnly(true)]
public float Mass
{
- get { return m_itemMass; }
- set
+ get
{
- if (m_itemMass == value) return;
- m_itemMass = value;
- Changed = true;
+ if (Definition == null)
+ return 0;
+ return Definition.Mass;
+ }
+ private set
+ {
+ //Do nothing!
}
}
@@ -557,12 +521,15 @@ public float Mass
[ReadOnly(true)]
public float Volume
{
- get { return m_itemVolume; }
- set
+ get
{
- if (m_itemVolume == value) return;
- m_itemVolume = value;
- Changed = true;
+ if (Definition == null)
+ return 0;
+ return Definition.Volume;
+ }
+ private set
+ {
+ //Do nothing!
}
}
@@ -606,58 +573,8 @@ public static uint GetInventoryItemId(object item)
public override void Dispose()
{
Amount = 0;
- }
-
- private bool FindMatchingItem()
- {
- bool foundMatchingItem = false;
- if (!foundMatchingItem)
- {
- foreach (var item in m_physicalItemsManager.Definitions)
- {
- if (item.Id.TypeId == PhysicalContent.TypeId && item.Id.SubtypeId == PhysicalContent.SubtypeName)
- {
- m_itemId = item.Id;
- m_itemMass = item.Mass;
- m_itemVolume = item.Volume;
-
- foundMatchingItem = true;
- break;
- }
- }
- }
- if (!foundMatchingItem)
- {
- foreach (var item in m_componentsManager.Definitions)
- {
- if (item.Id.TypeId == PhysicalContent.TypeId && item.Id.SubtypeId == PhysicalContent.SubtypeName)
- {
- m_itemId = item.Id;
- m_itemMass = item.Mass;
- m_itemVolume = item.Volume;
-
- foundMatchingItem = true;
- break;
- }
- }
- }
- if (!foundMatchingItem)
- {
- foreach (var item in m_ammoManager.Definitions)
- {
- if (item.Id.TypeId == PhysicalContent.TypeId && item.Id.SubtypeId == PhysicalContent.SubtypeName)
- {
- m_itemId = item.Id;
- m_itemMass = item.Mass;
- m_itemVolume = item.Volume;
-
- foundMatchingItem = true;
- break;
- }
- }
- }
- return foundMatchingItem;
+ base.Dispose();
}
#endregion
diff --git a/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs b/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs
index c963b0d4..27d4bb7e 100644
--- a/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs
+++ b/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs
@@ -151,12 +151,9 @@ public override string Name
{
get
{
- if (ObjectBuilder == null)
- return "Cube Grid";
-
string name = "";
TimeSpan timeSinceLastNameRefresh = DateTime.Now - m_lastNameRefresh;
- if (timeSinceLastNameRefresh.TotalSeconds < 1)
+ if (timeSinceLastNameRefresh.TotalSeconds < 2)
{
name = m_name;
}
@@ -232,16 +229,6 @@ public override string DisplayName
ObjectBuilder = objectBuilder;
}
- if (BackingObject != null)
- {
- TimeSpan timeSinceLastBaseCubeBlockRefresh = DateTime.Now - m_lastBaseCubeBlockRefresh;
- if (timeSinceLastBaseCubeBlockRefresh.TotalSeconds > 30)
- {
- m_lastBaseCubeBlockRefresh = DateTime.Now;
- RefreshBaseCubeBlocks();
- }
- }
-
objectBuilder.LinearVelocity = LinearVelocity;
objectBuilder.AngularVelocity = AngularVelocity;
diff --git a/SEModAPIInternal/API/Entity/SectorEntity.cs b/SEModAPIInternal/API/Entity/SectorEntity.cs
index a91db7e6..51742d95 100644
--- a/SEModAPIInternal/API/Entity/SectorEntity.cs
+++ b/SEModAPIInternal/API/Entity/SectorEntity.cs
@@ -448,7 +448,7 @@ protected override void LoadDynamic()
if (matchingEntity == null || matchingEntity.IsDisposed)
continue;
- //Update the base entity (not the same as BackingObject which is the internal object)
+ matchingEntity.BackingObject = entity;
matchingEntity.ObjectBuilder = baseEntity;
}
else
diff --git a/SEServerExtender/InventoryItemDialog.cs b/SEServerExtender/InventoryItemDialog.cs
index 501a272d..bd929308 100644
--- a/SEServerExtender/InventoryItemDialog.cs
+++ b/SEServerExtender/InventoryItemDialog.cs
@@ -1,18 +1,12 @@
using System;
+using System.Collections;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
using System.Linq;
-using System.Text;
using System.Windows.Forms;
using Sandbox.Common.ObjectBuilders;
using Sandbox.Common.ObjectBuilders.Definitions;
-
-using SEModAPI.Support;
-using SEModAPI.API.Definitions;
-using SEModAPI.API.Definitions.CubeBlocks;
+using Sandbox.Definitions;
using SEModAPIInternal.API.Entity;
using SEModAPIInternal.Support;
@@ -25,11 +19,7 @@ public partial class InventoryItemDialog : Form
{
#region "Attributes"
- private static PhysicalItemDefinitionsManager m_physicalItemsManager;
- private static ComponentDefinitionsManager m_componentsManager;
- private static AmmoMagazinesDefinitionsManager m_ammoManager;
-
- private static List m_idList;
+ private static List m_idList;
private InventoryEntity m_container;
@@ -39,36 +29,20 @@ public partial class InventoryItemDialog : Form
public InventoryItemDialog()
{
- //Load up the static item managers
- if (m_physicalItemsManager == null)
- {
- m_physicalItemsManager = new PhysicalItemDefinitionsManager();
- m_physicalItemsManager.Load(PhysicalItemDefinitionsManager.GetContentDataFile("PhysicalItems.sbc"));
- }
- if (m_componentsManager == null)
- {
- m_componentsManager = new ComponentDefinitionsManager();
- m_componentsManager.Load(ComponentDefinitionsManager.GetContentDataFile("Components.sbc"));
- }
- if (m_ammoManager == null)
- {
- m_ammoManager = new AmmoMagazinesDefinitionsManager();
- m_ammoManager.Load(AmmoMagazinesDefinitionsManager.GetContentDataFile("AmmoMagazines.sbc"));
- }
-
//Populate the static list with the ids from the items
if (m_idList == null)
{
- m_idList = new List();
- foreach (var def in m_physicalItemsManager.Definitions)
+ m_idList = new List();
+
+ foreach (MyPhysicalItemDefinition def in Enumerable.OfType((IEnumerable)MyDefinitionManager.Static.GetAllDefinitions()))
{
m_idList.Add(def.Id);
}
- foreach (var def in m_componentsManager.Definitions)
+ foreach (MyComponentDefinition def in Enumerable.OfType((IEnumerable)MyDefinitionManager.Static.GetAllDefinitions()))
{
m_idList.Add(def.Id);
}
- foreach (var def in m_ammoManager.Definitions)
+ foreach (MyAmmoMagazineDefinition def in Enumerable.OfType((IEnumerable)MyDefinitionManager.Static.GetAllDefinitions()))
{
m_idList.Add(def.Id);
}
@@ -96,9 +70,9 @@ public InventoryEntity InventoryContainer
set { m_container = value; }
}
- public SerializableDefinitionId SelectedType
+ public MyDefinitionId SelectedType
{
- get { return (SerializableDefinitionId)CMB_ItemType.SelectedItem; }
+ get { return (MyDefinitionId)CMB_ItemType.SelectedItem; }
}
public float Amount
@@ -133,7 +107,7 @@ private void BTN_InventoryItem_Add_Click(object sender, EventArgs e)
try
{
MyObjectBuilder_InventoryItem objectBuilder = MyObjectBuilder_Base.CreateNewObject();
- objectBuilder.Content = MyObjectBuilder_Base.CreateNewObject(SelectedType.TypeId, SelectedType.SubtypeId);
+ objectBuilder.Content = MyObjectBuilder_Base.CreateNewObject(SelectedType.TypeId, SelectedType.SubtypeId.ToString());
objectBuilder.Amount = (MyFixedPoint)Amount;
InventoryItemEntity newItem = new InventoryItemEntity(objectBuilder);