Ejemplo n.º 1
0
 public static DecoratableState getState(DecoratableLocation location)
 {
     if (!states.ContainsKey(location))
     {
         Logger.Log("No state found for " + location.name + "!  (" + location.uniqueName + ")");
         states[location] = new DecoratableState(location);
     }
     return(states[location]);
 }
        internal static bool Prefix(int which, int whichRoom, bool persist, DecoratableLocation __instance)
        {
            //if (!(__instance is FarmHouse))
            //    return true;
            if (!persist)
            {
                return(true);
            }

            List <Rectangle> floors = __instance.getFloors();

            if (__instance.floor.Count < floors.Count)
            {
                MapUtilities.FacadeHelper.setMissingFloorsToDefault(__instance);
            }

            //__instance.floor.SetCountAtLeast(floors.Count);
            if (whichRoom == -1)
            {
                for (int index = 0; index < __instance.floor.Count; ++index)
                {
                    __instance.floor[index] = which;
                }
            }
            else
            {
                if (whichRoom > __instance.floor.Count - 1 || whichRoom >= floors.Count)
                {
                    return(false);
                }
                //FarmHouseState state = FarmHouseStates.getState(__instance as FarmHouse);

                OtherLocations.DecoratableState state = OtherLocations.DecoratableStates.getState(__instance);

                if (state.floorDictionary.ContainsKey(floors[whichRoom]))
                {
                    string roomLabel = state.floorDictionary[floors[whichRoom]];
                    Logger.Log("Finding all floors for room '" + roomLabel + "'...");
                    foreach (KeyValuePair <Rectangle, string> floorData in state.floorDictionary)
                    {
                        if (floors.Contains(floorData.Key) && floorData.Value == roomLabel)
                        {
                            Logger.Log(floors.IndexOf(floorData.Key) + " was a part of " + roomLabel);
                            __instance.floor[floors.IndexOf(floorData.Key)] = which;
                        }
                    }
                }
                else
                {
                    __instance.floor[whichRoom] = which;
                }
            }
            return(false);
        }
        public static void Postfix(ref List <Rectangle> __result, DecoratableLocation __instance)
        {
            __result.Clear();

            OtherLocations.DecoratableState state = OtherLocations.DecoratableStates.getState(__instance);

            __result = state.getFloors();

            if (__result.Count > 0)
            {
                return;
            }
            else
            {
                __result = new List <Rectangle>()
                {
                    new Rectangle(1, 3, 11, 11)
                };
            }
        }
        internal static bool Prefix(int which, int whichRoom, bool persist, DecoratableLocation __instance)
        {
            if (!persist)
            {
                return(true);
            }

            List <Rectangle> walls = __instance.getWalls();

            Logger.Log("Checking wallpaper indexes before SetCountAtLeast...");
            for (int wallIndex = 0; wallIndex < __instance.wallPaper.Count; wallIndex++)
            {
                Logger.Log("Wall " + wallIndex + " has a wallpaper index of " + __instance.wallPaper[wallIndex] + ".");
            }

            Logger.Log(__instance.Name + " has " + walls.Count + " walls, and " + __instance.wallPaper.Count + " wallpapers.");
            if (__instance.wallPaper.Count < walls.Count)
            {
                MapUtilities.FacadeHelper.setMissingWallpaperToDefault(__instance);
            }

            Logger.Log("Checking wallpaper indexes after SetCountAtLeast...");
            for (int wallIndex = 0; wallIndex < __instance.wallPaper.Count; wallIndex++)
            {
                Logger.Log("Wall " + wallIndex + " has a wallpaper index of " + __instance.wallPaper[wallIndex] + ".");
            }
            if (whichRoom == -1)
            {
                Logger.Log("Whichroom was -1, applying to all walls...");
                for (int index = 0; index < __instance.wallPaper.Count; ++index)
                {
                    __instance.wallPaper[index] = which;
                }
            }
            else
            {
                Logger.Log("Setting wallpaper to " + which + "...");
                if (whichRoom > __instance.wallPaper.Count - 1 || whichRoom >= walls.Count)
                {
                    return(false);
                }
                //FarmHouseState state = FarmHouseStates.getState(__instance as FarmHouse);
                OtherLocations.DecoratableState state = OtherLocations.DecoratableStates.getState(__instance);

                if (state.wallDictionary.ContainsKey(walls[whichRoom]))
                {
                    string roomLabel = state.wallDictionary[walls[whichRoom]];
                    Logger.Log("Finding all walls for room '" + roomLabel + "'...");
                    foreach (KeyValuePair <Rectangle, string> wallData in state.wallDictionary)
                    {
                        if (walls.Contains(wallData.Key) && wallData.Value == roomLabel)
                        {
                            Logger.Log(walls.IndexOf(wallData.Key) + " was a part of " + roomLabel);
                            __instance.wallPaper[walls.IndexOf(wallData.Key)] = which;
                        }
                    }
                }
                else
                {
                    __instance.wallPaper[whichRoom] = which;
                }
            }
            return(false);
        }