Decompiled source of ChebsMercenaries v3.0.1
plugins/ChebsValheimLibrary.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using ChebsValheimLibrary.Common; using ChebsValheimLibrary.Items; using ChebsValheimLibrary.Items.Armor.BlackMetal; using ChebsValheimLibrary.Items.Armor.Bronze; using ChebsValheimLibrary.Items.Armor.Iron; using ChebsValheimLibrary.Items.Armor.Leather; using ChebsValheimLibrary.Items.Armor.Leather.Lox; using ChebsValheimLibrary.Items.Armor.Leather.Troll; using ChebsValheimLibrary.Items.Armor.Leather.Wolf; using ChebsValheimLibrary.Items.Armor.Mage; using ChebsValheimLibrary.Items.Tools; using ChebsValheimLibrary.Items.Weapons.BlackMetal; using ChebsValheimLibrary.Items.Weapons.Bows; using ChebsValheimLibrary.Items.Weapons.Bronze; using ChebsValheimLibrary.Items.Weapons.Iron; using ChebsValheimLibrary.Items.Weapons.Mage; using ChebsValheimLibrary.Items.Weapons.Needle; using ChebsValheimLibrary.Items.Weapons.Poison; using ChebsValheimLibrary.Items.Weapons.Wood; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using SimpleJson; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Joshua Paul Woods")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Public Domain")] [assembly: AssemblyDescription("A library which contains shared classes and things required by all my mods.")] [assembly: AssemblyFileVersion("2.6.2.0")] [assembly: AssemblyInformationalVersion("2.6.2.0+a24042c85ef3531a466a89c2e7aac3dcf5ac22ae")] [assembly: AssemblyProduct("ChebsValheimLibrary")] [assembly: AssemblyTitle("Cheb's Valheim Library")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/jpw1991/chebs-valheim-library")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.6.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ChebsValheimLibrary { public class Base { public static readonly Version CurrentVersion = new Version("2.6.2"); public static bool VersionCheck(Version version, out string message) { if (version.Major != CurrentVersion.Major) { message = "Major version difference detected! Please check your ChebsValheimLibrary.dll version! " + $"Mod expected {version}, but library version is {CurrentVersion}"; return false; } if (version.Minor != CurrentVersion.Minor) { message = "Minor version difference detected! Please check your ChebsValheimLibrary.dll version! " + $"Mod expected {version}, but library version is {CurrentVersion}"; return false; } if (version.Build < CurrentVersion.Build) { message = "Patch version difference detected. The mod expects an older ChebsValheimLibrary.dll version. This probably won't cause problems." + $"Mod expected {version}, but library version is {CurrentVersion}"; return false; } message = ""; return true; } public static GameObject LoadPrefabFromBundle(string prefabName, AssetBundle bundle, bool radeonFriendly) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown GameObject val = bundle.LoadAsset<GameObject>(prefabName); if ((Object)(object)val == (Object)null) { Logger.LogFatal((object)("LoadPrefabFromBundle: " + prefabName + " is null!")); } if (radeonFriendly) { ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Humanoid val2 = default(Humanoid); if (val.TryGetComponent<Humanoid>(ref val2)) { ((Character)val2).m_deathEffects = new EffectList(); val2.m_dropEffects = new EffectList(); val2.m_equipEffects = new EffectList(); val2.m_pickupEffects = new EffectList(); val2.m_consumeItemEffects = new EffectList(); ((Character)val2).m_hitEffects = new EffectList(); ((Character)val2).m_jumpEffects = new EffectList(); ((Character)val2).m_slideEffects = new EffectList(); val2.m_perfectBlockEffect = new EffectList(); ((Character)val2).m_tarEffects = new EffectList(); ((Character)val2).m_waterEffects = new EffectList(); ((Character)val2).m_flyingContinuousEffect = new EffectList(); } } return val; } public static void LoadMinionItems(AssetBundle bundle, bool radeonFriendly) { List<Item> list = new List<Item>(); list.Add(new SkeletonClub()); list.Add(new SkeletonBow()); list.Add(new SkeletonBow2()); list.Add(new SkeletonBow3()); list.Add(new SkeletonHelmetLeather()); list.Add(new SkeletonHelmetBronze()); list.Add(new SkeletonHelmetIron()); list.Add(new SkeletonFireballLevel1()); list.Add(new SkeletonFireballLevel2()); list.Add(new SkeletonFireballLevel3()); list.Add(new SkeletonMageCirclet()); list.Add(new SkeletonAxe()); list.Add(new BlackIronChest()); list.Add(new BlackIronHelmet()); list.Add(new BlackIronLegs()); list.Add(new SkeletonHelmetBlackIron()); list.Add(new SkeletonMace()); list.Add(new SkeletonMace2()); list.Add(new SkeletonMace3()); list.Add(new SkeletonHelmetIronPoison()); list.Add(new SkeletonHelmetBlackIronPoison()); list.Add(new SkeletonHelmetLeatherPoison()); list.Add(new SkeletonHelmetBronzePoison()); list.Add(new SkeletonWoodAxe()); list.Add(new SkeletonPickaxe()); list.Add(new SkeletonAxeBlackMetal()); list.Add(new SkeletonAxeBronze()); list.Add(new SkeletonMaceBlackMetal()); list.Add(new SkeletonMaceBronze()); list.Add(new SkeletonMaceIron()); list.Add(new SkeletonSwordBlackMetal()); list.Add(new SkeletonSwordBronze()); list.Add(new SkeletonSwordIron()); list.Add(new SkeletonBowFire()); list.Add(new SkeletonBowPoison()); list.Add(new SkeletonBowFrost()); list.Add(new SkeletonBowSilver()); list.Add(new SkeletonMaceNeedle()); list.Add(new HelmetLeatherTroll()); list.Add(new HelmetLeatherWolf()); list.Add(new HelmetLeatherLox()); list.Add(new SkeletonHelmetLeatherTroll()); list.Add(new SkeletonHelmetLeatherPoisonTroll()); list.Add(new SkeletonArmorLeatherChestTroll()); list.Add(new SkeletonArmorLeatherLegsTroll()); list.Add(new SkeletonHelmetLeatherWolf()); list.Add(new SkeletonHelmetLeatherPoisonWolf()); list.Add(new SkeletonArmorLeatherChestWolf()); list.Add(new SkeletonArmorLeatherLegsWolf()); list.Add(new SkeletonHelmetLeatherLox()); list.Add(new SkeletonHelmetLeatherPoisonLox()); list.Add(new SkeletonArmorLeatherChestLox()); list.Add(new SkeletonArmorLeatherLegsLox()); list.ForEach(delegate(Item minionItem) { if (ItemManager.Instance.GetItem(minionItem.ItemName) == null) { GameObject prefab = LoadPrefabFromBundle(minionItem.PrefabName, bundle, radeonFriendly); ItemManager.Instance.AddItem(minionItem.GetCustomItemFromPrefab(prefab)); } }); } } } namespace ChebsValheimLibrary.Structures { public class Structure : MonoBehaviour { public const float PlayerDetectionDistance = 150f; public static ChebsRecipe ChebsRecipeConfig; public static void UpdateRecipe() { } protected bool EnemiesNearby(out Character characterInRange, float radius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)this).transform.position, radius, list); using (IEnumerator<Character> enumerator = list.Where((Character character) => (Object)(object)character != (Object)null && (int)character.m_faction != 0 && !character.m_tamed).GetEnumerator()) { if (enumerator.MoveNext()) { Character current = enumerator.Current; characterInRange = current; return true; } } characterInRange = null; return false; } } } namespace ChebsValheimLibrary.PvP { public class PvPManager { [CompilerGenerated] private static class <>O { public static CoroutineHandler <0>__PvP_RPCServerReceive; public static CoroutineHandler <1>__PvP_RPCClientReceive; } public static bool HeavyLogging; private static CustomRPC _pvPrpc; private const string GetDictString = "CG_PvP_1"; private const string UpdateDictString = "CG_PvP_2"; private const string PvPrpcName = "PvPrpc"; private static Dictionary<string, List<string>> _playerFriends; private static string AllyFileName => ZNet.instance.GetWorldName() + ".ChebsValheimLibrary.PvP.json"; private static Dictionary<string, List<string>> PlayerFriends { get { if ((ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance)) && _playerFriends == null) { _playerFriends = new Dictionary<string, List<string>>(); _playerFriends = ReadAllyFile(); } return _playerFriends; } set { _playerFriends = value; } } public static void InitialFriendsListRequest() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (ZNetExtension.IsClientInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance)) { ZPackage val = new ZPackage(Encoding.UTF8.GetBytes("CG_PvP_1 " + Player.m_localPlayer.GetPlayerID())); _pvPrpc.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val); } } public static List<string> GetPlayerFriends() { if (PlayerFriends == null || !PlayerFriends.TryGetValue(Player.m_localPlayer.GetPlayerName(), out var value)) { return new List<string>(); } return value; } public static bool Friendly(string minionMasterA, string minionMasterB) { if (PlayerFriends != null && PlayerFriends.TryGetValue(minionMasterA, out var value)) { return value.Contains(minionMasterB); } return false; } public static void ConfigureRPC() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0035: 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_0040: Expected O, but got Unknown NetworkManager instance = NetworkManager.Instance; object obj = <>O.<0>__PvP_RPCServerReceive; if (obj == null) { CoroutineHandler val = PvP_RPCServerReceive; <>O.<0>__PvP_RPCServerReceive = val; obj = (object)val; } object obj2 = <>O.<1>__PvP_RPCClientReceive; if (obj2 == null) { CoroutineHandler val2 = PvP_RPCClientReceive; <>O.<1>__PvP_RPCClientReceive = val2; obj2 = (object)val2; } _pvPrpc = instance.AddRPC("PvPrpc", (CoroutineHandler)obj, (CoroutineHandler)obj2); } private static void UpdateAllyFile(string content) { string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AllyFileName); if (!File.Exists(text)) { try { using FileStream fileStream = File.Create(text); fileStream.Close(); } catch (Exception ex) { Logger.LogError((object)("Error creating " + text + ": " + ex.Message)); } } try { using StreamWriter streamWriter = new StreamWriter(text, append: false); streamWriter.Write(content); streamWriter.Close(); } catch (Exception ex2) { Logger.LogError((object)("Error writing to " + text + ": " + ex2.Message)); } } private static Dictionary<string, List<string>> ReadAllyFile() { string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AllyFileName); if (!File.Exists(text)) { try { using FileStream fileStream = File.Create(text); fileStream.Close(); } catch (Exception ex) { Logger.LogError((object)("Error creating " + text + ": " + ex.Message)); } } string text2 = null; try { using StreamReader streamReader = new StreamReader(text); text2 = streamReader.ReadToEnd(); streamReader.Close(); } catch (Exception ex2) { Logger.LogError((object)("Error reading from " + text + ": " + ex2.Message)); } if (text2 == null) { Logger.LogError((object)("Error reading " + text + ": content is null!")); return new Dictionary<string, List<string>>(); } if (!(text2 == "")) { return SimpleJson.DeserializeObject<Dictionary<string, List<string>>>(text2); } return new Dictionary<string, List<string>>(); } public static void UpdatePlayerFriendsDict(List<string> list, Player player = null) { UpdatePlayerFriendsDict(string.Join(",", list.Select((string s) => s.Trim())), player); } private static void UpdatePlayerFriendsDict(string list, Player player = null) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown if ((Object)(object)player == (Object)null) { player = Player.m_localPlayer; } if ((Object)(object)player == (Object)null) { Logger.LogWarning((object)"UpdatePlayerFriendsDict m_localPlayer is null"); return; } string s = "CG_PvP_2;" + player.GetPlayerName() + ";" + list; ZPackage val = new ZPackage(Encoding.UTF8.GetBytes(s)); _pvPrpc.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val); } private static IEnumerator PvP_RPCServerReceive(long sender, ZPackage package) { if ((Object)(object)ZNet.instance == (Object)null) { yield return null; } if (ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance)) { byte[] array = package.GetArray(); string @string = Encoding.UTF8.GetString(array); if (@string.StartsWith("CG_PvP_1")) { if (HeavyLogging) { Logger.LogInfo((object)"PvP_RPCServerReceive CG_PvP_1"); } string text = SimpleJson.SerializeObject((object)((IEnumerable<KeyValuePair<string, List<string>>>)PlayerFriends).ToDictionary((Func<KeyValuePair<string, List<string>>, string>)((KeyValuePair<string, List<string>> kvp) => kvp.Key), (Func<KeyValuePair<string, List<string>>, object>)((KeyValuePair<string, List<string>> kvp) => kvp.Value))); _pvPrpc.SendPackage(sender, new ZPackage(Encoding.UTF8.GetBytes("CG_PvP_1;" + text))); } else if (@string.StartsWith("CG_PvP_2")) { if (HeavyLogging) { Logger.LogInfo((object)"PvP_RPCServerReceive CG_PvP_2"); } string[] array2 = @string.Split(new char[1] { ';' }); if (array2.Length != 3) { Logger.LogError((object)$"Failed to parse payload ({array2.Length})"); } string key = array2[1]; string[] source = array2[2].Split(new char[1] { ',' }); PlayerFriends[key] = source.ToList(); string text2 = SimpleJson.SerializeObject((object)((IEnumerable<KeyValuePair<string, List<string>>>)PlayerFriends).ToDictionary((Func<KeyValuePair<string, List<string>>, string>)((KeyValuePair<string, List<string>> kvp) => kvp.Key), (Func<KeyValuePair<string, List<string>>, object>)((KeyValuePair<string, List<string>> kvp) => kvp.Value))); string text3 = "CG_PvP_1;" + text2; if (HeavyLogging) { Logger.LogMessage((object)("PvP_RPCServerReceive CG_PvP_2 sending to all peers: " + text3)); } _pvPrpc.SendPackage(ZNet.instance.m_peers, new ZPackage(Encoding.UTF8.GetBytes(text3))); UpdateAllyFile(text2); } } yield return null; } private static IEnumerator PvP_RPCClientReceive(long sender, ZPackage package) { byte[] array = package.GetArray(); if (array.Length != 0) { string @string = Encoding.UTF8.GetString(array); if (@string.StartsWith("CG_PvP_1")) { if (HeavyLogging) { Logger.LogInfo((object)("PvP_RPCClientReceive decoded: " + @string)); } string[] array2 = @string.Split(new char[1] { ';' }); if (array2.Length != 2) { Logger.LogError((object)$"Failed to parse payload ({array2.Length})"); } PlayerFriends = SimpleJson.DeserializeObject<Dictionary<string, List<string>>>(array2[1]); } } else if (HeavyLogging) { Logger.LogInfo((object)"PvP_RPCClientReceive received no data"); } yield return null; } } } namespace ChebsValheimLibrary.Minions { public class ChebGonazMinion : MonoBehaviour { public enum CleanupType { None, Time, Logout } public enum DropType { Nothing, JustResources, Everything } public enum State { Waiting, Roaming, Following } public enum ArmorType { None, Leather, LeatherTroll, LeatherWolf, LeatherLox, Bronze, Iron, BlackMetal } public bool canBeCommanded = true; public const string MinionOwnershipZdoKey = "UndeadMinionMaster"; public const string MinionDropsZdoKey = "UndeadMinionDrops"; public const string MinionWaitPosZdoKey = "UndeadMinionWaitPosition"; public const string MinionWaitObjectName = "UndeadMinionWaitPositionObject"; public int createdOrder; private static readonly int VehicleLayer = LayerMask.NameToLayer("vehicle"); private static List<Transform> _deathCrates = new List<Transform>(); public bool ItemsDropped { get; private set; } private Vector3 StatusRoaming => Vector3.negativeInfinity; private Vector3 StatusFollowing => Vector3.positiveInfinity; public string UndeadMinionMaster { get { ZNetView val = default(ZNetView); if (!((Component)this).TryGetComponent<ZNetView>(ref val)) { return ""; } return val.GetZDO().GetString("UndeadMinionMaster", ""); } set { ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { val.GetZDO().Set("UndeadMinionMaster", value); } else { Logger.LogError((object)("Cannot SetUndeadMinionMaster to " + value + " because it has no ZNetView component.")); } } } public State Status { get { //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_000a: 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) Vector3 waitPosition = GetWaitPosition(); if (((Vector3)(ref waitPosition)).Equals(StatusFollowing)) { return State.Following; } if (!((Vector3)(ref waitPosition)).Equals(StatusRoaming)) { return State.Waiting; } return State.Roaming; } } public bool DepositIntoNearbyDeathCrate(CharacterDrop characterDrop, float range = 15f) { _deathCrates.RemoveAll((Transform t) => (Object)(object)t == (Object)null); Container val = default(Container); foreach (Transform item in _deathCrates.OrderBy((Transform t) => Vector3.Distance(t.position, ((Component)this).transform.position) < range)) { if (characterDrop.m_drops.Count < 1) { break; } if (!((Component)item).TryGetComponent<Container>(ref val)) { continue; } Inventory inventory = val.GetInventory(); if (inventory == null) { continue; } List<Drop> list = new List<Drop>(); foreach (Drop drop in characterDrop.m_drops) { if (inventory.CanAddItem(drop.m_prefab, -1)) { inventory.AddItem(drop.m_prefab, drop.m_amountMax); } else { list.Add(drop); } } characterDrop.m_drops = list; } if (characterDrop.m_drops.Count < 1) { ItemsDropped = true; return ItemsDropped; } Container val2 = CreateDeathCrate(); if ((Object)(object)val2 != (Object)null) { Inventory inv = val2.GetInventory(); List<Drop> unsuccessful = new List<Drop>(); characterDrop.m_drops.ForEach(delegate(Drop drop) { if (!inv.AddItem(drop.m_prefab, drop.m_amountMax)) { unsuccessful.Add(drop); } }); characterDrop.m_drops = unsuccessful; ItemsDropped = unsuccessful.Count == 0; } return ItemsDropped; } private Container CreateDeathCrate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("CargoCrate"), ((Component)this).transform.position + Vector3.up, Quaternion.identity); _deathCrates.Add(val.transform); return val.GetComponent<Container>(); } public static ArmorType DetermineArmorType(Inventory inventory, int armorBlackIronRequired, int armorIronRequired, int armorBronzeRequired, int armorLeatherRequired) { if (inventory.CountItems("$item_blackmetal", -1, true) >= armorBlackIronRequired) { return ArmorType.BlackMetal; } if (inventory.CountItems("$item_iron", -1, true) >= armorIronRequired) { return ArmorType.Iron; } if (inventory.CountItems("$item_bronze", -1, true) >= armorBronzeRequired) { return ArmorType.Bronze; } if (inventory.CountItems("$item_trollhide", -1, true) >= armorLeatherRequired) { return ArmorType.LeatherTroll; } if (inventory.CountItems("$item_wolfpelt", -1, true) >= armorLeatherRequired) { return ArmorType.LeatherWolf; } if (inventory.CountItems("$item_loxpelt", -1, true) >= armorLeatherRequired) { return ArmorType.LeatherLox; } foreach (string item in new List<string> { "$item_leatherscraps", "$item_deerhide", "$item_scalehide" }) { if (inventory.CountItems(item, -1, true) >= armorLeatherRequired) { return ArmorType.Leather; } } return ArmorType.None; } public static bool CanSpawn(MemoryConfigEntry<string, List<string>> itemsCost, Inventory inventory, out string message) { return CanSpawn(itemsCost.Value, inventory, out message); } public static bool CanSpawn(string itemsCost, Inventory inventory, out string message) { return CanSpawn(itemsCost?.Split(new char[1] { ',' }).ToList(), inventory, out message); } public static bool CanSpawn(List<string> itemsCost, Inventory inventory, out string message) { message = ""; List<Tuple<bool, string>> list = new List<Tuple<bool, string>>(); foreach (string item2 in itemsCost) { string[] array = item2.Split(new char[1] { ':' }); if (array.Length != 2) { message = "[1] Error in config for ItemsCost - please revise: (" + item2 + ")"; Logger.LogError((object)message); return false; } string item = array[0]; if (!int.TryParse(array[1], out var result)) { message = "[2] Error in config for ItemsCost - please revise: (" + item2 + ")"; Logger.LogError((object)message); return false; } Tuple<int, string, List<string>> tuple = CountItems(item, inventory); bool flag = tuple.Item1 >= result; message = (flag ? "" : ("Not enough " + string.Join("/", tuple.Item3))); list.Add(new Tuple<bool, string>(flag, message)); } Tuple<bool, string> tuple2 = list.Find((Tuple<bool, string> t) => !t.Item1); if (tuple2 != null) { message = tuple2.Item2; return false; } return true; } public static void ConsumeRequirements(MemoryConfigEntry<string, List<string>> itemsCost, Inventory inventory) { ConsumeRequirements(itemsCost.Value, inventory); } public static void ConsumeRequirements(string itemsCost, Inventory inventory) { ConsumeRequirements(itemsCost?.Split(new char[1] { ',' }).ToList(), inventory); } protected static void ConsumeRequirements(List<string> itemsCost, Inventory inventory) { foreach (string item in itemsCost) { string[] array = item.Split(new char[1] { ':' }); if (array.Length != 2) { Logger.LogError((object)"Error in config for ItemsCost - please revise."); break; } string text = array[0]; if (!int.TryParse(array[1], out var result)) { Logger.LogError((object)"Error in config for ItemsCost - please revise."); break; } int num = 0; string[] array2 = text.Split(new char[1] { '|' }); foreach (string text2 in array2) { if (num >= result) { break; } GameObject prefab = ZNetScene.instance.GetPrefab(text2); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)("Error processing config for ItemsCost: " + text + " doesn't exist.")); return; } string text3 = prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name; int num2 = inventory.CountItems(text3, -1, true); for (int j = 0; j < num2; j++) { if (num >= result) { break; } inventory.RemoveItem(text3, 1, -1, true); num++; } } } } protected static void GenerateDeathDrops(CharacterDrop characterDrop, MemoryConfigEntry<string, List<string>> itemsCost) { List<string> value = itemsCost.Value; GenerateDeathDrops(characterDrop, value); } protected static void GenerateDeathDrops(CharacterDrop characterDrop, string itemsCost) { List<string> itemsCost2 = itemsCost?.Split(new char[1] { ',' }).ToList(); GenerateDeathDrops(characterDrop, itemsCost2); } protected static void GenerateDeathDrops(CharacterDrop characterDrop, List<string> itemsCost) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown foreach (string item in itemsCost) { string[] array = item.Split(new char[1] { ':' }); if (array.Length != 2) { Logger.LogError((object)"Error in config for ItemsCost - please revise."); break; } string text = array[0]; if (!int.TryParse(array[1], out var result)) { Logger.LogError((object)"Error in config for ItemsCost - please revise."); break; } string[] array2 = text.Split(new char[1] { '|' }); int num = 0; if (num < array2.Length) { string text2 = array2[num]; GameObject prefab = ZNetScene.instance.GetPrefab(text2); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)("Error processing config for ItemsCost: " + text2 + " doesn't exist.")); break; } characterDrop.m_drops.Add(new Drop { m_prefab = prefab, m_onePerPlayer = false, m_amountMin = result, m_amountMax = result, m_chance = 1f }); } } } private static Tuple<int, string, List<string>> CountItems(string item, Inventory inventory) { int num = 0; List<string> list = new List<string>(); string[] array = item.Split(new char[1] { '|' }); foreach (string text in array) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { string text2 = "Error processing config for ItemsCost: " + text + " doesn't exist."; Logger.LogError((object)text2); return new Tuple<int, string, List<string>>(0, text2, list); } string text3 = prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name; list.Add(text3); int num2 = inventory.CountItems(text3, -1, true); num += num2; } return new Tuple<int, string, List<string>>(num, "", list); } private void OnCollisionEnter(Collision collision) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Character component = collision.gameObject.GetComponent<Character>(); if ((Object)(object)component != (Object)null && (int)component.m_faction == 0 && (Object)(object)((Component)component).GetComponent<ChebGonazMinion>() == (Object)null) { Physics.IgnoreCollision(collision.collider, ((Component)this).GetComponent<Collider>()); } else if ((Object)(object)collision.gameObject.GetComponentInParent<Vagon>() != (Object)null) { Physics.IgnoreCollision(collision.collider, ((Component)this).GetComponent<Collider>()); } } public void Kill() { Character val = default(Character); if (((Component)this).TryGetComponent<Character>(ref val)) { if (!val.IsDead()) { val.SetHealth(0f); } } else { Logger.LogError((object)("Cannot kill " + ((Object)this).name + " because it has no Character component.")); } } public bool BelongsToPlayer(string playerName) { ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { return val.GetZDO().GetString("UndeadMinionMaster", "").ToLower() .Trim() .Equals(playerName.ToLower().Trim()); } return false; } public void RecordDrops(CharacterDrop characterDrop) { ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { string text = ""; List<string> drops = new List<string>(); characterDrop.m_drops.ForEach(delegate(Drop drop) { drops.Add($"{((Object)drop.m_prefab).name}:{drop.m_amountMax}"); }); text = string.Join(",", drops); val.GetZDO().Set("UndeadMinionDrops", string.Join(",", text)); } else { Logger.LogError((object)("Cannot record drops because " + ((Object)this).name + " has no ZNetView component.")); } } public void RestoreDrops() { ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { CharacterDrop characterDrop = ((Component)this).gameObject.GetComponent<CharacterDrop>(); if ((Object)(object)characterDrop == (Object)null) { characterDrop = ((Component)this).gameObject.AddComponent<CharacterDrop>(); } string @string = val.GetZDO().GetString("UndeadMinionDrops", ""); if (!(@string == "")) { new List<string>(@string.Split(new char[1] { ',' })).ForEach(delegate(string dropString) { string[] array = dropString.Split(new char[1] { ':' }); string prefabName = array[0]; int amount = int.Parse(array[1]); AddOrUpdateDrop(characterDrop, prefabName, amount); }); } } else { Logger.LogError((object)("Cannot record drops because " + ((Object)this).name + " has no ZNetView component.")); } } protected void RecordWaitPosition(Vector3 waitPos) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { if (!val.IsOwner()) { val.ClaimOwnership(); } val.GetZDO().Set("UndeadMinionWaitPosition", waitPos); } else { Logger.LogError((object)$"Cannot RecordWaitPosition {waitPos} because it has no ZNetView component."); } } protected Vector3 GetWaitPosition() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) ZNetView val = default(ZNetView); if (((Component)this).TryGetComponent<ZNetView>(ref val)) { return val.GetZDO().GetVec3("UndeadMinionWaitPosition", StatusRoaming); } Logger.LogError((object)"Cannot GetWaitPosition because it has no ZNetView component."); return StatusRoaming; } public void RoamFollowOrWait() { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) //IL_00a0: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 waitPosition = GetWaitPosition(); MonsterAI val2 = default(MonsterAI); if (((Vector3)(ref waitPosition)).Equals(StatusFollowing)) { Player val = Player.GetAllPlayers().Find((Player p) => BelongsToPlayer(p.GetPlayerName())); if ((Object)(object)val == (Object)null) { Logger.LogError((object)(((Object)this).name + " should be following but has no associated player. Roaming instead.")); Roam(); } else { Follow(((Component)val).gameObject); } } else if (((Vector3)(ref waitPosition)).Equals(StatusRoaming)) { Roam(); } else if (!((Component)this).TryGetComponent<MonsterAI>(ref val2)) { Logger.LogError((object)(((Object)this).name + " cannot WaitAtRecordedPosition because it has no MonsterAI component.")); } else { GameObject val3 = new GameObject("UndeadMinionWaitPositionObject"); val3.transform.position = waitPosition; val2.SetFollowTarget(val3); } } public void Follow(GameObject followObject) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) MonsterAI val = default(MonsterAI); if (!((Component)this).TryGetComponent<MonsterAI>(ref val)) { Logger.LogError((object)"Cannot Follow because it has no MonsterAI component."); return; } GameObject followTarget = val.GetFollowTarget(); if ((Object)(object)followTarget != (Object)null && ((Object)followTarget).name == "UndeadMinionWaitPositionObject") { Object.Destroy((Object)(object)followTarget); } RecordWaitPosition(StatusFollowing); val.SetFollowTarget(followObject); } public void Wait(Vector3 waitPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RecordWaitPosition(waitPosition); RoamFollowOrWait(); } public void Roam() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) RecordWaitPosition(StatusRoaming); MonsterAI val = default(MonsterAI); if (!((Component)this).TryGetComponent<MonsterAI>(ref val)) { Logger.LogError((object)("Cannot Roam because " + ((Object)this).name + " has no MonsterAI component!")); return; } GameObject followTarget = val.GetFollowTarget(); if ((Object)(object)followTarget != (Object)null && ((Object)followTarget).name == "UndeadMinionWaitPositionObject") { Object.Destroy((Object)(object)followTarget); } val.SetFollowTarget((GameObject)null); } public static T FindClosest<T>(Transform targetTransform, float radius, int mask, Func<T, bool> where, bool interactable) where T : Component { //IL_001b: Unknown result type (might be due to invalid IL or missing references) ZNetView val = default(ZNetView); return (from t in (from c in Physics.OverlapSphere(targetTransform.position, radius, mask) where (Object)(object)((Component)c).GetComponentInParent<T>() != (Object)null select ((Component)c).GetComponentInParent<T>() into c where !interactable || (((Component)c).TryGetComponent<ZNetView>(ref val) && val.IsValid()) select c).Where(@where) orderby Vector3.Distance(((Component)t).transform.position, targetTransform.position) select t).FirstOrDefault(); } public static List<T> FindNearby<T>(Transform targetTransform, float radius, int mask, Func<T, bool> where, bool interactable) where T : Component { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ZNetView val = default(ZNetView); return (from c in Physics.OverlapSphere(targetTransform.position, radius, mask) where (Object)(object)((Component)c).GetComponentInParent<T>() != (Object)null select ((Component)c).GetComponentInParent<T>() into c where !interactable || (((Component)c).TryGetComponent<ZNetView>(ref val) && val.IsValid()) select c).Where(where).ToList(); } public static void AddOrUpdateDrop(CharacterDrop characterDrop, string prefabName, int amount) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_006a: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown Drop val = ((IEnumerable<Drop>)characterDrop.m_drops).FirstOrDefault((Func<Drop, bool>)((Drop drop) => ((Object)drop.m_prefab).name.Equals(prefabName))); if (val != null) { val.m_amountMin = amount; val.m_amountMax = amount; val.m_chance = 1f; return; } characterDrop.m_drops.Add(new Drop { m_prefab = ZNetScene.instance.GetPrefab(prefabName), m_onePerPlayer = true, m_amountMin = amount, m_amountMax = amount, m_chance = 1f }); } public virtual void Awake() { } } public class FreshMinion : MonoBehaviour { } public class NukeRock : NukeTree { protected override void Nuke() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_008e: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) Destructible componentInParent = ((Component)this).GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent != (Object)null) { HitData val = new HitData(); val.m_damage.m_pickaxe = 500f; val.m_toolTier = 100; componentInParent.Damage(val); return; } MineRock5 componentInParent2 = ((Component)this).GetComponentInParent<MineRock5>(); Bounds bounds; if ((Object)(object)componentInParent2 != (Object)null) { for (int i = 0; i < componentInParent2.m_hitAreas.Count; i++) { HitArea val2 = componentInParent2.m_hitAreas[i]; if (val2.m_health > 0f) { HitData val3 = new HitData(); val3.m_damage.m_damage = val2.m_health; bounds = val2.m_collider.bounds; val3.m_point = ((Bounds)(ref bounds)).center; val3.m_toolTier = 100; componentInParent2.DamageArea(i, val3); } } return; } MineRock componentInParent3 = ((Component)this).GetComponentInParent<MineRock>(); if (!((Object)(object)componentInParent3 != (Object)null)) { return; } HitArea val5 = default(HitArea); for (int j = 0; j < componentInParent3.m_hitAreas.Length; j++) { Collider val4 = componentInParent3.m_hitAreas[j]; if (((Component)val4).TryGetComponent<HitArea>(ref val5) && val5.m_health > 0f) { HitData val6 = new HitData(); val6.m_damage.m_damage = val5.m_health; bounds = val4.bounds; val6.m_point = ((Bounds)(ref bounds)).center; val6.m_toolTier = 100; componentInParent2.DamageArea(j, val6); } } } } public class NukeTree : MonoBehaviour { public const float NukeAfter = 120f; private IEnumerator Start() { yield return (object)new WaitForSeconds(120f); Nuke(); Object.Destroy((Object)(object)this); } protected virtual void Nuke() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 HitData val = new HitData(); val.m_damage.m_chop = 999f; val.m_toolTier = 4; Destructible componentInParent = ((Component)this).GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2) { componentInParent.Damage(val); return; } TreeLog componentInParent2 = ((Component)this).GetComponentInParent<TreeLog>(); if ((Object)(object)componentInParent2 != (Object)null) { componentInParent2.Damage(val); return; } TreeBase componentInParent3 = ((Component)this).GetComponentInParent<TreeBase>(); if ((Object)(object)componentInParent3 != (Object)null) { componentInParent3.Damage(val); } } } } namespace ChebsValheimLibrary.Minions.AI { public class MinerAI : MonoBehaviour { private float _nextCheck; private float _lastChat; private MonsterAI _monsterAI; private Humanoid _humanoid; private List<string> _rocksList; private string _status; private bool _inContact; public virtual string RockInternalIDsList => ""; public virtual float RoamRange => 0f; public virtual float LookRadius => 0f; public virtual float UpdateDelay => 0f; public virtual float ToolDamage => 6f; public virtual short ToolTier => 2; public virtual float ChatInterval => 5f; public virtual float ChatDistance => 5f; public string Status { get { return _status; } protected set { _status = value; } } public void LookForMineableObjects() { if ((Object)(object)_monsterAI.GetFollowTarget() != (Object)null) { return; } int mask = (1 << LayerMask.NameToLayer("static_solid")) | (1 << LayerMask.NameToLayer("Default_small")); Transform val = (from c in ChebGonazMinion.FindNearby<Transform>(((Component)this).transform, LookRadius, mask, (Func<Transform, bool>)Hittable, interactable: false) select (c, (((Object)c).name.Contains("_Tin") || ((Object)c).name.Contains("silver") || ((Object)c).name.Contains("copper")) ? 1 : 2) into t orderby t.Item2, Vector3.Distance(((Component)this).transform.position, t.c.position) select t).FirstOrDefault().ToTuple()?.Item1; if ((Object)(object)val != (Object)null) { _monsterAI.SetFollowTarget(((Component)val).gameObject); NukeRock nukeRock = default(NukeRock); if (!((Component)val).TryGetComponent<NukeRock>(ref nukeRock)) { ((Component)val).gameObject.AddComponent<NukeRock>(); } } } public void UpdateToolProperties() { GameObject[] randomWeapon = _humanoid.m_randomWeapon; object obj; if (randomWeapon == null) { obj = null; } else { GameObject? obj2 = randomWeapon.FirstOrDefault(); obj = ((obj2 != null) ? obj2.GetComponent<ItemDrop>() : null); } ItemDrop val = (ItemDrop)obj; if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Failed to update tool properties: tool is null"); return; } val.m_itemData.m_shared.m_damages.m_pickaxe = ToolDamage; val.m_itemData.m_shared.m_toolTier = ToolTier; } protected virtual void Awake() { _rocksList = RockInternalIDsList.Split(new char[1] { ',' }).ToList(); _monsterAI = ((Component)this).GetComponent<MonsterAI>(); _humanoid = ((Component)this).GetComponent<Humanoid>(); _monsterAI.m_alertRange = 1f; ((BaseAI)_monsterAI).m_randomMoveRange = RoamRange; UpdateToolProperties(); } protected virtual void FixedUpdate() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) GameObject followTarget = _monsterAI.GetFollowTarget(); if ((Object)(object)followTarget != (Object)null) { Player val = default(Player); if (followTarget.TryGetComponent<Player>(ref val)) { string text = LocalizationManager.Instance.TryTranslate("$chebgonaz_minionstatus_following"); _status = text + " " + val.GetPlayerName(); return; } if (ChatInterval != 0f && Time.time > _lastChat + ChatInterval) { _lastChat = Time.time; List<Player> list = new List<Player>(); Player.GetPlayersInRange(((Component)this).transform.position, ChatDistance, list); if (list.Count > 0) { string text2 = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target"); Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 10f, "", text2 + ": " + ((Object)followTarget.gameObject).name, false); } } Vector3 position = followTarget.transform.position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position.x, ((Component)this).transform.position.y, position.z); ((Component)this).transform.LookAt(val2); TryAttack(); } if (Time.time > _nextCheck) { _nextCheck = Time.time + UpdateDelay + Random.value; LookForMineableObjects(); _status = (((Object)(object)_monsterAI.GetFollowTarget() != (Object)null) ? (LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target") + ": (" + ((Object)_monsterAI.GetFollowTarget()).name + ").") : LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_cantfindtarget")); ((Character)_humanoid).m_name = _status; } } private void TryAttack() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_017f: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) GameObject followTarget = _monsterAI.GetFollowTarget(); if (!((Object)(object)followTarget != (Object)null) || !_inContact || !_monsterAI.DoAttack((Character)null, false)) { return; } Destructible componentInParent = followTarget.GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.m_minToolTier <= ToolTier) { HitData val = new HitData(); val.m_damage.m_pickaxe = ToolDamage; val.m_toolTier = ToolTier; componentInParent.Damage(val); return; } MineRock5 componentInParent2 = followTarget.GetComponentInParent<MineRock5>(); Bounds bounds; if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.m_minToolTier <= ToolTier) { for (int i = 0; i < componentInParent2.m_hitAreas.Count; i++) { HitArea val2 = componentInParent2.m_hitAreas[i]; if (val2.m_health > 0f) { HitData val3 = new HitData(); val3.m_damage.m_damage = ToolDamage; bounds = val2.m_collider.bounds; val3.m_point = ((Bounds)(ref bounds)).center; val3.m_toolTier = ToolTier; componentInParent2.DamageArea(i, val3); } } return; } MineRock componentInParent3 = followTarget.GetComponentInParent<MineRock>(); if (!((Object)(object)componentInParent3 != (Object)null) || componentInParent3.m_minToolTier > ToolTier) { return; } HitArea val5 = default(HitArea); for (int j = 0; j < componentInParent3.m_hitAreas.Length; j++) { Collider val4 = componentInParent3.m_hitAreas[j]; if (((Component)val4).TryGetComponent<HitArea>(ref val5) && val5.m_health > 0f) { HitData val6 = new HitData(); val6.m_damage.m_damage = ToolDamage; bounds = val4.bounds; val6.m_point = ((Bounds)(ref bounds)).center; val6.m_toolTier = ToolTier; componentInParent2.DamageArea(j, val6); } } } private void OnCollisionEnter(Collision collision) { _inContact = Hittable((collision != null) ? collision.gameObject : null); } private void OnCollisionExit(Collision other) { _inContact = Hittable((other != null) ? other.gameObject : null); } private bool Hittable(Transform t) { return Hittable(((Component)t).gameObject); } private bool Hittable(GameObject go) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 if ((Object)(object)go == (Object)null) { return false; } Destructible componentInParent = go.GetComponentInParent<Destructible>(); if (_rocksList.FirstOrDefault(delegate(string rocksListName) { Transform parent = go.transform.parent; return (Object)(object)parent != (Object)null && rocksListName.Contains(((Object)parent).name); }) == null && (!((Object)(object)componentInParent != (Object)null) || (int)componentInParent.m_destructibleType != 1 || !((Object)(object)((Component)componentInParent).GetComponent<Container>() == (Object)null) || !((Object)(object)((Component)componentInParent).GetComponent<Pickable>() == (Object)null)) && !((Object)(object)go.GetComponentInParent<MineRock5>() != (Object)null)) { return (Object)(object)go.GetComponentInParent<MineRock>() != (Object)null; } return true; } } public class WoodcutterAI : MonoBehaviour { private float _nextCheck; private float _lastChat; private MonsterAI _monsterAI; private Humanoid _humanoid; private readonly int _defaultMask = LayerMask.GetMask(new string[1] { "Default" }); private static List<Transform> _transforms = new List<Transform>(); private string _status; private bool _inContact; private bool _chopping; public virtual float RoamRange => 0f; public virtual float LookRadius => 0f; public virtual float UpdateDelay => 0f; public virtual float ToolDamage => 6f; public virtual short ToolTier => 2; public virtual float ChatInterval => 5f; public virtual float ChatDistance => 5f; public string Status { get { return _status; } protected set { _status = value; } } public void LookForCuttableObjects() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Invalid comparison between Unknown and I4 if ((Object)(object)_monsterAI.GetFollowTarget() != (Object)null) { return; } _transforms.RemoveAll((Transform a) => (Object)(object)a == (Object)null); Transform val = ChebGonazMinion.FindClosest<Transform>(((Component)this).transform, LookRadius, _defaultMask, (Func<Transform, bool>)((Transform a) => !_transforms.Contains(a)), interactable: false); if ((Object)(object)val == (Object)null) { val = (from t in _transforms.Where(delegate(Transform t) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 Destructible componentInParent4 = ((Component)t).GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent4 != (Object)null && (int)componentInParent4.GetDestructibleType() == 2 && componentInParent4.m_minToolTier <= ToolTier) { return true; } TreeLog componentInParent5 = ((Component)t).GetComponentInParent<TreeLog>(); if ((Object)(object)componentInParent5 != (Object)null && componentInParent5.m_minToolTier <= ToolTier) { return true; } TreeBase componentInParent6 = ((Component)t).GetComponentInParent<TreeBase>(); return ((Object)(object)componentInParent6 != (Object)null && componentInParent6.m_minToolTier <= ToolTier) ? true : false; }) orderby Vector3.Distance(t.position, ((Component)this).transform.position) select t).FirstOrDefault(); } if (!((Object)(object)val != (Object)null)) { return; } Destructible componentInParent = ((Component)val).GetComponentInParent<Destructible>(); NukeTree nukeTree = default(NukeTree); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2) { _transforms.Add(val); _monsterAI.SetFollowTarget(((Component)componentInParent).gameObject); _status = "Moving to stump."; if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree)) { ((Component)val).gameObject.AddComponent<NukeTree>(); } return; } TreeLog componentInParent2 = ((Component)val).GetComponentInParent<TreeLog>(); if ((Object)(object)componentInParent2 != (Object)null) { _transforms.Add(val); _monsterAI.SetFollowTarget(((Component)componentInParent2).gameObject); _status = "Moving to log."; if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree)) { ((Component)val).gameObject.AddComponent<NukeTree>(); } return; } TreeBase componentInParent3 = ((Component)val).GetComponentInParent<TreeBase>(); if ((Object)(object)componentInParent3 != (Object)null) { _transforms.Add(val); _monsterAI.SetFollowTarget(((Component)componentInParent3).gameObject); _status = "Moving to tree."; if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree)) { ((Component)val).gameObject.AddComponent<NukeTree>(); } } } public void UpdateToolProperties() { GameObject[] randomWeapon = _humanoid.m_randomWeapon; object obj; if (randomWeapon == null) { obj = null; } else { GameObject? obj2 = randomWeapon.FirstOrDefault(); obj = ((obj2 != null) ? obj2.GetComponent<ItemDrop>() : null); } ItemDrop val = (ItemDrop)obj; if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Failed to update tool properties: tool is null"); return; } val.m_itemData.m_shared.m_damages.m_chop = ToolDamage; val.m_itemData.m_shared.m_toolTier = ToolTier; } protected virtual void Awake() { _monsterAI = ((Component)this).GetComponent<MonsterAI>(); _humanoid = ((Component)this).GetComponent<Humanoid>(); _monsterAI.m_alertRange = 1f; ((BaseAI)_monsterAI).m_randomMoveRange = RoamRange; UpdateToolProperties(); } protected virtual void FixedUpdate() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) GameObject followTarget = _monsterAI.GetFollowTarget(); if ((Object)(object)followTarget != (Object)null) { Player val = default(Player); if (followTarget.TryGetComponent<Player>(ref val)) { string text = LocalizationManager.Instance.TryTranslate("$chebgonaz_minionstatus_following"); _status = text + " " + val.GetPlayerName(); return; } if (ChatInterval != 0f && Time.time > _lastChat + ChatInterval) { _lastChat = Time.time; List<Player> list = new List<Player>(); Player.GetPlayersInRange(((Component)this).transform.position, ChatDistance, list); if (list.Count > 0) { string text2 = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target"); Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 10f, "", text2 + ": " + ((Object)followTarget.gameObject).name, false); } } Vector3 position = followTarget.transform.position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position.x, ((Component)this).transform.position.y, position.z); ((Component)this).transform.LookAt(val2); TryAttack(val2); } if (Time.time > _nextCheck) { _nextCheck = Time.time + UpdateDelay + Random.value; LookForCuttableObjects(); if ((Object)(object)_monsterAI.GetFollowTarget() == (Object)null) { _status = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_cantfindtarget"); } ((Character)_humanoid).m_name = _status; } } private void TryAttack(Vector3 lookAtPos) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 if ((Object)(object)_humanoid == (Object)null || (Object)(object)_monsterAI == (Object)null || _chopping) { return; } GameObject followTarget = _monsterAI.GetFollowTarget(); if (!((Object)(object)followTarget != (Object)null) || (!_inContact && !(Vector3.Distance(lookAtPos, ((Component)this).transform.position) < 1.5f))) { return; } Destructible destructible = followTarget.GetComponentInParent<Destructible>(); if ((Object)(object)destructible != (Object)null && (int)destructible.GetDestructibleType() == 2) { ((MonoBehaviour)this).StartCoroutine(Chop(destructible.m_health, (IDestructible)(object)destructible, () => destructible.m_health)); return; } TreeLog treeLog = followTarget.GetComponentInParent<TreeLog>(); if ((Object)(object)treeLog != (Object)null) { ((MonoBehaviour)this).StartCoroutine(Chop(treeLog.m_health, (IDestructible)(object)treeLog, () => treeLog.m_health)); return; } TreeBase tree = followTarget.GetComponentInParent<TreeBase>(); if ((Object)(object)tree != (Object)null) { ((MonoBehaviour)this).StartCoroutine(Chop(tree.m_health, (IDestructible)(object)treeLog, () => tree.m_health)); } } private IEnumerator Chop(float healthBeforeAttack, IDestructible destructible, Func<float> healthAfterDamaged) { _chopping = true; _monsterAI.DoAttack((Character)null, false); yield return (object)new WaitForSeconds(2f); if (healthAfterDamaged() < healthBeforeAttack) { _chopping = false; yield break; } HitData val = new HitData(); val.m_damage.m_chop = ToolDamage; val.m_toolTier = ToolTier; if (destructible != null) { destructible.Damage(val); } _chopping = false; } private void OnCollisionEnter(Collision collision) { _inContact = Hittable((collision != null) ? collision.gameObject : null); } private void OnCollisionExit(Collision other) { _inContact = Hittable((other != null) ? other.gameObject : null); } private bool Hittable(GameObject go) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 Destructible componentInParent = go.GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2) { return true; } if ((Object)(object)go.GetComponentInParent<TreeLog>() != (Object)null) { return true; } if ((Object)(object)go.GetComponentInParent<TreeBase>() != (Object)null) { return true; } return false; } } } namespace ChebsValheimLibrary.Items { public enum CraftingTable { None, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("blackforge")] BlackForge } public class Item { public ConfigEntry<bool> Allowed; protected float DoOnUpdateDelay; public virtual string ItemName => ""; public virtual string PrefabName => ""; public virtual string NameLocalization => ""; public virtual string DescriptionLocalization => ""; protected virtual string DefaultRecipe => ""; public virtual void CreateConfigs(BaseUnityPlugin plugin) { } public virtual void UpdateRecipe() { } public virtual void UpdateRecipe(ConfigEntry<CraftingTable> craftingStationRequired, ConfigEntry<string> craftingCost, ConfigEntry<int> craftingStationLevel) { //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown ItemManager instance = ItemManager.Instance; object obj; if (instance == null) { obj = null; } else { CustomItem item = instance.GetItem(ItemName); if (item == null) { obj = null; } else { CustomRecipe recipe = item.Recipe; obj = ((recipe != null) ? recipe.Recipe : null); } } Recipe val = (Recipe)obj; if ((Object)(object)val == (Object)null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because ItemManager returned null for " + ItemName + ".")); return; } if (craftingStationRequired == null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingStationRequired is null.")); return; } if (craftingCost == null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingCost is null.")); return; } if (craftingStationLevel == null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingStationLevel is null.")); return; } string name = InternalName.GetName(craftingStationRequired.Value); val.m_minStationLevel = craftingStationLevel.Value; PrefabManager instance2 = PrefabManager.Instance; GameObject val2 = ((instance2 != null) ? instance2.GetPrefab(name) : null); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because of failure to get " + name + " from ZNetScene.instance.")); return; } val.m_craftingStation = val2.GetComponent<CraftingStation>(); List<Requirement> list = new List<Requirement>(); string[] array = craftingCost.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); string text = array2[0]; int num = int.Parse(array2[1]); PrefabManager instance3 = PrefabManager.Instance; GameObject val3 = ((instance3 != null) ? instance3.GetPrefab(text) : null); if ((Object)(object)val3 == (Object)null) { Logger.LogError((object)("Failed to update recipe for " + ItemName + " because of failure to get " + text + "'s prefab from ZNetScene.instance.")); } else { list.Add(new Requirement { m_amount = num, m_amountPerLevel = num * 2, m_resItem = val3.GetComponent<ItemDrop>() }); } } val.m_resources = list.ToArray(); } protected void SetRecipeReqs(ItemConfig recipeConfig, ConfigEntry<string> craftingCost, ConfigEntry<CraftingTable> craftingStationRequired, ConfigEntry<int> craftingStationLevel) { recipeConfig.CraftingStation = ((InternalName)typeof(CraftingTable).GetMember(craftingStationRequired.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).Name; if (Enumerable.Contains(craftingCost.Value, ',')) { string[] array = craftingCost.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { AddMaterial(array[i]); } } else { AddMaterial(craftingCost.Value); } recipeConfig.MinStationLevel = craftingStationLevel.Value; void AddMaterial(string material) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown string[] array2 = material.Split(new char[1] { ':' }); string text = array2[0]; int num = int.Parse(array2[1]); recipeConfig.AddRequirement(new RequirementConfig(text, num, num * 2, false)); } } public virtual void DoOnUpdate() { } public virtual CustomItem GetCustomItemFromPrefab(GameObject prefab, bool fixReference = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown ItemConfig val = new ItemConfig(); val.Name = NameLocalization; val.Description = DescriptionLocalization; CustomItem val2 = new CustomItem(prefab, fixReference, val); if ((Object)(object)val2.ItemPrefab == (Object)null) { Logger.LogError((object)("GetCustomItemFromPrefab: " + PrefabName + "'s ItemPrefab is null!")); return null; } return val2; } } } namespace ChebsValheimLibrary.Items.Weapons.Wood { public class SkeletonClub : Item { public override string ItemName => "ChebGonaz_SkeletonClub"; public override string PrefabName => "ChebGonaz_SkeletonClub.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonclub_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonclub_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Poison { public class SkeletonMace : Item { public override string ItemName => "ChebGonaz_SkeletonMace"; public override string PrefabName => "ChebGonaz_SkeletonMace.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmace_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc"; } public class SkeletonMace2 : Item { public override string ItemName => "ChebGonaz_SkeletonMace2"; public override string PrefabName => "ChebGonaz_SkeletonMace2.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmace_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc"; } public class SkeletonMace3 : Item { public override string ItemName => "ChebGonaz_SkeletonMace3"; public override string PrefabName => "ChebGonaz_SkeletonMace3.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmace_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Needle { public class SkeletonMaceNeedle : Item { public override string ItemName => "ChebGonaz_SkeletonMaceNeedle"; public override string PrefabName => "ChebGonaz_SkeletonMaceNeedle.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmaceneedle_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceneedle_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Mage { public class SkeletonFireballLevel1 : Item { public override string ItemName => "ChebGonaz_FireballLevel1"; public override string PrefabName => "ChebGonaz_FireballLevel1.prefab"; public override string NameLocalization => "$item_chebgonaz_fireballlevel1_name"; public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel1_desc"; } public class SkeletonFireballLevel2 : Item { public override string ItemName => "ChebGonaz_FireballLevel2"; public override string PrefabName => "ChebGonaz_FireballLevel2.prefab"; public override string NameLocalization => "$item_chebgonaz_fireballlevel2_name"; public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel2_desc"; } public class SkeletonFireballLevel3 : Item { public override string ItemName => "ChebGonaz_FireballLevel3"; public override string PrefabName => "ChebGonaz_FireballLevel3.prefab"; public override string NameLocalization => "$item_chebgonaz_fireballlevel3_name"; public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel3_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Iron { public class SkeletonAxe : Item { public override string ItemName => "ChebGonaz_SkeletonAxe"; public override string PrefabName => "ChebGonaz_SkeletonAxe.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonaxe_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxe_desc"; } public class SkeletonMaceIron : Item { public override string ItemName => "ChebGonaz_SkeletonMaceIron"; public override string PrefabName => "ChebGonaz_SkeletonMaceIron.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmaceiron_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceiron_desc"; } public class SkeletonSwordIron : Item { public override string ItemName => "ChebGonaz_SkeletonSwordIron"; public override string PrefabName => "ChebGonaz_SkeletonSwordIron.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonswordiron_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordiron_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Bronze { public class SkeletonAxeBronze : Item { public override string ItemName => "ChebGonaz_SkeletonAxeBronze"; public override string PrefabName => "ChebGonaz_SkeletonAxeBronze.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonaxebronze_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxebronze_desc"; } public class SkeletonMaceBronze : Item { public override string ItemName => "ChebGonaz_SkeletonMaceBronze"; public override string PrefabName => "ChebGonaz_SkeletonMaceBronze.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmacebronze_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmacebronze_desc"; } public class SkeletonSwordBronze : Item { public override string ItemName => "ChebGonaz_SkeletonSwordBronze"; public override string PrefabName => "ChebGonaz_SkeletonSwordBronze.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonswordbronze_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordbronze_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.Bows { public class SkeletonBow : Item { public override string ItemName => "ChebGonaz_SkeletonBow"; public override string PrefabName => "ChebGonaz_SkeletonBow.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbow_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow_desc"; } public class SkeletonBow2 : Item { public override string ItemName => "ChebGonaz_SkeletonBow2"; public override string PrefabName => "ChebGonaz_SkeletonBow2.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbow2_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow2_desc"; } public class SkeletonBow3 : Item { public override string ItemName => "ChebGonaz_SkeletonBow3"; public override string PrefabName => "ChebGonaz_SkeletonBow3.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbow3_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow3_desc"; } public class SkeletonBowFire : Item { public override string ItemName => "ChebGonaz_SkeletonBowFire"; public override string PrefabName => "ChebGonaz_SkeletonBowFire.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbowfire_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowfire_desc"; } public class SkeletonBowFrost : Item { public override string ItemName => "ChebGonaz_SkeletonBowFrost"; public override string PrefabName => "ChebGonaz_SkeletonBowFrost.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbowfrost_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowfrost_desc"; } public class SkeletonBowPoison : Item { public override string ItemName => "ChebGonaz_SkeletonBowPoison"; public override string PrefabName => "ChebGonaz_SkeletonBowPoison.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbowpoison_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowpoison_desc"; } public class SkeletonBowSilver : Item { public override string ItemName => "ChebGonaz_SkeletonBowSilver"; public override string PrefabName => "ChebGonaz_SkeletonBowSilver.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonbowsilver_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowsilver_desc"; } } namespace ChebsValheimLibrary.Items.Weapons.BlackMetal { public class SkeletonAxeBlackMetal : Item { public override string ItemName => "ChebGonaz_SkeletonAxeBlackMetal"; public override string PrefabName => "ChebGonaz_SkeletonAxeBlackMetal.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonaxeblackmetal_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxeblackmetal_desc"; } public class SkeletonMaceBlackMetal : Item { public override string ItemName => "ChebGonaz_SkeletonMaceBlackMetal"; public override string PrefabName => "ChebGonaz_SkeletonMaceBlackMetal.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonmaceblackmetal_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceblackmetal_desc"; } public class SkeletonSwordBlackMetal : Item { public override string ItemName => "ChebGonaz_SkeletonSwordBlackMetal"; public override string PrefabName => "ChebGonaz_SkeletonSwordBlackMetal.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonswordblackmetal_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordblackmetal_desc"; } } namespace ChebsValheimLibrary.Items.Tools { public class SkeletonPickaxe : Item { public override string ItemName => "ChebGonaz_SkeletonPickaxe"; public override string PrefabName => "ChebGonaz_SkeletonPickaxe.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonpickaxe_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonpickaxe_desc"; } public class SkeletonWoodAxe : Item { public override string ItemName => "ChebGonaz_SkeletonWoodAxe"; public override string PrefabName => "ChebGonaz_SkeletonWoodAxe.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonaxe_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxe_desc"; } } namespace ChebsValheimLibrary.Items.Armor.Mage { public class SkeletonMageCirclet : Item { public override string ItemName => "ChebGonaz_SkeletonMageCirclet"; public override string PrefabName => "ChebGonaz_SkeletonMageCirclet.prefab"; public override string NameLocalization => "$item_chebgonaz_magecirclet_name"; public override string DescriptionLocalization => "$item_chebgonaz_magecirclet_desc"; } } namespace ChebsValheimLibrary.Items.Armor.Leather { public class SkeletonHelmetLeather : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeather"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeather.prefab"; public override string NameLocalization => "$item_helmet_leather"; public override string DescriptionLocalization => "$item_helmet_leather_description"; } public class SkeletonHelmetLeatherPoison : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoison"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoison.prefab"; public override string NameLocalization => "$item_helmet_leather"; public override string DescriptionLocalization => "$item_helmet_leather_description"; } } namespace ChebsValheimLibrary.Items.Armor.Leather.Wolf { public class HelmetLeatherWolf : Item { public override string ItemName => "ChebGonaz_HelmetLeatherWolf"; public override string PrefabName => "ChebGonaz_HelmetLeatherWolf.prefab"; public override string NameLocalization => "$item_helmet_leather_wolf"; public override string DescriptionLocalization => "$item_helmet_leather_description_wolf"; } public class SkeletonArmorLeatherChestWolf : Item { public override string ItemName => "ChebGonaz_ArmorLeatherChestWolf"; public override string PrefabName => "ChebGonaz_ArmorLeatherChestWolf.prefab"; public override string NameLocalization => "$item_chest_leather_wolf"; public override string DescriptionLocalization => "$item_chest_leather_description_wolf"; } public class SkeletonArmorLeatherLegsWolf : Item { public override string ItemName => "ChebGonaz_ArmorLeatherLegsWolf"; public override string PrefabName => "ChebGonaz_ArmorLeatherLegsWolf.prefab"; public override string NameLocalization => "$item_legs_leather_wolf"; public override string DescriptionLocalization => "$item_legs_leather_description_wolf"; } public class SkeletonHelmetLeatherPoisonWolf : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonWolf"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonWolf.prefab"; public override string NameLocalization => "$item_helmet_leather_wolf_poison"; public override string DescriptionLocalization => "$item_helmet_leather_wolf_poison_desc"; } public class SkeletonHelmetLeatherWolf : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherWolf"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherWolf.prefab"; public override string NameLocalization => "$item_helmet_leather_wolf"; public override string DescriptionLocalization => "$item_helmet_leather_description_wolf"; } } namespace ChebsValheimLibrary.Items.Armor.Leather.Troll { public class SkeletonArmorLeatherChestTroll : Item { public override string ItemName => "ChebGonaz_ArmorLeatherChestTroll"; public override string PrefabName => "ChebGonaz_ArmorLeatherChestTroll.prefab"; public override string NameLocalization => "$item_chest_leather_troll"; public override string DescriptionLocalization => "$item_chest_leather_description_troll"; } public class SkeletonArmorLeatherLegsTroll : Item { public override string ItemName => "ChebGonaz_ArmorLeatherLegsTroll"; public override string PrefabName => "ChebGonaz_ArmorLeatherLegsTroll.prefab"; public override string NameLocalization => "$item_legs_leather_troll"; public override string DescriptionLocalization => "$item_legs_leather_description_troll"; } public class SkeletonHelmetLeatherPoisonTroll : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonTroll"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonTroll.prefab"; public override string NameLocalization => "$item_helmet_leather_troll_poison"; public override string DescriptionLocalization => "$item_helmet_leather_description_troll_poison"; } public class SkeletonHelmetLeatherTroll : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherTroll"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherTroll.prefab"; public override string NameLocalization => "$item_helmet_leather_troll"; public override string DescriptionLocalization => "$item_helmet_leather_description_troll"; } } namespace ChebsValheimLibrary.Items.Armor.Leather.Lox { public class HelmetLeatherLox : Item { public override string ItemName => "ChebGonaz_HelmetLeatherLox"; public override string PrefabName => "ChebGonaz_HelmetLeatherLox.prefab"; public override string NameLocalization => "$item_helmet_leather_lox"; public override string DescriptionLocalization => "$item_helmet_leather_description_lox"; } public class SkeletonArmorLeatherChestLox : Item { public override string ItemName => "ChebGonaz_ArmorLeatherChestLox"; public override string PrefabName => "ChebGonaz_ArmorLeatherChestLox.prefab"; public override string NameLocalization => "$item_chest_leather_lox"; public override string DescriptionLocalization => "$item_chest_leather_description_lox"; } public class SkeletonArmorLeatherLegsLox : Item { public override string ItemName => "ChebGonaz_ArmorLeatherLegsLox"; public override string PrefabName => "ChebGonaz_ArmorLeatherLegsLox.prefab"; public override string NameLocalization => "$item_legs_leather_lox"; public override string DescriptionLocalization => "$item_legs_leather_description_lox"; } public class SkeletonHelmetLeatherLox : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherLox"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherLox.prefab"; public override string NameLocalization => "$item_helmet_leather_lox"; public override string DescriptionLocalization => "$item_helmet_leather_description_lox"; } public class SkeletonHelmetLeatherPoisonLox : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonLox"; public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonLox.prefab"; public override string NameLocalization => "$item_helmet_leather_troll_lox"; public override string DescriptionLocalization => "$item_helmet_leather_description_lox_poison"; } public class HelmetLeatherTroll : Item { public override string ItemName => "ChebGonaz_HelmetLeatherTroll"; public override string PrefabName => "ChebGonaz_HelmetLeatherTroll.prefab"; public override string NameLocalization => "$item_helmet_leather_troll"; public override string DescriptionLocalization => "$item_helmet_leather_description_troll"; } } namespace ChebsValheimLibrary.Items.Armor.Iron { public class SkeletonHelmetIron : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetIron"; public override string PrefabName => "ChebGonaz_SkeletonHelmetIron.prefab"; public override string NameLocalization => "$item_helmet_iron"; public override string DescriptionLocalization => "$item_helmet_iron_description"; } public class SkeletonHelmetIronPoison : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetIronPoison"; public override string PrefabName => "ChebGonaz_SkeletonHelmetIronPoison.prefab"; public override string NameLocalization => "$item_helmet_iron"; public override string DescriptionLocalization => "$item_helmet_iron_description"; } } namespace ChebsValheimLibrary.Items.Armor.Bronze { public class SkeletonHelmetBronze : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetBronze"; public override string PrefabName => "ChebGonaz_SkeletonHelmetBronze.prefab"; public override string NameLocalization => "$item_helmet_bronze"; public override string DescriptionLocalization => "$item_helmet_bronze_description"; } public class SkeletonHelmetBronzePoison : Item { public override string ItemName => "ChebGonaz_SkeletonHelmetBronzePoison"; public override string PrefabName => "ChebGonaz_SkeletonHelmetBronzePoison.prefab"; public override string NameLocalization => "$item_helmet_bronze"; public override string DescriptionLocalization => "$item_helmet_bronze_description"; } } namespace ChebsValheimLibrary.Items.Armor.BlackMetal { public class BlackIronChest : Item { public override string ItemName => "ChebGonaz_ArmorBlackIronChest"; public override string PrefabName => "ChebGonaz_ArmorBlackIronChest.prefab"; public override string NameLocalization => "$item_chebgonaz_blackironchest_name"; public override string DescriptionLocalization => "$item_chebgonaz_blackironchest_desc"; protected override string DefaultRecipe => "BlackMetal:5"; } public class BlackIronHelmet : Item { public override string ItemName => "ChebGonaz_HelmetBlackIron"; public override string PrefabName => "ChebGonaz_HelmetBlackIron.prefab"; public override string NameLocalization => "$item_chebgonaz_blackironhelmet_name"; public override string DescriptionLocalization => "$item_chebgonaz_blackironhelmet_desc"; protected override string DefaultRecipe => "BlackMetal:5"; } public class BlackIronLegs : Item { public override string ItemName => "ChebGonaz_ArmorBlackIronLegs"; public override string PrefabName => "ChebGonaz_ArmorBlackIronLegs.prefab"; public override string NameLocalization => "$item_chebgonaz_blackironlegs_name"; public override string DescriptionLocalization => "$item_chebgonaz_blackironlegs_desc"; protected override string DefaultRecipe => "BlackMetal:5"; } public class SkeletonHelmetBlackIron : Item { public override string ItemName => "ChebGonaz_HelmetBlackIronSkeleton"; public override string PrefabName => "ChebGonaz_HelmetBlackIronSkeleton.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonblackironhelmet_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonblackironhelmet_desc"; } public class SkeletonHelmetBlackIronPoison : Item { public override string ItemName => "ChebGonaz_HelmetBlackIronSkeletonPoison"; public override string PrefabName => "ChebGonaz_HelmetBlackIronSkeletonPoison.prefab"; public override string NameLocalization => "$item_chebgonaz_skeletonblackironhelmet_name"; public override string DescriptionLocalization => "$item_chebgonaz_skeletonblackironhelmet_desc"; } } namespace ChebsValheimLibrary.Common { public class ChebsRecipe { public string RecipeValue = "<Prefab1>:<quantity>[[,<PreFab2>:<quantity>], ...]"; public ConfigEntry<bool> Allowed { get; set; } public ConfigEntry<string> CraftingCost { get; set; } public string DefaultRecipe { get; set; } public string PieceTable { get; set; } public string PieceCategory { get; set; } public string PieceName { get; set; } public string PieceDescription { get; set; } public string PrefabName { get; set; } public string IconName { get; set; } public string ObjectName { get; set; } public virtual void UpdateRecipe(ConfigEntry<string> craftingCost) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown string text = PrefabName.Split(new char[1] { '.' })[0]; Piece piece = PieceManager.Instance.GetPiece(text).Piece; List<Requirement> list = new List<Requirement>(); string[] array = craftingCost.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); string text2 = array2[0]; int num = int.Parse(array2[1]); list.Add(new Requirement { m_amount = num, m_amountPerLevel = num * 2, m_resItem = ZNetScene.instance.GetPrefab(text2).GetComponent<ItemDrop>() }); } piece.m_resources = list.ToArray(); } public CustomPiece GetCustomPieceFromPrefab(GameObject prefab, Sprite icon, bool fixReference = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_001e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = PieceName, Description = PieceDescription }; if (Allowed.Value) { if (string.IsNullOrEmpty(CraftingCost.Value)) { CraftingCost.Value = DefaultRecipe; } SetRecipeReqs(val, CraftingCost); } else { val.Enabled = false; } val.Icon = icon; val.PieceTable = PieceTable; val.Category = PieceCategory; CustomPiece val2 = new CustomPiece(prefab, fixReference, val); if ((Object)(object)val2.PiecePrefab == (Object)null) { Logger.LogError((object)("AddCustomPieces: " + PrefabName + "'s PiecePrefab is null!")); return null; } return val2; } private void SetRecipeReqs(PieceConfig config, ConfigEntry<string> craftingCost) { if (Enumerable.Contains(craftingCost.Value, ',')) { string[] array = craftingCost.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { addMaterial(array[i]); } } else { addMaterial(craftingCost.Value); } void addMaterial(string material) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown string[] array2 = material.Split(new char[1] { ':' }); string text = array2[0]; int num = int.Parse(array2[1]); config.AddRequirement(new RequirementConfig(text, num, 0, true)); } } } public class InternalName : Attribute { public readonly string Name; public InternalName(string internalName) { Name = internalName; } public static string GetName(Enum value) { Type type = value.GetType(); string name = Enum.GetName(type, value); return (type.GetField(name).GetCustomAttributes(typeof(InternalName), inherit: false).FirstOrDefault() as InternalName)?.Name ?? value.ToString(); } } public class MemoryConfigEntry<T, TT> { private readonly Func<T, TT> _processValueFunc; private T _lastKnownValue; private TT _processedValue; private readonly ConfigEntry<T> _configEntry; public TT Value => _processedValue; public ConfigEntry<T> ConfigEntry => _configEntry; public MemoryConfigEntry(ConfigEntry<T> configEntry, Func<T, TT> processValueFunc) { _configEntry = configEntry; _processValueFunc = processValueFunc; _lastKnownValue = _configEntry.Value; _processedValue = _processValueFunc(_lastKnownValue); if (configEntry == null) { Logger.LogError((object)"MemoryConfigEntry: configEntry is null!"); } else { _configEntry.SettingChanged += OnConfigEntryValueChanged; } } private void OnConfigEntryValueChanged(object sender, EventArgs args) { T value = _configEntry.Value; if (value == null) { Logger.LogError((object)"MemoryConfigEntry.OnConfigEntryValueChanged: value is null!"); } else if (!EqualityComparer<T>.Default.Equals(value, _lastKnownValue)) { Logger.LogInfo((object)$"MemoryConfigEntry.OnConfigEntryValueChanged: value is new! {value}"); _lastKnownValue = value; _processedValue = _processValueFunc(value); } } } public static class Weather { public enum Env { None, [InternalName("Clear")] Clear, [InternalName("Twilight_Clear")] TwilightClear, [InternalName("Misty")] Misty, [InternalName("Darklands_dark")] DarklandsDark, [InternalName("Heath_clear")] HeathClear, [InternalName("DeepForest")] DeepForest, [InternalName("Mist")] Mist, [InternalName("GDKing")] GDKing, [InternalName("Rain")] Rain, [InternalName("LightRain")] LightRain, [InternalName("ThunderStorm")] ThunderStorm, [InternalName("Eikthyr")] Eikthyr, [InternalName("GoblinKing")] GoblinKing, [InternalName("nofogts")] Nofogts, [InternalName("SwampRain")] SwampRain, [InternalName("Bonemass")] Bonemass, [InternalName("Snow")] Snow, [InternalName("Twilight_Snow")] TwilightSnow, [InternalName("Twilight_SnowStorm")] TwilightSnowStorm, [InternalName("SnowStorm")] SnowStorm, [InternalName("Moder")] Moder, [InternalName("Ashrain")] Ashrain, [InternalName("Crypt")] Crypt, [InternalName("SunkenCrypt")] SunkenCrypt } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }
plugins/ChebsMercenaries.dll
Decompiled 4 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ChebsMercenaries.Commands; using ChebsMercenaries.Commands.PvP; using ChebsMercenaries.Items; using ChebsMercenaries.Items.Minions; using ChebsMercenaries.Minions; using ChebsMercenaries.Minions.WorkerAI; using ChebsMercenaries.PvPOptions; using ChebsMercenaries.Structure; using ChebsValheimLibrary; using ChebsValheimLibrary.Common; using ChebsValheimLibrary.Items; using ChebsValheimLibrary.Items.Armor.Leather.Lox; using ChebsValheimLibrary.Items.Armor.Leather.Troll; using ChebsValheimLibrary.Items.Armor.Leather.Wolf; using ChebsValheimLibrary.Minions; using ChebsValheimLibrary.Minions.AI; using ChebsValheimLibrary.PvP; using ChebsValheimLibrary.Structures; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.GUI; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Cheb Gonaz")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("3.0.1.0")] [assembly: AssemblyInformationalVersion("3.0.1.0+6307d6506e483197a4a22c584268a2a0e03f4af6")] [assembly: AssemblyProduct("Cheb's Mercenaries")] [assembly: AssemblyTitle("Cheb's Mercenaries")] [assembly: NeutralResourcesLanguage("en")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ChebsMercenaries { [BepInPlugin("com.chebgonaz.chebsmercenaries", "ChebsMercenaries", "3.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BasePlugin : BaseUnityPlugin { public const string PluginGuid = "com.chebgonaz.chebsmercenaries"; public const string PluginName = "ChebsMercenaries"; public const string PluginVersion = "3.0.1"; private const string ConfigFileName = "com.chebgonaz.chebsmercenaries.cfg"; private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, "com.chebgonaz.chebsmercenaries.cfg"); public readonly Version ChebsValheimLibraryVersion = new Version("2.6.2"); private readonly Harmony harmony = new Harmony("com.chebgonaz.chebsmercenaries"); private List<WeaponOfCommand> _weaponsOfCommand = new List<WeaponOfCommand> { new AxeOfCommand(), new MaceOfCommand(), new SwordOfCommand() }; public static ConfigEntry<bool> PvPAllowed; public static ConfigEntry<bool> RadeonFriendly; public static ConfigEntry<bool> HeavyLogging; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); public static readonly List<string> MercenaryPrefabPaths = new List<string> { "ChebGonaz_HumanMiner.prefab", "ChebGonaz_HumanWoodcutter.prefab", "ChebGonaz_HumanArcher.prefab", "ChebGonaz_HumanArcherTier2.prefab", "ChebGonaz_HumanArcherTier3.prefab", "ChebGonaz_HumanWarrior.prefab", "ChebGonaz_HumanWarriorTier2.prefab", "ChebGonaz_HumanWarriorTier3.prefab", "ChebGonaz_HumanWarriorTier4.prefab", "ChebGonaz_HumanMinerFemale.prefab", "ChebGonaz_HumanWoodcutterFemale.prefab", "ChebGonaz_HumanArcherFemale.prefab", "ChebGonaz_HumanArcherTier2Female.prefab", "ChebGonaz_HumanArcherTier3Female.prefab", "ChebGonaz_HumanWarriorFemale.prefab", "ChebGonaz_HumanWarriorTier2Female.prefab", "ChebGonaz_HumanWarriorTier3Female.prefab", "ChebGonaz_HumanWarriorTier4Female.prefab", "ChebGonaz_Catapult.prefab" }; public AcceptableValueList<bool> BoolValue = new AcceptableValueList<bool>(new bool[2] { true, false }); public AcceptableValueRange<float> FloatQuantityValue = new AcceptableValueRange<float>(1f, 1000f); public AcceptableValueRange<int> IntQuantityValue = new AcceptableValueRange<int>(1, 1000); private double _inputDelay; public ConfigEntry<T> ModConfig<T>(string group, string name, T default_value, string description = "", AcceptableValueBase acceptableValues = null, bool serverSync = false, params object[] tags) { //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_002f: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description + (serverSync ? " [Synced with Server]" : " [Not Synced with Server]"), acceptableValues, new object[2] { (object)new ConfigurationManagerAttributes { IsAdminOnly = serverSync }, tags }); return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, default_value, val); } private void CreateConfigValues() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; PvPAllowed = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Server Synced)", "PvPAllowed", false, new ConfigDescription("Whether minions will target and attack other players and their minions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RadeonFriendly = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Client)", "RadeonFriendly", false, new ConfigDescription("ONLY set this to true if you have graphical issues with the mod. It will disable all particle effects for the mod's prefabs which seem to give users with Radeon cards trouble for unknown reasons. If you have problems with lag it might also help to switchthis setting on.", (AcceptableValueBase)null, Array.Empty<object>())); HeavyLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Client)", "HeavyLogging", false, new ConfigDescription("Turn this on for debugging. Lots of things will get logged.", (AcceptableValueBase)null, Array.Empty<object>())); PvPOptionsGUI.CreateConfigs((BaseUnityPlugin)(object)this, "com.chebgonaz.chebsmercenaries"); MercenaryMinion.CreateConfigs(this); HumanWoodcutterMinion.CreateConfigs(this); HumanMinerMinion.CreateConfigs(this); MercenaryArcherTier1Minion.CreateConfigs(this); MercenaryArcherTier2Minion.CreateConfigs(this); MercenaryArcherTier3Minion.CreateConfigs(this); MercenaryWarriorTier1Minion.CreateConfigs(this); MercenaryWarriorTier2Minion.CreateConfigs(this); MercenaryWarriorTier3Minion.CreateConfigs(this); MercenaryWarriorTier4Minion.CreateConfigs(this); CatapultMinion.CreateConfigs(this); MercenaryChest.CreateConfigs(this); _weaponsOfCommand.ForEach(delegate(WeaponOfCommand w) { ((Item)w).CreateConfigs((BaseUnityPlugin)(object)this); }); } private byte[] GetFileHash(string fileName) { HashAlgorithm hashAlgorithm = HashAlgorithm.Create(); using FileStream inputStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); return hashAlgorithm.ComputeHash(inputStream); } private IEnumerator WatchConfigFile() { byte[] lastHash = GetFileHash(ConfigFileFullPath); while (true) { yield return (object)new WaitForSeconds(5f); byte[] fileHash = GetFileHash(ConfigFileFullPath); if (!fileHash.SequenceEqual(lastHash)) { lastHash = fileHash; ReadConfigValues(); } } } private void ReadConfigValues() { try { bool flag = ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Read updated config values (admin/local={flag})"); if (flag) { ((BaseUnityPlugin)this).Config.Reload(); } MercenaryChest.UpdateRecipe(); _weaponsOfCommand.ForEach(delegate(WeaponOfCommand w) { ((Item)w).UpdateRecipe(); }); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("There was an issue loading your {0}: {1}", "com.chebgonaz.chebsmercenaries.cfg", arg)); } } private void Awake() { string text = default(string); if (!Base.VersionCheck(ChebsValheimLibraryVersion, ref text)) { Logger.LogWarning((object)text); } CreateConfigValues(); PvPManager.ConfigureRPC(); LoadChebGonazAssetBundle(); harmony.PatchAll(); foreach (ConsoleCommand pvpCommand in new List<ConsoleCommand> { (ConsoleCommand)(object)new PvPAddFriend(), (ConsoleCommand)(object)new PvPRemoveFriend(), (ConsoleCommand)(object)new PvPListFriends() }) { if (!CommandManager.Instance.CustomCommands.ToList().Exists((ConsoleCommand c) => c.Name == pvpCommand.Name)) { CommandManager.Instance.AddConsoleCommand(pvpCommand); } } CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SpawnMerc()); SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { ((BaseUnityPlugin)this).Logger.LogInfo((object)((!attr.InitialSynchronization) ? "Syncing configuration changes from server..." : "Syncing initial configuration...")); ((MonoBehaviour)this).StartCoroutine(RequestPvPDict()); }; ((MonoBehaviour)this).StartCoroutine(WatchConfigFile()); } private IEnumerator RequestPvPDict() { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ZNet.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null)); PvPManager.InitialFriendsListRequest(); } private void LoadChebGonazAssetBundle() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "chebgonaz"); AssetBundle chebgonazAssetBundle = AssetUtils.LoadAssetBundle(text); try { foreach (Item item in new List<Item> { (Item)(object)new MercenaryBowItem(), (Item)(object)new MercenaryBow2Item(), (Item)(object)new MercenaryBow3Item(), (Item)(object)new MercenaryBowFireItem(), (Item)(object)new MercenaryBowFrostItem(), (Item)(object)new MercenaryBowSilverItem(), (Item)(object)new MercenaryBowPoisonItem(), (Item)new HelmetLeatherTroll(), (Item)new HelmetLeatherWolf(), (Item)new HelmetLeatherLox(), (Item)new SkeletonHelmetLeatherTroll(), (Item)new SkeletonHelmetLeatherPoisonTroll(), (Item)new SkeletonArmorLeatherChestTroll(), (Item)new SkeletonArmorLeatherLegsTroll(), (Item)new SkeletonHelmetLeatherWolf(), (Item)new SkeletonHelmetLeatherPoisonWolf(), (Item)new SkeletonArmorLeatherChestWolf(), (Item)new SkeletonArmorLeatherLegsWolf(), (Item)new SkeletonHelmetLeatherLox(), (Item)new SkeletonHelmetLeatherPoisonLox(), (Item)new SkeletonArmorLeatherChestLox(), (Item)new SkeletonArmorLeatherLegsLox() }) { if (ItemManager.Instance.GetItem(item.ItemName) == null) { GameObject val = Base.LoadPrefabFromBundle(item.PrefabName, chebgonazAssetBundle, RadeonFriendly.Value); ItemManager.Instance.AddItem(item.GetCustomItemFromPrefab(val, true)); } } _weaponsOfCommand.ForEach(delegate(WeaponOfCommand w) { GameObject val5 = Base.LoadPrefabFromBundle(((Item)w).PrefabName, chebgonazAssetBundle, RadeonFriendly.Value); w.CreateButtons(); KeyHintManager.Instance.AddKeyHint(w.GetKeyHint()); ItemManager.Instance.AddItem(((Item)w).GetCustomItemFromPrefab(val5, true)); }); MercenaryPrefabPaths.ForEach(delegate(string prefabName) { //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Expected O, but got Unknown if (HeavyLogging.Value) { Logger.LogInfo((object)("Loading prefab " + prefabName + "...")); } GameObject val4 = Base.LoadPrefabFromBundle(prefabName, chebgonazAssetBundle, RadeonFriendly.Value); switch (prefabName) { case "ChebGonaz_HumanMinerFemale.prefab": case "ChebGonaz_HumanMiner.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding HumanMinerMinion component to " + prefabName + ".")); } val4.AddComponent<HumanMinerMinion>(); break; case "ChebGonaz_HumanWoodcutter.prefab": case "ChebGonaz_HumanWoodcutterFemale.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding HumanWoodcutterMinion component to " + prefabName + ".")); } val4.AddComponent<HumanWoodcutterMinion>(); break; case "ChebGonaz_HumanWarrior.prefab": case "ChebGonaz_HumanWarriorFemale.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryWarriorTier1Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryWarriorTier1Minion>(); break; case "ChebGonaz_HumanWarriorTier2.prefab": case "ChebGonaz_HumanWarriorTier2Female.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryWarriorTier2Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryWarriorTier2Minion>(); break; case "ChebGonaz_HumanWarriorTier3.prefab": case "ChebGonaz_HumanWarriorTier3Female.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryWarriorTier3Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryWarriorTier3Minion>(); break; case "ChebGonaz_HumanWarriorTier4.prefab": case "ChebGonaz_HumanWarriorTier4Female.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryWarriorTier4Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryWarriorTier4Minion>(); break; case "ChebGonaz_HumanArcherFemale.prefab": case "ChebGonaz_HumanArcher.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryArcherTier1Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryArcherTier1Minion>(); break; case "ChebGonaz_HumanArcherTier2.prefab": case "ChebGonaz_HumanArcherTier2Female.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryArcherTier2Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryArcherTier2Minion>(); break; case "ChebGonaz_HumanArcherTier3.prefab": case "ChebGonaz_HumanArcherTier3Female.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding MercenaryArcherTier3Minion component to " + prefabName + ".")); } val4.AddComponent<MercenaryArcherTier3Minion>(); break; case "ChebGonaz_Catapult.prefab": if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding CatapultMinion component to " + prefabName + ".")); } val4.AddComponent<CatapultMinion>(); break; default: if (HeavyLogging.Value) { Logger.LogInfo((object)("Adding HumanMinion component to " + prefabName + ".")); } val4.gameObject.AddComponent<HumanMinion>(); break; } CreatureManager.Instance.AddCreature(new CustomCreature(val4, true)); }); GameObject val2 = chebgonazAssetBundle.LoadAsset<GameObject>(MercenaryChest.ChebsRecipeConfig.PrefabName); val2.AddComponent<MercenaryChest>(); PieceManager.Instance.AddPiece(MercenaryChest.ChebsRecipeConfig.GetCustomPieceFromPrefab(val2, chebgonazAssetBundle.LoadAsset<Sprite>(MercenaryChest.ChebsRecipeConfig.IconName), true)); foreach (string item2 in new List<string> { "sfx_chebsmerc_alerted", "sfx_chebsmerc_alerted_female", "sfx_chebsmerc_death", "sfx_chebsmerc_death_female", "sfx_chebsmerc_idle", "sfx_chebsmerc_idle_female", "sfx_chebsmerc_injured", "sfx_chebsmerc_injured_female", "vfx_chebgonazhuman_death", "sfx_chebscatapult_alert", "sfx_chebscatapult_death", "sfx_chebscatapult_idle", "sfx_chebscatapult_injured" }) { GameObject val3 = Base.LoadPrefabFromBundle(item2, chebgonazAssetBundle, RadeonFriendly.Value); PrefabManager.Instance.AddPrefab(val3); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while loading assets: {arg}"); } finally { chebgonazAssetBundle.Unload(false); } } private void Update() { if (ZInput.instance == null) { return; } if ((double)Time.time > _inputDelay) { _weaponsOfCommand.ForEach(delegate(WeaponOfCommand w) { if (w.HandleInputs()) { _inputDelay = Time.time + 0.5f; } }); } if (PvPOptionsGUI.OptionsButton != null && ZInput.GetButtonUp(PvPOptionsGUI.OptionsButton.Name)) { PvPOptionsGUI.TogglePanel(); } } } } namespace ChebsMercenaries.Structure { public class MercenaryChest : Structure { public static ConfigEntry<float> RecruitmentInterval; public static ConfigEntry<int> ArmorLeatherScrapsRequiredConfig; public static ConfigEntry<int> ArmorBronzeRequiredConfig; public static ConfigEntry<int> ArmorIronRequiredConfig; public static ConfigEntry<int> ArmorBlackIronRequiredConfig; private Container _container; private Inventory _inventory; private float _lastRecruitmentAt; public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe { DefaultRecipe = "Wood:25,Coins:100", IconName = "chebgonaz_mercenarychest_icon.png", PieceTable = "_HammerPieceTable", PieceCategory = "Misc", PieceName = "$chebgonaz_mercenarychest_name", PieceDescription = "$chebgonaz_mercenarychest_desc", PrefabName = "ChebGonaz_MercenaryChest.prefab", ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name }; private List<MercenaryMinion.MercenaryType> _orderedByPreference = new List<MercenaryMinion.MercenaryType> { MercenaryMinion.MercenaryType.Catapult, MercenaryMinion.MercenaryType.Woodcutter, MercenaryMinion.MercenaryType.Miner, MercenaryMinion.MercenaryType.ArcherTier3, MercenaryMinion.MercenaryType.ArcherTier2, MercenaryMinion.MercenaryType.ArcherTier1, MercenaryMinion.MercenaryType.WarriorTier4, MercenaryMinion.MercenaryType.WarriorTier3, MercenaryMinion.MercenaryType.WarriorTier2, MercenaryMinion.MercenaryType.WarriorTier1 }; public static void UpdateRecipe() { ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost); } public static void CreateConfigs(BasePlugin plugin) { ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "Allowed", true, "Whether making this is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true); ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true); RecruitmentInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RecruitmentInterval", 30f, "Every X seconds, attempt to recruit a mercenary", null, true); ArmorLeatherScrapsRequiredConfig = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ArmorLeatherScrapsRequired", 2, "The amount of LeatherScraps required to craft a minion in leather armor.", null, true); ArmorBronzeRequiredConfig = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ArmorBronzeRequired", 1, "The amount of Bronze required to craft a minion in bronze armor.", null, true); ArmorIronRequiredConfig = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ArmoredIronRequired", 1, "The amount of Iron required to craft a minion in iron armor.", null, true); ArmorBlackIronRequiredConfig = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ArmorBlackIronRequired", 1, "The amount of Black Metal required to craft a minion in black iron armor.", null, true); } private void Awake() { ((MonoBehaviour)this).StartCoroutine(Recruitment()); } private MercenaryMinion.MercenaryType NextMercenary() { string text = default(string); foreach (MercenaryMinion.MercenaryType item in _orderedByPreference) { if (ChebGonazMinion.CanSpawn((MemoryConfigEntry<string, List<string>>)(item switch { MercenaryMinion.MercenaryType.Catapult => CatapultMinion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier1 => MercenaryWarriorTier1Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier2 => MercenaryWarriorTier2Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier3 => MercenaryWarriorTier3Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier4 => MercenaryWarriorTier4Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier1 => MercenaryArcherTier1Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier2 => MercenaryArcherTier2Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier3 => MercenaryArcherTier3Minion.ItemsCost, MercenaryMinion.MercenaryType.Miner => HumanMinerMinion.ItemsCost, MercenaryMinion.MercenaryType.Woodcutter => HumanWoodcutterMinion.ItemsCost, _ => null, }), _inventory, ref text)) { return item; } } return MercenaryMinion.MercenaryType.None; } private void PayForMercenary(MercenaryMinion.MercenaryType mercenaryType) { MemoryConfigEntry<string, List<string>> val = (MemoryConfigEntry<string, List<string>>)(mercenaryType switch { MercenaryMinion.MercenaryType.Catapult => CatapultMinion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier1 => MercenaryWarriorTier1Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier2 => MercenaryWarriorTier2Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier3 => MercenaryWarriorTier3Minion.ItemsCost, MercenaryMinion.MercenaryType.WarriorTier4 => MercenaryWarriorTier4Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier1 => MercenaryArcherTier1Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier2 => MercenaryArcherTier2Minion.ItemsCost, MercenaryMinion.MercenaryType.ArcherTier3 => MercenaryArcherTier3Minion.ItemsCost, MercenaryMinion.MercenaryType.Miner => HumanMinerMinion.ItemsCost, MercenaryMinion.MercenaryType.Woodcutter => HumanWoodcutterMinion.ItemsCost, _ => null, }); if (BasePlugin.HeavyLogging.Value) { string arg = ((val?.Value == null) ? "" : string.Join(", ", val.Value)); Logger.LogInfo((object)$"Paying for mercenary {mercenaryType} with {arg}..."); } ChebGonazMinion.ConsumeRequirements(val, _inventory); } private ArmorType UpgradeMercenaryEquipment() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0079: Expected I4, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) ArmorType val = ChebGonazMinion.DetermineArmorType(_inventory, ArmorBlackIronRequiredConfig.Value, ArmorIronRequiredConfig.Value, ArmorBronzeRequiredConfig.Value, ArmorLeatherScrapsRequiredConfig.Value); if (BasePlugin.HeavyLogging.Value) { Logger.LogInfo((object)$"Determining mercenary's armour type: {val}."); } switch (val - 1) { case 6: _inventory.RemoveItem("$item_blackmetal", ArmorBlackIronRequiredConfig.Value, -1, true); break; case 5: _inventory.RemoveItem("$item_iron", ArmorBlackIronRequiredConfig.Value, -1, true); break; case 4: _inventory.RemoveItem("$item_bronze", ArmorBlackIronRequiredConfig.Value, -1, true); break; case 0: foreach (string item in new List<string> { "$item_leatherscraps", "$item_deerhide", "$item_scalehide" }) { if (_inventory.CountItems(item, -1, true) >= ArmorLeatherScrapsRequiredConfig.Value) { _inventory.RemoveItem(item, ArmorLeatherScrapsRequiredConfig.Value, -1, true); break; } } break; case 3: _inventory.RemoveItem("$item_loxpelt", ArmorLeatherScrapsRequiredConfig.Value, -1, true); break; case 1: _inventory.RemoveItem("$item_trollhide", ArmorLeatherScrapsRequiredConfig.Value, -1, true); break; case 2: _inventory.RemoveItem("$item_wolfpelt", ArmorLeatherScrapsRequiredConfig.Value, -1, true); break; } return val; } private IEnumerator Recruitment() { Piece piece = ((Component)this).GetComponent<Piece>(); yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer())); _container = ((Component)this).gameObject.AddComponent<Container>(); _container.m_name = "$chebgonaz_mercenarychest_name"; _inventory = _container.GetInventory(); _inventory.m_name = Localization.instance.Localize(_container.m_name); Color val2 = default(Color); Color val = default(Color); while (true) { yield return (object)new WaitForSeconds(5f); if (!piece.m_nview.IsOwner()) { continue; } List<Player> playersInRange = new List<Player>(); Player.GetPlayersInRange(((Component)this).transform.position, 150f, playersInRange); if (playersInRange.Count < 1) { continue; } yield return (object)new WaitWhile((Func<bool>)(() => playersInRange[0].IsSleeping())); MercenaryMinion.MercenaryType mercenaryType = NextMercenary(); if (playersInRange.Any((Player player) => Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) < 5f)) { string newValue = mercenaryType switch { MercenaryMinion.MercenaryType.Catapult => Localization.instance.Localize("$chebgonaz_mercenarytype_catapult"), MercenaryMinion.MercenaryType.WarriorTier1 => Localization.instance.Localize("$chebgonaz_mercenarytype_warriortier1"), MercenaryMinion.MercenaryType.WarriorTier2 => Localization.instance.Localize("$chebgonaz_mercenarytype_warriortier2"), MercenaryMinion.MercenaryType.WarriorTier3 => Localization.instance.Localize("$chebgonaz_mercenarytype_warriortier3"), MercenaryMinion.MercenaryType.WarriorTier4 => Localization.instance.Localize("$chebgonaz_mercenarytype_warriortier4"), MercenaryMinion.MercenaryType.ArcherTier1 => Localization.instance.Localize("$chebgonaz_mercenarytype_archertier1"), MercenaryMinion.MercenaryType.ArcherTier2 => Localization.instance.Localize("$chebgonaz_mercenarytype_archertier2"), MercenaryMinion.MercenaryType.ArcherTier3 => Localization.instance.Localize("$chebgonaz_mercenarytype_archertier3"), MercenaryMinion.MercenaryType.Miner => Localization.instance.Localize("$chebgonaz_mercenarytype_miner"), MercenaryMinion.MercenaryType.Woodcutter => Localization.instance.Localize("$chebgonaz_mercenarytype_woodcutter"), _ => Localization.instance.Localize("$chebgonaz_mercenarytype_none"), }; string text = Localization.instance.Localize("$chebgonaz_mercenarychest_recruitmentmessage").Replace("%1", newValue).Replace("%2", (RecruitmentInterval.Value - (Time.time - _lastRecruitmentAt)).ToString("0")); if (BasePlugin.HeavyLogging.Value) { Logger.LogInfo((object)text); } Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 4f, "", text, false); } if (!(Time.time - _lastRecruitmentAt > RecruitmentInterval.Value)) { continue; } _lastRecruitmentAt = Time.time; if (mercenaryType == MercenaryMinion.MercenaryType.None) { continue; } PayForMercenary(mercenaryType); if (mercenaryType == MercenaryMinion.MercenaryType.Catapult) { CatapultMinion.Spawn(((Component)this).transform); continue; } List<Vector3> skinColors = (from html in (from str in MercenaryChestOptionsGUI.GetSkins(_container) select str.Trim()).ToList() select (!ColorUtility.TryParseHtmlString(html, ref val2)) ? Vector3.zero : Utils.ColorToVec3(val2)).ToList(); List<Vector3> hairColors = (from html in (from str in MercenaryChestOptionsGUI.GetHairs(_container) select str.Trim()).ToList() select (!ColorUtility.TryParseHtmlString(html, ref val)) ? Vector3.zero : Utils.ColorToVec3(val)).ToList(); string gender = MercenaryChestOptionsGUI.GetGender(_container); if (!float.TryParse(gender, out var result)) { Logger.LogError((object)("Failed to parse " + gender + ", defaulting to 50%")); result = 50f; } result /= 100f; HumanMinion.Spawn(mercenaryType, UpgradeMercenaryEquipment(), ((Component)this).transform, result, skinColors, hairColors); } } } public class MercenaryChestOptionsGUI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ColorEvent <>9__13_2; public static ColorEvent <>9__13_6; internal void <Show>b__13_2(Color <p0>) { } internal void <Show>b__13_6(Color <p0>) { } } private const string SkinZdoKey = "ChebGonazMercSkin"; private const string DefaultSkinColors = "#FEF5E7,#F5CBA7,#784212,#F5B041"; private const string HairZdoKey = "ChebGonazMercHair"; private const string DefaultHairColors = "#F7DC6F,#935116,#AFABAB,#FF5733,#1C2833"; private const string GenderZdoKey = "ChebGonazMercSex"; private const string DefaultGender = "50"; private static GameObject _panel; private static Dropdown _skinColorsDropdown; private static Dropdown _hairColorsDropdown; private static Text _skinColorDisplay; private static Text _hairColorDisplay; private static InputField _chanceOfFemaleInputField; private static Container _lastContainer; public static void Show(Container container) { //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_0809: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_082e: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Expected O, but got Unknown //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Expected O, but got Unknown //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_panel)) { if (GUIManager.Instance == null) { Logger.LogError((object)"GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Logger.LogError((object)"GUIManager CustomGUI is null"); return; } _panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -100f), 500f, 600f, false); _panel.SetActive(false); _panel.AddComponent<DragWindowCntrl>(); GUIManager.Instance.CreateText("Mercenary Options", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -50f), GUIManager.Instance.AveriaSerifBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 40f, false); GUIManager.Instance.CreateText("Skin Colors:", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-150f, -100f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 120f, 30f, false); _skinColorsDropdown = GUIManager.Instance.CreateDropDown(_panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-40f, 210f), 16, 120f, 30f).GetComponent<Dropdown>(); ((UnityEvent<int>)(object)_skinColorsDropdown.onValueChanged).AddListener((UnityAction<int>)UpdateSkinColorDisplay); _skinColorDisplay = GUIManager.Instance.CreateText("Skin", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(60f, -100f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 60f, 30f, false).GetComponent<Text>(); ColorEvent val = default(ColorEvent); ((UnityEvent)GUIManager.Instance.CreateButton("+", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(140f, 210f), 30f, 30f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_004e: 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_006c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a8: 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) //IL_00af: Expected O, but got Unknown //IL_00b4: Expected O, but got Unknown string text5 = _skinColorsDropdown.options[_skinColorsDropdown.value].text; Color val11 = default(Color); if (!ColorUtility.TryParseHtmlString(text5, ref val11)) { Logger.LogError((object)$"Failed to parse color {text5}, defaulting to {val11}"); } GUIManager instance2 = GUIManager.Instance; Vector2 val12 = new Vector2(0.5f, 0.5f); Vector2 val13 = new Vector2(0.5f, 0.5f); Vector2 val14 = new Vector2(0.5f, 0.5f); Color val15 = val11; object obj3 = <>c.<>9__13_2; if (obj3 == null) { ColorEvent val16 = delegate { }; <>c.<>9__13_2 = val16; obj3 = (object)val16; } ColorEvent obj4 = val; if (obj4 == null) { ColorEvent val17 = delegate(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) string item2 = "#" + ColorUtility.ToHtmlStringRGB(color); List<string> skins2 = GetSkins(container); skins2.Add(item2); SetSkins(container, skins2); RefreshSkinDropdown(container, skins2.Count - 1); UpdateSkinColorDisplay(_skinColorsDropdown.value); }; ColorEvent val18 = val17; val = val17; obj4 = val18; } instance2.CreateColorPicker(val12, val13, val14, val15, "Choose a Skin Color", (ColorEvent)obj3, obj4, false); }); ((UnityEvent)GUIManager.Instance.CreateButton("-", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(170f, 210f), 30f, 30f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate { if (_skinColorsDropdown.options.Count > 1) { string text4 = _skinColorsDropdown.options[_skinColorsDropdown.value].text; List<string> skins = GetSkins(container); skins.Remove(text4); SetSkins(container, skins); RefreshSkinDropdown(container); UpdateSkinColorDisplay(_skinColorsDropdown.value); } }); GUIManager.Instance.CreateText("Hair Colors:", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-150f, -140f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 120f, 30f, false); _hairColorsDropdown = GUIManager.Instance.CreateDropDown(_panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-40f, 170f), 16, 120f, 30f).GetComponent<Dropdown>(); ((UnityEvent<int>)(object)_hairColorsDropdown.onValueChanged).AddListener((UnityAction<int>)UpdateHairColorDisplay); _hairColorDisplay = GUIManager.Instance.CreateText("Hair", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(60f, -140f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 60f, 30f, false).GetComponent<Text>(); ColorEvent val2 = default(ColorEvent); ((UnityEvent)GUIManager.Instance.CreateButton("+", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(140f, 170f), 30f, 30f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_004e: 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_006c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a8: 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) //IL_00af: Expected O, but got Unknown //IL_00b4: Expected O, but got Unknown string text3 = _hairColorsDropdown.options[_hairColorsDropdown.value].text; Color val3 = default(Color); if (!ColorUtility.TryParseHtmlString(text3, ref val3)) { Logger.LogError((object)$"Failed to parse color {text3}, defaulting to {val3}"); } GUIManager instance = GUIManager.Instance; Vector2 val4 = new Vector2(0.5f, 0.5f); Vector2 val5 = new Vector2(0.5f, 0.5f); Vector2 val6 = new Vector2(0.5f, 0.5f); Color val7 = val3; object obj = <>c.<>9__13_6; if (obj == null) { ColorEvent val8 = delegate { }; <>c.<>9__13_6 = val8; obj = (object)val8; } ColorEvent obj2 = val2; if (obj2 == null) { ColorEvent val9 = delegate(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) string item = "#" + ColorUtility.ToHtmlStringRGB(color); List<string> hairs2 = GetHairs(container); hairs2.Add(item); SetHairs(container, hairs2); RefreshHairDropdown(container, hairs2.Count - 1); UpdateHairColorDisplay(_hairColorsDropdown.value); }; ColorEvent val10 = val9; val2 = val9; obj2 = val10; } instance.CreateColorPicker(val4, val5, val6, val7, "Choose a Hair Color", (ColorEvent)obj, obj2, false); }); ((UnityEvent)GUIManager.Instance.CreateButton("-", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(170f, 170f), 30f, 30f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate { if (_hairColorsDropdown.options.Count > 1) { string text2 = _hairColorsDropdown.options[_hairColorsDropdown.value].text; List<string> hairs = GetHairs(container); hairs.Remove(text2); SetHairs(container, hairs); RefreshHairDropdown(container); UpdateHairColorDisplay(_hairColorsDropdown.value); } }); GUIManager.Instance.CreateText("Female %:", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-150f, -180f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 120f, 30f, false); _chanceOfFemaleInputField = GUIManager.Instance.CreateInputField(_panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-40f, 130f), (ContentType)4, "50%", 16, 120f, 30f).GetComponent<InputField>(); _chanceOfFemaleInputField.characterLimit = 3; ((UnityEvent<string>)(object)_chanceOfFemaleInputField.onValueChanged).AddListener((UnityAction<string>)ChanceOfFemaleInputHandler); } string text = "Here you can configure the aesthetics of the mercenaries spawned by this chest. These settings are unique to this chest.\n\nMercenary creation costs:\n\nMiner: " + string.Join(", ", HumanMinerMinion.ItemsCost.Value) + "\nWoodcutter: " + string.Join(", ", HumanWoodcutterMinion.ItemsCost.Value) + "\nWarrior I: " + string.Join(", ", MercenaryWarriorTier1Minion.ItemsCost.Value) + "\nWarrior II: " + string.Join(", ", MercenaryWarriorTier2Minion.ItemsCost.Value) + "\nWarrior III: " + string.Join(", ", MercenaryWarriorTier3Minion.ItemsCost.Value) + "\nWarrior IV: " + string.Join(", ", MercenaryWarriorTier4Minion.ItemsCost.Value) + "\nArcher I: " + string.Join(", ", MercenaryArcherTier1Minion.ItemsCost.Value) + "\nArcher II: " + string.Join(", ", MercenaryArcherTier2Minion.ItemsCost.Value) + "\nArcher III: " + string.Join(", ", MercenaryArcherTier3Minion.ItemsCost.Value) + "\nCatapult: " + string.Join(", ", CatapultMinion.ItemsCost.Value); GUIManager.Instance.CreateText(text, _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -470f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 500f, false); _lastContainer = container; RefreshSkinDropdown(container); RefreshHairDropdown(container); _skinColorsDropdown.value = 0; UpdateSkinColorDisplay(0); _hairColorsDropdown.value = 0; UpdateHairColorDisplay(0); _chanceOfFemaleInputField.text = GetGender(container); _panel.SetActive(true); } private static void ChanceOfFemaleInputHandler(string str) { if (!((Object)(object)_lastContainer == (Object)null) && int.TryParse(str, out var result)) { SetGender(_lastContainer, result.ToString()); } } public static void Hide() { if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } _lastContainer = null; } public static List<string> GetSkins(Container container) { string text = container.m_nview.GetZDO().GetString("ChebGonazMercSkin", ""); if (text == string.Empty) { container.m_nview.GetZDO().Set("ChebGonazMercSkin", "#FEF5E7,#F5CBA7,#784212,#F5B041"); text = "#FEF5E7,#F5CBA7,#784212,#F5B041"; } return text.Split(new char[1] { ',' }).ToList(); } private static void SetSkins(Container container, List<string> skins) { container.m_nview.GetZDO().Set("ChebGonazMercSkin", string.Join(",", skins)); } public static List<string> GetHairs(Container container) { string text = container.m_nview.GetZDO().GetString("ChebGonazMercHair", ""); if (text == string.Empty) { container.m_nview.GetZDO().Set("ChebGonazMercHair", "#F7DC6F,#935116,#AFABAB,#FF5733,#1C2833"); text = "#F7DC6F,#935116,#AFABAB,#FF5733,#1C2833"; } return text.Split(new char[1] { ',' }).ToList(); } private static void SetHairs(Container container, List<string> hairs) { container.m_nview.GetZDO().Set("ChebGonazMercHair", string.Join(",", hairs)); } public static string GetGender(Container container) { string text = container.m_nview.GetZDO().GetString("ChebGonazMercSex", ""); if (text == string.Empty) { container.m_nview.GetZDO().Set("ChebGonazMercSex", "50"); text = "50"; } return text; } private static void SetGender(Container container, string gender) { container.m_nview.GetZDO().Set("ChebGonazMercSex", gender); } private static void UpdateSkinColorDisplay(int unused) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) string text = _skinColorsDropdown.options[_skinColorsDropdown.value].text; Color val = default(Color); if (!ColorUtility.TryParseHtmlString(text, ref val)) { Logger.LogError((object)$"Failed to parse color {text}, defaulting to {val}"); } ((Graphic)_skinColorDisplay).color = val; } private static void UpdateHairColorDisplay(int unused) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) string text = _hairColorsDropdown.options[_hairColorsDropdown.value].text; Color val = default(Color); if (!ColorUtility.TryParseHtmlString(text, ref val)) { Logger.LogError((object)$"Failed to parse color {text}, defaulting to {val}"); } ((Graphic)_hairColorDisplay).color = val; } private static void RefreshSkinDropdown(Container container, int newIndex = 0) { _skinColorsDropdown.ClearOptions(); _skinColorsDropdown.AddOptions(GetSkins(container)); _skinColorsDropdown.value = newIndex; _skinColorsDropdown.RefreshShownValue(); } private static void RefreshHairDropdown(Container container, int newIndex = 0) { _hairColorsDropdown.ClearOptions(); _hairColorsDropdown.AddOptions(GetHairs(container)); _hairColorsDropdown.value = newIndex; _hairColorsDropdown.RefreshShownValue(); } } } namespace ChebsMercenaries.PvPOptions { public class PvPOptionsGUI { [CompilerGenerated] private static class <>O { public static UnityAction <0>__TogglePanel; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__7_1; public static UnityAction <>9__7_2; public static UnityAction <>9__7_0; internal void <TogglePanel>b__7_1() { if (_allyInput.text != string.Empty) { string text = _allyInput.text; if (!_unsavedFriends.Contains(text)) { _unsavedFriends.Add(text); } _alliesText.text = string.Join(", ", _unsavedFriends); _allyInput.text = string.Empty; } } internal void <TogglePanel>b__7_2() { if (_allyInput.text != string.Empty) { string text = _allyInput.text; if (_unsavedFriends.Contains(text)) { _unsavedFriends.Remove(text); } _alliesText.text = string.Join(", ", _unsavedFriends); _allyInput.text = string.Empty; } } internal void <TogglePanel>b__7_0() { PvPManager.UpdatePlayerFriendsDict(_unsavedFriends, (Player)null); TogglePanel(); } } private static GameObject _panel; private static Text _alliesText; private static InputField _allyInput; private static List<string> _unsavedFriends; public static ConfigEntry<KeyboardShortcut> OptionsKeyConfigEntry; public static ButtonConfig OptionsButton; public static void CreateConfigs(BaseUnityPlugin plugin, string pluginGuid) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown OptionsKeyConfigEntry = plugin.Config.Bind<KeyboardShortcut>("PvP Options (Client)", "PvPOpenOptions", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), new ConfigDescription("Open the mod PvP options window.", (AcceptableValueBase)null, Array.Empty<object>())); OptionsButton = new ButtonConfig { Name = "PvPOpenOptions", ShortcutConfig = OptionsKeyConfigEntry, HintToken = "PvPOpenOptions" }; InputManager.Instance.AddButton(pluginGuid, OptionsButton); } public static void TogglePanel() { //IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0173: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Expected O, but got Unknown if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } if (!Object.op_Implicit((Object)(object)_panel)) { if (GUIManager.Instance == null) { Logger.LogError((object)"GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Logger.LogError((object)"GUIManager CustomGUI is null"); return; } _panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 850f, 600f, false); _panel.SetActive(false); _panel.AddComponent<DragWindowCntrl>(); GUIManager.Instance.CreateText("PvP Options", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -50f), GUIManager.Instance.AveriaSerifBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 40f, false); List<string> playerFriends = PvPManager.GetPlayerFriends(); GUIManager.Instance.CreateText("PvP Allies:", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-250f, -100f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 200f, 30f, false); _alliesText = GUIManager.Instance.CreateText(string.Join(", ", playerFriends), _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -100f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 400f, 30f, false).GetComponentInChildren<Text>(); GUIManager.Instance.CreateText("Ally (case sensitive):", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-250f, -140f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 200f, 30f, false); _allyInput = GUIManager.Instance.CreateInputField(_panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 170f), (ContentType)0, "player", 16, 200f, 30f).GetComponentInChildren<InputField>(); _allyInput.characterValidation = (CharacterValidation)0; ButtonClickedEvent onClick = GUIManager.Instance.CreateButton("+", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(200f, 170f), 30f, 30f).GetComponent<Button>().onClick; object obj = <>c.<>9__7_1; if (obj == null) { UnityAction val = delegate { if (_allyInput.text != string.Empty) { string text2 = _allyInput.text; if (!_unsavedFriends.Contains(text2)) { _unsavedFriends.Add(text2); } _alliesText.text = string.Join(", ", _unsavedFriends); _allyInput.text = string.Empty; } }; <>c.<>9__7_1 = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ButtonClickedEvent onClick2 = GUIManager.Instance.CreateButton("-", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(260f, 170f), 30f, 30f).GetComponent<Button>().onClick; object obj2 = <>c.<>9__7_2; if (obj2 == null) { UnityAction val2 = delegate { if (_allyInput.text != string.Empty) { string text = _allyInput.text; if (_unsavedFriends.Contains(text)) { _unsavedFriends.Remove(text); } _alliesText.text = string.Join(", ", _unsavedFriends); _allyInput.text = string.Empty; } }; <>c.<>9__7_2 = val2; obj2 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); ButtonClickedEvent onClick3 = GUIManager.Instance.CreateButton("Cancel", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -250f), 250f, 60f).GetComponent<Button>().onClick; object obj3 = <>O.<0>__TogglePanel; if (obj3 == null) { UnityAction val3 = TogglePanel; <>O.<0>__TogglePanel = val3; obj3 = (object)val3; } ((UnityEvent)onClick3).AddListener((UnityAction)obj3); ButtonClickedEvent onClick4 = GUIManager.Instance.CreateButton("Save", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(250f, -250f), 250f, 60f).GetComponent<Button>().onClick; object obj4 = <>c.<>9__7_0; if (obj4 == null) { UnityAction val4 = delegate { PvPManager.UpdatePlayerFriendsDict(_unsavedFriends, (Player)null); TogglePanel(); }; <>c.<>9__7_0 = val4; obj4 = (object)val4; } ((UnityEvent)onClick4).AddListener((UnityAction)obj4); } bool flag = !_panel.activeSelf; _panel.SetActive(flag); _unsavedFriends = PvPManager.GetPlayerFriends().ToList(); _alliesText.text = string.Join(", ", _unsavedFriends); GUIManager.BlockInput(flag); } } } namespace ChebsMercenaries.Patches { [HarmonyPatch(typeof(Aoe), "OnHit")] internal class SharpStakesMinionPatch { [HarmonyPrefix] private static bool Prefix(Collider collider, Vector3 hitPoint, Aoe __instance) { ChebGonazMinion val = default(ChebGonazMinion); if (((Component)collider).TryGetComponent<ChebGonazMinion>(ref val)) { Piece componentInParent = ((Component)__instance).GetComponentInParent<Piece>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.IsPlacedByPlayer()) { __instance.m_damage.m_pierce = 0f; __instance.m_damageSelf = 0f; } } return true; } } public class BaseAIPatches { [HarmonyPatch(typeof(BaseAI))] private class BaseAIPatch { [HarmonyPatch("Follow")] [HarmonyPostfix] private static void Postfix(GameObject go, float dt, BaseAI __instance) { //IL_002d: 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_0086: Unknown result type (might be due to invalid IL or missing references) MercenaryMinion mercenaryMinion = default(MercenaryMinion); if (((Component)__instance).TryGetComponent<MercenaryMinion>(ref mercenaryMinion)) { bool flag = ((mercenaryMinion is HumanMinerMinion || mercenaryMinion is HumanWoodcutterMinion) ? true : false); float num = Vector3.Distance(go.transform.position, ((Component)__instance).transform.position); bool flag2 = (flag && num > 3f) || num > MercenaryMinion.RunDistance.Value; float num2 = (flag ? 0f : MercenaryMinion.FollowDistance.Value); if (num < num2) { __instance.StopMoving(); } else { __instance.MoveTo(dt, go.transform.position, 0f, flag2); } } } } [HarmonyPatch(typeof(BaseAI))] private class BaseAIPatch2 { [HarmonyPatch("IsEnemy", new Type[] { typeof(Character), typeof(Character) })] [HarmonyPostfix] private static void Postfix(Character a, Character b, ref bool __result) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null || !BasePlugin.PvPAllowed.Value) { return; } Faction faction = a.GetFaction(); Faction faction2 = b.GetFaction(); if ((int)faction != 0 || (int)faction2 != 0) { return; } ChebGonazMinion component = ((Component)a).GetComponent<ChebGonazMinion>(); ChebGonazMinion component2 = ((Component)b).GetComponent<ChebGonazMinion>(); string text = (((Object)(object)component != (Object)null) ? component.UndeadMinionMaster : null); string text2 = (((Object)(object)component2 != (Object)null) ? component2.UndeadMinionMaster : null); Player val2 = default(Player); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { bool num = text == ""; bool flag = text2 == ""; if (num || flag) { __result = false; } else if (text != text2) { bool flag2 = PvPManager.Friendly(text, text2); bool flag3 = PvPManager.Friendly(text2, text); __result = !(flag2 && flag3); } } else if ((Object)(object)component2 != (Object)null) { Player val = default(Player); if (((Component)a).TryGetComponent<Player>(ref val) && text2 != "" && text2 != val.GetPlayerName()) { bool flag4 = PvPManager.Friendly(val.GetPlayerName(), text2); __result = !flag4; } } else if ((Object)(object)component != (Object)null && ((Component)b).TryGetComponent<Player>(ref val2) && text != "" && text != val2.GetPlayerName()) { bool flag5 = PvPManager.Friendly(val2.GetPlayerName(), text); __result = !flag5; } } } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] internal class CharacterDrop_Patches { [HarmonyPrefix] private static void AddBonesToDropList(ref List<Drop> ___m_drops, CharacterDrop __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) MercenaryMinion mercenaryMinion = default(MercenaryMinion); if (!((Component)__instance).TryGetComponent<MercenaryMinion>(ref mercenaryMinion)) { return; } if ((int)MercenaryMinion.DropOnDeath.Value != 0 && MercenaryMinion.PackDropItemsIntoCargoCrate.Value) { ((ChebGonazMinion)mercenaryMinion).DepositIntoNearbyDeathCrate(__instance, 15f); } if (((ChebGonazMinion)mercenaryMinion).ItemsDropped) { Logger.LogInfo((object)"items dropped is true"); ___m_drops.RemoveAll((Drop a) => true); } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal class CharacterGetDamageModifiersPatch { [HarmonyPrefix] private static void Prefix(ref long sender, ref HitData hit, Character __instance) { HumanMinion humanMinion = default(HumanMinion); Humanoid val = default(Humanoid); if (((Component)__instance).TryGetComponent<HumanMinion>(ref humanMinion) && ((Component)__instance).TryGetComponent<Humanoid>(ref val)) { float num = 0f; num += ((val.m_chestItem != null) ? val.m_chestItem.m_shared.m_armor : 0f); num += ((val.m_legItem != null) ? val.m_legItem.m_shared.m_armor : 0f); num += ((val.m_helmetItem != null) ? val.m_helmetItem.m_shared.m_armor : 0f); hit.ApplyArmor(num); } } } [HarmonyPatch(typeof(ImpactEffect), "OnCollisionEnter")] internal class ImpactEffectPatch { private static bool Prefix(ref Collision info, ImpactEffect __instance) { MercenaryMinion mercenaryMinion = default(MercenaryMinion); if (info.gameObject.TryGetComponent<MercenaryMinion>(ref mercenaryMinion)) { return false; } return true; } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal class InventoryGuiPatch { [HarmonyPostfix] private static void Postfix(Container container, int activeGroup) { if ((Object)(object)container != (Object)null && ((Object)container).name.Contains("ChebGonaz_MercenaryChest")) { MercenaryChestOptionsGUI.Show(container); } } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal class InventoryGuiPatch2 { [HarmonyPostfix] private static void Postfix(InventoryGui __instance) { MercenaryChestOptionsGUI.Hide(); } } [HarmonyPatch(typeof(MonsterAI))] internal class MonsterAIPatch1 { [HarmonyPatch("UpdateTarget")] [HarmonyPostfix] private static void Postfix(MonsterAI __instance, Humanoid humanoid, float dt, ref bool canHearTarget, ref bool canSeeTarget) { CatapultMinion catapultMinion = default(CatapultMinion); Piece val = default(Piece); if (!__instance.m_attackPlayerObjects || !((Object)(object)__instance.m_targetStatic != (Object)null) || !((Component)__instance).TryGetComponent<CatapultMinion>(ref catapultMinion) || !BasePlugin.PvPAllowed.Value || !((Component)__instance.m_targetStatic).TryGetComponent<Piece>(ref val)) { return; } long structureCreator = val.m_creator; Player val2 = Player.s_players.Find((Player p) => p.GetPlayerID() == structureCreator); if ((Object)(object)val2 != (Object)null) { string undeadMinionMaster = ((ChebGonazMinion)catapultMinion).UndeadMinionMaster; string playerName = val2.GetPlayerName(); bool num = PvPManager.Friendly(undeadMinionMaster, playerName); bool flag = PvPManager.Friendly(playerName, undeadMinionMaster); if (num && flag) { __instance.m_targetStatic = null; } } } } [HarmonyPatch(typeof(Tameable), "Interact")] internal class TameablePatch1 { [HarmonyPrefix] private static bool InteractPrefix(Humanoid user, bool hold, bool alt, Tameable __instance) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0070: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) MercenaryMinion mercenaryMinion = default(MercenaryMinion); Player val = default(Player); if (((Component)__instance).TryGetComponent<MercenaryMinion>(ref mercenaryMinion) && ((Component)user).TryGetComponent<Player>(ref val)) { if (((ChebGonazMinion)mercenaryMinion).UndeadMinionMaster == "") { ((ChebGonazMinion)mercenaryMinion).UndeadMinionMaster = val.GetPlayerName(); } if (!((ChebGonazMinion)mercenaryMinion).BelongsToPlayer(val.GetPlayerName())) { ((Character)user).Message((MessageType)2, "$chebgonaz_mercenaries_notyourminion", 0, (Sprite)null); return false; } if (!MercenaryMinion.Commandable.Value) { return false; } State status = ((ChebGonazMinion)mercenaryMinion).Status; State val2 = (((int)status == 0) ? ((State)1) : (((int)status != 2) ? ((State)2) : ((State)0))); State val3 = val2; if (((object)(State)(ref val3)).Equals((object)(State)2)) { ((Character)user).Message((MessageType)2, "$chebgonaz_mercenaries_humanfollowing", 0, (Sprite)null); ((ChebGonazMinion)mercenaryMinion).Follow(((Component)val).gameObject); return false; } if (((object)(State)(ref val3)).Equals((object)(State)0)) { ((Character)user).Message((MessageType)2, "$chebgonaz_mercenaries_humanwaiting", 0, (Sprite)null); ((ChebGonazMinion)mercenaryMinion).Wait(((Component)val).transform.position); return false; } ((Character)user).Message((MessageType)2, "$chebgonaz_mercenaries_humanroaming", 0, (Sprite)null); ((ChebGonazMinion)mercenaryMinion).Roam(); return false; } return true; } } [HarmonyPatch(typeof(Tameable))] internal class TameablePatch2 { [HarmonyPatch("GetHoverText")] [HarmonyPostfix] private static void Postfix(Tameable __instance, ref string __result) { //IL_002d: 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_0033: 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_0038: Invalid comparison between Unknown and I4 MercenaryMinion mercenaryMinion = default(MercenaryMinion); if (__instance.m_nview.IsValid() && __instance.m_commandable && ((Component)__instance).TryGetComponent<MercenaryMinion>(ref mercenaryMinion) && (Object)(object)Player.m_localPlayer != (Object)null) { State status = ((ChebGonazMinion)mercenaryMinion).Status; string text = (((int)status == 0) ? Localization.instance.Localize("$chebgonaz_mercenaries_roam") : (((int)status != 2) ? Localization.instance.Localize("$chebgonaz_mercenaries_follow") : Localization.instance.Localize("$chebgonaz_mercenaries_wait"))); __result = text; } } } [HarmonyPatch(typeof(Tameable))] internal class TameablePatch3 { [HarmonyPatch("GetHoverName")] [HarmonyPostfix] private static void Postfix(Tameable __instance, ref string __result) { //IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 MercenaryMinion mercenaryMinion = default(MercenaryMinion); if (__instance.m_nview.IsValid() && ((Component)__instance).TryGetComponent<MercenaryMinion>(ref mercenaryMinion)) { string text = Localization.instance.Localize("$chebgonaz_mercenaries_owner"); string undeadMinionMaster = ((ChebGonazMinion)mercenaryMinion).UndeadMinionMaster; State status = ((ChebGonazMinion)mercenaryMinion).Status; string text2 = (((int)status == 1) ? Localization.instance.Localize("$chebgonaz_minionstatus_roaming") : (((int)status != 2) ? Localization.instance.Localize("$chebgonaz_minionstatus_waiting") : Localization.instance.Localize("$chebgonaz_minionstatus_following"))); __result = text + ": " + undeadMinionMaster + " (" + text2 + ")"; } } } [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] internal class VisEquipmentPatch1 { [HarmonyPostfix] private static void UpdateVisualsPostfix(VisEquipment __instance) { if (((Object)((Component)__instance).gameObject).name.StartsWith("ChebGonaz_Human")) { __instance.UpdateBaseModel(); __instance.UpdateColors(); } } } [HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")] internal class VisEquipmentPatch2 { [HarmonyPostfix] private static void Postfix(VisEquipment __instance) { //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)((Component)__instance).gameObject).name.StartsWith("ChebGonaz_Human")) { return; } int num = 0; int rightHandEquipped = 0; int chestEquipped = 0; int legEquipped = 0; int num2 = 0; int beardEquipped = 0; int num3 = 0; int num4 = 0; int utilityEquipped = 0; int num5 = 0; int num6 = 0; int num7 = __instance.m_shoulderItemVariant; int num8 = __instance.m_leftItemVariant; int num9 = __instance.m_leftBackItemVariant; ZDO zDO = __instance.m_nview.GetZDO(); if (zDO != null) { num = zDO.GetInt("LeftItem", 0); rightHandEquipped = zDO.GetInt("RightItem", 0); chestEquipped = zDO.GetInt("ChestItem", 0); legEquipped = zDO.GetInt("LegItem", 0); num2 = zDO.GetInt("HelmetItem", 0); num4 = zDO.GetInt("ShoulderItem", 0); utilityEquipped = zDO.GetInt("UtilityItem", 0); beardEquipped = zDO.GetInt("BeardItem", 0); num3 = zDO.GetInt("HairItem", 0); num5 = zDO.GetInt("LeftBackItem", 0); num6 = zDO.GetInt("RightBackItem", 0); num7 = zDO.GetInt("ShoulderItemVariant", 0); num8 = zDO.GetInt("LeftItemVariant", 0); num9 = zDO.GetInt("LeftBackItemVariant", 0); } else { if (!string.IsNullOrEmpty(__instance.m_leftItem)) { num = StringExtensionMethods.GetStableHashCode(__instance.m_leftItem); } if (!string.IsNullOrEmpty(__instance.m_rightItem)) { rightHandEquipped = StringExtensionMethods.GetStableHashCode(__instance.m_rightItem); } if (!string.IsNullOrEmpty(__instance.m_chestItem)) { chestEquipped = StringExtensionMethods.GetStableHashCode(__instance.m_chestItem); } if (!string.IsNullOrEmpty(__instance.m_legItem)) { legEquipped = StringExtensionMethods.GetStableHashCode(__instance.m_legItem); } if (!string.IsNullOrEmpty(__instance.m_helmetItem)) { num2 = StringExtensionMethods.GetStableHashCode(__instance.m_helmetItem); } if (!string.IsNullOrEmpty(__instance.m_shoulderItem)) { num4 = StringExtensionMethods.GetStableHashCode(__instance.m_shoulderItem); } if (!string.IsNullOrEmpty(__instance.m_utilityItem)) { utilityEquipped = StringExtensionMethods.GetStableHashCode(__instance.m_utilityItem); } if (!string.IsNullOrEmpty(__instance.m_beardItem)) { beardEquipped = StringExtensionMethods.GetStableHashCode(__instance.m_beardItem); } if (!string.IsNullOrEmpty(__instance.m_hairItem)) { num3 = StringExtensionMethods.GetStableHashCode(__instance.m_hairItem); } if (!string.IsNullOrEmpty(__instance.m_leftBackItem)) { num5 = StringExtensionMethods.GetStableHashCode(__instance.m_leftBackItem); } if (!string.IsNullOrEmpty(__instance.m_rightBackItem)) { num6 = StringExtensionMethods.GetStableHashCode(__instance.m_rightBackItem); } } bool flag = false; bool flag2 = __instance.SetRightHandEquipped(rightHandEquipped) || flag; bool flag3 = __instance.SetLeftHandEquipped(num, num8) || flag2; bool flag4 = __instance.SetChestEquipped(chestEquipped) || flag3; bool flag5 = __instance.SetLegEquipped(legEquipped) || flag4; bool flag6 = __instance.SetHelmetEquipped(num2, num3) || flag5; bool flag7 = __instance.SetShoulderEquipped(num4, num7) || flag6; bool flag8 = __instance.SetUtilityEquipped(utilityEquipped) || flag7; if ((int)__instance.m_helmetHideBeard != 0) { beardEquipped = 0; } bool flag9 = __instance.SetBeardEquipped(beardEquipped) || flag8; bool flag10 = __instance.SetBackEquipped(num5, num6, num9) || flag9; if ((int)__instance.m_helmetHideHair != 0) { num3 = 0; } if (__instance.SetHairEquipped(num3) || flag10) { __instance.UpdateLodgroup(); } } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] internal class ArrowImpactPatch { private static void Prefix(ref HitData hit, Piece ___m_piece) { if (hit != null) { Character attacker = hit.GetAttacker(); MercenaryMinion mercenaryMinion = default(MercenaryMinion); if ((Object)(object)attacker != (Object)null && ((Component)attacker).TryGetComponent<MercenaryMinion>(ref mercenaryMinion) && (Object)(object)___m_piece != (Object)null && ___m_piece.IsPlacedByPlayer()) { hit.m_damage.m_damage = 0f; hit.m_damage.m_blunt = 0f; hit.m_damage.m_slash = 0f; hit.m_damage.m_pierce = 0f; hit.m_damage.m_chop = 0f; hit.m_damage.m_pickaxe = 0f; hit.m_damage.m_fire = 0f; hit.m_damage.m_frost = 0f; hit.m_damage.m_lightning = 0f; hit.m_damage.m_poison = 0f; hit.m_damage.m_spirit = 0f; } } } } [HarmonyPatch] public class ZNetScenePatches { [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPostfix] public static void ZNetScenePatch(ZNetScene __instance) { GameObject prefab = __instance.GetPrefab("Player"); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)"ZNetScenePatches: Failed to get player prefab. Armor may not displaycorrectly on mercenaries."); return; } VisEquipment val = default(VisEquipment); if (!prefab.TryGetComponent<VisEquipment>(ref val)) { Logger.LogError((object)"ZNetScenePatches: Failed to get Player's VisEquipment component. Armor may not display correctly on mercenaries."); return; } Material male = val.m_models[0].m_baseMaterial; Material female = val.m_models[1].m_baseMaterial; BasePlugin.MercenaryPrefabPaths.ForEach(delegate(string prefabFileName) { if (!(prefabFileName == "ChebGonaz_Catapult.prefab")) { string text = prefabFileName.Replace(".prefab", ""); GameObject prefab2 = __instance.GetPrefab(text); VisEquipment val2 = default(VisEquipment); if ((Object)(object)prefab2 == (Object)null) { Logger.LogError((object)("ZNetScenePatches: Failed to get " + text + ". Armor may not displaycorrectly on mercenaries.")); } else if (!prefab2.TryGetComponent<VisEquipment>(ref val2)) { Logger.LogError((object)("ZNetScenePatches: Failed to get " + text + "'s VisEquipment component. Armor may not display correctly on mercenaries.")); } else { ((Renderer)val2.m_bodyModel).material = (text.Contains("Female") ? female : male); } } }); } } } namespace ChebsMercenaries.Minions { internal class CatapultMinion : MercenaryMinion { public new static ConfigEntry<float> Health; public static MemoryConfigEntry<string, List<string>> ItemsCost; public new static void CreateConfigs(BasePlugin plugin) { //IL_006d: 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_007a: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown ItemsCost = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig("CatapultMinion (Server Synced)", "ItemsCost", "Wood:25,RoundLog:5,Bronze:1", "The items that are consumed when creating a minion. Please use a comma-delimited list of prefab names with a : and integer for amount. Alternative items can be specified with a | eg. Wood|Coal:5 to mean wood and/or coal.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' }) select str.Trim()).ToList())); Health = ((BaseUnityPlugin)plugin).Config.Bind<float>("CatapultMinion (Server Synced)", "Health", 250f, new ConfigDescription("How much health the mercenary has.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } public sealed override void Awake() { ((ChebGonazMinion)this).Awake(); AfterAwake(); } public virtual void AfterAwake() { ConfigureHealth(); } protected virtual void ConfigureHealth() { Humanoid val = default(Humanoid); if (((Component)this).TryGetComponent<Humanoid>(ref val)) { ((Character)val).SetMaxHealth(Health.Value); ((Character)val).SetHealth(Health.Value); } else { Logger.LogError((object)"Error: Failed to get Humanoid component to set health value."); } } public static void Spawn(Transform spawner) { //IL_0044: 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_0054: 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_005e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Invalid comparison between Unknown and I4 if ((Object)(object)ZNetScene.instance == (Object)null) { Logger.LogWarning((object)"Spawn: ZNetScene.instance is null, trying again later..."); return; } GameObject prefab = ZNetScene.instance.GetPrefab(MercenaryMinion.PrefabNames[MercenaryType.Catapult]); if (!Object.op_Implicit((Object)(object)prefab)) { Logger.LogError((object)"Spawn: spawning catapult failed - can't find prefab"); return; } GameObject val = Object.Instantiate<GameObject>(prefab, spawner.position + spawner.forward * 2f + Vector3.up, Quaternion.identity); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Spawn: spawnedChar is null"); return; } val.AddComponent<FreshMinion>(); ChebGonazMinion val2 = default(ChebGonazMinion); if (!val.TryGetComponent<ChebGonazMinion>(ref val2)) { Logger.LogError((object)"Spawn: spawnedChar has no ChebGonazMinion component"); return; } val2.Roam(); if ((int)MercenaryMinion.DropOnDeath.Value != 0) { CharacterDrop val3 = val.AddComponent<CharacterDrop>(); if ((int)MercenaryMinion.DropOnDeath.Value == 2) { ChebGonazMinion.GenerateDeathDrops(val3, ItemsCost); } val2.RecordDrops(val3); } } } public class HumanMinerMinion : HumanMinion { public static ConfigEntry<float> UpdateDelay; public static ConfigEntry<float> LookRadius; public static ConfigEntry<float> ToolDamage; public static ConfigEntry<float> ChatInterval; public static ConfigEntry<float> ChatDistance; public static ConfigEntry<short> ToolTier; public new static ConfigEntry<float> RoamRange; public new static ConfigEntry<float> Health; public static ConfigEntry<string> RockInternalIDsList; public static MemoryConfigEntry<string, List<string>> ItemsCost; private const string DefaultOresList = "rock1_mistlands,rock1_mountain,rock1_mountain_frac,rock2_heath,rock2_heath_frac,rock2_mountain,rock2_mountain_frac,Rock_3,Rock_3_frac,rock3_mountain,rock3_mountain_frac,rock3_silver,rock3_silver_frac,Rock_4,Rock_4_plains,rock4_coast,rock4_coast_frac,rock4_copper,rock4_copper_frac,rock4_forest,rock4_forest_frac,rock4_heath,rock4_heath_frac,Rock_7,Rock_destructible,rock_mistlands1,rock_mistlands1_frac,rock_mistlands2,RockDolmen_1,RockDolmen_2,RockDolmen_3,silvervein,silvervein_frac,MineRock_Tin,MineRock_Obsidian"; public new static void CreateConfigs(BasePlugin plugin) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01f0: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown //IL_0261: 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_026e: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Expected O, but got Unknown UpdateDelay = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "UpdateDelay", 6f, new ConfigDescription("The delay, in seconds, between rock/ore searching attempts. Attention: small values may impact performance.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); LookRadius = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "LookRadius", 50f, new ConfigDescription("How far it can see rock/ore. High values may damage performance.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RoamRange = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "RoamRange", 50f, new ConfigDescription("How far it will randomly run to in search of rock/ore.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RockInternalIDsList = ((BaseUnityPlugin)plugin).Config.Bind<string>("HumanMiner (Server Synced)", "RockInternalIDsList", "rock1_mistlands,rock1_mountain,rock1_mountain_frac,rock2_heath,rock2_heath_frac,rock2_mountain,rock2_mountain_frac,Rock_3,Rock_3_frac,rock3_mountain,rock3_mountain_frac,rock3_silver,rock3_silver_frac,Rock_4,Rock_4_plains,rock4_coast,rock4_coast_frac,rock4_copper,rock4_copper_frac,rock4_forest,rock4_forest_frac,rock4_heath,rock4_heath_frac,Rock_7,Rock_destructible,rock_mistlands1,rock_mistlands1_frac,rock_mistlands2,RockDolmen_1,RockDolmen_2,RockDolmen_3,silvervein,silvervein_frac,MineRock_Tin,MineRock_Obsidian", new ConfigDescription("The types of rock the miner will attempt to mine. Internal IDs only.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ItemsCost = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig("HumanMiner (Server Synced)", "ItemsCost", "CookedMeat|Coins:5,HardAntler:1", "The items that are consumed when creating a minion. Please use a comma-delimited list of prefab names with a : and integer for amount. Alternative items can be specified with a | eg. Wood|Coal:5 to mean wood and/or coal.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' }) select str.Trim()).ToList())); Health = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "Health", 50f, new ConfigDescription("How much health the mercenary has.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ToolDamage = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "ToolDamage", 6f, new ConfigDescription("Damage dealt by the worker's tool to stuff it's harvesting.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ToolTier = ((BaseUnityPlugin)plugin).Config.Bind<short>("HumanMiner (Server Synced)", "ToolTier", (short)2, new ConfigDescription("Worker's tool tier (determines what stuff it can mine/harvest).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ChatInterval = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "ChatInterval", 6f, new ConfigDescription("The delay, in seconds, between worker updates. Set to 0 for no chatting.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ChatDistance = ((BaseUnityPlugin)plugin).Config.Bind<float>("HumanMiner (Server Synced)", "ChatDistance", 6f, new ConfigDescription("How close a player must be for the worker to speak.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } public override void AfterAwake() { ConfigureHealth(); ((ChebGonazMinion)this).canBeCommanded = false; HumanMinerAI humanMinerAI = default(HumanMinerAI); if (!((Component)this).TryGetComponent<HumanMinerAI>(ref humanMinerAI)) { ((Component)this).gameObject.AddComponent<HumanMinerAI>(); } } protected override void ConfigureHealth() { Humanoid val = default(Humanoid); if (((Component)this).TryGetComponent<Humanoid>(ref val)) { ((Character)val).SetMaxHealth(Health.Value); ((Character)val).SetHealth(Health.Value); } else { Logger.LogError((object)"Error: Failed to get Humanoid component to set health value."); } } } public class HumanMinion : MercenaryMinion { private static List<ItemDrop> _hairs; private static List<ItemDrop> _beards; public sealed override void Awake() { ((ChebGonazMinion)this).Awake(); if (_hairs == null) { _hairs = ObjectDB.instance.GetAllItems((ItemType)10, "Hair"); } if (_beards == null) { _beards = ObjectDB.instance.GetAllItems((ItemType)10, "Beard"); } ((MonoBehaviour)this).StartCoroutine(WaitForZNet()); AfterAwake(); } public virtual void AfterAwake() { ConfigureHealth(); } protected virtual void ConfigureHealth() { Humanoid val = default(Humanoid); if (((Component)this).TryGetComponent<Humanoid>(ref val)) { ((Character)val).SetMaxHealth(MercenaryMinion.Health.Value); ((Character)val).SetHealth(MercenaryMinion.Health.Value); } else { Logger.LogError((object)"Error: Failed to get Humanoid component to set health value."); } } protected IEnumerator WaitForZNet() { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ZNetScene.instance != (Object)null)); Humanoid humanoid = default(Humanoid); if (!((Component)this).TryGetComponent<Humanoid>(ref humanoid)) { Logger.LogError((object)"Humanoid component missing!"); yield break; } List<int> list = new List<int>(); list.Add(humanoid.m_visEquipment.m_currentChestItemHash); list.Add(humanoid.m_visEquipment.m_currentLegItemHash); list.Add(humanoid.m_visEquipment.m_currentHelmetItemHash); list.ForEach(delegate(int hash) { GameObject prefab = ZNetScene.instance.GetPrefab(hash); if ((Object)(object)prefab != (Object)null) { humanoid.GiveDefaultItem(prefab); } }); MonsterAI val = default(MonsterAI); if (((Component)this).TryGetComponent<MonsterAI>(ref val)) { ((BaseAI)val).m_randomMoveRange = MercenaryMinion.RoamRange.Value; } else { Logger.LogWarning((object)(((Object)((Component)this).gameObject).name + ": Failed to set roam range: no MonsterAI component.")); } ((ChebGonazMinion)this).RestoreDrops(); if (BasePlugin.HeavyLogging.Value) { Logger.LogInfo((object)$"Health set for {((Object)((Component)this).gameObject).name}: humanoid.m_health={((Character)humanoid).m_health}"); } } public void ScaleEquipment(MercenaryType mercenaryType, ArmorType armorType) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected I4, but got Unknown //IL_0304: Unknown result type (might be due to invalid IL or missing references) List<GameObject> list = new List<GameObject>(); Humanoid component = ((Component)this).GetComponent<Humanoid>(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)"ScaleEquipment: humanoid is null!"); return; } switch (armorType - 1) { case 0: list.AddRange((IEnumerable<GameObject>)(object)new GameObject[4] { ZNetScene.instance.GetPrefab("HelmetLeather"), ZNetScene.instance.GetPrefab("ArmorLeatherChest"), ZNetScene.instance.GetPrefab("ArmorLeatherLegs"), ZNetScene.instance.GetPrefab("CapeDeerHide") }); break; case 1: list.AddRange((IEnumerable<GameObject>)(object)new GameObject[4] { ZNetScene.instance.GetPrefab("ChebGonaz_HelmetLeatherTroll"), ZNetScene.instance.GetPrefab("ChebGonaz_ArmorLeatherChestTroll"), ZNetScene.instance.GetPrefab("ChebGonaz_ArmorLeatherLegsTroll"), ZNetScene.instance.GetPrefab("CapeTrollHide") }); break; case 2: list.AddRange((IEnumerable<GameObject>)(object)new GameObject[4] { ZNetScene.instance.GetPrefab("ChebGonaz_HelmetLeatherWolf"), ZNetScene.instance.GetPrefab("ChebGonaz_ArmorLeatherChestWolf"), ZNetScene.instance.GetPrefab("ChebGonaz_ArmorLeatherLegsWolf"), ZNetScene.instance.GetPrefab("CapeWolf") }); break; case 3: li