public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement) { Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); string GUID = additionalSaveData["GUID"]; ArcadeCabinetTile self = Revitalize.ModCore.Serializer.DeserializeGUID <ArcadeCabinetTile>(additionalSaveData["GUID"]); if (ModCore.IsNullOrDefault <ArcadeCabinetTile>(self)) { return(null); } try { if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) { ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID <ArcadeCabinetOBJ>(additionalSaveData["ParentGUID"]); self.containerObject = obj; self.containerObject.removeComponent(offsetKey); self.containerObject.addComponent(offsetKey, self); Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); } else { self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; self.containerObject.removeComponent(offsetKey); self.containerObject.addComponent(offsetKey, self); } } catch (Exception err) { ModCore.log(err); } return(self); }
public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement) { ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID <ArcadeCabinetOBJ>(additionalSaveData["GUID"]); if (obj == null) { return(null); } Dictionary <Vector2, Guid> guids = new Dictionary <Vector2, Guid>(); foreach (KeyValuePair <Vector2, Guid> pair in obj.childrenGuids) { guids.Add(pair.Key, pair.Value); } foreach (KeyValuePair <Vector2, Guid> pair in guids) { obj.childrenGuids.Remove(pair.Key); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID <ArcadeCabinetTile>(pair.Value.ToString()); component.InitNetFields(); obj.addComponent(pair.Key, component); } obj.InitNetFields(); if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) { Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj); return(obj); } else { return(Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]]); } }