示例#1
0
        public static void Prefix_placement(Wallpaper __instance, GameLocation location, int x, int y, Farmer who = null)
        {
            if (skip || __instance is CustomWallpaper || !Game1.IsMasterGame)
            {
                return;
            }

            skip = true;

            if (who == null)
            {
                who = Game1.player;
            }
            if (who.currentLocation is DecoratableLocation dec)
            {
                if (__instance.isFloor.Value)
                {
                    CustomWallpaper.floorReset = (r, w) => CustomWallpaper.Floor_OnChange1(r, w, dec);
                    dec.floor.OnChange        += CustomWallpaper.floorReset;
                }
                else
                {
                    CustomWallpaper.wallReset = (r, w) => CustomWallpaper.WallPaper_OnChange1(r, w, dec);
                    dec.wallPaper.OnChange   += CustomWallpaper.wallReset;
                }

                __instance.placementAction(location, x, y, who);
            }
            PyTK.PyUtils.setDelayedAction(500, () => skip = false);
        }
示例#2
0
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            CustomWallpaper.savFile = helper.Data.ReadSaveData <SaveFile>("Platonymous.CustomWallsAndFloors.Data");

            if (CustomWallpaper.savFile == null)
            {
                CustomWallpaper.savFile = new SaveFile();
            }

            foreach (SavedRoom room in CustomWallpaper.savFile.rooms.Where(r => r.Id == Game1.player.UniqueMultiplayerID))
            {
                try
                {
                    DecoratableLocation dec = (DecoratableLocation)Game1.getLocationFromName(room.Location);
                    if (room.Walls != "na")
                    {
                        CustomWallpaper walls = new CustomWallpaper(room.Walls, room.WallsNr, false);
                        if (CustomWallpaper.Walls.ContainsKey(room.Walls))
                        {
                            walls.Texture = CustomWallpaper.Floors[room.Walls];
                            walls.setChangeEventsAfterLoad(dec, room.Room);
                        }
                    }

                    if (room.Floors != "na")
                    {
                        CustomWallpaper floors = new CustomWallpaper(room.Floors, room.FloorsNr, true);
                        if (CustomWallpaper.Floors.ContainsKey(room.Floors))
                        {
                            floors.Texture = CustomWallpaper.Floors[room.Floors];
                            floors.setChangeEventsAfterLoad(dec, room.Room);
                        }
                    }
                }
                catch
                {
                }
            }
        }