/** * <summary>Serialises appropriate GameObject values into a string.</summary> * <returns>The data, serialised as a string</returns> */ public override string SaveData() { ContainerData containerData = new ContainerData(); containerData.objectID = constantID; containerData.savePrevented = savePrevented; if (_Container != null) { List <int> linkedIDs = new List <int>(); List <int> counts = new List <int>(); List <int> IDs = new List <int>(); for (int i = 0; i < _Container.items.Count; i++) { ContainerItem item = _Container.items[i]; linkedIDs.Add(item.linkedID); counts.Add(item.count); IDs.Add(item.id); } containerData._linkedIDs = ArrayToString <int> (linkedIDs.ToArray()); containerData._counts = ArrayToString <int> (counts.ToArray()); containerData._IDs = ArrayToString <int> (IDs.ToArray()); } return(Serializer.SaveScriptData <ContainerData> (containerData)); }
/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { ContainerData data = Serializer.LoadScriptData <ContainerData> (stringData); if (data == null) { return; } SavePrevented = data.savePrevented; if (savePrevented) { return; } if (_Container != null) { _Container.items.Clear(); int[] linkedIDs = StringToIntArray(data._linkedIDs); int[] counts = StringToIntArray(data._counts); int[] IDs = StringToIntArray(data._IDs); if (IDs != null) { for (int i = 0; i < IDs.Length; i++) { ContainerItem newItem = new ContainerItem(linkedIDs[i], counts[i], IDs[i]); _Container.items.Add(newItem); } } } }
public override void LoadData(string stringData) { ContainerData data = Serializer.LoadScriptData <ContainerData> (stringData); if (data == null) { return; } if (GetComponent <Container>()) { Container container = GetComponent <Container>(); container.items.Clear(); int[] linkedIDs = StringToIntArray(data._linkedIDs); int[] counts = StringToIntArray(data._counts); int[] IDs = StringToIntArray(data._IDs); for (int i = 0; i < IDs.Length; i++) { ContainerItem newItem = new ContainerItem(linkedIDs[i], counts[i], IDs[i]); container.items.Add(newItem); } } }
/** * <summary>Serialises appropriate GameObject values into a string.</summary> * <returns>The data, serialised as a string</returns> */ public override string SaveData() { ContainerData containerData = new ContainerData(); containerData.objectID = constantID; if (GetComponent <Container>()) { Container container = GetComponent <Container>(); List <int> linkedIDs = new List <int>(); List <int> counts = new List <int>(); List <int> IDs = new List <int>(); for (int i = 0; i < container.items.Count; i++) { linkedIDs.Add(container.items[i].linkedID); counts.Add(container.items[i].count); IDs.Add(container.items[i].id); } containerData._linkedIDs = ArrayToString <int> (linkedIDs.ToArray()); containerData._counts = ArrayToString <int> (counts.ToArray()); containerData._IDs = ArrayToString <int> (IDs.ToArray()); } return(Serializer.SaveScriptData <ContainerData> (containerData)); }
public override string SaveData() { ContainerData containerData = new ContainerData(); containerData.objectID = constantID; if (GetComponent <Container>()) { Container container = GetComponent <Container>(); List<int> linkedIDs = new List<int>(); List<int> counts = new List<int>(); List<int> IDs = new List<int>(); for (int i=0; i<container.items.Count; i++) { linkedIDs.Add (container.items[i].linkedID); counts.Add (container.items[i].count); IDs.Add (container.items[i].id); } containerData._linkedIDs = ArrayToString <int> (linkedIDs.ToArray ()); containerData._counts = ArrayToString <int> (counts.ToArray ()); containerData._IDs = ArrayToString <int> (IDs.ToArray ()); } return Serializer.SaveScriptData <ContainerData> (containerData); }
public void LoadData (ContainerData data) { if (GetComponent <Container>()) { Container container = GetComponent <Container>(); container.items.Clear (); for (int i=0; i<data.IDs.Count; i++) { ContainerItem newItem = new ContainerItem (data.linkedIDs[i], data.counts[i], data.IDs[i]); container.items.Add (newItem); } } }
/** * <summary>Serialises appropriate GameObject values into a string.</summary> * <returns>The data, serialised as a string</returns> */ public override string SaveData() { ContainerData containerData = new ContainerData(); containerData.objectID = constantID; containerData.savePrevented = savePrevented; if (_Container) { containerData.collectionData = _Container.InvCollection.GetSaveData(); containerData._linkedIDs = string.Empty; // Now deprecated containerData._counts = string.Empty; // Now deprecated containerData._IDs = string.Empty; // Now deprecated } return(Serializer.SaveScriptData <ContainerData> (containerData)); }
public ContainerData SaveData () { ContainerData containerData = new ContainerData(); containerData.objectID = constantID; if (GetComponent <Container>()) { Container container = GetComponent <Container>(); containerData.linkedIDs = new List<int>(); containerData.counts = new List<int>(); containerData.IDs = new List<int>(); for (int i=0; i<container.items.Count; i++) { containerData.linkedIDs.Add (container.items[i].linkedID); containerData.counts.Add (container.items[i].count); containerData.IDs.Add (container.items[i].id); } } return (containerData); }
/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { ContainerData data = Serializer.LoadScriptData <ContainerData> (stringData); if (data == null) { return; } SavePrevented = data.savePrevented; if (savePrevented) { return; } if (_Container) { List <InvInstance> invInstances = new List <InvInstance> (); if (!string.IsNullOrEmpty(data._linkedIDs)) { int[] linkedIDs = StringToIntArray(data._linkedIDs); int[] counts = StringToIntArray(data._counts); if (linkedIDs != null) { for (int i = 0; i < linkedIDs.Length; i++) { invInstances.Add(new InvInstance(linkedIDs[i], counts[i])); } } _Container.InvCollection = new InvCollection(invInstances); } else if (!string.IsNullOrEmpty(data.collectionData)) { _Container.InvCollection = InvCollection.LoadData(data.collectionData); } } }