Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CombatTrainer v0.5.7
CombatTrainer.dll
Decompiled 5 hours agousing System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace CombatTrainer; [BepInPlugin("trickstack.CombatTrainer", "CombatTrainer", "0.5.7")] public class Plugin : BaseUnityPlugin { internal static ConfigEntry<string> WorldName; internal static ConfigEntry<float> GroundHeight; internal static bool Active; private static string ListPath => Path.Combine(Paths.ConfigPath, "CombatTrainer.worlds.txt"); private static string TrainersPath => Path.Combine(Paths.ConfigPath, "CombatTrainer.trainers.txt"); private static string Norm(string s) { return (s ?? "").Replace(" ", "").ToLowerInvariant(); } internal static bool IsArena(World w) { if (w != null && !w.m_menu) { if (!File.Exists(ListPath) || !File.ReadAllLines(ListPath).Contains(w.m_uid.ToString())) { return Norm(w.m_name) == Norm(WorldName.Value); } return true; } return false; } internal static bool IsTrainerProfile(string file) { if (File.Exists(TrainersPath)) { return File.ReadAllLines(TrainersPath).Contains(file); } return false; } internal static void AddTrainerProfile(string file) { if (!IsTrainerProfile(file)) { File.AppendAllText(TrainersPath, file + Environment.NewLine); } } internal static void MarkArena(World w) { if (!IsArena(w)) { File.AppendAllText(ListPath, w.m_uid + Environment.NewLine); } Debug.Log((object)("[CombatTrainer] marked as arena: " + w.m_name + " (" + w.m_uid + ")")); } private void Awake() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) WorldName = ((BaseUnityPlugin)this).Config.Bind<string>("World", "Training World Name", "CombatTrainer", "Only a world with this name becomes the training arena (case and spaces ignored)."); GroundHeight = ((BaseUnityPlugin)this).Config.Bind<float>("World", "Ground Height", 34f, "Arena ground height in metres (water is at 30)."); Kits.AuthorMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Kits", "Author Mode", false, "Edits to preset kits save into the mod's own kits folder (to ship them), and your kits get a Ship with mod button."); Game.isModded = true; new Harmony("local.combattrainer").PatchAll(); } private void Update() { Trainer.Update(); } private void OnGUI() { Trainer.OnGUI(); } } [HarmonyPatch(typeof(WorldGenerator), "Initialize")] internal static class DetectWorld { private static void Postfix(World world) { Plugin.Active = Plugin.IsArena(world); if (Plugin.Active) { Debug.Log((object)("[CombatTrainer] training world loaded: " + world.m_name)); } } } [HarmonyPatch(typeof(FejdStartup), "OnWorldStart")] internal static class AskBeforeArena { private static bool allowOnce; private static bool Prefix(FejdStartup __instance) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown if (allowOnce) { allowOnce = false; return true; } Traverse val = Traverse.Create((object)__instance); World world = val.Field("m_world").GetValue<World>(); List<PlayerProfile> value = val.Field("m_profiles").GetValue<List<PlayerProfile>>(); int value2 = val.Field("m_profileIndex").GetValue<int>(); if (!Plugin.IsArena(world) || value == null || value2 < 0 || value2 >= value.Count) { return true; } PlayerProfile pr = value[value2]; if (Plugin.IsTrainerProfile(pr.GetFilename())) { return true; } byte[] value3 = Traverse.Create((object)pr).Field("m_playerData").GetValue<byte[]>(); if (value3 != null && Encoding.UTF8.GetString(value3).Contains("combattrainer_trainer")) { Plugin.AddTrainerProfile(pr.GetFilename()); return true; } bool flag = value3 != null; string text = world.m_name + " is a Combat Trainer Arena. Characters that enter it become trainers and can never join normal worlds again.\n\n" + (flag ? ("<color=#ff6060>" + pr.GetName() + " has already been played: this looks like a real character. Make a new character for training instead.</color>\n\n") : "") + "Turn " + pr.GetName() + " into a trainer and enter?"; UnifiedPopup.Push((PopupBase)new YesNoPopup("Combat Trainer Arena", text, (PopupButtonCallback)delegate { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown UnifiedPopup.Pop(); UnifiedPopup.Push((PopupBase)new YesNoPopup("Are you absolutely sure?", pr.GetName() + " will be a trainer forever and can never join a normal world again. This can't be undone.\n\nEnter " + world.m_name + " with " + pr.GetName() + "?", (PopupButtonCallback)delegate { UnifiedPopup.Pop(); Plugin.AddTrainerProfile(pr.GetFilename()); allowOnce = true; __instance.OnWorldStart(); }, (PopupButtonCallback)delegate { UnifiedPopup.Pop(); }, false, false)); }, (PopupButtonCallback)delegate { UnifiedPopup.Pop(); }, false, false)); return false; } } [HarmonyPatch(typeof(WorldGenerator), "Deitialize")] internal static class LeaveWorld { private static void Postfix() { Plugin.Active = false; } } [HarmonyPatch(typeof(WorldGenerator), "GetBiome", new Type[] { typeof(float), typeof(float), typeof(float), typeof(bool) })] internal static class FlatBiome { private static bool Prefix(ref Biome __result) { if (!Plugin.Active) { return true; } __result = (Biome)1; return false; } } [HarmonyPatch(typeof(WorldGenerator), "GetBiomeHeight")] internal static class FlatHeight { private static bool Prefix(ref float __result, out Color mask) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) mask = Color.black; if (!Plugin.Active) { return true; } __result = Plugin.GroundHeight.Value; return false; } } [HarmonyPatch(typeof(ZoneSystem), "GenerateLocations")] internal static class OnlyStartTemple { private static void Prefix(ZoneSystem __instance) { if (!Plugin.Active) { return; } foreach (ZoneLocation location in __instance.m_locations) { if (location.m_prefabName != Game.instance.m_StartLocation) { location.m_enable = false; } } } } [HarmonyPatch(typeof(ZoneSystem), "PlaceVegetation")] internal static class NoVegetation { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch(typeof(SpawnSystem), "UpdateSpawning")] internal static class NoNaturalSpawns { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch(typeof(RandEventSystem), "UpdateRandomEvent")] internal static class NoRaids { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch(typeof(Player), "OnSpawned")] internal static class ClearMidday { private static void Postfix(Player __instance) { if (Plugin.Active && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !((Object)(object)EnvMan.instance == (Object)null)) { EnvMan.instance.SetForceEnvironment("Clear"); EnvMan.instance.m_debugTimeOfDay = true; EnvMan.instance.m_debugTime = 0.5f; } } } [HarmonyPatch(typeof(FejdStartup), "OnWorldNew")] internal static class ArenaCheckbox { internal static Toggle Box; private static void Postfix(FejdStartup __instance) { //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Box == (Object)null) { RectTransform val = (RectTransform)((Component)__instance.m_newWorldSeed).transform; GameObject val2 = Object.Instantiate<GameObject>(((Component)__instance.m_publicServerToggle).gameObject, ((Transform)val).parent, false); ((Object)val2).name = "CombatTrainerToggle"; MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren) { if (((object)val3).GetType().Name == "Localize") { Object.Destroy((Object)(object)val3); } } Box = val2.GetComponent<Toggle>(); Box.onValueChanged = new ToggleEvent(); ((UnityEvent<bool>)(object)Box.onValueChanged).AddListener((UnityAction<bool>)delegate(bool on) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (on) { UnifiedPopup.Push((PopupBase)new YesNoPopup("Combat Trainer Arena", "This world becomes a flat training arena.\n\nPlay it with a NEW character made just for training. Any character that enters becomes a trainer and can never join normal worlds again.\n\nYour real characters stay safe: the trainer copies them read-only from the F8 menu.\n\nMake this an arena world?", (PopupButtonCallback)delegate { UnifiedPopup.Pop(); }, (PopupButtonCallback)delegate { UnifiedPopup.Pop(); Box.isOn = false; }, false, false)); } }); TMP_Text[] componentsInChildren2 = val2.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val4 in componentsInChildren2) { val4.text = "Combat Trainer Arena"; } RectTransform val5 = (RectTransform)val2.transform; val5.anchorMin = val.anchorMin; val5.anchorMax = val.anchorMax; val5.pivot = new Vector2(0f, 1f); Vector2 anchoredPosition = val.anchoredPosition; Rect rect = val.rect; float num2 = (0f - ((Rect)(ref rect)).width) * val.pivot.x; Rect rect2 = val.rect; val5.anchoredPosition = anchoredPosition + new Vector2(num2, (0f - ((Rect)(ref rect2)).height) * val.pivot.y - 12f); val2.SetActive(true); } ((Selectable)Box).interactable = true; Color value = Traverse.Create((object)__instance).Field("m_toggleColor").GetValue<Color>(); TMP_Text[] componentsInChildren3 = ((Component)Box).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val6 in componentsInChildren3) { ((Graphic)val6).color = value; } Box.isOn = false; } } [HarmonyPatch(typeof(FejdStartup), "OnNewWorldDone")] internal static class MarkNewWorld { private static void Prefix(FejdStartup __instance, out World __state) { __state = Traverse.Create((object)__instance).Field("m_world").GetValue<World>(); } private static void Postfix(FejdStartup __instance, World __state) { World value = Traverse.Create((object)__instance).Field("m_world").GetValue<World>(); if (value != null && value != __state && (Object)(object)ArenaCheckbox.Box != (Object)null && ArenaCheckbox.Box.isOn) { Plugin.MarkArena(value); } } } internal class Entry { public string Prefab; public string Label; public int Stars; public int Count = 1; public List<Character> Live = new List<Character>(); } internal static class Trainer { private const string Tag = "combattrainer_spawn"; internal const string TrainerKey = "combattrainer_trainer"; internal const string SourceKey = "combattrainer_source"; internal static bool MenuOpen; internal static bool Frozen; internal static readonly HashSet<BaseAI> Spawned = new HashSet<BaseAI>(); private static readonly List<Entry> Setup = new List<Entry>(); private static List<KeyValuePair<string, string>> catalog; private static string search = ""; private static float distance = 12f; private static float countdown = -1f; private static float nextTick; private static Vector2 scrollA; private static Vector2 scrollB; private static Rect win = new Rect(40f, 60f, 680f, 700f); internal static List<string> LastFoods = new List<string>(); internal static bool DiedHere; private static float healAt = -1f; internal static bool KickPending; private static List<PlayerProfile> profiles; private static string confirmFile; private static string status = ""; internal static bool FightOn; internal static GUIStyle sWin; internal static GUIStyle sHead; internal static GUIStyle sLbl; internal static GUIStyle sDim; internal static GUIStyle sBtn; internal static GUIStyle sOn; internal static GUIStyle sField; internal static GUIStyle sRow; internal static GUIStyle sNum; private static int tab; private static string itemSearch = ""; private static int itemQuality = 1; private static Vector2 scrollI; private static List<KeyValuePair<GameObject, string>> items; internal static void HealSoon() { healAt = Time.time + 5f; } internal static void RepairAll(Player p) { foreach (ItemData allItem in ((Humanoid)p).GetInventory().GetAllItems()) { if (allItem.m_shared.m_useDurability) { allItem.m_durability = allItem.GetMaxDurability(); } } } private static bool Live() { if (Plugin.Active && (Object)(object)Player.m_localPlayer != (Object)null) { return !((Character)Player.m_localPlayer).IsDead(); } return false; } internal static bool IsTrainer(Player p) { if ((Object)(object)p != (Object)null) { return p.m_customData.ContainsKey("combattrainer_trainer"); } return false; } private static void CopyFrom(PlayerProfile src) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; byte[] value = Traverse.Create((object)src).Field("m_playerData").GetValue<byte[]>(); if (value == null) { status = src.GetName() + " has no saved character data."; return; } ((Humanoid)localPlayer).UnequipAllItems(); while (localPlayer.RemoveUniqueKeyValue("invrows")) { } ((Humanoid)localPlayer).GetInventory().SetHeight(9); Traverse val = Traverse.Create((object)localPlayer); string[] array = new string[8] { "m_knownRecipes", "m_knownStations", "m_knownMaterial", "m_shownTutorials", "m_uniques", "m_trophies", "m_knownBiome", "m_knownTexts" }; foreach (string text in array) { val.Field(text).Method("Clear", new object[0]).GetValue(); } bool flag = true; try { localPlayer.Load(new ZPackage(value)); } catch (Exception ex) { flag = false; Debug.LogError((object)("[CombatTrainer] copy failed: " + ex)); } finally { val.Field("m_isLoading").SetValue((object)false); } string s = default(string); localPlayer.SetInventorySize((localPlayer.TryGetUniqueKeyValue("invrows", ref s) && int.TryParse(s, out var result)) ? result : 4); if (!flag) { status = "Copy failed partway (see BepInEx log). Try Re-copy; " + src.GetName() + "'s save was not touched."; return; } Traverse.Create((object)localPlayer).Method("EquipInventoryItems", new object[0]).GetValue(); localPlayer.m_customData["combattrainer_trainer"] = "1"; localPlayer.m_customData["combattrainer_source"] = src.GetFilename(); Kits.RememberSkills(localPlayer); ((Character)localPlayer).SetHealth(((Character)localPlayer).GetMaxHealth()); ((Character)localPlayer).AddStamina(((Character)localPlayer).GetMaxStamina()); HealSoon(); Game.instance.GetPlayerProfile().SavePlayerData(localPlayer); status = "Copied " + src.GetName() + ". " + src.GetName() + "'s own save was not touched."; confirmFile = null; } private static void DrawCharacter() { Player localPlayer = Player.m_localPlayer; GUILayout.Label("Your character", sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (profiles == null) { profiles = SaveSystem.GetAllPlayerProfiles(); } string me = Game.instance.GetPlayerProfile().GetFilename(); localPlayer.m_customData.TryGetValue("combattrainer_source", out var bound); if (IsTrainer(localPlayer)) { PlayerProfile val = ((IEnumerable<PlayerProfile>)profiles).FirstOrDefault((Func<PlayerProfile, bool>)((PlayerProfile x) => x.GetFilename() == bound)); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label((bound == null) ? "Fresh trainer: copy one of your characters to bring its gear, skills and food." : ("Trainer of " + ((val != null) ? val.GetName() : bound)), sLbl, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (val != null && GUILayout.Button("Re-copy " + val.GetName(), sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) })) { CopyFrom(val); } GUILayout.EndHorizontal(); GUILayout.Label("Or copy a different character instead (replaces this trainer's gear, skills and food):", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } else { GUILayout.Label("Copying replaces this character's gear, skills and food with the other character's, and turns it into a trainer that can only enter arena worlds. Use a fresh character for this.", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } List<PlayerProfile> list = profiles.Where((PlayerProfile x) => x.GetFilename() != me && x.GetFilename() != bound).ToList(); for (int num = 0; num < list.Count; num += 3) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); foreach (PlayerProfile item in list.Skip(num).Take(3)) { bool flag = confirmFile == item.GetFilename(); if (GUILayout.Button(flag ? ("Click again: copy " + item.GetName()) : ("Copy from " + item.GetName()), flag ? sOn : sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) })) { if (flag) { CopyFrom(item); } else { confirmFile = item.GetFilename(); } } } GUILayout.EndHorizontal(); } if (status.Length > 0) { GUILayout.Label(status, sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } } internal static void Update() { if (KickPending && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Game.instance != (Object)null) { KickPending = false; Game.instance.Logout(true, true); } if (!Plugin.Active) { MenuOpen = false; Frozen = false; countdown = -1f; return; } if (countdown > 0f) { countdown -= Time.deltaTime; if (countdown <= 0f) { Fight(); } } if (Time.time >= nextTick && Live() && IsTrainer(Player.m_localPlayer)) { nextTick = Time.time + 1f; Upkeep(Player.m_localPlayer); } if (healAt > 0f && Time.time >= healAt && Live()) { healAt = -1f; Player localPlayer = Player.m_localPlayer; ((Character)localPlayer).SetHealth(((Character)localPlayer).GetMaxHealth()); ((Character)localPlayer).AddStamina(((Character)localPlayer).GetMaxStamina()); } } internal static void SetMenu(bool open) { MenuOpen = open; if (open) { Frozen = true; countdown = -1f; profiles = null; } else if (AliveCount() == 0) { Frozen = false; FightOn = false; } else if (FightOn) { Frozen = false; } } private static void StartFight() { MenuOpen = false; if (AliveCount() > 0) { countdown = 3f; } else { Frozen = false; } } private static IEnumerable<Character> Alive() { return from c in Setup.SelectMany((Entry e) => e.Live) where (Object)(object)c != (Object)null && !c.IsDead() select c; } private static int AliveCount() { return Alive().Count(); } private static void Fight() { countdown = -1f; Frozen = false; FightOn = true; foreach (BaseAI item in Spawned) { if ((Object)(object)item != (Object)null) { item.Alert(); item.SetHuntPlayer(true); } } } private static void Upkeep(Player p) { SEMan sEMan = ((Character)p).GetSEMan(); StatusEffect val = sEMan.GetStatusEffect(SEMan.s_statusEffectRested) ?? sEMan.AddStatusEffect(SEMan.s_statusEffectRested, true, 0, 0f, (short)(-1)); if ((Object)(object)val != (Object)null) { val.m_ttl = 0f; } List<Food> value = Traverse.Create((object)p).Field("m_foods").GetValue<List<Food>>(); if (value != null && value.Count > 0) { LastFoods = (from f in value where f.m_item != null && (Object)(object)f.m_item.m_dropPrefab != (Object)null select ((Object)f.m_item.m_dropPrefab).name).ToList(); } foreach (Character item in Character.GetAllCharacters().ToList()) { if ((Object)(object)item == (Object)null || item is Player) { continue; } BaseAI component = ((Component)item).GetComponent<BaseAI>(); if (!((Object)(object)component != (Object)null) || !Spawned.Contains(component)) { ZNetView component2 = ((Component)item).GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.IsOwner() && component2.GetZDO().GetBool("combattrainer_spawn", false)) { ZNetScene.instance.Destroy(((Component)item).gameObject); } } } } internal static void OnArrive(Player p) { string filename = Game.instance.GetPlayerProfile().GetFilename(); if (IsTrainer(p)) { Plugin.AddTrainerProfile(filename); } else { if (!Plugin.IsTrainerProfile(filename)) { ((Character)p).Message((MessageType)2, "Only trainer characters can play Combat Trainer Arenas", 0, (Sprite)null, false); KickPending = true; return; } p.m_customData["combattrainer_trainer"] = "1"; } Clear(); if (DiedHere) { DiedHere = false; foreach (string lastFood in LastFoods) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(lastFood); if (!((Object)(object)itemPrefab == (Object)null)) { ItemData val = itemPrefab.GetComponent<ItemDrop>().m_itemData.Clone(); val.m_dropPrefab = itemPrefab; p.EatFood(val); } } ((Character)p).SetHealth(((Character)p).GetMaxHealth()); HealSoon(); RepairAll(p); ((Character)p).AddStamina(((Character)p).GetMaxStamina()); if (Setup.Count > 0) { RespawnAll(); SetMenu(open: true); } } GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("Pukeberries"); if ((Object)(object)itemPrefab2 != (Object)null) { ItemData val2 = itemPrefab2.GetComponent<ItemDrop>().m_itemData.Clone(); val2.m_dropPrefab = itemPrefab2; if (((Humanoid)p).GetInventory().CountItems(val2.m_shared.m_name, -1, true) == 0) { val2.m_stack = val2.m_shared.m_maxStackSize; ((Humanoid)p).GetInventory().AddItem(val2); } } } internal static void Clear() { foreach (Character item in Character.GetAllCharacters().ToList()) { if (!((Object)(object)item == (Object)null) && !(item is Player)) { ZNetView component = ((Component)item).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO().GetBool("combattrainer_spawn", false)) { ZNetScene.instance.Destroy(((Component)item).gameObject); } } } Spawned.Clear(); foreach (Entry item2 in Setup) { item2.Live.Clear(); } FightOn = false; } private static float RadiusOf(GameObject prefab) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) CapsuleCollider component = prefab.GetComponent<CapsuleCollider>(); if (!((Object)(object)component != (Object)null)) { return 1f; } return Mathf.Max(0.4f, component.radius * prefab.transform.localScale.x); } private static Vector3 PickSpot(float radius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Vector3 forward = ((Component)localPlayer).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); List<KeyValuePair<Vector3, float>> list = (from c in Alive() select new KeyValuePair<Vector3, float>(((Component)c).transform.position, c.GetRadius())).ToList(); Vector3 val = ((Component)localPlayer).transform.position + forward * distance; for (int num = 0; num < 60; num++) { float num2 = 1f + (float)num / 20f; float num3 = distance * Random.Range(1f - 0.25f * num2, 1f + 0.25f * num2); val = ((Component)localPlayer).transform.position + Quaternion.Euler(0f, Random.Range(-35f, 35f) * num2, 0f) * forward * Mathf.Max(3f, num3); bool flag = true; foreach (KeyValuePair<Vector3, float> item in list) { Vector3 val2 = val - item.Key; val2.y = 0f; if (((Vector3)(ref val2)).magnitude < radius + item.Value + 0.75f) { flag = false; break; } } if (flag) { break; } } float y = default(float); if (ZoneSystem.instance.GetGroundHeight(val, ref y)) { val.y = y; } return val + Vector3.up * 0.3f; } private static void SpawnOne(Entry e) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0061: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab(e.Prefab); if (!((Object)(object)prefab == (Object)null)) { Vector3 val = PickSpot(RadiusOf(prefab)); Vector3 val2 = ((Component)Player.m_localPlayer).transform.position - val; val2.y = 0f; GameObject val3 = Object.Instantiate<GameObject>(prefab, val, Quaternion.LookRotation((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? val2 : Vector3.forward)); ZNetView component = val3.GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.GetZDO().Set("combattrainer_spawn", true); } CharacterDrop component2 = val3.GetComponent<CharacterDrop>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } Character component3 = val3.GetComponent<Character>(); if ((Object)(object)component3 != (Object)null && e.Stars > 0) { component3.SetLevel(e.Stars + 1); } BaseAI component4 = val3.GetComponent<BaseAI>(); if ((Object)(object)component4 != (Object)null) { Spawned.Add(component4); } if ((Object)(object)component3 != (Object)null) { e.Live.Add(component3); } Frozen = true; FightOn = false; } } private static void Despawn(Character c) { if (!((Object)(object)c == (Object)null)) { BaseAI component = ((Component)c).GetComponent<BaseAI>(); if ((Object)(object)component != (Object)null) { Spawned.Remove(component); } ZNetScene.instance.Destroy(((Component)c).gameObject); } } private static void DespawnEntry(Entry e) { foreach (Character item in e.Live) { Despawn(item); } e.Live.Clear(); } private static void SpawnEntry(Entry e) { DespawnEntry(e); for (int i = 0; i < e.Count; i++) { SpawnOne(e); } } private static void RespawnAll() { foreach (Entry item in Setup) { DespawnEntry(item); } foreach (Entry item2 in Setup) { for (int i = 0; i < item2.Count; i++) { SpawnOne(item2); } } } private static List<KeyValuePair<string, string>> Catalog() { if (catalog != null) { return catalog; } catalog = new List<KeyValuePair<string, string>>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Character component = prefab.GetComponent<Character>(); if (!((Object)(object)component == (Object)null) && !(component is Player) && !((Object)(object)prefab.GetComponent<BaseAI>() == (Object)null)) { string text = Localization.instance.Localize(component.m_name); if (!string.IsNullOrEmpty(text) && !text.StartsWith("[") && !((Object)prefab).name.Contains("Test")) { catalog.Add(new KeyValuePair<string, string>(((Object)prefab).name, text)); } } } catalog = (from k in catalog orderby k.Value, k.Key select k).ToList(); return catalog; } internal static void OnGUI() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0053: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Active) { return; } Event current = Event.current; if ((int)current.type == 4 && Live() && IsTrainer(Player.m_localPlayer) && ((int)current.keyCode == 289 || ((int)current.keyCode == 27 && MenuOpen))) { SetMenu((int)current.keyCode == 289 && !MenuOpen); current.Use(); } if (countdown > 0f) { GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = 110; val.alignment = (TextAnchor)4; val.fontStyle = (FontStyle)1; GUIStyle val2 = val; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, (float)Screen.height * 0.28f, (float)Screen.width, 150f); string text = Mathf.CeilToInt(countdown).ToString(); val2.normal.textColor = Color.black; for (int i = -3; i <= 3; i += 3) { for (int j = -3; j <= 3; j += 3) { if (i != 0 || j != 0) { GUI.Label(new Rect(((Rect)(ref val3)).x + (float)i, ((Rect)(ref val3)).y + (float)j, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val2); } } } val2.normal.textColor = new Color(1f, 0.78f, 0.3f); GUI.Label(val3, text, val2); } if (MenuOpen && Live()) { Styles(); ((Rect)(ref win)).width = 680f; ((Rect)(ref win)).height = 10f; win = GUILayout.Window(735112, win, new WindowFunction(Draw), "Combat Trainer · X or F8 closes, Fight! starts", sWin, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(680f) }); } } private static Texture2D Tex(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, c); val.Apply(); return val; } private static void Styles() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_012b: 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_0142: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown if (sWin == null) { Color val = default(Color); ((Color)(ref val))..ctor(0.93f, 0.9f, 0.84f); Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.74f, 0.7f, 0.63f); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.72f, 0.3f); GUIStyle val3 = new GUIStyle(GUI.skin.window); val3.fontSize = 18; val3.fontStyle = (FontStyle)1; val3.padding = new RectOffset(14, 14, 34, 12); sWin = val3; GUIStyleState normal = sWin.normal; Texture2D background = (sWin.onNormal.background = Tex(new Color(0.09f, 0.08f, 0.07f, 0.97f))); normal.background = background; GUIStyleState normal2 = sWin.normal; Color textColor2 = (sWin.onNormal.textColor = val2); normal2.textColor = textColor2; GUIStyle val6 = new GUIStyle(GUI.skin.label); val6.fontSize = 16; val6.fontStyle = (FontStyle)1; val6.margin = new RectOffset(0, 0, 10, 4); sHead = val6; sHead.normal.textColor = val2; GUIStyle val7 = new GUIStyle(GUI.skin.label); val7.fontSize = 16; val7.richText = true; val7.alignment = (TextAnchor)3; val7.wordWrap = true; sLbl = val7; sLbl.normal.textColor = val; GUIStyle val8 = new GUIStyle(sLbl); val8.fontSize = 13; sDim = val8; sDim.normal.textColor = textColor; GUIStyle val9 = new GUIStyle(GUI.skin.button); val9.fontSize = 15; sBtn = val9; sBtn.normal.background = Tex(new Color(0.22f, 0.19f, 0.16f)); sBtn.hover.background = Tex(new Color(0.32f, 0.27f, 0.21f)); sBtn.active.background = Tex(new Color(0.42f, 0.33f, 0.2f)); GUIStyleState normal3 = sBtn.normal; GUIStyleState hover = sBtn.hover; Color val10 = (sBtn.active.textColor = val); Color textColor3 = (hover.textColor = val10); normal3.textColor = textColor3; sOn = new GUIStyle(sBtn); GUIStyleState normal4 = sOn.normal; Texture2D background2 = (sOn.hover.background = Tex(new Color(0.62f, 0.42f, 0.16f))); normal4.background = background2; GUIStyleState normal5 = sOn.normal; Color textColor4 = (sOn.hover.textColor = Color.white); normal5.textColor = textColor4; GUIStyle val14 = new GUIStyle(GUI.skin.textField); val14.fontSize = 16; val14.padding = new RectOffset(8, 8, 6, 6); sField = val14; GUIStyleState normal6 = sField.normal; Texture2D background3 = (sField.focused.background = Tex(new Color(0.03f, 0.03f, 0.03f))); normal6.background = background3; GUIStyleState normal7 = sField.normal; Color textColor5 = (sField.focused.textColor = val); normal7.textColor = textColor5; GUIStyle val17 = new GUIStyle(); val17.margin = new RectOffset(0, 0, 2, 2); sRow = val17; GUIStyle val18 = new GUIStyle(sLbl); val18.alignment = (TextAnchor)4; val18.wordWrap = false; sNum = val18; } } internal static List<KeyValuePair<GameObject, string>> Items() { if (items != null) { return items; } items = new List<KeyValuePair<GameObject, string>>(); foreach (GameObject item in ObjectDB.instance.m_items) { ItemDrop val = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null); if (!((Object)(object)val == (Object)null) && !((Object)item).name.StartsWith("FW_") && !((Object)item).name.StartsWith("SP_")) { string text = Localization.instance.Localize(val.m_itemData.m_shared.m_name); if (!string.IsNullOrEmpty(text) && !text.StartsWith("[") && val.m_itemData.m_shared.m_icons.Length != 0) { items.Add(new KeyValuePair<GameObject, string>(item, text)); } } } items = items.OrderBy((KeyValuePair<GameObject, string> k) => k.Value).ToList(); return items; } private static void Give(GameObject prefab, bool stack) { Player localPlayer = Player.m_localPlayer; ItemData val = prefab.GetComponent<ItemDrop>().m_itemData.Clone(); val.m_dropPrefab = prefab; if (val.m_shared.m_maxQuality > 1) { val.m_quality = itemQuality; } val.m_stack = ((!stack) ? 1 : val.m_shared.m_maxStackSize); val.m_durability = val.GetMaxDurability(); if (!((Humanoid)localPlayer).GetInventory().AddItem(val)) { ((Character)localPlayer).Message((MessageType)2, "Inventory full", 0, (Sprite)null, false); } } private static void DrawItems() { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) if (!IsTrainer(Player.m_localPlayer)) { GUILayout.Label("Item spawning only works on trainer characters, so spawned gear can never leave the arena. Copy a character above first.", sLbl, (GUILayoutOption[])(object)new GUILayoutOption[0]); return; } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Search", sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) }); itemSearch = GUILayout.TextField(itemSearch, sField, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space(12f); GUILayout.Label("Quality", sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) }); if (GUILayout.Button("-", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && itemQuality > 1) { itemQuality--; } GUILayout.Label(itemQuality.ToString(), sNum, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); if (GUILayout.Button("+", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { itemQuality++; } GUILayout.EndHorizontal(); scrollI = GUILayout.BeginScrollView(scrollI, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(470f) }); string text = itemSearch.Trim().ToLowerInvariant(); if (text.Length < 2) { GUILayout.Label("Type at least 2 letters to search all items.", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } else { foreach (KeyValuePair<GameObject, string> item in Items()) { if (item.Value.ToLowerInvariant().Contains(text) || ((Object)item.Key).name.ToLowerInvariant().Contains(text)) { SharedData shared = item.Key.GetComponent<ItemDrop>().m_itemData.m_shared; GUILayout.BeginHorizontal(sRow, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label(item.Value, sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); GUILayout.Label((shared.m_maxQuality > 1) ? ("q1-" + shared.m_maxQuality) : ((shared.m_maxStackSize > 1) ? ("stack " + shared.m_maxStackSize) : ""), sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("Give 1", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { Give(item.Key, stack: false); } if (shared.m_maxStackSize > 1 && GUILayout.Button("Stack", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { Give(item.Key, stack: true); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.Label("Quality applies to weapons, shields and armor; above an item's max it counts as forge levels.", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } private static void Draw(int id) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) if (GUI.Button(new Rect(((Rect)(ref win)).width - 40f, 6f, 30f, 26f), "X", sBtn)) { SetMenu(open: false); return; } DrawCharacter(); GUILayout.Space(8f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("Fight", (tab == 0) ? sOn : sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { tab = 0; } if (GUILayout.Button("Items", (tab == 1) ? sOn : sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { tab = 1; } if (GUILayout.Button("Kits", (tab == 2) ? sOn : sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { tab = 2; Kits.Reload(); } GUILayout.EndHorizontal(); if (tab == 1 || tab == 2) { if (tab == 1) { DrawItems(); } else { Kits.Draw(); } GUILayout.Space(6f); DrawFightButton(); GUI.DragWindow(); return; } GUILayout.Label("Add creatures", sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Search", sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) }); search = GUILayout.TextField(search, sField, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.EndHorizontal(); scrollA = GUILayout.BeginScrollView(scrollA, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(240f) }); string text = search.Trim().ToLowerInvariant(); foreach (KeyValuePair<string, string> kv in Catalog()) { if (text.Length > 0) { KeyValuePair<string, string> keyValuePair = kv; if (!keyValuePair.Value.ToLowerInvariant().Contains(text)) { KeyValuePair<string, string> keyValuePair2 = kv; if (!keyValuePair2.Key.ToLowerInvariant().Contains(text)) { continue; } } } GUILayout.BeginHorizontal(sRow, (GUILayoutOption[])(object)new GUILayoutOption[0]); KeyValuePair<string, string> keyValuePair3 = kv; GUILayout.Label(keyValuePair3.Value, sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); KeyValuePair<string, string> keyValuePair4 = kv; GUILayout.Label(keyValuePair4.Key, sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("Add", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })) { Entry entry = Setup.FirstOrDefault(delegate(Entry x) { string prefab = x.Prefab; KeyValuePair<string, string> keyValuePair7 = kv; return prefab == keyValuePair7.Key && x.Stars == 0; }); if (entry != null) { entry.Count++; SpawnOne(entry); } else { Entry entry2 = new Entry(); KeyValuePair<string, string> keyValuePair5 = kv; entry2.Prefab = keyValuePair5.Key; KeyValuePair<string, string> keyValuePair6 = kv; entry2.Label = keyValuePair6.Value; entry = entry2; Setup.Add(entry); SpawnOne(entry); } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Label("In the arena (frozen until Fight!)", sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); scrollB = GUILayout.BeginScrollView(scrollB, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(170f) }); if (Setup.Count == 0) { GUILayout.Label("Nothing yet: press Add on a creature above and it appears in front of you.", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } for (int num = 0; num < Setup.Count; num++) { Entry entry3 = Setup[num]; GUILayout.BeginHorizontal(sRow, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label(entry3.Label, sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }); GUILayout.Label("Stars", sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); for (int num2 = 0; num2 <= 2; num2++) { if (GUILayout.Button(num2.ToString(), (entry3.Stars == num2) ? sOn : sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }) && entry3.Stars != num2) { entry3.Stars = num2; SpawnEntry(entry3); } } GUILayout.Space(12f); GUILayout.Label("Count", sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) }); if (GUILayout.Button("-", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && entry3.Count > 1) { entry3.Count--; Character val = ((IEnumerable<Character>)entry3.Live).LastOrDefault((Func<Character, bool>)((Character c) => (Object)(object)c != (Object)null)); if ((Object)(object)val != (Object)null) { entry3.Live.Remove(val); Despawn(val); } } GUILayout.Label(entry3.Count.ToString(), sNum, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); if (GUILayout.Button("+", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && entry3.Count < 20) { entry3.Count++; SpawnOne(entry3); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(74f) })) { DespawnEntry(entry3); Setup.RemoveAt(num); num--; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Distance " + distance.ToString("0") + " m", sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); distance = Mathf.Round(GUILayout.HorizontalSlider(distance, 4f, 40f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("Respawn all", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { RespawnAll(); } if (GUILayout.Button("Remove all", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { foreach (Entry item in Setup) { DespawnEntry(item); } Setup.Clear(); Clear(); } if (GUILayout.Button("Heal me", sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { Player localPlayer = Player.m_localPlayer; ((Character)localPlayer).SetHealth(((Character)localPlayer).GetMaxHealth()); ((Character)localPlayer).AddStamina(((Character)localPlayer).GetMaxStamina()); } GUILayout.EndHorizontal(); GUILayout.Space(6f); DrawFightButton(); GUI.DragWindow(); } private static void DrawFightButton() { int num = AliveCount(); if (num > 0) { if (GUILayout.Button("Fight! (" + num + " creature" + ((num == 1) ? "" : "s") + ", 3 s countdown)", sOn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { StartFight(); } } else { GUILayout.Label("Add a creature to start a fight. X or F8 closes the menu.", sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] internal static class NoZoomInMenu { private static float Scroll() { if (!Trainer.MenuOpen) { return ZInput.GetMouseScrollWheel(); } return 0f; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code) { MethodInfo orig = AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null); MethodInfo mine = AccessTools.Method(typeof(NoZoomInMenu), "Scroll", (Type[])null, (Type[])null); foreach (CodeInstruction ins in code) { if ((ins.opcode == OpCodes.Call || ins.opcode == OpCodes.Callvirt) && object.Equals(ins.operand, orig)) { ins.operand = mine; } yield return ins; } } } [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] internal static class FreezeMonsters { private static bool Prefix(MonsterAI __instance, ref bool __result) { if (!Trainer.Frozen || !Trainer.Spawned.Contains((BaseAI)(object)__instance)) { return true; } ((BaseAI)__instance).StopMoving(); __result = false; return false; } } [HarmonyPatch(typeof(AnimalAI), "UpdateAI")] internal static class FreezeAnimals { private static bool Prefix(AnimalAI __instance, ref bool __result) { if (!Trainer.Frozen || !Trainer.Spawned.Contains((BaseAI)(object)__instance)) { return true; } ((BaseAI)__instance).StopMoving(); __result = false; return false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] internal static class Arrive { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { if (Plugin.Active) { Trainer.OnArrive(__instance); } else if (Trainer.IsTrainer(__instance)) { ((Character)__instance).Message((MessageType)2, "Trainer characters can only enter Combat Trainer Arena worlds", 0, (Sprite)null, false); Trainer.KickPending = true; } } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class RememberDeath { private static void Prefix(Player __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Active && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Trainer.DiedHere = true; Trainer.MenuOpen = false; Trainer.Frozen = false; DeathSpot.Pos = ((Component)__instance).transform.position; Trainer.RepairAll(__instance); } } } [HarmonyPatch(typeof(Player), "Load")] internal static class KeepExtraRows { private static void Prefix(Player __instance) { if (Plugin.Active) { ((Humanoid)__instance).GetInventory().SetHeight(9); } } private static void Postfix(Player __instance) { if (Plugin.Active) { string s = default(string); ((Humanoid)__instance).GetInventory().SetHeight((__instance.TryGetUniqueKeyValue("invrows", ref s) && int.TryParse(s, out var result)) ? Mathf.Clamp(result, 4, 9) : 4); } } } [HarmonyPatch] internal static class MuteGameKeys { private static IEnumerable<MethodBase> TargetMethods() { string[] names = new string[6] { "GetButton", "GetButtonDown", "GetButtonUp", "GetKey", "GetKeyDown", "GetKeyUp" }; return (from m in AccessTools.GetDeclaredMethods(typeof(ZInput)) where m.IsStatic && m.ReturnType == typeof(bool) && names.Contains(m.Name) select m).Cast<MethodBase>(); } private static void Postfix(ref bool __result) { if (Trainer.MenuOpen) { __result = false; } } } [HarmonyPatch(typeof(Character), "OnDeath")] internal static class RepairOnKill { private static void Postfix(Character __instance) { if (Plugin.Active && !(__instance is Player) && (Object)(object)Player.m_localPlayer != (Object)null) { Trainer.RepairAll(Player.m_localPlayer); } } } [HarmonyPatch(typeof(Player), "EatFood")] internal static class HealAfterEating { private static void Postfix(Player __instance, bool __result) { if (__result && Plugin.Active && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { Trainer.HealSoon(); } } } [HarmonyPatch(typeof(Game), "RequestRespawn")] internal static class QuickRespawn { private static void Prefix(ref float delay, bool afterDeath) { if (Plugin.Active && afterDeath) { delay = Mathf.Min(delay, 2f); } } } [HarmonyPatch(typeof(Game), "FindSpawnPoint")] internal static class DeathSpot { internal static Vector3? Pos; private static bool Prefix(ref bool __result, out Vector3 point, out bool usedLogoutPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; usedLogoutPoint = false; if (!Plugin.Active || !Pos.HasValue) { return true; } point = Pos.Value; float num = default(float); if (ZoneSystem.instance.GetGroundHeight(point, ref num) && point.y < num) { point.y = num; } point.y += 0.25f; usedLogoutPoint = true; Pos = null; __result = true; return false; } } [HarmonyPatch(typeof(Player), "CreateTombStone")] internal static class NoTombstone { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch(typeof(Skills), "OnDeath")] internal static class NoSkillLoss { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class BlockPlayerInput { private static void Postfix(ref bool __result) { if (Trainer.MenuOpen) { __result = false; } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class BlockControllerInput { private static void Postfix(ref bool __result) { if (Trainer.MenuOpen) { __result = false; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class FreeCursor { private static void Postfix() { if (Trainer.MenuOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } } [Serializable] public class KitItem { public string prefab; public int quality = 1; public int stack = 1; public int x; public int y; public bool equip; } [Serializable] public class Kit { public string name = "New kit"; public List<KitItem> items = new List<KitItem>(); } internal class KitEntry { public Kit Kit; public bool Preset; public bool Modified; public string File; public string Src; } internal static class Kits { private const int W = 8; private const int H = 6; private const string SkillsKey = "combattrainer_skills"; internal static ConfigEntry<bool> AuthorMode; private static List<KitEntry> entries = new List<KitEntry>(); private static string msg = ""; private static readonly string[] Healing = new string[10] { "MeadHealthMinor", "MeadHealthMedium", "MeadHealthMajor", "MeadHealthLingering", "MeadStaminaMinor", "MeadStaminaMedium", "MeadStaminaLingering", "MeadEitrMinor", "MeadEitrLingering", "MeadTasty" }; private static readonly string[] Resist = new string[3] { "BarleyWine", "MeadFrostResist", "MeadPoisonResist" }; private static readonly string[] Combat = new string[8] { "MeadBzerker", "MeadHasty", "MeadLightfoot", "MeadStrength", "MeadSwimmer", "MeadTrollPheromones", "MeadBugRepellent", "MeadTamer" }; private static KitEntry editing; private static Kit draft; private static int sel = -1; private static string slotSearch = ""; private static bool focusSearch; private static int dragFrom = -1; private static Vector2 dragStart; private static Sprite dragIcon; private static Vector2 scrollList; private static Vector2 scrollPick; private static string armDelete; private static string ModDir => Path.GetDirectoryName(typeof(Plugin).Assembly.Location); private static string PresetDir => Path.Combine(ModDir, "kits"); private static string Root => Path.Combine(Paths.ConfigPath, "CombatTrainer"); private static string EditDir => Path.Combine(Root, "kits-preset-edits"); private static string UserDir => Path.Combine(Root, "kits"); private static Kit Read(string path) { try { Kit kit = new Kit(); string[] array = File.ReadAllLines(path); foreach (string text in array) { if (text.StartsWith("name=")) { kit.name = text.Substring(5); } else if (text.StartsWith("item=")) { string[] array2 = text.Substring(5).Split('|'); if (array2.Length >= 6) { kit.items.Add(new KitItem { prefab = array2[0], quality = int.Parse(array2[1]), stack = int.Parse(array2[2]), x = int.Parse(array2[3]), y = int.Parse(array2[4]), equip = (array2[5] == "1") }); } } } return kit; } catch (Exception ex) { Debug.LogError((object)("[CombatTrainer] bad kit file " + path + ": " + ex.Message)); return null; } } private static void Write(string path, Kit k) { Directory.CreateDirectory(Path.GetDirectoryName(path)); List<string> list = new List<string>(); list.Add("name=" + k.name.Replace("\n", " ")); List<string> list2 = list; foreach (KitItem item in k.items) { list2.Add("item=" + item.prefab + "|" + item.quality + "|" + item.stack + "|" + item.x + "|" + item.y + "|" + (item.equip ? 1 : 0)); } File.WriteAllLines(path, list2.ToArray()); } internal static void Reload() { entries.Clear(); foreach (string item in from x in Directory.GetFiles(ModDir, "*.kit", SearchOption.AllDirectories) orderby Path.GetFileName(x) select x) { string fileName = Path.GetFileName(item); string text = Path.Combine(EditDir, fileName); bool flag = !AuthorMode.Value && File.Exists(text); Kit kit = Read(flag ? text : item); if (kit != null) { entries.Add(new KitEntry { Kit = kit, Preset = true, Modified = flag, File = fileName, Src = item }); } } if (!Directory.Exists(UserDir)) { return; } foreach (string item2 in from x in Directory.GetFiles(UserDir, "*.kit") orderby x select x) { Kit kit2 = Read(item2); if (kit2 != null) { entries.Add(new KitEntry { Kit = kit2, Preset = false, File = Path.GetFileName(item2) }); } } } private static string NewFileName(string name) { string text = new string((name ?? "kit").Where((char c) => char.IsLetterOrDigit(c) || c == '-' || c == '_' || c == ' ').ToArray()).Trim().Replace(' ', '-'); if (text.Length == 0) { text = "kit"; } return text + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".kit"; } private static void Save(KitEntry e, Kit k) { if (e.Preset) { Write(AuthorMode.Value ? e.Src : Path.Combine(EditDir, e.File), k); } else { Write(Path.Combine(UserDir, e.File), k); } } private static ItemData Make(string prefabName, int quality, int stack) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName); if ((Object)(object)itemPrefab == (Object)null) { return null; } ItemData val = itemPrefab.GetComponent<ItemDrop>().m_itemData.Clone(); val.m_dropPrefab = itemPrefab; if (val.m_shared.m_maxQuality > 1) { val.m_quality = Mathf.Max(1, quality); } val.m_stack = Mathf.Clamp(stack, 1, val.m_shared.m_maxStackSize); val.m_durability = val.GetMaxDurability(); return val; } private static void Use(Kit k) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Inventory inventory = ((Humanoid)localPlayer).GetInventory(); ((Humanoid)localPlayer).UnequipAllItems(); inventory.RemoveAll(); localPlayer.SetInventorySize(6); List<ItemData> list = new List<ItemData>(); int num = 0; foreach (KitItem item in k.items) { ItemData val = Make(item.prefab, item.quality, item.stack); if (val == null || !inventory.AddItem(val, new Vector2i(item.x, item.y))) { num++; } else if (item.equip) { list.Add(val); } } foreach (ItemData item2 in list) { ((Humanoid)localPlayer).EquipItem(item2, false); } List<ItemData> list2 = (from i in k.items orderby i.y, i.x select Make(i.prefab, 1, 1) into f where f != null && (f.m_shared.m_food > 0f || f.m_shared.m_foodStamina > 0f || f.m_shared.m_foodEitr > 0f) group f by ((Object)f.m_dropPrefab).name into g select g.First()).Take(3).ToList(); if (list2.Count > 0) { localPlayer.ClearFood(); foreach (ItemData item3 in list2) { localPlayer.EatFood(item3); } Trainer.LastFoods = list2.Select((ItemData f) => ((Object)f.m_dropPrefab).name).ToList(); } Trainer.HealSoon(); msg = "Using kit \"" + k.name + "\"." + ((num > 0) ? (" " + num + " item(s) couldn't be placed (unknown or blocked slot).") : "") + " Re-copy brings your own gear back."; } private static Kit FromInventory(Player p) { Kit kit = new Kit(); kit.name = "My kit " + DateTime.Now.ToString("MMM d HH:mm"); Kit kit2 = kit; foreach (ItemData allItem in ((Humanoid)p).GetInventory().GetAllItems()) { if (!((Object)(object)allItem.m_dropPrefab == (Object)null) && allItem.m_gridPos.y < 6) { kit2.items.Add(new KitItem { prefab = ((Object)allItem.m_dropPrefab).name, quality = allItem.m_quality, stack = allItem.m_stack, x = allItem.m_gridPos.x, y = allItem.m_gridPos.y, equip = allItem.m_equipped }); } } return kit2; } private static void Give(string prefabName, int stack) { ItemData val = Make(prefabName, 1, stack); if (val != null && !((Humanoid)Player.m_localPlayer).GetInventory().AddItem(val)) { msg = "Inventory full."; } } private static IEnumerable<Skill> AllSkills(Player p) { Skills sk = ((Character)p).GetSkills(); Traverse tr = Traverse.Create((object)sk); foreach (SkillDef def in sk.m_skills) { Skill s = null; try { s = tr.Method("GetSkill", new Type[1] { typeof(SkillType) }, new object[1] { def.m_skill }).GetValue<Skill>(); } catch { } if (s != null) { yield return s; } } } private static void SetSkills(Player p, float level) { foreach (Skill item in AllSkills(p)) { item.m_level = level; item.m_accumulator = 0f; } msg = "All skills set to " + level + "."; } internal static void RememberSkills(Player p) { p.m_customData["combattrainer_skills"] = string.Join(";", (from s in ((Character)p).GetSkills().GetSkillList() select (int)s.m_info.m_skill + "=" + s.m_level.ToString(CultureInfo.InvariantCulture)).ToArray()); } private static void RestoreSkills(Player p) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected I4, but got Unknown if (!p.m_customData.TryGetValue("combattrainer_skills", out var value)) { msg = "No imported skills stored yet: Re-copy your character once."; return; } Dictionary<int, float> dictionary = new Dictionary<int, float>(); string[] array = value.Split(';'); foreach (string text in array) { string[] array2 = text.Split('='); if (array2.Length == 2 && int.TryParse(array2[0], out var result) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { dictionary[result] = result2; } } foreach (Skill item in AllSkills(p)) { item.m_level = (dictionary.TryGetValue((int)item.m_info.m_skill, out var value2) ? value2 : 0f); item.m_accumulator = 0f; } msg = "Skills set back to your imported character's."; } internal static void Draw() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Trainer.IsTrainer(localPlayer)) { GUILayout.Label("Kits only work on trainer characters, so their gear can never leave the arena. Copy a character above first.", Trainer.sLbl, (GUILayoutOption[])(object)new GUILayoutOption[0]); return; } if (draft != null) { DrawEditor(); return; } GUILayout.Label("Kits (replace your whole inventory)", Trainer.sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); scrollList = GUILayout.BeginScrollView(scrollList, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(250f) }); if (entries.Count == 0) { GUILayout.Label("No kits yet. Make one below.", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } foreach (KitEntry item in entries.ToList()) { GUILayout.BeginHorizontal(Trainer.sRow, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label(item.Kit.name + " <size=12><color=#b4a990>" + ((!item.Preset) ? "yours" : (item.Modified ? "preset, edited" : "preset")) + " · " + item.Kit.items.Count + " items</color></size>", Trainer.sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("Use", Trainer.sOn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) })) { Use(item.Kit); } if (GUILayout.Button("Edit", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) })) { editing = item; draft = Clone(item.Kit); sel = -1; } if (item.Preset) { if (item.Modified && GUILayout.Button("Reset to Default", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { File.Delete(Path.Combine(EditDir, item.File)); Reload(); msg = "Reset \"" + item.Kit.name + "\" to the shipped version."; } if (!item.Modified) { GUILayout.Space(144f); } } else { bool flag = armDelete == item.File; if (GUILayout.Button(flag ? "Sure?" : "Delete", flag ? Trainer.sOn : Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { if (flag) { File.Delete(Path.Combine(UserDir, item.File)); armDelete = null; Reload(); } else { armDelete = item.File; } } if (AuthorMode.Value && GUILayout.Button("Ship with mod", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { Directory.CreateDirectory(PresetDir); File.Move(Path.Combine(UserDir, item.File), Path.Combine(PresetDir, item.File)); Reload(); } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("New empty kit", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { KitEntry kitEntry = new KitEntry(); kitEntry.Preset = false; kitEntry.File = null; editing = kitEntry; draft = new Kit(); sel = -1; } if (GUILayout.Button("Save my current inventory as a kit", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { KitEntry kitEntry2 = new KitEntry(); kitEntry2.Preset = false; kitEntry2.File = null; editing = kitEntry2; draft = FromInventory(localPlayer); sel = -1; } GUILayout.EndHorizontal(); GUILayout.Label("Meads (10 of each)", Trainer.sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("Health, stamina, eitr", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[0])) { string[] healing = Healing; foreach (string prefabName in healing) { Give(prefabName, 10); } } if (GUILayout.Button("Resistances", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[0])) { string[] resist = Resist; foreach (string prefabName2 in resist) { Give(prefabName2, 10); } } if (GUILayout.Button("Utility", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[0])) { string[] combat = Combat; foreach (string prefabName3 in combat) { Give(prefabName3, 10); } } if (GUILayout.Button("All", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[0])) { foreach (string item2 in Healing.Concat(Resist).Concat(Combat)) { Give(item2, 10); } } GUILayout.EndHorizontal(); GUILayout.Label("Skills", Trainer.sHead, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); int[] array = new int[4] { 25, 50, 75, 100 }; foreach (int num in array) { if (GUILayout.Button("All " + num, Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[0])) { SetSkills(localPlayer, num); } } if (GUILayout.Button("Use imported character skills", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) })) { RestoreSkills(localPlayer); } GUILayout.EndHorizontal(); if (msg.Length > 0) { GUILayout.Label(msg, Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } } private static bool IsArmor(ItemType 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 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((int)t != 6 && (int)t != 7 && (int)t != 11 && (int)t != 17 && (int)t != 18) { return (int)t == 24; } return true; } private static Kit Clone(Kit k) { Kit kit = new Kit(); kit.name = k.name; kit.items = k.items.Select((KitItem i) => new KitItem { prefab = i.prefab, quality = i.quality, stack = i.stack, x = i.x, y = i.y, equip = i.equip }).ToList(); return kit; } private static KitItem At(int x, int y) { return draft.items.FirstOrDefault((KitItem i) => i.x == x && i.y == y); } private static void DrawIcon(Rect r, Sprite s) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s == (Object)null)) { Texture2D texture = s.texture; Rect textureRect = s.textureRect; GUI.DrawTextureWithTexCoords(r, (Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height)); } } private static void DrawEditor() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Invalid comparison between Unknown and I4 //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Invalid comparison between Unknown and I4 //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Kit name", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); draft.name = GUILayout.TextField(draft.name, Trainer.sField, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.Label("Click a slot and type to fill it. Drag items to move or swap them. Gold border = equipped when the kit is used.", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(560f, 420f); Event current = Event.current; int num; if (dragFrom >= 0) { Vector2 val = current.mousePosition - dragStart; num = ((((Vector2)(ref val)).magnitude > 6f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; if ((int)current.type == 7 && !Input.GetMouseButton(0)) { dragFrom = -1; } if ((int)current.type == 1 && dragFrom >= 0) { int num2 = Mathf.FloorToInt((current.mousePosition.x - ((Rect)(ref rect)).x) / 70f); int num3 = Mathf.FloorToInt((current.mousePosition.y - ((Rect)(ref rect)).y) / 70f); int num4 = num3 * 8 + num2; if (flag && num2 >= 0 && num2 < 8 && num3 >= 0 && num3 < 6 && num4 != dragFrom) { KitItem kitItem = At(dragFrom % 8, dragFrom / 8); KitItem kitItem2 = At(num2, num3); if (kitItem2 != null) { kitItem2.x = dragFrom % 8; kitItem2.y = dragFrom / 8; } if (kitItem != null) { kitItem.x = num2; kitItem.y = num3; } sel = num4; focusSearch = true; } dragFrom = -1; } Rect val2 = default(Rect); for (int i = 0; i < 6; i++) { for (int j = 0; j < 8; j++) { ((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + (float)j * 70f, ((Rect)(ref rect)).y + (float)i * 70f, 66f, 66f); int num5 = i * 8 + j; KitItem kitItem3 = At(j, i); if ((int)current.type == 0 && current.button == 0 && kitItem3 != null && ((Rect)(ref val2)).Contains(current.mousePosition)) { dragFrom = num5; dragStart = current.mousePosition; } if (GUI.Button(val2, "", (num5 == sel) ? Trainer.sOn : Trainer.sBtn)) { sel = num5; slotSearch = ""; focusSearch = true; } if (kitItem3 != null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(kitItem3.prefab); ItemDrop val3 = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); bool flag2 = flag && num5 == dragFrom; if ((Object)(object)val3 != (Object)null) { Color color = GUI.color; if (flag2) { GUI.color = new Color(1f, 1f, 1f, 0.3f); } DrawIcon(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y + 6f, 50f, 50f), val3.m_itemData.GetIcon()); GUI.color = color; if (flag2 && (int)current.type == 7) { dragIcon = val3.m_itemData.GetIcon(); } } else { GUI.Label(val2, kitItem3.prefab, Trainer.sDim); } string text = (((Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_maxStackSize > 1) ? kitItem3.stack.ToString() : (((Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_maxQuality > 1) ? ("q" + kitItem3.quality) : "")); GUI.Label(new Rect(((Rect)(ref val2)).x + 4f, ((Rect)(ref val2)).y + 66f - 22f, 58f, 20f), text, Trainer.sNum); if (kitItem3.equip) { Color color2 = GUI.color; GUI.color = new Color(1f, 0.72f, 0.3f); GUI.Box(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, 66f, 3f), ""); GUI.Box(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + 66f - 3f, 66f, 3f), ""); GUI.color = color2; } } if (i == 0) { GUI.Label(new Rect(((Rect)(ref val2)).x + 3f, ((Rect)(ref val2)).y + 1f, 16f, 16f), (j + 1).ToString(), Trainer.sDim); } } } if (flag && (Object)(object)dragIcon != (Object)null) { DrawIcon(new Rect(current.mousePosition.x - 25f, current.mousePosition.y - 25f, 50f, 50f), dragIcon); } if (sel >= 0) { DrawSlot(sel % 8, sel / 8); } GUILayout.Space(6f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button("Save kit", Trainer.sOn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { if (editing.File == null) { editing.File = NewFileName(draft.name); } Save(editing, draft); draft = null; editing = null; Reload(); msg = "Saved."; } if (GUILayout.Button("Cancel", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { draft = null; editing = null; } GUILayout.EndHorizontal(); } private static void DrawSlot(int x, int y) { //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Invalid comparison between Unknown and I4 //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) KitItem kitItem = At(x, y); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Slot " + (x + 1) + "," + (y + 1) + ": ", Trainer.sHead, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }); if (kitItem != null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(kitItem.prefab); SharedData val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared : null); GUILayout.Label((val != null) ? Localization.instance.Localize(val.m_name) : kitItem.prefab, Trainer.sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); if (val != null && val.m_maxQuality > 1) { GUILayout.Label("Quality", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) }); if (GUILayout.Button("-", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && kitItem.quality > 1) { kitItem.quality--; } GUILayout.Label(kitItem.quality.ToString(), Trainer.sNum, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); if (GUILayout.Button("+", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { kitItem.quality++; } } if (val != null && val.m_maxStackSize > 1) { GUILayout.Label("Amount", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) }); if (GUILayout.Button("-", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && kitItem.stack > 1) { kitItem.stack--; } GUILayout.Label(kitItem.stack.ToString(), Trainer.sNum, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); if (GUILayout.Button("+", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }) && kitItem.stack < val.m_maxStackSize) { kitItem.stack++; } if (GUILayout.Button("Max", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) })) { kitItem.stack = val.m_maxStackSize; } } GUILayout.FlexibleSpace(); if (val != null && itemPrefab.GetComponent<ItemDrop>().m_itemData.IsEquipable() && GUILayout.Button(kitItem.equip ? "Equipped" : "Equip", kitItem.equip ? Trainer.sOn : Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(84f) })) { kitItem.equip = !kitItem.equip; } if (GUILayout.Button("Empty", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) })) { draft.items.Remove(kitItem); } } else { GUILayout.Label("empty", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label((kitItem == null) ? "Put in:" : "Replace:", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(62f) }); GUI.SetNextControlName("ct_slotsearch"); slotSearch = GUILayout.TextField(slotSearch, Trainer.sField, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.EndHorizontal(); if (focusSearch && (int)Event.current.type == 7) { GUI.FocusControl("ct_slotsearch"); focusSearch = false; } string q = slotSearch.Trim().ToLowerInvariant(); if (q.Length < 2) { GUILayout.Label("Type at least 2 letters to search all items.", Trainer.sDim, (GUILayoutOption[])(object)new GUILayoutOption[0]); return; } scrollPick = GUILayout.BeginScrollView(scrollPick, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) }); foreach (KeyValuePair<GameObject, string> item in (from k in Trainer.Items() where k.Value.ToLowerInvariant().Contains(q) || ((Object)k.Key).name.ToLowerInvariant().Contains(q) select k).Take(40)) { GUILayout.BeginHorizontal(Trainer.sRow, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label(item.Value, Trainer.sLbl, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("Put here", Trainer.sBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { if (kitItem != null) { draft.items.Remove(kitItem); } SharedData shared = item.Key.GetComponent<ItemDrop>().m_itemData.m_shared; draft.items.Add(new KitItem { prefab = ((Object)item.Key).name, x = x, y = y, quality = 1, stack = ((shared.m_maxStackSize <= 1) ? 1 : shared.m_maxStackSize), equip = IsArmor(shared.m_itemType) }); slotSearch = ""; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } }