public static SerializableItemInstance MakeSerializableItemInstance(InventoryItemInstance rItemInstance) { var sItemInstance = new SerializableItemInstance(); sItemInstance.Quantity = rItemInstance.Quantity; sItemInstance.Condition = rItemInstance.Condition; sItemInstance.ItemModel = rItemInstance.ItemModel.Name; return(sItemInstance); }
public static SerializableContainerModel MakeSerializableContainerModel(ContainerModel rContainerModel) { var rItems = rContainerModel.ListItems(); SerializableItemInstance[] sItems = new SerializableItemInstance[rItems.Length]; for (int i = 0; i < rItems.Length; i++) { sItems[i] = SerializableItemInstance.MakeSerializableItemInstance(rItems[i]); } var sContainerModel = new SerializableContainerModel(); sContainerModel.Items = sItems; return(sContainerModel); }
public static InventoryItemInstance MakeItemInstance(SerializableItemInstance sItemInstance) { InventoryItemModel model = InventoryModel.GetModel(sItemInstance.ItemModel); if (model == null) { CDebug.LogEx(string.Format("Couldn't find model {0} for SerializableItemInstance", sItemInstance.ItemModel), LogLevel.Error, sItemInstance); return(null); } InventoryItemInstance rItemInstance = new InventoryItemInstance(model, sItemInstance.Condition, sItemInstance.Quantity, false); return(rItemInstance); }
public static ContainerModel MakeContainerModel(SerializableContainerModel sContainerModel) { ContainerModel rContainerModel = new ContainerModel(); foreach (SerializableItemInstance sItemInstance in sContainerModel.Items) { InventoryItemInstance rItemInstance = SerializableItemInstance.MakeItemInstance(sItemInstance); if (rItemInstance != null) { rContainerModel.PutItem(rItemInstance); } else { CDebug.LogEx(string.Format("Couldn't create real item instance for item in container"), LogLevel.Error, sContainerModel); } } return(rContainerModel); }