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"])); Pipe self = Revitalize.ModCore.Serializer.DeserializeGUID <Pipe>(additionalSaveData["GUID"]); if (self == null) { return(null); } if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) { //Get new container PipeMultiTiledObject obj = (PipeMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <PipeMultiTiledObject>(additionalSaveData["ParentGUID"]); self.containerObject = obj; obj.addComponent(offsetKey, self); //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)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 bool placementAction(GameLocation location, int x, int y, Farmer who = null) { this.updateInfo(); PipeMultiTiledObject m = (PipeMultiTiledObject)this.getOne(); foreach (KeyValuePair <Vector2, StardewValley.Object> pair in m.objects) { /* * if ((pair.Value as CustomObject).info.ignoreBoundingBox) * { * pair.Value.placementAction(location, -1 * (x + (int)pair.Key.X * Game1.tileSize), -1 * (y + (int)pair.Key.Y * Game1.tileSize), who); * } * else * { * pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); * }*/ (pair.Value as MultiTiledComponent).placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); //ModCore.log(pair.Value.TileLocation); } m.location = location; return(true); //return base.placementAction(location, x, y, who); }
public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement) { PipeMultiTiledObject obj = (PipeMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <PipeMultiTiledObject>(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"]]); } }