public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
        {
            this.updateInfo();
            WireMultiTiledObject m = (WireMultiTiledObject)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);
        }
Ejemplo n.º 2
0
        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"]]);
            }
        }