示例#1
0
        private static void AnswerResult(string responseKey)
        {
            string[] split = responseKey.Split('#');
            int      x     = int.Parse(split[1]);
            int      y     = int.Parse(split[2]);

            Game1.player.currentLocation.removeTileProperty(x, y, "Buildings", "Action");

            string type = split[3];

            switch (type)
            {
            case "Y":
                Game1.player.currentLocation.removeTile(x, y - 1, "Front");
                Game1.player.currentLocation.removeTile(x, y, "Buildings");
                Utils.DropChest(Game1.player.currentLocation as MineShaft, new Vector2(x, y));
                return;

            case "S":
                Game1.player.currentLocation.removeTile(x, y - 1, "Front");
                Game1.player.currentLocation.removeTile(x, y, "Buildings");
                CollapsingFloors.collapseFloor(Game1.player.currentLocation as MineShaft, Game1.player.getTileLocation());
                return;

            default:
                Game1.player.currentLocation.setMapTileIndex(x, y - 1, litEyes + 16, "Front");
                Traps.TriggerRandomTrap(Game1.player.currentLocation as MineShaft, Game1.player.getTileLocation(), false);
                return;
            }
        }
示例#2
0
        public static bool GameLocation_performTouchAction_prefix(GameLocation __instance, string fullActionString, Vector2 playerStandingPosition)
        {
            if (!(__instance is MineShaft))
            {
                return(true);
            }
            ModEntry.context.Monitor.Log($"touch action at {playerStandingPosition} {fullActionString}");

            string action = fullActionString.Split(' ')[0];

            if (action == "collapseFloor")
            {
                CollapsingFloors.collapseFloor(__instance as MineShaft, playerStandingPosition);
                return(false);
            }
            if (action.StartsWith("tilePuzzle_"))
            {
                TilePuzzles.pressTile(__instance as MineShaft, playerStandingPosition, action);
                return(false);
            }
            if (action.StartsWith("lightPuzzle_"))
            {
                LightPuzzles.pressTile(__instance as MineShaft, playerStandingPosition, action);
                return(false);
            }
            if (action == "randomTrap")
            {
                Traps.TriggerRandomTrap(__instance as MineShaft, playerStandingPosition, true);
                return(false);
            }
            return(true);
        }
示例#3
0
        public override void Entry(IModHelper helper)
        {
            context = this;
            Config  = this.Helper.ReadConfig <ModConfig>();
            if (!Config.EnableMod)
            {
                return;
            }

            tileSheetPath = this.Helper.Content.GetActualAssetKey(Path.Combine("assets", "underground_secrets.png"), ContentSource.ModFolder);

            HelperEvents.Initialize(Helper, Monitor, Config);
            UndergroundPatches.Initialize(Helper, Monitor, Config);
            Utils.Initialize(Helper, Monitor, Config);

            TilePuzzles.Initialize(Helper, Monitor, Config);
            OfferingPuzzles.Initialize(Helper, Monitor, Config);
            LightPuzzles.Initialize(Helper, Monitor, Config);
            Altars.Initialize(Helper, Monitor, Config);
            RiddlePuzzles.Initialize(Helper, Monitor, Config);
            CollapsingFloors.Initialize(Helper, Monitor, Config);
            Traps.Initialize(Helper, Monitor, Config);
            MushroomTrees.Initialize(Helper, Monitor, Config);

            //Helper.Events.Player.Warped += HelperEvents.Player_Warped;
            Helper.Events.GameLoop.UpdateTicked += HelperEvents.GameLoop_UpdateTicked;
            Helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;

            var harmony = HarmonyInstance.Create(ModManifest.UniqueID);

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.performTouchAction)),
                prefix: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.GameLocation_performTouchAction_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.loadMap)),
                postfix: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.GameLocation_loadMap_postfix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(MineShaft), "populateLevel"),
                transpiler: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.MineShaft_populateLevel_transpiler))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(MineShaft), "checkAction"),
                prefix: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.MineShaft_checkAction_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(MineShaft), "addLevelChests"),
                prefix: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.MineShaft_addLevelChests_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(MineShaft), nameof(MineShaft.enterMineShaft)),
                postfix: new HarmonyMethod(typeof(UndergroundPatches), nameof(UndergroundPatches.MineShaft_enterMineShaft_postfix))
                );
        }
示例#4
0
        internal static void OfferObject(MineShaft shaft, string action, Location tileLocation, Farmer who)
        {
            string[] parts = action.Split('_').Skip(1).ToArray();

            int type = int.Parse(parts[0]);
            int cx   = int.Parse(parts[1]);
            int cy   = int.Parse(parts[2]);

            if (who.ActiveObject == null)
            {
                Game1.activeClickableMenu = new DialogueBox(helper.Translation.Get($"altar-explain-{type}"));
                return;
            }

            int value = who.ActiveObject.salePrice();

            who.reduceActiveItemByOne();
            if (value < 10)
            {
                if (type == 0)
                {
                    CollapsingFloors.collapseFloor(shaft, who.getTileLocation());
                    return;
                }
                else if (type == 1)
                {
                    Traps.TriggerRandomTrap(shaft, who.getTileLocation(), false);
                    return;
                }
            }

            string sound = "yoba";

            if (type == 0)
            {
                sound = "grunt";
            }
            else if (type == 1)
            {
                sound = "debuffSpell";
            }
            shaft.playSound(sound, SoundContext.Default);

            BuffsDisplay buffsDisplay = Game1.buffsDisplay;
            Buff         buff2        = GetBuff(value, who, shaft, type);

            buffsDisplay.addOtherBuff(buff2);
        }
示例#5
0
        public static void AddSecrets(MineShaft shaft)
        {
            if (config.OverrideTreasureRooms && (helper.Reflection.GetField <NetBool>(shaft, "netIsTreasureRoom").GetValue().Value || (shaft.mineLevel < 121 && shaft.mineLevel % 20 == 0) || shaft.mineLevel == 10 || shaft.mineLevel == 50 || shaft.mineLevel == 70 || shaft.mineLevel == 90 || shaft.mineLevel == 110))
            {
                monitor.Log($"is treasure room");

                return;
            }

            List <Vector2> clearSpots        = new List <Vector2>();
            List <Vector2> clearCenters      = new List <Vector2>();
            List <Vector2> superClearCenters = new List <Vector2>();

            Vector2 tileBeneathLadder = helper.Reflection.GetField <NetVector2>(shaft, "netTileBeneathLadder").GetValue();

            monitor.Log($"tileBeneathLadder: {tileBeneathLadder}");

            for (int x = 0; x < shaft.map.Layers[0].LayerWidth; x++)
            {
                for (int y = 0; y < shaft.map.Layers[0].LayerHeight; y++)
                {
                    Tile build = shaft.map.GetLayer("Buildings").PickTile(new Location(x, y) * Game1.tileSize, Game1.viewport.Size);

                    if (build != null)
                    {
                        if (build.TileIndex == 115)
                        {
                            tileBeneathLadder = new Vector2(x, y + 1);
                            monitor.Log($"made tileBeneathLadder: {tileBeneathLadder}");
                        }
                        continue;
                    }

                    if (x == tileBeneathLadder.X && y == tileBeneathLadder.Y)
                    {
                        continue;
                    }
                    Tile tile = shaft.map.GetLayer("Back").PickTile(new Location(x, y) * Game1.tileSize, Game1.viewport.Size);
                    if (tile != null && (tile.TileIndex / 16 > 7 || tile.TileIndex % 16 < 9) && shaft.map.GetLayer("Front").PickTile(new Location(x, y) * Game1.tileSize, Game1.viewport.Size) == null)
                    {
                        clearSpots.Add(new Vector2(x, y));
                    }
                }
            }
            monitor.Log($"clearSpots contains tileBeneathLadder: {clearSpots.Contains(tileBeneathLadder)}");


            foreach (Vector2 spot in clearSpots)
            {
                int clear = GetTileClearance(shaft, spot, clearSpots);
                if (clear > 0)
                {
                    clearCenters.Add(spot);
                }
                if (clear > 1)
                {
                    superClearCenters.Add(spot);
                }
            }
            monitor.Log($"got {clearSpots.Count} clear spots in {shaft.Name}");
            monitor.Log($"got {clearCenters.Count} clear centers in {shaft.Name}");
            monitor.Log($"got {superClearCenters.Count} super clear centers in {shaft.Name}");

            monitor.Log($"adding underground_secrets tilesheet");
            TileSheet mine = shaft.map.TileSheets[0];

            helper.Reflection.GetField <Size>(mine, "m_sheetSize").SetValue(new Size(16, 18));
            shaft.map.AddTileSheet(new TileSheet(ModEntry.tileSheetId, shaft.map, ModEntry.tileSheetPath, new Size(16, 18), new Size(16, 16)));
            shaft.map.LoadTileSheets(Game1.mapDisplayDevice);
            TilePuzzles.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            LightPuzzles.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            OfferingPuzzles.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            Altars.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            RiddlePuzzles.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            Traps.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            if (shaft.mineLevel > 120)
            {
                CollapsingFloors.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
            }
            MushroomTrees.Start(shaft, ref superClearCenters, ref clearCenters, ref clearSpots);
        }