public static bool ModPatch_BattleAction(BattleAction __instance, ref bool __result) { if (!Application.isPlaying || __instance.battleId.IsNullOrEmpty()) { __result = false; return(false); } string battleId = __instance.battleId; BattleArea battleArea = Game.Data.Get <BattleArea>(battleId); BattleGrid battleGrid = Game.Data.Get <BattleGrid>(battleArea?.BattleMap); if (battleGrid == null) { battleGrid = Randomizer.GetOneFromData <BattleGrid>(battleArea?.BattleMap); if (battleGrid != null) { BattleArea battleAreaClone = battleArea.Clone <BattleArea>(); battleAreaClone.Id = "!" + battleAreaClone.Id; battleAreaClone.BattleMap = battleGrid.Id; // 复写mapId ModExtensionSaveData.AddTempItem(battleAreaClone); battleId = battleAreaClone.Id; } } string mapId = battleGrid?.MapId; Console.WriteLine("当前MapId=" + Game.GameData.MapId); Console.WriteLine("需要MapId=" + mapId); if (mapId == Game.GameData.MapId) { Game.FSM.SendEvent("BATTLE", new Heluo.FSM.Main.BattleEventArgs() { BattleId = battleId }); __result = true; } else { CachedBattleId = battleId; Console.WriteLine("设置BattleId=" + CachedBattleId); Game.FSM.SendEvent("LOADING", new LoadingEventArgs { MapId = mapId, CinematicId = null, TimeStage = Heluo.Manager.TimeStage.None, LoadType = LoadType.Default }); __result = true; } return(false); }