using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Randoms;
using LBoL.Core.SaveData;
using LBoL.Core.Stations;
using LBoL.Core.Units;
using LBoL.EntityLib.Adventures;
using LBoL.EntityLib.Adventures.Common;
using LBoL.EntityLib.Adventures.FirstPlace;
using LBoL.EntityLib.Adventures.Shared12;
using LBoL.EntityLib.Adventures.Shared23;
using LBoL.EntityLib.Adventures.Stage1;
using LBoL.EntityLib.Adventures.Stage2;
using LBoL.EntityLib.Adventures.Stage3;
using LBoL.EntityLib.Stages.NormalStages;
using LBoL.Presentation.I10N;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.ExtraWidgets;
using LBoL.Presentation.UI.Panels;
using LBoL.Presentation.UI.Widgets;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Resource;
using StsMap.Localization;
using StsMap.Source.Stages;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("StsMap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+63bb43836485913cc63a15595b88247f3a0c34ff")]
[assembly: AssemblyProduct("StsMap")]
[assembly: AssemblyTitle("StsMap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace StsMap
{
[BepInPlugin("valon.misc.StsMap", "StsMap", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LBoL.exe")]
public class BepinexPlugin : BaseUnityPlugin
{
public static string modUniqueID = "StsMap";
private static readonly Harmony harmony = PInfo.harmony;
internal static ManualLogSource log;
internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());
internal static DirectorySource directorySource = new DirectorySource("valon.misc.StsMap", "");
public static ConfigEntry<int> VisionRangeConfig;
public static ConfigEntry<bool> HideBossConfig;
private void Awake()
{
log = ((BaseUnityPlugin)this).Logger;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
VisionRangeConfig = ((BaseUnityPlugin)this).Config.Bind<int>("FogOfWar", "VisionRange", 2, "Number of nodes you can see ahead in Fog of War. Values less than 0 will be treated as 0.");
HideBossConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("FogOfWar", "HideBoss", true, "If true, the boss node at the end of the map is also hidden until you are within vision range.");
EntityManager.RegisterSelf();
harmony.PatchAll();
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public static class PInfo
{
public const string GUID = "valon.misc.StsMap";
public const string Name = "StsMap";
public const string version = "1.0.0";
public static readonly Harmony harmony = new Harmony("valon.misc.StsMap");
}
}
namespace StsMap.Localization
{
public sealed class StsMapLocalization
{
public static string Jadeboxes = "jadeboxes";
public static BatchLocalization jadeboxLoc = new BatchLocalization((IResourceSource)(object)BepinexPlugin.directorySource, typeof(JadeBoxTemplate), Jadeboxes, (Locale)0, false);
public static void Init()
{
jadeboxLoc.DiscoverAndLoadLocFiles(Jadeboxes);
}
}
}
namespace StsMap.Source.Stages
{
public sealed class BambooForestStSDef : StageTemplate
{
public override IdContainer GetId()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return IdContainer.op_Implicit("BambooForestStS");
}
public override StageConfig MakeConfig()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
return new StageConfig("BambooForestStS", "BambooForest0", "BambooForest1", 1, "BambooForest2", 6, "BambooForest3", 11, "", 16);
}
}
[EntityLogic(typeof(BambooForestStSDef))]
public sealed class BambooForestStS : StSStageBase
{
private const float W = 1.2f;
private const string ForceSanyueFlag = "ForceSanyue";
private const string Force11Flag = "Force11";
private const string Force14Flag = "Force14";
private const string Force17Flag = "Force17";
public BambooForestStS()
{
((Stage)this).Level = 1;
((Stage)this).CardUpgradedChance = 0f;
((Stage)this).IsSelectingBoss = true;
UniqueRandomPool<string> obj = new UniqueRandomPool<string>(true);
obj.Add("11", 1f);
obj.Add("12", 1f);
obj.Add("13", 1f);
((Stage)this).EnemyPoolAct1 = obj;
UniqueRandomPool<string> obj2 = new UniqueRandomPool<string>(true);
obj2.Add("14", 1f);
obj2.Add("15", 1f);
obj2.Add("16", 1f);
((Stage)this).EnemyPoolAct2 = obj2;
UniqueRandomPool<string> obj3 = new UniqueRandomPool<string>(true);
obj3.Add("17", 1f);
obj3.Add("18", 1f);
obj3.Add("19", 1f);
((Stage)this).EnemyPoolAct3 = obj3;
UniqueRandomPool<string> obj4 = new UniqueRandomPool<string>(true);
obj4.Add("Sanyue", 1f);
obj4.Add("Aya", 1f);
obj4.Add("Rin", 1f);
((Stage)this).EliteEnemyPool = obj4;
UniqueRandomPool<Type> val = new UniqueRandomPool<Type>(true);
val.Add(typeof(YorigamiSisters), 1f);
val.Add(typeof(HecatiaTshirt), 1f);
val.Add(typeof(KeineSales), 1f);
val.Add(typeof(MikeInvest), 1f);
val.Add(typeof(YoumuDelivery), 1f);
val.Add(typeof(AssistKagerou), 1.2f);
val.Add(typeof(EternityAscension), 1.2f);
val.Add(typeof(KaguyaVersusMokou), 1.2f);
val.Add(typeof(MystiaBbq), 1.2f);
val.Add(typeof(ParseeJealousy), 1.2f);
val.Add(typeof(RumiaDriving), 1.2f);
val.Add(typeof(TewiThreat), 1.2f);
((Stage)this).AdventurePool = val;
}
public override void InitExtraFlags(ProfileSaveData userProfile)
{
if (!userProfile.EnemyGroupRevealed.Contains("Sanyue"))
{
((Stage)this).ExtraFlags.Add("ForceSanyue");
}
if (!userProfile.EnemyGroupRevealed.Contains("11"))
{
((Stage)this).ExtraFlags.Add("Force11");
}
if (!userProfile.EnemyGroupRevealed.Contains("14"))
{
((Stage)this).ExtraFlags.Add("Force14");
}
if (!userProfile.EnemyGroupRevealed.Contains("17"))
{
((Stage)this).ExtraFlags.Add("Force17");
}
}
public override EnemyGroupEntry GetEnemies(Station station)
{
switch (station.Act)
{
case 1:
if (((Stage)this).ExtraFlags.Contains("Force11"))
{
((Stage)this).ExtraFlags.Remove("Force11");
((Stage)this).EnemyPoolAct1.Remove("11", false);
return Library.GetEnemyGroupEntry("11");
}
break;
case 2:
if (((Stage)this).ExtraFlags.Contains("Force14"))
{
((Stage)this).ExtraFlags.Remove("Force14");
((Stage)this).EnemyPoolAct2.Remove("14", false);
return Library.GetEnemyGroupEntry("14");
}
break;
case 3:
if (((Stage)this).ExtraFlags.Contains("Force17"))
{
((Stage)this).ExtraFlags.Remove("Force17");
((Stage)this).EnemyPoolAct3.Remove("17", false);
return Library.GetEnemyGroupEntry("17");
}
break;
}
return ((Stage)this).GetEnemies(station);
}
public override EnemyGroupEntry GetEliteEnemies(Station station)
{
if (((Stage)this).ExtraFlags.Contains("ForceSanyue"))
{
((Stage)this).ExtraFlags.Remove("ForceSanyue");
((Stage)this).EliteEnemyPool.Remove("Sanyue", false);
return Library.GetEnemyGroupEntry("Sanyue");
}
if (station.Act == 1)
{
string text = ((Stage)this).EliteEnemyPool.Without("Aya").Sample(((GameEntity)this).GameRun.StationRng);
((Stage)this).EliteEnemyPool.Remove(text, false);
return Library.GetEnemyGroupEntry(text);
}
return ((Stage)this).GetEliteEnemies(station);
}
}
public class StsGameMap
{
private const int XLandmark1 = 5;
private const int XLandmark2 = 10;
private const int XGap = 15;
private const int XBoss = 16;
private const int MapWidth = 8;
private const int MapLevels = 17;
private static int GetAct(int x)
{
if (x <= 5)
{
return 1;
}
if (x <= 10)
{
return 2;
}
return 3;
}
public static GameMap CreateStSStyleMap(RandomGen rng, [CanBeNull] string bossId, bool isSelectingBoss)
{
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Expected O, but got Unknown
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Expected O, but got Unknown
//IL_01fc: Expected O, but got Unknown
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Expected O, but got Unknown
int num = 48 + rng.NextInt(-2, 2);
int num2 = rng.NextInt(7, 9);
int num3 = rng.NextInt(3, num2 - 3);
int num4 = num2 - num3;
if (num4 < 3)
{
num4 = 3;
num3 = num2 - 3;
}
if (num3 < 3)
{
num3 = 3;
num4 = num2 - 3;
}
int num5 = rng.NextInt(1, 2);
int num6 = rng.NextInt(2, 4);
int num7 = rng.NextInt(2, 4);
int num8 = num5 + num6 + num7;
int val = num - num2 - num8;
val = Math.Max(val, 0);
int num9 = Mathf.RoundToInt((float)val * 0.4f);
int num10 = val - num9;
List<StationType> list = new List<StationType>();
for (int i = 0; i < num3; i++)
{
list.Add((StationType)4);
}
for (int j = 0; j < num4; j++)
{
list.Add((StationType)5);
}
for (int k = 0; k < num6 + num7; k++)
{
list.Add((StationType)2);
}
for (int l = 0; l < num9; l++)
{
list.Add((StationType)6);
}
for (int m = 0; m < num10; m++)
{
list.Add((StationType)1);
}
CollectionsExtensions.Shuffle<StationType>((IList<StationType>)list, rng);
List<StationType> list2 = new List<StationType>();
for (int n = 0; n < num5; n++)
{
list2.Add((StationType)2);
}
list2.Add((StationType)1);
list2.Add((StationType)6);
list2.Add((StationType)1);
list2.Add((StationType)1);
CollectionsExtensions.Shuffle<StationType>((IList<StationType>)list2, rng);
GameMap val2 = new GameMap(17, 8, (UiType)2, bossId);
val2.Nodes[0, 0] = new MapNode(val2, 0, 0, 1)
{
StationType = (StationType)7
};
for (int num11 = 1; num11 < 8; num11++)
{
val2.Nodes[5, num11] = new MapNode(val2, 5, num11, 1)
{
StationType = (StationType)(isSelectingBoss ? 8 : 9)
};
val2.Nodes[10, num11] = new MapNode(val2, 10, num11, 2)
{
StationType = (StationType)3
};
}
val2.Nodes[15, 0] = new MapNode(val2, 15, 0, 3)
{
StationType = (StationType)4
};
val2.Nodes[16, 0] = new MapNode(val2, 16, 0, 3)
{
StationType = (StationType)10
};
List<(int, int, int)> edges = new List<(int, int, int)>();
int num12 = rng.NextInt(3, 4);
List<int> list3 = Enumerable.Range(1, 7).ToList();
CollectionsExtensions.Shuffle<int>((IList<int>)list3, rng);
list3 = list3.Take(num12).ToList();
foreach (int item in list3)
{
val2.Nodes[0, 0].FollowerList.Add(item);
}
foreach (int item2 in list3)
{
WalkHallway(val2, edges, rng, 1, 4, 0, 0, item2, 5);
}
WalkFromLandmark(val2, edges, rng, 5, 6, 9, 10);
WalkFromLandmark(val2, edges, rng, 10, 11, 14, 15);
ConvergeToSingle(val2, edges, 14, 15, 0);
val2.Nodes[15, 0].FollowerList.Add(0);
AssignTypesToHallway(val2, rng, 1, 4, list2, list, isH1: true);
AssignTypesToHallway(val2, rng, 6, 9, list, null, isH1: false);
AssignTypesToHallway(val2, rng, 11, 14, list, null, isH1: false);
BepinexPlugin.log.LogInfo((object)$"Remaining in bucket: {list.Count}");
int count = list.Count;
int num13 = count / 3;
int num14 = count % 3;
PepperNodes(val2, edges, rng, list, 1, 4, 1, isH1: true, num13);
PepperNodes(val2, edges, rng, list, 6, 9, 2, isH1: false, num13);
PepperNodes(val2, edges, rng, list, 11, 14, 3, isH1: false, num13 + num14);
AddCrossConnections(val2, edges, rng, 1, 4);
AddCrossConnections(val2, edges, rng, 6, 9);
AddCrossConnections(val2, edges, rng, 11, 14);
SweepAndPruneOrphans(val2, edges);
val2.StartNode = val2.Nodes[0, 0];
val2.StartNode.Status = (MapNodeStatus)1;
MapNode bossNode = (val2.EndNode = val2.Nodes[16, 0]);
val2.BossNode = bossNode;
LogMapShape(val2, num12);
return val2;
}
private static void LogMapShape(GameMap map, int pathCount)
{
BepinexPlugin.log.LogInfo((object)"=================== MAP SHAPE DIAGNOSTICS ===================");
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int[] array = new int[17];
for (int i = 0; i < 17; i++)
{
int num5 = 0;
for (int j = 0; j < 8; j++)
{
if (map.Nodes[i, j] != null)
{
num5++;
num4++;
if (i <= 5)
{
num++;
}
else if (i <= 10)
{
num2++;
}
else
{
num3++;
}
}
}
array[i] = num5;
}
BepinexPlugin.log.LogInfo((object)$"Initial Path Count: {pathCount}");
BepinexPlugin.log.LogInfo((object)$"Total Nodes in Grid: {num4}");
BepinexPlugin.log.LogInfo((object)$"Act 1 Nodes (Columns 0-{5}): {num}");
BepinexPlugin.log.LogInfo((object)$"Act 2 Nodes (Columns {6}-{10}): {num2}");
BepinexPlugin.log.LogInfo((object)$"Act 3 Nodes (Columns {11}+): {num3}");
string text = "Nodes per Column: ";
for (int k = 0; k < 17; k++)
{
text += $"[X{k}:{array[k]}] ";
}
BepinexPlugin.log.LogInfo((object)text);
BepinexPlugin.log.LogInfo((object)"Visual Grid Profile:");
for (int l = 0; l < 8; l++)
{
string text2 = $"Y={l} | ";
for (int m = 0; m < 17; m++)
{
text2 += ((map.Nodes[m, l] != null) ? "O " : ". ");
}
BepinexPlugin.log.LogInfo((object)text2);
}
BepinexPlugin.log.LogInfo((object)"=============================================================");
}
private static void WalkHallway(GameMap map, List<(int x, int fromY, int toY)> edges, RandomGen rng, int xStart, int xEnd, int entryX, int entryY, int startY, int landmarkX)
{
int num = startY;
EnsureNode(map, xStart, num, GetAct(xStart));
TryAddEdge(map, edges, entryX, entryY, xStart, num);
for (int i = xStart; i < xEnd; i++)
{
bool flag = false;
List<int> list = new List<int>
{
num - 1,
num,
num + 1
};
CollectionsExtensions.Shuffle<int>((IList<int>)list, rng);
foreach (int item in list)
{
int num2 = ClampY(i + 1, item);
EnsureNode(map, i + 1, num2, GetAct(i + 1));
if (TryAddEdge(map, edges, i, num, i + 1, num2))
{
num = num2;
flag = true;
break;
}
}
if (!flag)
{
break;
}
}
if (landmarkX == 15 || landmarkX == 16)
{
TryAddEdge(map, edges, xEnd, num, landmarkX, 0);
}
else
{
TryAddEdge(map, edges, xEnd, num, landmarkX, num);
}
}
private static void WalkFromLandmark(GameMap map, List<(int x, int fromY, int toY)> edges, RandomGen rng, int landmarkX, int xHallStart, int xHallEnd, int nextLandmarkX)
{
int num = ((landmarkX != 0 && landmarkX != 15 && landmarkX != 16) ? 1 : 0);
int y;
for (y = num; y < 8; y++)
{
MapNode val = map.Nodes[landmarkX, y];
if (val != null && edges.Any(((int x, int fromY, int toY) e) => e.x == landmarkX - 1 && e.toY == y))
{
WalkHallway(map, edges, rng, xHallStart, xHallEnd, landmarkX, y, y, nextLandmarkX);
}
}
}
private static void ConvergeToSingle(GameMap map, List<(int x, int fromY, int toY)> edges, int xFrom, int xTo, int toY)
{
List<int> list = new List<int>();
for (int i = 1; i < 8; i++)
{
if (map.Nodes[xFrom, i] != null)
{
list.Add(i);
}
}
if (list.Count == 1)
{
int num = list[0];
int num2 = ((num + 1 < 8) ? (num + 1) : (num - 1));
EnsureNode(map, xFrom, num2, GetAct(xFrom));
list.Add(num2);
for (int j = 1; j < 8 && (map.Nodes[xFrom - 1, j] == null || !TryAddEdge(map, edges, xFrom - 1, j, xFrom, num2)); j++)
{
}
}
foreach (int item in list)
{
TryAddEdge(map, edges, xFrom, item, xTo, toY);
}
}
private static void AssignTypesToHallway(GameMap map, RandomGen rng, int xStart, int xEnd, List<StationType> bucket, [CanBeNull] List<StationType> mainBucket, bool isH1)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
for (int i = xStart; i <= xEnd; i++)
{
int num = ((i != 0 && i != 15 && i != 16) ? 1 : 0);
for (int j = num; j < 8; j++)
{
MapNode val = map.Nodes[i, j];
if (val != null && (int)val.StationType <= 0)
{
List<StationType> bucket2 = ((isH1 && i == xEnd) ? bucket : (mainBucket ?? bucket));
val.StationType = PullFromBucket(bucket2, val, map, i, xEnd, isH1);
}
}
}
}
private static StationType PullFromBucket(List<StationType> bucket, MapNode node, GameMap map, int x, int xEnd, bool isH1)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < bucket.Count; i++)
{
StationType val = bucket[i];
if (IsPlacementValid(val, map, x, node.Y, xEnd, isH1))
{
bucket.RemoveAt(i);
return val;
}
}
return (StationType)1;
}
private static bool IsPlacementValid(StationType candidate, StationType? predecessor, int x, int xEnd, bool isH1)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
if (x == 1 && (int)candidate != 1)
{
return false;
}
if (x < 4 && IsRestSite(candidate))
{
return false;
}
if (x == 14 && IsRestSite(candidate))
{
return false;
}
if (isH1 && (int)candidate == 2 && x != xEnd)
{
return false;
}
if (predecessor.HasValue && predecessor.Value == candidate && (int)candidate != 1 && (int)candidate != 6)
{
return false;
}
return true;
}
private static bool IsPlacementValid(StationType candidate, GameMap map, int x, int y, int xEnd, bool isH1)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
MapNode val = map.Nodes[x, y];
if (!IsPlacementValid(candidate, null, x, xEnd, isH1))
{
return false;
}
if (val != null)
{
foreach (StationType predecessorType in GetPredecessorTypes(map, val))
{
if (!IsPlacementValid(candidate, predecessorType, x, xEnd, isH1))
{
return false;
}
}
foreach (StationType successorType in GetSuccessorTypes(map, val))
{
if (!IsPlacementValid(candidate, successorType, x, xEnd, isH1))
{
return false;
}
}
}
return true;
}
private static bool IsRestSite(StationType t)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
return (int)t == 4 || (int)t == 5;
}
private static List<StationType> GetPredecessorTypes(GameMap map, MapNode node)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
List<StationType> list = new List<StationType>();
for (int i = 0; i < 8; i++)
{
MapNode val = map.Nodes[node.X - 1, i];
if (val != null && val.FollowerList.Contains(node.Y) && !list.Contains(val.StationType))
{
list.Add(val.StationType);
}
}
return list;
}
private static List<StationType> GetSuccessorTypes(GameMap map, MapNode node)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
List<StationType> list = new List<StationType>();
for (int i = 0; i < 8; i++)
{
if (node.FollowerList.Contains(i))
{
MapNode val = map.Nodes[node.X + 1, i];
if (val != null && !list.Contains(val.StationType))
{
list.Add(val.StationType);
}
}
}
return list;
}
private static void PepperNodes(GameMap map, List<(int x, int fromY, int toY)> edges, RandomGen rng, List<StationType> bucket, int xStart, int xEnd, int act, bool isH1, int maxNodes)
{
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Expected O, but got Unknown
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
if (bucket.Count == 0 || maxNodes <= 0)
{
return;
}
List<(int, int)> list = new List<(int, int)>();
for (int i = xStart; i <= xEnd; i++)
{
for (int j = 1; j < 8; j++)
{
if (map.Nodes[i, j] == null)
{
list.Add((i, j));
}
}
}
CollectionsExtensions.Shuffle<(int, int)>((IList<(int, int)>)list, rng);
int num = 0;
foreach (var item3 in list)
{
int item = item3.Item1;
int item2 = item3.Item2;
if (bucket.Count == 0 || num >= maxNodes)
{
break;
}
int predMinY = ((item - 1 != 0) ? 1 : 0);
int succMinY = ((item + 1 != 15) ? 1 : 0);
List<int> list2 = (from y in GetNeighbours(map, item - 1, item2)
where y >= predMinY
select y).ToList();
List<int> list3 = (from y in GetNeighbours(map, item + 1, item2)
where y >= succMinY
select y).ToList();
if (list2.Count == 0 || list3.Count == 0)
{
continue;
}
List<int> list4 = new List<int>();
List<int> list5 = new List<int>();
foreach (int item4 in list2)
{
foreach (int item5 in list3)
{
if (!WouldCross(edges, item - 1, item4, item2) && !WouldCross(edges, item, item2, item5))
{
if (!list4.Contains(item4))
{
list4.Add(item4);
}
if (!list5.Contains(item5))
{
list5.Add(item5);
}
}
}
}
if (list4.Count != 0 && list5.Count != 0)
{
MapNode val = new MapNode(map, item, item2, act);
map.Nodes[item, item2] = val;
CollectionsExtensions.Shuffle<int>((IList<int>)list4, rng);
CollectionsExtensions.Shuffle<int>((IList<int>)list5, rng);
TryAddEdge(map, edges, item - 1, list4[0], item, item2);
TryAddEdge(map, edges, item, item2, item + 1, list5[0]);
val.StationType = PullFromBucket(bucket, val, map, item, xEnd, isH1);
num++;
}
}
}
private static List<int> GetNeighbours(GameMap map, int x, int cy)
{
List<int> list = new List<int>();
if (x < 0 || x >= 17)
{
return list;
}
int num = ((x != 0 && x != 15 && x != 16) ? 1 : 0);
int num2 = ((x != 0 && x != 15 && x != 16) ? 7 : 0);
for (int i = -1; i <= 1; i++)
{
int num3 = cy + i;
if (num3 >= num && num3 <= num2 && map.Nodes[x, num3] != null)
{
list.Add(num3);
}
}
return list;
}
private static void AddCrossConnections(GameMap map, List<(int x, int fromY, int toY)> edges, RandomGen rng, int xStart, int xEnd)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
for (int i = xStart; i < xEnd; i++)
{
int num = 1;
for (int j = num; j < 8; j++)
{
MapNode val = map.Nodes[i, j];
if (val == null)
{
continue;
}
List<(int, int)> list = new List<(int, int)>();
for (int k = -1; k <= 1; k++)
{
int num2 = j + k;
if (num2 >= num && num2 < 8)
{
MapNode val2 = map.Nodes[i + 1, num2];
if (val2 != null && !val.FollowerList.Contains(num2) && IsPlacementValid(val2.StationType, val.StationType, i + 1, xEnd, isH1: false) && !WouldCross(edges, i, j, num2))
{
list.Add((j, num2));
}
}
}
if (list.Count >= 1 && !(rng.NextFloat() < 0.5f))
{
CollectionsExtensions.Shuffle<(int, int)>((IList<(int, int)>)list, rng);
(int, int) tuple = list.First();
TryAddEdge(map, edges, i, tuple.Item1, i + 1, tuple.Item2);
}
}
}
}
private static void SweepAndPruneOrphans(GameMap map, List<(int x, int fromY, int toY)> edges)
{
bool flag = true;
while (flag)
{
flag = false;
for (int i = 1; i <= 14; i++)
{
for (int j = 1; j < 8; j++)
{
MapNode val = map.Nodes[i, j];
if (val == null)
{
continue;
}
bool flag2 = val.FollowerList.Count > 0;
bool flag3 = false;
if (i == 1)
{
flag3 = map.Nodes[0, 0] != null && map.Nodes[0, 0].FollowerList.Contains(j);
}
else
{
for (int k = 1; k < 8; k++)
{
MapNode val2 = map.Nodes[i - 1, k];
if (val2 != null && val2.FollowerList.Contains(j))
{
flag3 = true;
break;
}
}
}
if (flag3 && flag2)
{
continue;
}
if (!flag3 && !flag2)
{
KillNode(map, edges, i, j);
flag = true;
continue;
}
bool missingPred = !flag3;
bool missingSucc = !flag2;
if (!TryRescue(map, edges, i, j, missingPred, missingSucc))
{
KillNode(map, edges, i, j);
flag = true;
}
}
}
}
}
private static bool TryRescue(GameMap map, List<(int x, int fromY, int toY)> edges, int x, int y, bool missingPred, bool missingSucc)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
StationType stationType = map.Nodes[x, y].StationType;
if (missingSucc)
{
int num = x + 1;
int num2 = ((num != 15 && num != 16) ? 1 : 0);
for (int i = -1; i <= 1; i++)
{
int num3 = y + i;
if (num3 >= num2 && num3 < 8)
{
MapNode val = map.Nodes[num, num3];
if (val != null && IsPlacementValid(stationType, val.StationType, x, 14, isH1: false) && TryAddEdge(map, edges, x, y, num, num3))
{
return true;
}
}
}
}
if (missingPred)
{
int num4 = x - 1;
int num5 = ((num4 != 0) ? 1 : 0);
for (int j = -1; j <= 1; j++)
{
int num6 = y + j;
if (num6 >= num5 && num6 < 8)
{
MapNode val2 = map.Nodes[num4, num6];
if (val2 != null && IsPlacementValid(stationType, val2.StationType, x, 14, isH1: false) && TryAddEdge(map, edges, num4, num6, x, y))
{
return true;
}
}
}
}
return false;
}
private static void KillNode(GameMap map, List<(int x, int fromY, int toY)> edges, int x, int y)
{
map.Nodes[x, y] = null;
if (x == 1)
{
MapNode obj = map.Nodes[0, 0];
if (obj != null)
{
obj.FollowerList.Remove(y);
}
}
else
{
for (int i = 1; i < 8; i++)
{
MapNode val = map.Nodes[x - 1, i];
if (val != null)
{
val.FollowerList.Remove(y);
}
}
}
edges.RemoveAll(((int x, int fromY, int toY) e) => (e.x == x && e.fromY == y) || (e.x == x - 1 && e.toY == y));
}
private static bool TryAddEdge(GameMap map, List<(int x, int fromY, int toY)> edges, int fx, int fy, int tx, int ty)
{
if (map.Nodes[fx, fy] == null || map.Nodes[tx, ty] == null)
{
return false;
}
if (map.Nodes[fx, fy].FollowerList.Contains(ty))
{
return false;
}
if (WouldCross(edges, fx, fy, ty))
{
return false;
}
map.Nodes[fx, fy].FollowerList.Add(ty);
edges.Add((fx, fy, ty));
return true;
}
private static bool WouldCross(List<(int x, int fromY, int toY)> edges, int x, int fromY, int toY)
{
foreach (var (num, num2, num3) in edges)
{
if (num == x && (num2 != fromY || num3 != toY))
{
int num4 = num2 - fromY;
int num5 = num3 - toY;
if (num4 != 0 && num5 != 0 && num4 > 0 != num5 > 0)
{
return true;
}
}
}
return false;
}
private static void EnsureNode(GameMap map, int x, int y, int act)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
if (map.Nodes[x, y] == null)
{
map.Nodes[x, y] = new MapNode(map, x, y, act);
}
}
private static int ClampY(int x, int y)
{
if (x == 0 || x == 15 || x == 16)
{
return 0;
}
return Math.Max(1, Math.Min(7, y));
}
}
public abstract class StSStageBase : NormalStageBase
{
public override GameMap CreateMap()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
ulong mapSeed = ((Stage)this).MapSeed;
EnemyGroupEntry boss = ((Stage)this).Boss;
string text = ((boss != null) ? boss.Id : null);
try
{
BepinexPlugin.log.LogInfo((object)"Creating STS-style map");
return StsGameMap.CreateStSStyleMap(new RandomGen(mapSeed), text, ((Stage)this).IsSelectingBoss);
}
catch (Exception ex)
{
BepinexPlugin.log.LogError((object)("Map generation failed, falling back to vanilla: " + ex.Message));
BepinexPlugin.log.LogError((object)ex.StackTrace);
return GameMap.CreateNormalMap(new RandomGen(mapSeed), text, ((Stage)this).IsSelectingBoss);
}
}
}
public sealed class WindGodLakeStsDef : StageTemplate
{
public override IdContainer GetId()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return IdContainer.op_Implicit("WindGodLakeSts");
}
public override StageConfig MakeConfig()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
return new StageConfig("WindGodLakeSts", "WindGodLake1", "WindGodLake2", 1, "", 6, "", 11, "", 16);
}
}
[EntityLogic(typeof(WindGodLakeStsDef))]
public sealed class WindGodLakeSts : StSStageBase
{
public const float W = 1.2f;
public WindGodLakeSts()
{
((Stage)this).Level = 3;
((Stage)this).CardUpgradedChance = 0.5f;
((Stage)this).TradeAdventureType = typeof(SumirekoGathering);
UniqueRandomPool<string> obj = new UniqueRandomPool<string>(true);
obj.Add("31", 1f);
obj.Add("32", 1f);
obj.Add("33", 1f);
((Stage)this).EnemyPoolAct1 = obj;
UniqueRandomPool<string> obj2 = new UniqueRandomPool<string>(true);
obj2.Add("34", 1f);
obj2.Add("35", 1f);
obj2.Add("36", 1f);
((Stage)this).EnemyPoolAct2 = obj2;
UniqueRandomPool<string> obj3 = new UniqueRandomPool<string>(true);
obj3.Add("37", 1f);
obj3.Add("38", 1f);
obj3.Add("39", 1f);
((Stage)this).EnemyPoolAct3 = obj3;
UniqueRandomPool<string> obj4 = new UniqueRandomPool<string>(true);
obj4.Add("Clownpiece", 1f);
obj4.Add("Siji", 1f);
obj4.Add("Doremy", 1f);
((Stage)this).EliteEnemyPool = obj4;
RepeatableRandomPool<string> obj5 = new RepeatableRandomPool<string>();
obj5.Add("Sanae", 1f);
obj5.Add("Remilia", 1f);
obj5.Add("Junko", 1f);
((Stage)this).BossPool = obj5;
((Stage)this).StoryBossId = "Sanae";
UniqueRandomPool<Type> val = new UniqueRandomPool<Type>(false);
val.Add(typeof(MiyoiBartender), 1f);
val.Add(typeof(WatatsukiPurify), 1f);
val.Add(typeof(DoremyPortal), 1f);
((Stage)this).FirstAdventurePool = val;
val = new UniqueRandomPool<Type>(true);
val.Add(typeof(YorigamiSisters), 1f);
val.Add(typeof(HatateInterview), 1f);
val.Add(typeof(HinaCollect), 1f);
val.Add(typeof(KogasaSpook), 1f);
val.Add(typeof(KosuzuBookstore), 1f);
val.Add(typeof(NarumiOfferCard), 1f);
val.Add(typeof(NazrinDetect), 1f);
val.Add(typeof(MedicinePoison), 1.2f);
val.Add(typeof(BackgroundDancers), 1.2f);
val.Add(typeof(MikoDonation), 1.2f);
val.Add(typeof(SatoriCounseling), 1.2f);
((Stage)this).AdventurePool = val;
((Stage)this).TradeAdventureType = typeof(SumirekoGathering);
}
}
public sealed class XuanwuRavineStsDef : StageTemplate
{
public override IdContainer GetId()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return IdContainer.op_Implicit("XuanwuRavineSts");
}
public override StageConfig MakeConfig()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
return new StageConfig("XuanwuRavineSts", "XuanwuRavine1", "", 1, "XuanwuRavine3", 6, "", 11, "", 16);
}
}
[EntityLogic(typeof(XuanwuRavineStsDef))]
public sealed class XuanwuRavineSts : StSStageBase
{
public const float W = 1.4f;
public XuanwuRavineSts()
{
((Stage)this).Level = 2;
((Stage)this).CardUpgradedChance = 0.25f;
UniqueRandomPool<string> obj = new UniqueRandomPool<string>(true);
obj.Add("21", 1f);
obj.Add("22", 1f);
obj.Add("23", 1f);
((Stage)this).EnemyPoolAct1 = obj;
UniqueRandomPool<string> obj2 = new UniqueRandomPool<string>(true);
obj2.Add("24", 1f);
obj2.Add("25", 1f);
obj2.Add("26", 1f);
((Stage)this).EnemyPoolAct2 = obj2;
UniqueRandomPool<string> obj3 = new UniqueRandomPool<string>(true);
obj3.Add("27", 1f);
obj3.Add("28", 1f);
obj3.Add("29", 1f);
((Stage)this).EnemyPoolAct3 = obj3;
UniqueRandomPool<string> obj4 = new UniqueRandomPool<string>(true);
obj4.Add("Nitori", 1f);
obj4.Add("Youmu", 1f);
obj4.Add("Kokoro", 1f);
((Stage)this).EliteEnemyPool = obj4;
RepeatableRandomPool<string> obj5 = new RepeatableRandomPool<string>();
obj5.Add("Long", 1f);
obj5.Add("Tianzi", 1f);
obj5.Add("Yuyuko", 1f);
((Stage)this).BossPool = obj5;
((Stage)this).StoryBossId = "Long";
UniqueRandomPool<Type> val = new UniqueRandomPool<Type>(false);
val.Add(typeof(PatchouliPhilosophy), 1f);
val.Add(typeof(JunkoColorless), 1f);
val.Add(typeof(ShinmyoumaruForge), 1f);
((Stage)this).FirstAdventurePool = val;
val = new UniqueRandomPool<Type>(true);
val.Add(typeof(YorigamiSisters), 1f);
val.Add(typeof(HecatiaTshirt), 1f);
val.Add(typeof(KeineSales), 1f);
val.Add(typeof(MikeInvest), 1f);
val.Add(typeof(YoumuDelivery), 1f);
val.Add(typeof(HatateInterview), 1f);
val.Add(typeof(HinaCollect), 1f);
val.Add(typeof(KogasaSpook), 1f);
val.Add(typeof(KosuzuBookstore), 1f);
val.Add(typeof(NarumiOfferCard), 1f);
val.Add(typeof(NazrinDetect), 1f);
val.Add(typeof(BuduSuanming), 1.4f);
val.Add(typeof(YachieOppression), 1.4f);
val.Add(typeof(RemiliaMeet), 1.4f);
val.Add(typeof(RingoEmp), 1.4f);
((Stage)this).AdventurePool = val;
}
}
}
namespace StsMap.Source.Patching
{
internal class MapButtonPatch
{
[HarmonyPatch(typeof(StartGamePanel), "OnShowing")]
private static class StartGamePanel_OnShowing_Patch
{
private static void Postfix(StartGamePanel __instance, StartGameData data)
{
try
{
InjectToggleButton(__instance, data);
}
catch (Exception ex)
{
BepinexPlugin.log.LogError((object)("StS Map Mod: failed to inject toggle button: " + ex));
}
}
}
internal static bool UseStSMap;
private static void InjectToggleButton(StartGamePanel panel, StartGameData data)
{
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)panel).transform.Find("DifficultyPanel/MainRoot");
if ((Object)(object)val == (Object)null)
{
BepinexPlugin.log.LogWarning((object)"StS Map Mod: DifficultyPanel/MainRoot not found.");
return;
}
Func<Stage[]> stagesCreateFunc = data.StagesCreateFunc;
Transform val2 = val.Find("StSMapToggle");
if ((Object)(object)val2 != (Object)null)
{
SwitchWidget component = ((Component)val2).GetComponent<SwitchWidget>();
if ((Object)(object)component != (Object)null)
{
component.SetValueWithoutNotifier(UseStSMap, true);
RewireListener(component, panel, stagesCreateFunc);
ApplyToggle(panel, UseStSMap, stagesCreateFunc);
}
return;
}
Transform val3 = val.Find("RandomResult");
if ((Object)(object)val3 == (Object)null)
{
BepinexPlugin.log.LogWarning((object)"StS Map Mod: RandomResult not found.");
return;
}
GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, val);
((Object)val4).name = "StSMapToggle";
RectTransform component2 = val4.GetComponent<RectTransform>();
Vector3 val5 = default(Vector3);
((Vector3)(ref val5))..ctor(9.7294f, -4.7611f, 10f);
Vector3 val6 = default(Vector3);
((Vector3)(ref val6))..ctor(5.9873f, -4.7611f, 10f);
((Transform)component2).position = val6 + (val6 - val5);
Transform val7 = val4.transform.Find("TextRoot/TextOn");
if ((Object)(object)val7 != (Object)null)
{
((Component)val7).GetComponent<LocalizedText>().key = "StartGame.StsMapOn";
((Behaviour)((Component)val7).GetComponent<LocalizedText>()).enabled = false;
((TMP_Text)((Component)val7).GetComponent<TextMeshProUGUI>()).text = "Sts Map Enabled";
}
else
{
BepinexPlugin.log.LogWarning((object)"Text on not found!");
}
Transform val8 = val4.transform.Find("TextRoot/TextOff");
if ((Object)(object)val8 != (Object)null)
{
((Component)val8).GetComponent<LocalizedText>().key = "StartGame.StsMapOff";
((Behaviour)((Component)val8).GetComponent<LocalizedText>()).enabled = false;
((TMP_Text)((Component)val8).GetComponent<TextMeshProUGUI>()).text = "Sts Map Disabled";
}
else
{
BepinexPlugin.log.LogWarning((object)"Text off not found!");
}
SimpleTooltipSource component3 = val4.GetComponent<SimpleTooltipSource>();
if ((Object)(object)component3 != (Object)null)
{
component3.SetDirect("StS Map", "Use the Slay the Spire-style map generator.");
}
SwitchWidget component4 = val4.GetComponent<SwitchWidget>();
if ((Object)(object)component4 != (Object)null)
{
component4.SetValueWithoutNotifier(UseStSMap, true);
RewireListener(component4, panel, stagesCreateFunc);
ApplyToggle(panel, UseStSMap, stagesCreateFunc);
}
BepinexPlugin.log.LogInfo((object)"StS Map Mod: toggle button injected.");
}
private static void RewireListener(SwitchWidget sw, StartGamePanel panel, Func<Stage[]> vanillaFunc)
{
((UnityEventBase)sw.onToggleChanged).RemoveAllListeners();
sw.AddListener((UnityAction<bool>)delegate(bool isOn)
{
UseStSMap = isOn;
BepinexPlugin.log.LogInfo((object)("StS Map Mod: toggle " + (isOn ? "ON" : "OFF")));
ApplyToggle(panel, isOn, vanillaFunc);
});
}
private static void ApplyToggle(StartGamePanel panel, bool isOn, Func<Stage[]> vanillaFunc)
{
Stage[] array = vanillaFunc();
Stage[] stages = (Stage[])((!isOn) ? ((Array)array) : ((Array)new Stage[4]
{
(Stage)Library.CreateStage<BambooForestStS>(),
(Stage)Library.CreateStage<XuanwuRavineSts>(),
((Stage)Library.CreateStage<WindGodLakeSts>()).AsNormalFinal(),
((Stage)Library.CreateStage<FinalStage>()).AsTrueEndFinal()
}));
panel._stages = stages;
}
}
public class MapNodeHighlightHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
{
private bool _isHighlighted = false;
public GameObject highlightRing;
public void OnPointerClick(PointerEventData eventData)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)eventData.button == 1)
{
_isHighlighted = !_isHighlighted;
if ((Object)(object)highlightRing != (Object)null)
{
highlightRing.SetActive(_isHighlighted);
}
}
}
}
[HarmonyPatch(typeof(MapPanel), "LBoL.Presentation.UI.IInputActionHandler.OnCancel")]
public static class MapPanel_OnCancel_Patch
{
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(MapPanel), "GenerateMapUI")]
public static class MapPanel_GenerateMapUI_Patch
{
public static float GetDynamicNodeY(MapNode mapNode)
{
if (mapNode.Map == null)
{
return ((float)mapNode.Y - 2.5f) * 350f;
}
int width = mapNode.Map.Width;
if (width <= 5)
{
return ((float)mapNode.Y - 2.5f) * 350f;
}
float num = (float)width - 1f;
float num2 = (1f + num) / 2f;
float num3 = 740f / (num - num2);
return ((float)mapNode.Y - num2) * num3;
}
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = -1;
for (int i = 0; i < list.Count - 3; i++)
{
if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 2.5f && list[i + 1].opcode == OpCodes.Sub && list[i + 2].opcode == OpCodes.Ldc_R4 && (float)list[i + 2].operand == 350f && list[i + 3].opcode == OpCodes.Mul)
{
num = i;
break;
}
}
if (num != -1)
{
int num2 = num - 2;
list[num2].opcode = OpCodes.Call;
list[num2].operand = AccessTools.Method(typeof(MapPanel_GenerateMapUI_Patch), "GetDynamicNodeY", (Type[])null, (Type[])null);
list[num2 + 1].opcode = OpCodes.Nop;
list[num].opcode = OpCodes.Nop;
list[num + 1].opcode = OpCodes.Nop;
list[num + 2].opcode = OpCodes.Nop;
list[num + 3].opcode = OpCodes.Nop;
}
else
{
Debug.LogWarning((object)"MapPanel.GenerateMapUI Transpiler failed: Could not find the Y positioning math.");
}
return list;
}
}
[HarmonyPatch(typeof(MapNodeWidget), "Initialize")]
public static class MapNodeWidget_Initialize_ScalePatch
{
public static void Postfix(MapNodeWidget __instance, MapNode mapNode)
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Invalid comparison between Unknown and I4
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
if (mapNode == null || mapNode.Map == null)
{
return;
}
if ((Object)(object)((Component)__instance).gameObject.GetComponent<MapNodeHighlightHandler>() == (Object)null)
{
Image outerImage = __instance.outerImage;
if ((Object)(object)outerImage != (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(((Component)outerImage).gameObject, ((Component)outerImage).transform.parent);
((Object)val).name = "RightClickHighlightRing";
val.transform.localScale = new Vector3(1.2f, 1.2f, 1f);
Image component = val.GetComponent<Image>();
((Graphic)component).color = Color.yellow;
val.SetActive(false);
MapNodeHighlightHandler mapNodeHighlightHandler = ((Component)__instance).gameObject.AddComponent<MapNodeHighlightHandler>();
mapNodeHighlightHandler.highlightRing = val;
val.transform.SetSiblingIndex(((Component)outerImage).transform.GetSiblingIndex() + 1);
}
}
int width = mapNode.Map.Width;
if (width > 5 && (int)mapNode.StationType != 10)
{
float num = 5f / ((float)width - 1f);
RectTransform component2 = ((Component)__instance).GetComponent<RectTransform>();
component2.sizeDelta = new Vector2(component2.sizeDelta.x * num, component2.sizeDelta.y * num);
}
}
}
}
namespace StsMap.Source.Jadeboxes
{
public sealed class FogOfWarJadeBoxDef : JadeBoxTemplate
{
public override IdContainer GetId()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return IdContainer.op_Implicit("FogOfWarJadeBox");
}
public override JadeBoxConfig MakeConfig()
{
JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
val.Value1 = Mathf.Max(0, BepinexPlugin.VisionRangeConfig.Value);
return val;
}
public override LocalizationOption LoadLocalization()
{
return (LocalizationOption)(object)StsMapLocalization.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
}
}
[EntityLogic(typeof(FogOfWarJadeBoxDef))]
public sealed class FogOfWarJadeBox : JadeBox
{
public static bool IsActive(GameRunController run)
{
return run != null && run.HasJadeBox<FogOfWarJadeBox>();
}
public static int VisionRange(GameRunController run)
{
if (!IsActive(run))
{
return 99;
}
JadeBox val = ((IEnumerable<JadeBox>)run.JadeBoxes).FirstOrDefault((Func<JadeBox, bool>)((JadeBox c) => c is FogOfWarJadeBox));
return (val != null) ? Mathf.Max(0, val.Value1) : 99;
}
}
public class FogOfWarVisuals : MonoBehaviour
{
public Sprite realSprite;
public Sprite fogSprite;
public Image iconImage;
public GameObject bossNameObj;
public string realTooltipText;
public string fogTooltipText;
public SimpleTooltipSource tooltip;
}
[HarmonyPatch(typeof(MapPanel), "UpdateMapNodesStatus")]
public static class MapPanel_UpdateMapNodesStatus_FOW_Patch
{
public static void Postfix(MapPanel __instance)
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Invalid comparison between Unknown and I4
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Invalid comparison between Unknown and I4
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Invalid comparison between Unknown and I4
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Invalid comparison between Unknown and I4
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Invalid comparison between Unknown and I4
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Invalid comparison between Unknown and I4
int num = FogOfWarJadeBox.VisionRange(((UiPanelBase)__instance).GameRun);
if (num >= 99)
{
return;
}
GameMap currentMap = ((UiPanelBase)__instance).GameRun.CurrentMap;
if (currentMap == null)
{
return;
}
MapNode visitingNode = currentMap.VisitingNode;
int num2 = ((visitingNode != null) ? visitingNode.X : (-1));
MapNodeWidget[,] mapNodeWidgets = __instance._mapNodeWidgets;
if (mapNodeWidgets == null)
{
return;
}
MapNodeWidget[,] array = mapNodeWidgets;
foreach (MapNodeWidget val in array)
{
if ((Object)(object)val == (Object)null || val.MapNode == null || (!BepinexPlugin.HideBossConfig.Value && (int)val.MapNode.StationType == 10) || (int)val.MapNode.StationType == 9 || (int)val.MapNode.StationType == 8 || (int)val.MapNode.StationType == 3)
{
continue;
}
FogOfWarVisuals fogOfWarVisuals = ((Component)val).gameObject.GetComponent<FogOfWarVisuals>();
if ((Object)(object)fogOfWarVisuals == (Object)null)
{
fogOfWarVisuals = ((Component)val).gameObject.AddComponent<FogOfWarVisuals>();
fogOfWarVisuals.iconImage = val.iconImage;
fogOfWarVisuals.realSprite = fogOfWarVisuals.iconImage.sprite;
fogOfWarVisuals.fogSprite = val.bossUnselect;
fogOfWarVisuals.tooltip = ((Component)val).GetComponent<SimpleTooltipSource>();
fogOfWarVisuals.realTooltipText = LocalizationExtensions.Localize("Map." + ((object)val.MapNode.StationType/*cast due to .constrained prefix*/).ToString(), true);
fogOfWarVisuals.fogTooltipText = "???";
if ((int)val.MapNode.StationType == 10)
{
TextMeshProUGUI bossName = val.bossName;
if ((Object)(object)bossName != (Object)null)
{
fogOfWarVisuals.bossNameObj = ((Component)bossName).gameObject;
}
}
}
if ((Object)(object)fogOfWarVisuals.iconImage.sprite != (Object)(object)fogOfWarVisuals.realSprite && (Object)(object)fogOfWarVisuals.iconImage.sprite != (Object)(object)fogOfWarVisuals.fogSprite)
{
fogOfWarVisuals.realSprite = fogOfWarVisuals.iconImage.sprite;
}
if (val.MapNode.X > num2 + num)
{
if ((Object)(object)fogOfWarVisuals.fogSprite != (Object)null)
{
fogOfWarVisuals.iconImage.sprite = fogOfWarVisuals.fogSprite;
((Component)fogOfWarVisuals.iconImage).gameObject.SetActive(true);
}
if ((Object)(object)fogOfWarVisuals.bossNameObj != (Object)null)
{
fogOfWarVisuals.bossNameObj.SetActive(false);
}
if ((Object)(object)fogOfWarVisuals.tooltip != (Object)null && (int)val.MapNode.StationType != 10)
{
fogOfWarVisuals.tooltip.SetDirect(fogOfWarVisuals.fogTooltipText, (string)null);
}
}
else
{
if ((Object)(object)fogOfWarVisuals.realSprite != (Object)null)
{
fogOfWarVisuals.iconImage.sprite = fogOfWarVisuals.realSprite;
}
if ((Object)(object)fogOfWarVisuals.bossNameObj != (Object)null && (Object)(object)fogOfWarVisuals.realSprite == (Object)null)
{
fogOfWarVisuals.bossNameObj.SetActive(true);
((Component)fogOfWarVisuals.iconImage).gameObject.SetActive(false);
}
if ((Object)(object)fogOfWarVisuals.tooltip != (Object)null)
{
fogOfWarVisuals.tooltip.SetDirect(fogOfWarVisuals.realTooltipText, (string)null);
}
}
}
}
}
}
namespace StsMap.ImageLoader
{
public sealed class TrukeImageLoader
{
public class EffectHider : MonoBehaviour
{
private void Start()
{
if (!((Object)this).name.Contains("Clone"))
{
((MonoBehaviour)this).StartCoroutine(HideAfterFrame());
}
}
private IEnumerator HideAfterFrame()
{
SpriteRenderer renderer = default(SpriteRenderer);
if (((Component)this).TryGetComponent<SpriteRenderer>(ref renderer))
{
((Renderer)renderer).enabled = false;
}
yield return null;
((Component)this).transform.localPosition = new Vector3(0f, 0f, 0f);
if ((Object)(object)renderer != (Object)null)
{
((Renderer)renderer).enabled = true;
}
Debug.Log((object)"Truke Exists!");
}
}
public static string file_extension = ".png";
public static GameObject effectParent;
public static Dictionary<string, GameObject> effectObjects = new Dictionary<string, GameObject>();
public static GameObject LoadEffectGameObject(string imageName)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
if ((Object)(object)effectParent == (Object)null)
{
Debug.Log((object)"Spawned effect parent");
GameObject val = new GameObject("EffectParent");
Object.DontDestroyOnLoad((Object)(object)val);
effectParent = val;
effectParent.transform.position = new Vector3(-10f, 0f, 0f);
}
if (effectObjects.TryGetValue(imageName, out var value))
{
return value;
}
string text = imageName + file_extension;
Sprite val2 = ResourceLoader.LoadSprite(text, BepinexPlugin.embeddedSource, (Rect?)null, 256, (Vector2?)null);
Debug.Log((object)("Trying to load " + imageName));
if ((Object)(object)val2 == (Object)null)
{
Debug.LogWarning((object)("Failed to load effect sprite at path: " + text));
return new GameObject(imageName + "_Failed");
}
GameObject val3 = new GameObject(imageName + "_Effect");
val3.transform.parent = effectParent.transform;
val3.AddComponent<EffectHider>();
SpriteRenderer val4 = val3.AddComponent<SpriteRenderer>();
val4.sprite = val2;
ParticleSystem val5 = val3.AddComponent<ParticleSystem>();
MainModule main = val5.main;
((MainModule)(ref main)).playOnAwake = false;
((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)1;
EmissionModule emission = val5.emission;
((EmissionModule)(ref emission)).enabled = false;
Debug.Log((object)("Spawning the effect object of " + imageName + " successful!"));
return val3;
}
public static Sprite LoadSprite(IdContainer ID)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return ResourceLoader.LoadSprite(IdContainer.op_Implicit(ID) + file_extension, BepinexPlugin.embeddedSource, (Rect?)null, 1, (Vector2?)null);
}
}
}
namespace StsMap.Config
{
public struct CustomConfigEntry<T>
{
public T Value { get; set; }
public string Section { get; set; }
public string Key { get; set; }
public string Description { get; set; }
public CustomConfigEntry(T value, string section, string key, string description)
{
Value = value;
Section = section;
Key = key;
Description = description;
}
}
public sealed class MintyDefaultConfig
{
private static readonly string OwnerName = BepinexPlugin.modUniqueID;
public static string DefaultID(EntityDefinition entity)
{
string name = ((object)entity).GetType().Name;
return name.Remove(name.Length - 3);
}
public static CardConfig CardDefaultConfig()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
return new CardConfig(0, "", 10, true, new string[0][], "", "", 0, false, true, false, true, true, (Rarity)0, (CardType)0, (TargetType?)null, (IReadOnlyList<ManaColor>)new List<ManaColor>(), false, default(ManaGroup), (ManaGroup?)null, (ManaGroup?)null, (ManaGroup?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (ManaGroup?)null, (ManaGroup?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (Keyword)0, (Keyword)0, false, (Keyword)0, (Keyword)0, (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), OwnerName, (string)null, "", "", false, (string)null, (IReadOnlyList<string>)new List<string>());
}
public static ExhibitConfig DefaultExhibitConfig()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
return new ExhibitConfig(0, "", 10, false, false, false, false, (AppearanceType)3, OwnerName, (ExhibitLosableType)1, (Rarity)3, (int?)null, (int?)null, (int?)null, (ManaGroup?)default(ManaGroup), (ManaColor?)null, (ManaColor?)(ManaColor)1, 1, false, (int?)null, (Keyword)0, (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>());
}
public static StatusEffectConfig DefaultStatusEffectConfig()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
return new StatusEffectConfig(0, "", 10, (StatusEffectType)0, false, true, (int?)null, true, (StackType?)(StackType)0, false, (StackType?)(StackType)0, (DurationDecreaseTiming)0, false, (StackType?)(StackType)3, (StackType?)(StackType)3, false, (Keyword)0, (IReadOnlyList<string>)new List<string>(), (string)null, "Default", "Default", "Default");
}
public static UltimateSkillConfig DefaultUltConfig()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
return new UltimateSkillConfig("", 10, 100, 100, 2, (UsRepeatableType)1, 1, 0, 0, (Keyword)256, (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>());
}
public static EnemyUnitConfig EnemyUnitDefaultConfig()
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Expected O, but got Unknown
return new EnemyUnitConfig("", false, false, (IReadOnlyList<ManaColor>)new List<ManaColor> { (ManaColor)6 }, 10, "", "#ffff", (EnemyType)1, false, (float?)null, (int?)null, 250, (int?)10, (int?)10, (int?)10, (int?)10, (int?)1, (int?)15, (int?)1, (int?)2, (int?)250, (int?)10, (int?)10, (int?)10, (int?)10, (int?)1, (int?)15, (int?)1, (int?)2, (int?)250, (int?)10, (int?)10, (int?)10, (int?)10, (int?)1, (int?)15, (int?)1, (int?)2, new MinMax(100, 100), new MinMax(100, 100), (IReadOnlyList<string>)new List<string> { "simple" }, (IReadOnlyList<string>)new List<string> { "simple" }, (IReadOnlyList<string>)new List<string> { "simple" }, (IReadOnlyList<string>)new List<string> { "simple" });
}
public static EnemyGroupConfig EnemyGroupDefaultConfig()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
return new EnemyGroupConfig("", false, (IReadOnlyList<string>)new List<string>(), "", "Single", (IReadOnlyList<string>)new List<string>(), (EnemyType)3, false, 1f, true, new Vector2(-4f, 0.5f), "", "", (string)null);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}