public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement) { //instead of using this.offsetkey.x use get additional save data function and store offset key there Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); Wire self = Revitalize.ModCore.Serializer.DeserializeGUID <Wire>(additionalSaveData["GUID"]); if (self == null) { return(null); } if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) { //Get new container WireMultiTiledObject obj = (WireMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <WireMultiTiledObject>(additionalSaveData["ParentGUID"]); self.containerObject = obj; obj.addComponent(offsetKey, self); //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (WireMultiTiledObject)obj); } else { self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); //Revitalize.ModCore.log("READD AN OBJECT!!!!"); } return((ICustomObject)self); }
public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement) { WireMultiTiledObject obj = (WireMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <WireMultiTiledObject>(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); MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID <MultiTiledComponent>(pair.Value.ToString()); component.InitNetFields(); obj.removeComponent(pair.Key); 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"]]); } }