Beispiel #1
0
        public static void SetCave(bool isMushroom, bool isMessageVisible)
        {
            Utils.SetCaveEvent(isSeen: true);

            string caveName = isMushroom ? "mushroom" : "fruit";

            if (isMushroom && Game1.MasterPlayer.caveChoice.Value == Utils.CaveIdMushroom)
            {
                Utils.Monitor.Log($"The farm already has a {caveName} cave.",
                                  isMessageVisible ? LogLevel.Debug : LogLevel.Trace);
                return;
            }
            FarmCave farmCave = Utils.GetFarmCave();

            Game1.MasterPlayer.caveChoice.Value = isMushroom ? Utils.CaveIdMushroom : Utils.CaveIdFruit;
            if (isMushroom)
            {
                farmCave.setUpMushroomHouse();
            }
            else
            {
                Utils.RemoveMushroomBoxesFromCave(farmCave);
            }

            Utils.Monitor.Log($"Set the farm to have a {caveName} cave.",
                              isMessageVisible ? LogLevel.Debug : LogLevel.Trace);
        }
Beispiel #2
0
 public static void RemoveMushroomBoxesFromCave(FarmCave farmCave)
 {
     foreach (Vector2 key in farmCave.Objects.Keys.Where(key => farmCave.Objects[key].ParentSheetIndex == Utils.ObjectIdMushroomBox).ToList())
     {
         farmCave.Objects.Remove(key);
     }
     farmCave.UpdateReadyFlag();
 }
Beispiel #3
0
        public static void ClearCave(bool isMessageVisible)
        {
            FarmCave farmCave = Utils.GetFarmCave();

            Utils.RemoveMushroomBoxesFromCave(farmCave);
            Game1.MasterPlayer.caveChoice.Value = Utils.CaveIdNone;

            Utils.Monitor.Log($"Set the farm cave to neutral.",
                              isMessageVisible ? LogLevel.Debug : LogLevel.Trace);
        }
        private static bool FarmCave_DayUpdate_Prefix(FarmCave __instance, int dayOfMonth)
        {
            if (!Config.EnableMod)
            {
                return(true);
            }
            LoadCaveChoice();
            if (caveChoice == null)
            {
                return(true);
            }

            var ptr        = typeof(GameLocation).GetMethod("DayUpdate", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).MethodHandle.GetFunctionPointer();
            var baseMethod = (Func <GameLocation>)Activator.CreateInstance(typeof(Func <GameLocation>), __instance, ptr);

            baseMethod();
            if (caveChoice.resources.Count > 0)
            {
                SMonitor.Log($"Spawning resources");
                float totalWeight = 0;
                foreach (var r in caveChoice.resources)
                {
                    totalWeight += r.weight;
                }
                int spawned = 0;
                while (Game1.random.NextDouble() < Math.Min(0.99f, caveChoice.resourceChance / 100f))
                {
                    float  currentWeight = 0;
                    double chance        = Game1.random.NextDouble();
                    foreach (var r in caveChoice.resources)
                    {
                        currentWeight += r.weight;
                        if (chance < currentWeight / totalWeight)
                        {
                            Vector2 v = new Vector2(Game1.random.Next(1, __instance.map.Layers[0].LayerWidth - 1), Game1.random.Next(1, __instance.map.Layers[0].LayerHeight - 4));
                            if (__instance.isTileLocationTotallyClearAndPlaceable(v))
                            {
                                spawned++;
                                int    amount = Game1.random.Next(r.min, r.max + 1);
                                Object obj    = GetObjectFromID(r.id, Vector2.Zero, amount, true);
                                __instance.setObject(v, obj);
                            }
                            break;
                        }
                    }
                }
                SMonitor.Log($"Spawned {spawned} resources, total weight {totalWeight}");
            }
            __instance.UpdateReadyFlag();
            return(false);
        }
Beispiel #5
0
        public static void additionalMapLoad()
        {
            Map    map;
            string mapAssetKey;

            if (Game1.multiplayerMode != 0)
            {
                return;
            }

            if (Memory.isCustomFarmLoaded && Memory.loadedFarm.additionalMaps != null)
            {
                foreach (additionalMap <GameLocation> m in Memory.loadedFarm.additionalMaps)
                {
                    object newMap;
                    object temp;

                    if (m.type == fileType.raw)
                    {
                        map = Memory.loadedFarm.contentpack.LoadAsset <Map>(m.FileName + ".tbin");
                    }

                    mapAssetKey = Memory.loadedFarm.contentpack.GetActualAssetKey(m.FileName + ((m.type == fileType.raw) ? ".tbin" : ".xnb"));

                    switch (m.mapType)
                    {
                    case "Farm":
                        newMap = new Farm(mapAssetKey, m.Location);
                        Game1.locations.Add((Farm)newMap);
                        Memory.farmMaps.Add(new additionalMap <Farm>(m, Game1.locations.Last() as Farm));
                        break;

                    case "FarmCave":
                        newMap = new FarmCave(mapAssetKey, m.Location);
                        Game1.locations.Add((FarmCave)newMap);
                        break;

                    case "GameLocation":
                        newMap = new GameLocation(mapAssetKey, m.Location);
                        Game1.locations.Add((GameLocation)newMap);
                        break;

                    default:
                        newMap = new GameLocation(mapAssetKey, m.Location);
                        Game1.locations.Add((GameLocation)newMap);
                        break;
                    }
                }
            }
        }
        private static bool FarmCave_resetLocalState_Prefix(FarmCave __instance)
        {
            if (!Config.EnableMod)
            {
                return(true);
            }
            LoadCaveChoice();
            if (caveChoice == null)
            {
                return(true);
            }

            var ptr        = typeof(GameLocation).GetMethod("resetLocalState", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).MethodHandle.GetFunctionPointer();
            var baseMethod = (Func <GameLocation>)Activator.CreateInstance(typeof(Func <GameLocation>), __instance, ptr);

            baseMethod();


            if (caveChoice.animations.Count > 0)
            {
                foreach (var a in caveChoice.animations)
                {
                    __instance.temporarySprites.Add(new TemporaryAnimatedSprite(a.sourceFile, new Rectangle(a.sourceX, a.sourceY, a.width, a.height), new Vector2(a.right ? __instance.map.Layers[0].LayerWidth * 64 + a.X : a.X, a.bottom ? __instance.map.Layers[0].LayerHeight * 64 + a.Y : a.Y), false, 0f, Color.White)
                    {
                        interval           = a.interval,
                        animationLength    = a.length,
                        totalNumberOfLoops = a.loops,
                        scale = a.scale,
                        delayBeforeAnimationStart = a.delay,
                        layerDepth  = 1f,
                        light       = a.light,
                        lightRadius = a.lightRadius
                    });
                }
            }
            Game1.ambientLight = caveChoice.ambientLight;
            return(false);
        }
 private static bool Event_answerDialogue_Prefix(string questionKey, int answerChoice)
 {
     if (!Config.EnableMod || questionKey != "cave")
     {
         return(true);
     }
     caveChoice = SHelper.Content.Load <Dictionary <string, CaveChoice> >(frameworkPath, ContentSource.GameContent)[answerIds[answerChoice]];
     SMonitor.Log($"Chose {caveChoice.choice}, objects {caveChoice.objects.Count}");
     SHelper.Data.WriteSaveData("farm-cave-framework-choice", caveChoice.id);
     if (caveChoice.objects.Count > 0)
     {
         FarmCave cave = Game1.getLocationFromName("FarmCave") as FarmCave;
         foreach (var o in caveChoice.objects)
         {
             Object obj = GetObjectFromID(o.id, new Vector2(o.X, o.Y));
             if (obj != null)
             {
                 cave.setObject(new Vector2(o.X, o.Y), obj);
             }
         }
     }
     return(false);
 }
        private static bool FarmCave_UpdateReadyFlag_Prefix(FarmCave __instance)
        {
            if (!Config.EnableMod)
            {
                return(true);
            }

            /*
             * string choiceId = SHelper.Data.ReadSaveData<string>("farm-cave-framework-choice");
             * if (choiceId == null)
             *  return true;
             * Dictionary<string, CaveChoice> choices = SHelper.Content.Load<Dictionary<string, CaveChoice>>(frameworkPath, ContentSource.GameContent);
             * if (!choices.ContainsKey(choiceId))
             * {
             *  SMonitor.Log($"Choice key {choiceId} not found");
             *  return true;
             * }
             * CaveChoice choice = choices[choiceId];
             */
            bool flag_value = false;

            foreach (Object o in __instance.objects.Values)
            {
                if (o.IsSpawnedObject)
                {
                    flag_value = true;
                    break;
                }
                if (o.bigCraftable.Value && o.heldObject.Value != null && o.MinutesUntilReady <= 0)
                {
                    flag_value = true;
                    break;
                }
            }
            Game1.getFarm().farmCaveReady.Value = flag_value;
            return(false);
        }
        /// <summary>
        /// Postfix method. Occurs after the original method of Game1.loadForNewGame is executed.
        ///
        /// Loads the custom farm in, if it hasn't already (saved game is being loaded) into farmManager.
        /// Sets the Farm map with the correct map (the custom map that was requested).
        /// Loads additional maps that are apart of custom farm's content pack.
        /// Loads map overrides that are apart of custom farm's content pack.
        /// </summary>
        public static void Postfix()
        {
            int    farmIndex;
            int    greenhouseIndex;
            Map    map;
            string mapAssetKey;

            if (customManager.LoadedFarm == null)
            {
                if (Game1.whichFarm < 6)
                {
                    customManager.LoadCustomFarm(Game1.whichFarm);
                }
                else
                {
                    customManager.LoadCustomFarmByMtnData();
                }
            }

            if (!customManager.Canon)
            {
                Game1.removeLocationFromLocationLookup("Farm");

                for (farmIndex = 0; farmIndex < Game1.locations.Count; farmIndex++)
                {
                    if (Game1.locations[farmIndex].Name == "Farm")
                    {
                        break;
                    }
                }

                mapAssetKey = customManager.GetAssetKey(out map, "Farm");
                Game1.locations[farmIndex] = new Farm(mapAssetKey, "Farm");
                Game1.locations[farmIndex].reloadMap();

                //if (customManager.LoadedFarm.FarmMap.FileType != FileType.xnb && Game1.multiplayerMode == 1) {
                //    customManager.LoadedFarm.ContentPack.LoadAsset<Map>(mapAssetKey);
                //}

                if (customManager.LoadedFarm.StartingGreenHouse != null)
                {
                    for (greenhouseIndex = 0; greenhouseIndex < Game1.locations.Count; greenhouseIndex++)
                    {
                        if (Game1.locations[greenhouseIndex].Name == "Greenhouse")
                        {
                            break;
                        }
                    }

                    mapAssetKey = customManager.GetAssetKey(out map, "Greenhouse");
                    Game1.locations[greenhouseIndex] = new GameLocation(mapAssetKey, "Greenhouse");
                }
            }

            if (!customManager.Canon && customManager.LoadedFarm.AdditionalMaps != null)
            {
                foreach (MapFile mf in customManager.LoadedFarm.AdditionalMaps)
                {
                    object newMap;

                    if (mf.FileType == FileType.raw)
                    {
                        map = customManager.LoadMap(mf.FileName + ".tbin");
                    }

                    mapAssetKey = customManager.GetAssetKey(mf.FileName, mf.FileType);

                    switch (mf.MapType)
                    {
                    case "Farm":
                    case "FarmExpansion":
                    case "MTNFarmExtension":
                        newMap = new Farm(mapAssetKey, mf.Name);
                        Game1.locations.Add((Farm)newMap);
                        //Game1.locations.Add(new FarmExtension(mapAssetKey, m.Location, newMap as Farm));
                        //Memory.farmMaps.Add(new additionalMap<Farm>(m, Game1.locations.Last() as Farm));
                        break;

                    case "FarmCave":
                        newMap = new FarmCave(mapAssetKey, mf.Name);
                        Game1.locations.Add((FarmCave)newMap);
                        break;

                    case "GameLocation":
                        newMap = new GameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((GameLocation)newMap);
                        break;

                    case "BuildableGameLocation":
                        newMap = new BuildableGameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((BuildableGameLocation)newMap);
                        break;

                    default:
                        newMap = new GameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((GameLocation)newMap);
                        break;
                    }
                    Monitor.Log("Custom map loaded. Name: " + (newMap as GameLocation).Name + " Type: " + newMap.ToString());
                }
            }

            if (!customManager.Canon && customManager.LoadedFarm.Overrides != null)
            {
                int i;
                foreach (MapFile mf in customManager.LoadedFarm.Overrides)
                {
                    if (mf.FileType == FileType.raw)
                    {
                        map = customManager.LoadMap(mf.FileName + ".tbin");
                    }
                    mapAssetKey = customManager.GetAssetKey(mf.FileName, mf.FileType);

                    for (i = 0; i < Game1.locations.Count; i++)
                    {
                        if (Game1.locations[i].Name == mf.Name)
                        {
                            break;
                        }
                    }

                    if (i >= Game1.locations.Count)
                    {
                        Monitor.Log(String.Format("Unable to replace {0}, map was not found. Skipping", mf.Name), LogLevel.Warn);
                    }
                    else
                    {
                        switch (mf.Name)
                        {
                        case "AdventureGuild":
                            Game1.locations[i] = new AdventureGuild(mapAssetKey, mf.Name);
                            break;

                        case "BathHousePool":
                            Game1.locations[i] = new BathHousePool(mapAssetKey, mf.Name);
                            break;

                        case "Beach":
                            Game1.locations[i] = new Beach(mapAssetKey, mf.Name);
                            break;

                        case "BusStop":
                            Game1.locations[i] = new BusStop(mapAssetKey, mf.Name);
                            break;

                        case "Club":
                            Game1.locations[i] = new Club(mapAssetKey, mf.Name);
                            break;

                        case "Desert":
                            Game1.locations[i] = new Desert(mapAssetKey, mf.Name);
                            break;

                        case "Forest":
                            Game1.locations[i] = new Forest(mapAssetKey, mf.Name);
                            break;

                        case "FarmCave":
                            Game1.locations[i] = new FarmCave(mapAssetKey, mf.Name);
                            break;

                        case "Mountain":
                            Game1.locations[i] = new Mountain(mapAssetKey, mf.Name);
                            break;

                        case "Railroad":
                            Game1.locations[i] = new Railroad(mapAssetKey, mf.Name);
                            break;

                        case "SeedShop":
                            Game1.locations[i] = new SeedShop(mapAssetKey, mf.Name);
                            break;

                        case "Sewer":
                            Game1.locations[i] = new Sewer(mapAssetKey, mf.Name);
                            break;

                        case "Town":
                            Game1.locations[i] = new Town(mapAssetKey, mf.Name);
                            break;

                        case "WizardHouse":
                            Game1.locations[i] = new WizardHouse(mapAssetKey, mf.Name);
                            break;

                        case "Woods":
                            Game1.locations[i] = new Woods(mapAssetKey, mf.Name);
                            break;

                        default:
                            Game1.locations[i] = new GameLocation(mapAssetKey, mf.Name);
                            break;
                        }
                        Monitor.Log("Map has been overridden with a custom map: " + mf.Name);
                    }
                }
            }
        }
        private static bool FarmCave_UpdateWhenCurrentLocation_Prefix(FarmCave __instance, GameTime time)
        {
            if (!Config.EnableMod || caveChoice == null)
            {
                return(true);
            }
            var ptr        = typeof(GameLocation).GetMethod("UpdateWhenCurrentLocation", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).MethodHandle.GetFunctionPointer();
            var baseMethod = (Func <GameTime, GameLocation>)Activator.CreateInstance(typeof(Func <GameTime, GameLocation>), __instance, ptr);

            baseMethod(time);

            if (caveChoice.periodics.Count > 0)
            {
                foreach (var p in caveChoice.periodics)
                {
                    if (Game1.random.NextDouble() < p.chance / 100f)
                    {
                        if (p.animations.Count > 0)
                        {
                            var a = p.animations[Game1.random.Next(p.animations.Count)];
                            __instance.TemporarySprites.Add(new TemporaryAnimatedSprite(a.sourceFile, new Rectangle(a.sourceX, a.sourceY, a.width, a.height), a.interval, a.length, a.loops, new Vector2(!a.randomX ? (a.right ? __instance.map.Layers[0].LayerWidth * 64 + a.X : a.X) : Game1.random.Next(__instance.map.Layers[0].LayerWidth) * 64f, !a.randomY ? (a.bottom ? __instance.map.Layers[0].LayerHeight * 64 + a.Y : a.Y) : Game1.random.Next(__instance.map.Layers[0].LayerHeight) * 64f), a.flicker, a.flipped, 1f, a.alphaFade, a.color, a.scale, a.scaleChange, a.rotation, a.rotationChange, false)
                            {
                                xPeriodic         = true,
                                xPeriodicLoopTime = a.loopTIme,
                                xPeriodicRange    = a.range,
                                motion            = new Vector2(a.motionX, a.motionY)
                            });
                        }
                        if (p.randomSounds.Count > 0)
                        {
                            var s = p.randomSounds[Game1.random.Next(p.randomSounds.Count)];
                            if (Game1.random.NextDouble() < s.chance / 100f)
                            {
                                __instance.localSound(s.id);
                            }
                        }
                        if (p.repeatedSounds.Count > 0)
                        {
                            var s = p.repeatedSounds[Game1.random.Next(p.repeatedSounds.Count)];
                            if (Game1.random.NextDouble() < s.chance / 100f)
                            {
                                for (int i = 1; i < s.count; i++)
                                {
                                    DelayedAction.playSoundAfterDelay(s.id, s.delayMult * i + s.delayAdd, null, s.pitch);
                                }
                            }
                        }
                        if (p.specials.Count > 0)
                        {
                            var s = p.specials[Game1.random.Next(p.specials.Count)];
                            if (s == "BatTemporarySprite")
                            {
                                __instance.temporarySprites.Add(new BatTemporarySprite(new Vector2((float)((Game1.random.NextDouble() < 0.5) ? 0 : (__instance.map.DisplayWidth - 64)), (float)(__instance.map.DisplayHeight - 64))));
                            }
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #11
0
        /// <summary>
        /// Postfix method. Occurs after the original method of Game1.loadForNewGame is executed.
        ///
        /// Loads the custom farm in, if it hasn't already (saved game is being loaded) into farmManager.
        /// Sets the Farm map with the correct map (the custom map that was requested).
        /// Loads additional maps that are apart of custom farm's content pack.
        /// Loads map overrides that are apart of custom farm's content pack.
        /// </summary>
        public static void Postfix()
        {
            int    farmIndex;
            Map    map;
            string mapAssetKey;

            if (farmManager.LoadedFarm == null)
            {
                farmManager.LoadCustomFarm(Game1.whichFarm);
            }

            if (!farmManager.Canon)
            {
                for (farmIndex = 0; farmIndex < Game1.locations.Count; farmIndex++)
                {
                    if (Game1.locations[farmIndex].Name == "Farm")
                    {
                        break;
                    }
                }

                mapAssetKey = farmManager.GetAssetKey(out map);
                Game1.locations[farmIndex] = new Farm(mapAssetKey, "Farm");
            }

            //Loaded Farm Maps
            //Memory.farmMaps.Add(new additionalMap<Farm>("BaseFarm", "Farm", (Game1.whichFarm > 4) ? Memory.loadedFarm.farmMapType : fileType.xnb, "Farm", "Base Farm", Game1.getFarm()));

            if (!farmManager.Canon && farmManager.LoadedFarm.AdditionalMaps != null)
            {
                foreach (MapFile mf in farmManager.LoadedFarm.AdditionalMaps)
                {
                    object newMap;

                    if (mf.FileType == FileType.raw)
                    {
                        map = farmManager.LoadMap(mf.FileName + ".tbin");
                    }

                    mapAssetKey = farmManager.GetAssetKey(mf.FileName, mf.FileType);

                    switch (mf.MapType)
                    {
                    case "Farm":
                    case "FarmExpansion":
                    case "MTNFarmExtension":
                        newMap = new Farm(mapAssetKey, mf.Name);
                        Game1.locations.Add((Farm)newMap);
                        //Game1.locations.Add(new FarmExtension(mapAssetKey, m.Location, newMap as Farm));
                        //Memory.farmMaps.Add(new additionalMap<Farm>(m, Game1.locations.Last() as Farm));
                        break;

                    case "FarmCave":
                        newMap = new FarmCave(mapAssetKey, mf.Name);
                        Game1.locations.Add((FarmCave)newMap);
                        break;

                    case "GameLocation":
                        newMap = new GameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((GameLocation)newMap);
                        break;

                    case "BuildableGameLocation":
                        newMap = new BuildableGameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((BuildableGameLocation)newMap);
                        break;

                    default:
                        newMap = new GameLocation(mapAssetKey, mf.Name);
                        Game1.locations.Add((GameLocation)newMap);
                        break;
                    }
                    Monitor.Log("Custom map loaded. Name: " + (newMap as GameLocation).Name + " Type: " + newMap.ToString());
                }
            }

            if (!farmManager.Canon && farmManager.LoadedFarm.Overrides != null)
            {
                int i;
                foreach (MapFile mf in farmManager.LoadedFarm.Overrides)
                {
                    if (mf.FileType == FileType.raw)
                    {
                        map = farmManager.LoadMap(mf.FileName + ".tbin");
                    }
                    mapAssetKey = farmManager.GetAssetKey(mf.FileName, mf.FileType);

                    for (i = 0; i < Game1.locations.Count; i++)
                    {
                        if (Game1.locations[i].Name == mf.Name)
                        {
                            break;
                        }
                    }

                    if (i >= Game1.locations.Count)
                    {
                        Monitor.Log(String.Format("Unable to replace {0}, map was not found. Skipping", mf.Name), LogLevel.Warn);
                    }
                    else
                    {
                        switch (mf.Name)
                        {
                        case "AdventureGuild":
                            Game1.locations[i] = new AdventureGuild(mapAssetKey, mf.Name);
                            break;

                        case "BathHousePool":
                            Game1.locations[i] = new BathHousePool(mapAssetKey, mf.Name);
                            break;

                        case "Beach":
                            Game1.locations[i] = new Beach(mapAssetKey, mf.Name);
                            break;

                        case "BusStop":
                            Game1.locations[i] = new BusStop(mapAssetKey, mf.Name);
                            break;

                        case "Club":
                            Game1.locations[i] = new Club(mapAssetKey, mf.Name);
                            break;

                        case "Desert":
                            Game1.locations[i] = new Desert(mapAssetKey, mf.Name);
                            break;

                        case "Forest":
                            Game1.locations[i] = new Forest(mapAssetKey, mf.Name);
                            break;

                        case "FarmCave":
                            Game1.locations[i] = new FarmCave(mapAssetKey, mf.Name);
                            break;

                        case "Mountain":
                            Game1.locations[i] = new Mountain(mapAssetKey, mf.Name);
                            break;

                        case "Railroad":
                            Game1.locations[i] = new Railroad(mapAssetKey, mf.Name);
                            break;

                        case "SeedShop":
                            Game1.locations[i] = new SeedShop(mapAssetKey, mf.Name);
                            break;

                        case "Sewer":
                            Game1.locations[i] = new Sewer(mapAssetKey, mf.Name);
                            break;

                        case "Town":
                            Game1.locations[i] = new Town(mapAssetKey, mf.Name);
                            break;

                        case "WizardHouse":
                            Game1.locations[i] = new WizardHouse(mapAssetKey, mf.Name);
                            break;

                        case "Woods":
                            Game1.locations[i] = new Woods(mapAssetKey, mf.Name);
                            break;

                        default:
                            Game1.locations[i] = new GameLocation(mapAssetKey, mf.Name);
                            break;
                        }
                        Monitor.Log("Map has been overridden with a custom map: " + mf.Name);
                    }
                }
            }
        }
Beispiel #12
0
        public static void Postfix()
        {
            int    farmIndex;
            Map    map;
            string mapAssetKey;

            if (Game1.whichFarm > 4)
            {
                if (Memory.loadedFarm == null)
                {
                    Memory.loadCustomFarmType(Game1.whichFarm);
                }

                for (farmIndex = 0; farmIndex < Game1.locations.Count; farmIndex++)
                {
                    if (Game1.locations[farmIndex].Name == "Farm")
                    {
                        break;
                    }
                }

                if (Memory.loadedFarm.farmMapType == fileType.raw)
                {
                    map = Memory.loadedFarm.contentpack.LoadAsset <Map>(Memory.loadedFarm.farmMapFile + ".tbin");
                }
                mapAssetKey = Memory.loadedFarm.contentpack.GetActualAssetKey(Memory.loadedFarm.farmMapFile + ((Memory.loadedFarm.farmMapType == fileType.raw) ? ".tbin" : ".xnb"));
                Game1.locations[farmIndex] = new Farm(mapAssetKey, "Farm");
            }

            Memory.farmMaps.Add(new additionalMap <Farm>("BaseFarm", "Farm", (Game1.whichFarm > 4) ? Memory.loadedFarm.farmMapType : fileType.xnb, "Farm", "Base Farm", Game1.getFarm()));

            if (Memory.isCustomFarmLoaded && Memory.loadedFarm.additionalMaps != null)
            {
                foreach (additionalMap <GameLocation> m in Memory.loadedFarm.additionalMaps)
                {
                    object newMap;

                    if (m.type == fileType.raw)
                    {
                        map = Memory.loadedFarm.contentpack.LoadAsset <Map>(m.FileName + ".tbin");
                    }

                    mapAssetKey = Memory.loadedFarm.contentpack.GetActualAssetKey(m.FileName + ((m.type == fileType.raw) ? ".tbin" : ".xnb"));

                    switch (m.mapType)
                    {
                    case "Farm":
                    case "FarmExpansion":
                    case "MTNFarmExtension":
                        newMap = new Farm(mapAssetKey, m.Location);
                        Game1.locations.Add((Farm)newMap);
                        //Game1.locations.Add(new FarmExtension(mapAssetKey, m.Location, newMap as Farm));
                        Memory.farmMaps.Add(new additionalMap <Farm>(m, Game1.locations.Last() as Farm));
                        break;

                    case "FarmCave":
                        newMap = new FarmCave(mapAssetKey, m.Location);
                        Game1.locations.Add((FarmCave)newMap);
                        break;

                    case "GameLocation":
                        newMap = new GameLocation(mapAssetKey, m.Location);
                        Game1.locations.Add((GameLocation)newMap);
                        break;

                    case "BuildableGameLocation":
                        newMap = new BuildableGameLocation(mapAssetKey, m.Location);
                        Game1.locations.Add((BuildableGameLocation)newMap);
                        break;

                    default:
                        newMap = new GameLocation(mapAssetKey, m.Location);
                        Game1.locations.Add((GameLocation)newMap);
                        break;
                    }
                    Memory.instance.Monitor.Log("Custom map loaded. Name: " + (newMap as GameLocation).Name + " Type: " + newMap.ToString());
                }
            }

            if (Memory.isCustomFarmLoaded && Memory.loadedFarm.overrideMaps != null)
            {
                int i;
                foreach (overrideMap m in Memory.loadedFarm.overrideMaps)
                {
                    if (m.type == fileType.raw)
                    {
                        map = Memory.loadedFarm.contentpack.LoadAsset <Map>(m.FileName + ".tbin");
                    }
                    mapAssetKey = Memory.loadedFarm.contentpack.GetActualAssetKey(m.FileName + ((m.type == fileType.raw) ? ".tbin" : ".xnb"));

                    for (i = 0; i < Game1.locations.Count; i++)
                    {
                        if (Game1.locations[i].Name == m.Location)
                        {
                            break;
                        }
                    }
                    if (i >= Game1.locations.Count)
                    {
                        Memory.instance.Monitor.Log(String.Format("Unable to replace {0}, map was not found. Skipping", m.Location), LogLevel.Warn);
                    }
                    else
                    {
                        switch (m.Location)
                        {
                        case "AdventureGuild":
                            Game1.locations[i] = new AdventureGuild(mapAssetKey, m.Location);
                            break;

                        case "BathHousePool":
                            Game1.locations[i] = new BathHousePool(mapAssetKey, m.Location);
                            break;

                        case "Beach":
                            Game1.locations[i] = new Beach(mapAssetKey, m.Location);
                            break;

                        case "BusStop":
                            Game1.locations[i] = new BusStop(mapAssetKey, m.Location);
                            break;

                        case "Club":
                            Game1.locations[i] = new Club(mapAssetKey, m.Location);
                            break;

                        case "Desert":
                            Game1.locations[i] = new Desert(mapAssetKey, m.Location);
                            break;

                        case "Forest":
                            Game1.locations[i] = new Forest(mapAssetKey, m.Location);
                            break;

                        case "FarmCave":
                            Game1.locations[i] = new FarmCave(mapAssetKey, m.Location);
                            break;

                        case "Mountain":
                            Game1.locations[i] = new Mountain(mapAssetKey, m.Location);
                            break;

                        case "Railroad":
                            Game1.locations[i] = new Railroad(mapAssetKey, m.Location);
                            break;

                        case "SeedShop":
                            Game1.locations[i] = new SeedShop(mapAssetKey, m.Location);
                            break;

                        case "Sewer":
                            Game1.locations[i] = new Sewer(mapAssetKey, m.Location);
                            break;

                        case "WizardHouse":
                            Game1.locations[i] = new WizardHouse(mapAssetKey, m.Location);
                            break;

                        case "Woods":
                            Game1.locations[i] = new Woods(mapAssetKey, m.Location);
                            break;

                        default:
                            Game1.locations[i] = new GameLocation(mapAssetKey, m.Location);
                            break;
                        }
                        Memory.instance.Monitor.Log("Map has been overridden with a custom map: " + m.Location);
                    }
                }
            }
        }