Decompiled source of Deadheim v11.0.4
Combat.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Combat { public class Patches { [HarmonyPatch(typeof(Character), "ApplyDamage")] public static class ApplyDamage { public static int combatHashCode = StringExtensionMethods.GetStableHashCode("Combat"); public static void Postfix(Character __instance, HitData hit) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)hit.GetAttacker())) { return; } StatusEffect statusEffect = ObjectDB.m_instance.GetStatusEffect(combatHashCode); statusEffect.m_ttl = Combat.BuffSeconds.Value; if (Combat.ActivateOnlyForPVP.Value && (!hit.GetAttacker().IsPlayer() || !__instance.IsPlayer())) { return; } if (hit.GetAttacker().IsPlayer()) { Player val = (Player)hit.GetAttacker(); if (((Character)val).GetSEMan().HaveStatusEffect("Combat")) { ((Character)val).GetSEMan().RemoveStatusEffect(combatHashCode, false); } ((Character)val).GetSEMan().AddStatusEffect(statusEffect, false, 0, 0f); } if (__instance.IsPlayer()) { Player val2 = (Player)__instance; if (((Character)val2).GetSEMan().HaveStatusEffect("Combat")) { ((Character)val2).GetSEMan().RemoveStatusEffect(combatHashCode, false); } ((Character)val2).GetSEMan().AddStatusEffect(statusEffect, false, 0, 0f); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ConsumeItem { private static void Postfix(ObjectDB __instance) { __instance.m_StatusEffects.Add((StatusEffect)(object)StatusEffects.CreateStatusEffect("Combat", "Combat", ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_player_32")))); } } [HarmonyPatch(typeof(Humanoid), "IsTeleportable")] public static class IsTeleportable { private static bool Prefix(Humanoid __instance) { if (!Combat.PreventTeleport.Value) { return true; } if (!((Character)__instance).GetSEMan().HaveStatusEffect("Combat")) { return true; } ((Character)__instance).Message((MessageType)2, "You can't teleport in Combat", 0, (Sprite)null); return false; } } } [BepInPlugin("Detalhes.Combat", "Detalhes.Combat", "1.0.0")] public class Combat : BaseUnityPlugin { public const string PluginGUID = "Detalhes.Combat"; public const string Name = "Combat"; public const string Version = "1.0.0"; private ConfigSync configSync = new ConfigSync("Detalhes.Combat") { DisplayName = "Combat", CurrentVersion = "1.0.0", MinimumRequiredVersion = "1.0.0" }; private Harmony _harmony = new Harmony("Detalhes.Combat"); public static ConfigEntry<int> BuffSeconds; public static ConfigEntry<bool> ActivateOnlyForPVP; public static ConfigEntry<bool> PreventTeleport; public void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown BuffSeconds = config("Server config", "BuffSeconds", 30, new ConfigDescription("BuffSeconds", (AcceptableValueBase)null, Array.Empty<object>())); ActivateOnlyForPVP = config("Server config", "ActivateOnlyForPVP", value: false, new ConfigDescription("ActivateOnlyForPVP", (AcceptableValueBase)null, Array.Empty<object>())); PreventTeleport = config("Server config", "PreventTeleport", value: true, new ConfigDescription("PreventTeleport", (AcceptableValueBase)null, Array.Empty<object>())); _harmony.PatchAll(); } private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } } public class StatusEffects { public static SE_Stats CreateStatusEffect(string effectName, string m_name, Sprite icon) { SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = effectName; ((StatusEffect)val).m_name = m_name; ((StatusEffect)val).m_tooltip = m_name; ((StatusEffect)val).m_icon = icon; return val; } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 ServerSync { [PublicAPI] internal abstract class OwnConfigEntryBase { public object? LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] internal class SyncedConfigEntry<T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } internal abstract class CustomSyncedValueBase { public object? LocalBaseValue; public readonly string Identifier; public readonly Type Type; private object? boxedValue; protected bool localIsOwner; public readonly int Priority; public object? BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action? ValueChanged; protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [PublicAPI] internal class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { public static ZRpc? currentRpc; [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } static IEnumerator WatchAdminListChanges() { SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = (from p in ZNet.instance.GetPeers() where adminList.Contains(p.m_rpc.GetSocket().GetHostName()) select p).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } private class ParsedConfigs { public readonly Dictionary<OwnConfigEntryBase, object?> configValues = new Dictionary<OwnConfigEntryBase, object>(); public readonly Dictionary<CustomSyncedValueBase, object?> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private class SendConfigsAfterLogin { private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ref Dictionary<Assembly, BufferingSocket>? __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZRpc rpc2 = rpc; ZNet __instance2 = __instance; Dictionary<Assembly, BufferingSocket> __state2 = __state; ZNetPeer peer; if (__instance2.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance2).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc2.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc2, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state2[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc2.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc2.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select((OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance2).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } private class PackageEntry { public string section = null; public string key = null; public Type type = null; public object? value; } [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] private static class PreventSavingServerInfo { [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, ref string __result) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase)) { return true; } __result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType); return false; } } [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] private static class PreventConfigRereadChangingValues { [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, string value) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null) { return true; } try { ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType); } catch (Exception ex) { Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}"); } return false; } } private class InvalidDeserializationTypeException : Exception { public string expected = null; public string received = null; public string field = ""; } public static bool ProcessingServerUpdate; public readonly string Name; public string? DisplayName; public string? CurrentVersion; public string? MinimumRequiredVersion; public bool ModRequired = false; private bool? forceConfigLocking; private bool isSourceOfTruth = true; private static readonly HashSet<ConfigSync> configSyncs; private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>(); private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>(); private static bool isServer; private static bool lockExempt; private OwnConfigEntryBase? lockedConfig = null; private const byte PARTIAL_CONFIGS = 1; private const byte FRAGMENTED_CONFIG = 2; private const byte COMPRESSED_CONFIG = 4; private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>(); private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>(); private static long packageCounter; public bool IsLocked { get { bool? flag = forceConfigLocking; bool num; if (!flag.HasValue) { if (lockedConfig == null) { goto IL_0052; } num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0; } else { num = flag.GetValueOrDefault(); } if (!num) { goto IL_0052; } int result = ((!lockExempt) ? 1 : 0); goto IL_0053; IL_0053: return (byte)result != 0; IL_0052: result = 0; goto IL_0053; } set { forceConfigLocking = value; } } public bool IsAdmin => lockExempt || isSourceOfTruth; public bool IsSourceOfTruth { get { return isSourceOfTruth; } private set { if (value != isSourceOfTruth) { isSourceOfTruth = value; this.SourceOfTruthChanged?.Invoke(value); } } } public bool InitialSyncDone { get; private set; } = false; public event Action<bool>? SourceOfTruthChanged; private event Action? lockedConfigChanged; static ConfigSync() { ProcessingServerUpdate = false; configSyncs = new HashSet<ConfigSync>(); lockExempt = false; packageCounter = 0L; RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle); } public ConfigSync(string name) { Name = name; configSyncs.Add(this); new VersionCheck(this); } public SyncedConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry) { ConfigEntry<T> configEntry2 = configEntry; OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry2); SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>; if (syncedEntry == null) { syncedEntry = new SyncedConfigEntry<T>(configEntry2); AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry2).Description, new object[1] { new ConfigurationManagerAttributes() }.Concat(((ConfigEntryBase)configEntry2).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray()); configEntry2.SettingChanged += delegate { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry2); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) { throw new Exception("Cannot initialize locking ConfigEntry twice"); } lockedConfig = AddConfigEntry<T>(lockingConfig); lockingConfig.SettingChanged += delegate { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { CustomSyncedValueBase customValue2 = customValue; if (allCustomValues.Select((CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue2.Identifier)) { throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)"); } allCustomValues.Add(customValue2); allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending((CustomSyncedValueBase v) => v.Priority)); customValue2.ValueChanged += delegate { if (!ProcessingServerUpdate) { Broadcast(ZRoutedRpc.Everybody, customValue2); } }; } private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package) { lockedConfigChanged += serverLockedSettingChanged; IsSourceOfTruth = false; if (HandleConfigSyncRPC(0L, package, clientUpdate: false)) { InitialSyncDone = true; } } private void RPC_FromOtherClientConfigSync(long sender, ZPackage package) { HandleConfigSyncRPC(sender, package, clientUpdate: true); } private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown try { if (isServer && IsLocked) { ZRpc? currentRpc = SnatchCurrentlyHandlingRPC.currentRpc; object obj; if (currentRpc == null) { obj = null; } else { ISocket socket = currentRpc.GetSocket(); obj = ((socket != null) ? socket.GetHostName() : null); } string text = (string)obj; if (text != null) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text })))) { return false; } } } cacheExpirations.RemoveAll(delegate(KeyValuePair<long, string> kv) { if (kv.Key < DateTimeOffset.Now.Ticks) { configValueCache.Remove(kv.Value); return true; } return false; }); byte b = package.ReadByte(); if ((b & 2u) != 0) { long num = package.ReadLong(); string text2 = sender.ToString() + num; if (!configValueCache.TryGetValue(text2, out SortedDictionary<int, byte[]> value)) { value = new SortedDictionary<int, byte[]>(); configValueCache[text2] = value; cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2)); } int key = package.ReadInt(); int num2 = package.ReadInt(); value.Add(key, package.ReadByteArray()); if (value.Count < num2) { return false; } configValueCache.Remove(text2); package = new ZPackage(value.Values.SelectMany((byte[] a) => a).ToArray()); b = package.ReadByte(); } ProcessingServerUpdate = true; if ((b & 4u) != 0) { byte[] buffer = package.ReadByteArray(); MemoryStream stream = new MemoryStream(buffer); MemoryStream memoryStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } package = new ZPackage(memoryStream.ToArray()); b = package.ReadByte(); } if ((b & 1) == 0) { resetConfigsFromServer(); } ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package); foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues) { if (!isServer && configValue.Key.LocalBaseValue == null) { configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue; } configValue.Key.BaseConfig.BoxedValue = configValue.Value; } foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues) { if (!isServer) { CustomSyncedValueBase key2 = customValue.Key; if (key2.LocalBaseValue == null) { key2.LocalBaseValue = customValue.Key.BoxedValue; } } customValue.Key.BoxedValue = customValue.Value; } Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name)); if (!isServer) { serverLockedSettingChanged(); } return true; } finally { ProcessingServerUpdate = false; } } private ParsedConfigs ReadConfigsFromPackage(ZPackage package) { ParsedConfigs parsedConfigs = new ParsedConfigs(); Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where((OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary((OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary((CustomSyncedValueBase c) => c.Identifier, (CustomSyncedValueBase c) => c); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string text = package.ReadString(); string text2 = package.ReadString(); string text3 = package.ReadString(); Type type = Type.GetType(text3); if (text3 == "" || type != null) { object obj; try { obj = ((text3 == "") ? null : ReadValueWithTypeFromZPackage(package, type)); } catch (InvalidDeserializationTypeException ex) { Debug.LogWarning((object)("Got unexpected struct internal type " + ex.received + " for field " + ex.field + " struct " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + ex.expected)); continue; } OwnConfigEntryBase value2; if (text == "Internal") { CustomSyncedValueBase value; if (text2 == "serverversion") { if (obj?.ToString() != CurrentVersion) { Debug.LogWarning((object)("Received server version is not equal: server version = " + (obj?.ToString() ?? "null") + "; local version = " + (CurrentVersion ?? "unknown"))); } } else if (text2 == "lockexempt") { if (obj is bool flag) { lockExempt = flag; } } else if (dictionary2.TryGetValue(text2, out value)) { if ((text3 == "" && (!value.Type.IsValueType || Nullable.GetUnderlyingType(value.Type) != null)) || GetZPackageTypeString(value.Type) == text3) { parsedConfigs.customValues[value] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for internal value " + text2 + " for mod " + (DisplayName ?? Name) + ", expecting " + value.Type.AssemblyQualifiedName)); } } else if (dictionary.TryGetValue(text + "_" + text2, out value2)) { Type type2 = configType(value2.BaseConfig); if ((text3 == "" && (!type2.IsValueType || Nullable.GetUnderlyingType(type2) != null)) || GetZPackageTypeString(type2) == text3) { parsedConfigs.configValues[value2] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + type2.AssemblyQualifiedName)); } else { Debug.LogWarning((object)("Received unknown config entry " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ". This may happen if client and server versions of the mod do not match.")); } continue; } Debug.LogWarning((object)("Got invalid type " + text3 + ", abort reading of received configs")); return new ParsedConfigs(); } return parsedConfigs; } private static bool isWritableConfig(OwnConfigEntryBase config) { OwnConfigEntryBase config2 = config; ConfigSync configSync = configSyncs.FirstOrDefault((ConfigSync cs) => cs.allConfigs.Contains(config2)); if (configSync == null) { return true; } return configSync.IsSourceOfTruth || !config2.SynchronizedConfig || config2.LocalBaseValue == null || (!configSync.IsLocked && (config2 != configSync.lockedConfig || lockExempt)); } private void serverLockedSettingChanged() { foreach (OwnConfigEntryBase allConfig in allConfigs) { configAttribute<ConfigurationManagerAttributes>(allConfig.BaseConfig).ReadOnly = !isWritableConfig(allConfig); } } private void resetConfigsFromServer() { foreach (OwnConfigEntryBase item in allConfigs.Where((OwnConfigEntryBase config) => config.LocalBaseValue != null)) { item.BaseConfig.BoxedValue = item.LocalBaseValue; item.LocalBaseValue = null; } foreach (CustomSyncedValueBase item2 in allCustomValues.Where((CustomSyncedValueBase config) => config.LocalBaseValue != null)) { item2.BoxedValue = item2.LocalBaseValue; item2.LocalBaseValue = null; } lockedConfigChanged -= serverLockedSettingChanged; serverLockedSettingChanged(); } private IEnumerator<bool> distributeConfigToPeers(ZNetPeer peer, ZPackage package) { ZNetPeer peer2 = peer; ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc == null) { yield break; } byte[] data = package.GetArray(); if (data != null && data.LongLength > 250000) { int fragments = (int)(1 + (data.LongLength - 1) / 250000); long packageIdentifier = ++packageCounter; int fragment = 0; while (fragment < fragments) { foreach (bool item in waitForQueue()) { yield return item; } if (peer2.m_socket.IsConnected()) { ZPackage fragmentedPackage = new ZPackage(); fragmentedPackage.Write((byte)2); fragmentedPackage.Write(packageIdentifier); fragmentedPackage.Write(fragment); fragmentedPackage.Write(fragments); fragmentedPackage.Write(data.Skip(250000 * fragment).Take(250000).ToArray()); SendPackage(fragmentedPackage); if (fragment != fragments - 1) { yield return true; } int num = fragment + 1; fragment = num; continue; } break; } yield break; } foreach (bool item2 in waitForQueue()) { yield return item2; } SendPackage(package); void SendPackage(ZPackage pkg) { string text = Name + " ConfigSync"; if (isServer) { peer2.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer2.m_server ? 0 : peer2.m_uid, text, new object[1] { pkg }); } } IEnumerable<bool> waitForQueue() { float timeout = Time.time + 30f; while (peer2.m_socket.GetSendQueueSize() > 20000) { if (Time.time > timeout) { Debug.Log((object)$"Disconnecting {peer2.m_uid} after 30 seconds config sending timeout"); peer2.m_rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)5 }); ZNet.instance.Disconnect(peer2); break; } yield return false; } } } private IEnumerator sendZPackage(long target, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return Enumerable.Empty<object>().GetEnumerator(); } List<ZNetPeer> list = (List<ZNetPeer>)AccessTools.DeclaredField(typeof(ZRoutedRpc), "m_peers").GetValue(ZRoutedRpc.instance); if (target != ZRoutedRpc.Everybody) { list = list.Where((ZNetPeer p) => p.m_uid == target).ToList(); } return sendZPackage(list, package); } private IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { ZPackage package2 = package; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package2.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write((byte)4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package2 = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select distributeConfigToPeers(p, package2)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private void Broadcast(long target, params ConfigEntryBase[] configs) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(configs); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private void Broadcast(long target, params CustomSyncedValueBase[] customValues) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(null, customValues); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private static OwnConfigEntryBase? configData(ConfigEntryBase config) { return config.Description.Tags?.OfType<OwnConfigEntryBase>().SingleOrDefault(); } public static SyncedConfigEntry<T>? ConfigData<T>(ConfigEntry<T> config) { return ((ConfigEntryBase)config).Description.Tags?.OfType<SyncedConfigEntry<T>>().SingleOrDefault(); } private static T configAttribute<T>(ConfigEntryBase config) { return config.Description.Tags.OfType<T>().First(); } private static Type configType(ConfigEntryBase config) { return configType(config.SettingType); } private static Type configType(Type type) { return type.IsEnum ? Enum.GetUnderlyingType(type) : type; } private static ZPackage ConfigsToPackage(IEnumerable<ConfigEntryBase>? configs = null, IEnumerable<CustomSyncedValueBase>? customValues = null, IEnumerable<PackageEntry>? packageEntries = null, bool partial = true) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown List<ConfigEntryBase> list = configs?.Where((ConfigEntryBase config) => configData(config).SynchronizedConfig).ToList() ?? new List<ConfigEntryBase>(); List<CustomSyncedValueBase> list2 = customValues?.ToList() ?? new List<CustomSyncedValueBase>(); ZPackage val = new ZPackage(); val.Write((byte)(partial ? 1 : 0)); val.Write(list.Count + list2.Count + (packageEntries?.Count() ?? 0)); foreach (PackageEntry item in packageEntries ?? Array.Empty<PackageEntry>()) { AddEntryToPackage(val, item); } foreach (CustomSyncedValueBase item2 in list2) { AddEntryToPackage(val, new PackageEntry { section = "Internal", key = item2.Identifier, type = item2.Type, value = item2.BoxedValue }); } foreach (ConfigEntryBase item3 in list) { AddEntryToPackage(val, new PackageEntry { section = item3.Definition.Section, key = item3.Definition.Key, type = configType(item3), value = item3.BoxedValue }); } return val; } private static void AddEntryToPackage(ZPackage package, PackageEntry entry) { package.Write(entry.section); package.Write(entry.key); package.Write((entry.value == null) ? "" : GetZPackageTypeString(entry.type)); AddValueToZPackage(package, entry.value); } private static string GetZPackageTypeString(Type type) { return type.AssemblyQualifiedName; } private static void AddValueToZPackage(ZPackage package, object? value) { Type type = value?.GetType(); if (value is Enum) { value = ((IConvertible)value).ToType(Enum.GetUnderlyingType(value.GetType()), CultureInfo.InvariantCulture); } else { if (value is ICollection collection) { package.Write(collection.Count); { foreach (object item in collection) { AddValueToZPackage(package, item); } return; } } if ((object)type != null && type.IsValueType && !type.IsPrimitive) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); package.Write(fields.Length); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { package.Write(GetZPackageTypeString(fieldInfo.FieldType)); AddValueToZPackage(package, fieldInfo.GetValue(value)); } return; } } ZRpc.Serialize(new object[1] { value }, ref package); } private static object ReadValueWithTypeFromZPackage(ZPackage package, Type type) { if ((object)type != null && type.IsValueType && !type.IsPrimitive && !type.IsEnum) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num = package.ReadInt(); if (num != fields.Length) { throw new InvalidDeserializationTypeException { received = $"(field count: {num})", expected = $"(field count: {fields.Length})" }; } object uninitializedObject = FormatterServices.GetUninitializedObject(type); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { string text = package.ReadString(); if (text != GetZPackageTypeString(fieldInfo.FieldType)) { throw new InvalidDeserializationTypeException { received = text, expected = GetZPackageTypeString(fieldInfo.FieldType), field = fieldInfo.Name }; } fieldInfo.SetValue(uninitializedObject, ReadValueWithTypeFromZPackage(package, fieldInfo.FieldType)); } return uninitializedObject; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<, >)) { int num2 = package.ReadInt(); IDictionary dictionary = (IDictionary)Activator.CreateInstance(type); Type type2 = typeof(KeyValuePair<, >).MakeGenericType(type.GenericTypeArguments); FieldInfo field = type2.GetField("key", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = type2.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic); for (int j = 0; j < num2; j++) { object obj = ReadValueWithTypeFromZPackage(package, type2); dictionary.Add(field.GetValue(obj), field2.GetValue(obj)); } return dictionary; } if (type != typeof(List<string>) && type.IsGenericType) { Type type3 = typeof(ICollection<>).MakeGenericType(type.GenericTypeArguments[0]); if ((object)type3 != null && type3.IsAssignableFrom(type)) { int num3 = package.ReadInt(); object obj2 = Activator.CreateInstance(type); MethodInfo method = type3.GetMethod("Add"); for (int k = 0; k < num3; k++) { method.Invoke(obj2, new object[1] { ReadValueWithTypeFromZPackage(package, type.GenericTypeArguments[0]) }); } return obj2; } } ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo)); AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl").SetValue(parameterInfo, type); List<object> source = new List<object>(); ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, package, ref source); return source.First(); } } [HarmonyPatch] [PublicAPI] internal class VersionCheck { private static readonly HashSet<VersionCheck> versionChecks; private static readonly Dictionary<string, string> notProcessedNames; public string Name; private string? displayName; private string? currentVersion; private string? minimumRequiredVersion; public bool ModRequired = true; private string? ReceivedCurrentVersion; private string? ReceivedMinimumRequiredVersion; private readonly List<ZRpc> ValidatedClients = new List<ZRpc>(); private ConfigSync? ConfigSync; public string DisplayName { get { return displayName ?? Name; } set { displayName = value; } } public string CurrentVersion { get { return currentVersion ?? "0.0.0"; } set { currentVersion = value; } } public string MinimumRequiredVersion { get { return minimumRequiredVersion ?? (ModRequired ? CurrentVersion : "0.0.0"); } set { minimumRequiredVersion = value; } } private static void PatchServerSync() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Patches patchInfo = PatchProcessor.GetPatchInfo((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null)); if (patchInfo != null && patchInfo.Postfixes.Count((Patch p) => p.PatchMethod.DeclaringType == typeof(ConfigSync.RegisterRPCPatch)) > 0) { return; } Harmony val = new Harmony("org.bepinex.helpers.ServerSync"); foreach (Type item in from t in typeof(ConfigSync).GetNestedTypes(BindingFlags.NonPublic).Concat(new Type[1] { typeof(VersionCheck) }) where t.IsClass select t) { val.PatchAll(item); } } static VersionCheck() { versionChecks = new HashSet<VersionCheck>(); notProcessedNames = new Dictionary<string, string>(); typeof(ThreadingHelper).GetMethod("StartSyncInvoke").Invoke(ThreadingHelper.Instance, new object[1] { new Action(PatchServerSync) }); } public VersionCheck(string name) { Name = name; ModRequired = true; versionChecks.Add(this); } public VersionCheck(ConfigSync configSync) { ConfigSync = configSync; Name = ConfigSync.Name; versionChecks.Add(this); } public void Initialize() { ReceivedCurrentVersion = null; ReceivedMinimumRequiredVersion = null; if (ConfigSync != null) { Name = ConfigSync.Name; DisplayName = ConfigSync.DisplayName; CurrentVersion = ConfigSync.CurrentVersion; MinimumRequiredVersion = ConfigSync.MinimumRequiredVersion; ModRequired = ConfigSync.ModRequired; } } private bool IsVersionOk() { if (ReceivedMinimumRequiredVersion == null || ReceivedCurrentVersion == null) { return !ModRequired; } bool flag = new Version(CurrentVersion) >= new Version(ReceivedMinimumRequiredVersion); bool flag2 = new Version(ReceivedCurrentVersion) >= new Version(MinimumRequiredVersion); return flag && flag2; } private string ErrorClient() { if (ReceivedMinimumRequiredVersion == null) { return "Mod " + DisplayName + " must not be installed."; } return (new Version(CurrentVersion) >= new Version(ReceivedMinimumRequiredVersion)) ? ("Mod " + DisplayName + " requires maximum " + ReceivedCurrentVersion + ". Installed is version " + CurrentVersion + ".") : ("Mod " + DisplayName + " requires minimum " + ReceivedMinimumRequiredVersion + ". Installed is version " + CurrentVersion + "."); } private string ErrorServer(ZRpc rpc) { return "Disconnect: The client (" + rpc.GetSocket().GetHostName() + ") doesn't have the correct " + DisplayName + " version " + MinimumRequiredVersion; } private string Error(ZRpc? rpc = null) { return (rpc == null) ? ErrorClient() : ErrorServer(rpc); } private static VersionCheck[] GetFailedClient() { return versionChecks.Where((VersionCheck check) => !check.IsVersionOk()).ToArray(); } private static VersionCheck[] GetFailedServer(ZRpc rpc) { ZRpc rpc2 = rpc; return versionChecks.Where((VersionCheck check) => check.ModRequired && !check.ValidatedClients.Contains(rpc2)).ToArray(); } private static void Logout() { Game.instance.Logout(true, true); AccessTools.DeclaredField(typeof(ZNet), "m_connectionStatus").SetValue(null, (object)(ConnectionStatus)3); } private static void DisconnectClient(ZRpc rpc) { rpc.Invoke("Error", new object[1] { 3 }); } private static void CheckVersion(ZRpc rpc, ZPackage pkg) { CheckVersion(rpc, pkg, null); } private static void CheckVersion(ZRpc rpc, ZPackage pkg, Action<ZRpc, ZPackage>? original) { string text = pkg.ReadString(); string text2 = pkg.ReadString(); string text3 = pkg.ReadString(); bool flag = false; foreach (VersionCheck versionCheck in versionChecks) { if (!(text != versionCheck.Name)) { Debug.Log((object)("Received " + versionCheck.DisplayName + " version " + text3 + " and minimum version " + text2 + " from the " + (ZNet.instance.IsServer() ? "client" : "server") + ".")); versionCheck.ReceivedMinimumRequiredVersion = text2; versionCheck.ReceivedCurrentVersion = text3; if (ZNet.instance.IsServer() && versionCheck.IsVersionOk()) { versionCheck.ValidatedClients.Add(rpc); } flag = true; } } if (flag) { return; } pkg.SetPos(0); if (original != null) { original(rpc, pkg); if (pkg.GetPos() == 0) { notProcessedNames.Add(text, text3); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private static bool RPC_PeerInfo(ZRpc rpc, ZNet __instance) { VersionCheck[] array = (__instance.IsServer() ? GetFailedServer(rpc) : GetFailedClient()); if (array.Length == 0) { return true; } VersionCheck[] array2 = array; foreach (VersionCheck versionCheck in array2) { Debug.LogWarning((object)versionCheck.Error(rpc)); } if (__instance.IsServer()) { DisconnectClient(rpc); } else { Logout(); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static void RegisterAndCheckVersion(ZNetPeer peer, ZNet __instance) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown notProcessedNames.Clear(); IDictionary dictionary = (IDictionary)typeof(ZRpc).GetField("m_functions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(peer.m_rpc); if (dictionary.Contains(StringExtensionMethods.GetStableHashCode("ServerSync VersionCheck"))) { object obj = dictionary[StringExtensionMethods.GetStableHashCode("ServerSync VersionCheck")]; Action<ZRpc, ZPackage> action = (Action<ZRpc, ZPackage>)obj.GetType().GetField("m_action", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj); peer.m_rpc.Register<ZPackage>("ServerSync VersionCheck", (Action<ZRpc, ZPackage>)delegate(ZRpc rpc, ZPackage pkg) { CheckVersion(rpc, pkg, action); }); } else { peer.m_rpc.Register<ZPackage>("ServerSync VersionCheck", (Action<ZRpc, ZPackage>)CheckVersion); } foreach (VersionCheck versionCheck in versionChecks) { versionCheck.Initialize(); if (versionCheck.ModRequired || __instance.IsServer()) { Debug.Log((object)("Sending " + versionCheck.DisplayName + " version " + versionCheck.CurrentVersion + " and minimum version " + versionCheck.MinimumRequiredVersion + " to the " + (__instance.IsServer() ? "client" : "server") + ".")); ZPackage val = new ZPackage(); val.Write(versionCheck.Name); val.Write(versionCheck.MinimumRequiredVersion); val.Write(versionCheck.CurrentVersion); peer.m_rpc.Invoke("ServerSync VersionCheck", new object[1] { val }); } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] [HarmonyPrefix] private static void RemoveDisconnected(ZNetPeer peer, ZNet __instance) { if (!__instance.IsServer()) { return; } foreach (VersionCheck versionCheck in versionChecks) { versionCheck.ValidatedClients.Remove(peer.m_rpc); } } [HarmonyPostfix] [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] private static void ShowConnectionError(FejdStartup __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (!__instance.m_connectionFailedPanel.activeSelf || (int)ZNet.GetConnectionStatus() != 3) { return; } VersionCheck[] failedClient = GetFailedClient(); if (failedClient.Length != 0) { string text = string.Join("\n", failedClient.Select((VersionCheck check) => check.Error())); TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + text; } foreach (KeyValuePair<string, string> item in notProcessedNames.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> kv) => kv.Key)) { if (!__instance.m_connectionFailedError.text.Contains(item.Key)) { TMP_Text connectionFailedError2 = __instance.m_connectionFailedError; connectionFailedError2.text = connectionFailedError2.text + "\n" + item.Key + " (Version: " + item.Value + ")"; } } } } }
Deadheim.dll
Decompiled 4 months agousing System; 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 Groups; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Steamworks; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Deadheim { [HarmonyPatch] public class Boss { [HarmonyPatch(typeof(OfferingBowl), "Interact")] public static class Interact { private static bool Prefix(OfferingBowl __instance, Humanoid user) { if (Validate(((Object)__instance.m_bossPrefab).name)) { return true; } ((Character)Player.m_localPlayer).Message((MessageType)2, "You don't know enough", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(OfferingBowl), "UseItem")] public static class UseItem { private static bool Prefix(OfferingBowl __instance, Humanoid user, ItemData item) { if (Validate(((Object)__instance.m_bossPrefab).name)) { return true; } ((Character)Player.m_localPlayer).Message((MessageType)2, "You don't know enough", 0, (Sprite)null); return false; } } public static bool Validate(string bossName) { if (!Plugin.BlockedBosses.Value.Contains(bossName)) { return true; } return false; } } [HarmonyPatch(typeof(Container), "Awake")] public static class Container_Awake_Patch { private const int woodChestRows = 4; private const int woodChestColumns = 5; private const int personalChestRows = 6; private const int personalChestColumns = 6; private const int ironChestRows = 8; private const int ironChestColumns = 6; private const int karveInventoryRows = 4; private const int karveInventoryColumns = 2; private const int longboatInventoryRows = 6; private const int longboatInventoryColumns = 6; private const int cartInventoryRows = 5; private const int cartInventoryColumns = 6; private const int aesirRows = 8; private static void Postfix(Container __instance, ref Inventory ___m_inventory) { if (((Object)(object)__instance == (Object)null || ___m_inventory == null || !Object.op_Implicit((Object)(object)((Component)__instance).transform.parent)) && ___m_inventory != null && ((Object)((Component)__instance).gameObject).name.Contains("AesirChest")) { ___m_inventory.m_width = 6; ___m_inventory.m_height = 6; } } } internal class CraftingStations { [HarmonyPatch(typeof(CraftingStation), "CheckUsable")] public static class WorkbenchRemoveRestrictions { private static bool Prefix(ref CraftingStation __instance) { __instance.m_craftRequireRoof = false; return true; } } [HarmonyPatch(typeof(PrivateArea), "Awake")] public static class PrivateAreaAwake { public static void Postfix(ref PrivateArea __instance) { int num = Plugin.WardRadius.Value; if (__instance.m_name.Contains("AdminWard")) { num = 150; } if (__instance.m_name.Contains("RaidWard")) { num = 100; } __instance.m_areaMarker.m_radius = num; __instance.m_radius = num; } } } public static class EpicMMOApi { private enum API_State { NotReady, NotInstalled, Ready } private static string pluginKey = "EpicMMOSystem"; private static API_State state = API_State.NotReady; private static MethodInfo eGetLevel; private static MethodInfo eAddExp; private static MethodInfo eGetAttribute; public static int GetLevel() { int result = 0; Init(); if (eGetLevel != null) { result = (int)eGetLevel.Invoke(null, null); } return result; } public static int GetAttribute(string attribute) { string value = 0.ToString(); Player.m_localPlayer.m_knownTexts.TryGetValue(pluginKey + "_LevelSystem_" + attribute, out value); return Convert.ToInt32(value); } public static void AddExp(int value) { Init(); eAddExp?.Invoke(null, new object[1] { value }); } private static void Init() { API_State aPI_State = state; if (aPI_State != API_State.Ready && aPI_State != API_State.NotInstalled) { if (Type.GetType("EpicMMOSystem.EpicMMOSystem, EpicMMOSystem") == null) { state = API_State.NotInstalled; return; } state = API_State.Ready; Type type = Type.GetType("API.EMMOS_API, EpicMMOSystem"); eGetLevel = type.GetMethod("GetLevel", BindingFlags.Static | BindingFlags.Public); eAddExp = type.GetMethod("AddExp", BindingFlags.Static | BindingFlags.Public); eGetAttribute = type.GetMethod("GetAttribute", BindingFlags.Static | BindingFlags.Public); } } } internal class ItemService { public static void ModifyItemsCost() { GameObject prefab = PrefabManager.Instance.GetPrefab("piece_cartographytable"); prefab.GetComponent<Piece>().m_resources[0].m_amount = 100; prefab.GetComponent<Piece>().m_resources[1].m_amount = 100; prefab.GetComponent<Piece>().m_resources[2].m_amount = 100; prefab.GetComponent<Piece>().m_resources[3].m_amount = 100; prefab.GetComponent<Piece>().m_resources[4].m_amount = 100; GameObject prefab2 = PrefabManager.Instance.GetPrefab("portal_wood"); Piece component = prefab2.GetComponent<Piece>(); component.m_resources[0].m_amount = 1500; component.m_resources[1].m_amount = 1; component.m_resources[1].m_resItem = PrefabManager.Instance.GetPrefab("PortalToken").GetComponent<ItemDrop>(); component.m_resources[2].m_amount = 225; } public static void OnlyAdminPieces() { GameObject val = ((IEnumerable<GameObject>)ObjectDB.instance.m_items).FirstOrDefault((Func<GameObject, bool>)((GameObject x) => ((Object)x).name == "Hammer")); PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces; string[] array = Plugin.OnlyAdminPieces.Value.Split(new char[1] { ',' }); foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (prefab != null) { Piece component = prefab.GetComponent<Piece>(); Requirement[] resources = component.m_resources; foreach (Requirement val2 in resources) { val2.m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent<ItemDrop>(); val2.m_recover = false; } if (!SynchronizationManager.Instance.PlayerIsAdmin) { buildPieces.m_pieces.Remove(prefab); } } } } public static void SetWardFirePlace() { GameObject prefab = PrefabManager.Instance.GetPrefab("guard_stone"); Fireplace val = prefab.AddComponent<Fireplace>(); val.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent<ItemDrop>(); } public static void NerfRunicCape() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("rae_CapeHorseHide"); if (Object.op_Implicit((Object)(object)itemPrefab)) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); SE_Stats val = (SE_Stats)component.m_itemData.m_shared.m_equipStatusEffect; val.m_mods = new List<DamageModPair>(); } } public static void WolvesTameable() { if (!Plugin.WolvesAreTameable.Value) { GameObject prefab = PrefabManager.Instance.GetPrefab("Wolf"); if (Object.op_Implicit((Object)(object)prefab)) { Tameable component = prefab.GetComponent<Tameable>(); Procreation component2 = prefab.GetComponent<Procreation>(); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); } } } public static void LoxTameable() { if (!Plugin.LoxTameable.Value) { GameObject prefab = PrefabManager.Instance.GetPrefab("Lox"); if (Object.op_Implicit((Object)(object)prefab)) { Tameable component = prefab.GetComponent<Tameable>(); Procreation component2 = prefab.GetComponent<Procreation>(); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); } } } public static void StubNoLife() { List<GameObject> list = new List<GameObject>(); list.Add(PrefabManager.Instance.GetPrefab("Pinetree_01_Stub")); list.Add(PrefabManager.Instance.GetPrefab("SwampTree1_Stub")); list.Add(PrefabManager.Instance.GetPrefab("BirchStub")); list.Add(PrefabManager.Instance.GetPrefab("FirTree_Stub")); list.Add(PrefabManager.Instance.GetPrefab("OakStub")); list.Add(PrefabManager.Instance.GetPrefab("Beech_Stub")); foreach (GameObject item in list) { Destructible component = item.GetComponent<Destructible>(); component.m_health = 1f; } } } [HarmonyPatch] internal class Portal { [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(800)] private static bool Prefix(Piece piece, Player __instance) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown if (SynchronizationManager.Instance.PlayerIsAdmin) { return true; } if (!((Object)((Component)piece).gameObject).name.Contains("portal_wood")) { return true; } int portalCount = GetPortalCount(); if (Plugin.Vip.Value.Contains(Plugin.steamId)) { if (portalCount >= Plugin.PortalLimitVip.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar portais.", 0, (Sprite)null); return false; } } else if (portalCount >= Plugin.PortalLimit.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar portais.", 0, (Sprite)null); return false; } ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return true; } } private static int GetPortalCount() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (SynchronizationManager.Instance.PlayerIsAdmin) { return 0; } ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return Plugin.PlayerPortalCount; } } [HarmonyPatch] public class Retreat { [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class AddChatCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void <Postfix>b__0_0(ConsoleEventArgs args) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Vip.Value.Contains(Plugin.steamId)) { args.Context.AddString("Only Aesir can use this command"); return; } if (!((Humanoid)Player.m_localPlayer).IsTeleportable()) { args.Context.AddString("Can't teleport"); return; } Vector3 hearthStonePosition = GetHearthStonePosition(); if (hearthStonePosition == Vector3.zero) { args.Context.AddString("You need to set hearthstone spawn point"); } else { ((Character)Player.m_localPlayer).TeleportTo(hearthStonePosition, ((Component)Player.m_localPlayer).transform.rotation, true); } } } private static void Postfix() { //IL_0033: 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) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Vip.Value.Contains(Plugin.steamId)) { args.Context.AddString("Only Aesir can use this command"); } else if (!((Humanoid)Player.m_localPlayer).IsTeleportable()) { args.Context.AddString("Can't teleport"); } else { Vector3 hearthStonePosition = GetHearthStonePosition(); if (hearthStonePosition == Vector3.zero) { args.Context.AddString("You need to set hearthstone spawn point"); } else { ((Character)Player.m_localPlayer).TeleportTo(hearthStonePosition, ((Component)Player.m_localPlayer).transform.rotation, true); } } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("retreat", "go back home", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(Chat), "Awake")] public class AddGroupChat { private static void Postfix(Chat __instance) { int index = Math.Max(0, ((Terminal)__instance).m_chatBuffer.Count - 5); ((Terminal)__instance).m_chatBuffer.Insert(index, "/retreat go back home"); ((Terminal)__instance).UpdateChat(); } } public static Vector3 GetHearthStonePosition() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!Player.m_localPlayer.m_knownTexts.ContainsKey("positionX")) { return Vector3.zero; } Vector3 result = default(Vector3); result.x = float.Parse(Player.m_localPlayer.m_knownTexts["positionX"]); result.y = float.Parse(Player.m_localPlayer.m_knownTexts["positionY"]); result.z = float.Parse(Player.m_localPlayer.m_knownTexts["positionZ"]); return result; } } [HarmonyPatch] internal class RPC { [HarmonyPatch(typeof(Player), "OnSpawned")] public static class OnSpawned { public static void Postfix() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); } } [HarmonyPatch(typeof(Game), "Start")] public static class GameStart { public static void Postfix() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("DeadheimPortalAndTotemCountServer", (Action<long, ZPackage>)RPC_PortalAndTotemCountServer); ZRoutedRpc.instance.Register<ZPackage>("DeadheimPortalAndTotemCountClient", (Action<long, ZPackage>)RPC_PortalAndTotemCountClient); } } } public static void RPC_PortalAndTotemCountServer(long sender, ZPackage pkg) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (ZNet.instance.IsServer()) { long creatorId = pkg.ReadLong(); string creatorWardAndPortalCount = Util.GetCreatorWardAndPortalCount(creatorId); ZPackage val = new ZPackage(); val.Write(creatorWardAndPortalCount); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "DeadheimPortalAndTotemCountClient", new object[1] { val }); } } public static void RPC_PortalAndTotemCountClient(long sender, ZPackage pkg) { string text = pkg.ReadString(); Plugin.PlayerPortalCount = Convert.ToInt32(text.Split(new char[1] { ',' })[0]); Plugin.PlayerWardCount = Convert.ToInt32(text.Split(new char[1] { ',' })[1]); } } public static class Util { public static int CREATORHASH = StringExtensionMethods.GetStableHashCode("creator"); public static string GetCreatorWardAndPortalCount(long creatorId) { int creatorPrefabCount = GetCreatorPrefabCount(StringExtensionMethods.GetStableHashCode("portal_wood"), creatorId); int creatorPrefabCount2 = GetCreatorPrefabCount(StringExtensionMethods.GetStableHashCode("guard_stone"), creatorId); return $"{creatorPrefabCount},{creatorPrefabCount2}"; } private static int GetCreatorPrefabCount(int prefabHash, long creatorId) { int num = 0; List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List<ZDO> list in objectsBySector) { if (list == null) { continue; } for (int j = 0; j < list.Count; j++) { ZDO val = list[j]; if (val.GetPrefab() == prefabHash) { long @long = val.GetLong(CREATORHASH, 0L); if (@long != 0 && @long == creatorId) { num++; } } } } return num; } private static byte[] ReadEmbeddedFileBytes(string name) { using MemoryStream memoryStream = new MemoryStream(); Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream); return memoryStream.ToArray(); } private static Texture2D LoadTexture(string name) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown Texture2D val = new Texture2D(0, 0); ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("assets." + name)); return val; } public static Sprite LoadSprite(string name, int width, int height) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return Sprite.Create(LoadTexture(name), new Rect(0f, 0f, (float)width, (float)height), Vector2.zero); } } [HarmonyPatch] public class FasterBoats { [HarmonyPatch(typeof(Ship), "GetSailForce")] private class ChangeShipBaseSpeed { private static void Postfix(ref Vector3 __result) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) __result *= Plugin.BoatWindSpeedmultiplier.Value; } } } [BepInPlugin("Detalhes.Deadheim", "Detalhes.Deadheim", "6.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Version = "6.0.0"; public const string PluginGUID = "Detalhes.Deadheim"; public static string steamId = ""; public static ConfigEntry<string> Vip; public static ConfigEntry<string> AdminList; public static ConfigEntry<string> OnlyAdminPieces; public static ConfigEntry<string> VipPortalNames; public static ConfigEntry<int> WardRadius; public static ConfigEntry<string> StaffMessage; public static ConfigEntry<string> DungeonPrefabs; public static ConfigEntry<string> BlockedBosses; public static ConfigEntry<float> SkillMultiplier; public static ConfigEntry<float> BoatWindSpeedmultiplier; public static ConfigEntry<float> BoatRudderSpeedmultiplier; public static ConfigEntry<float> CapeRunicSpeed; public static ConfigEntry<float> CapeRunicRegen; public static ConfigEntry<float> SkillDeathFactor; public static ConfigEntry<int> SafeArea; public static ConfigEntry<int> WardLimit; public static ConfigEntry<int> WardLimitVip; public static ConfigEntry<int> PortalLimit; public static ConfigEntry<int> PortalLimitVip; public static ConfigEntry<int> DropPercentagePerItem; public static ConfigEntry<int> WardChargeDurationInSec; public static ConfigEntry<bool> ResetWorldDay; public static ConfigEntry<bool> WolvesAreTameable; public static ConfigEntry<bool> LoxTameable; public static ConfigEntry<int> SkillCap; public static ConfigEntry<string> dropTypes; public static string PlayerName = ""; public static bool IsAdmin = false; public static int PlayerWardCount = 999; public static int PlayerPortalCount = 999; public static int maxPlayers = 50; public static List<ZRpc> validatedUsers = new List<ZRpc>(); public static bool hasSpawned = false; private Harmony _harmony = new Harmony("Detalhes.deadheim"); private void Awake() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0113: 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_0121: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_0225: 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_0233: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Expected O, but got Unknown //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Expected O, but got Unknown //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Expected O, but got Unknown //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Expected O, but got Unknown //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Expected O, but got Unknown //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Expected O, but got Unknown //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Expected O, but got Unknown //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Expected O, but got Unknown //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Expected O, but got Unknown //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Expected O, but got Unknown //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Expected O, but got Unknown //IL_05c9: 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_05d7: Expected O, but got Unknown //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Expected O, but got Unknown //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Expected O, but got Unknown //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Expected O, but got Unknown //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Expected O, but got Unknown //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Expected O, but got Unknown SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { if (attr.InitialSynchronization) { ItemService.SetWardFirePlace(); ItemService.ModifyItemsCost(); ItemService.LoxTameable(); ItemService.WolvesTameable(); ItemService.StubNoLife(); ItemService.OnlyAdminPieces(); IsAdmin = AdminList.Value.Contains(steamId); } else { Logger.LogMessage((object)"Config sync event received"); } }; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; OnlyAdminPieces = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "OnlyAdminPieces", "SHGateHouse,SHWallMusteringHall,SHTowerSquareTwoFloorCenter,SHTowerSquareTwoFloorCorner,SHTowerSquareTwoFloorJunction,SHWallOpenTwoFloorCapped,SHWallOpenTwoFloorWithNest,SHWallOpenTwoFloorWithNestCapped,SHWallOpenTwoFloor,SHEnclosedTower,SHBunkhouse,SHWell,SHOuterWallCovered,SHOuterWallOpenCapped,SHOuterWallOpen,SHOuterWallTowerSquareCenter,SHOuterWallTowerTransition,SHOuterWallTowerRound,SHOuterWallGate,SHWatchtower,SHTowerRoundWallEnd,SHOuterWallCoverdCapped,SHWallInnerArch,SHWallInnerPillar,SHWallInnerPlain,SHWallInnerPosh,SHHouseSmall,SHHouseMedium,SHHouseLarge,SHHayBarn,SHOldBarn,SHStorageBarn,SHMainHall", new ConfigDescription("OnlyAdminPieces", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); VipPortalNames = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "VipPortalNames", "cavalinho,eguinha", new ConfigDescription("VipPortalNames", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SkillCap = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "SkillCap", 100, new ConfigDescription("SkillCap", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); AdminList = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "AdminList", "76561198053330247 76561197961128381 76561198111650012 76561197993642177 76561198993982965", new ConfigDescription("AdminList", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Vip = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "Vip", "76561198053330247", new ConfigDescription("VipList", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SkillDeathFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "SkillDeathFactor", 0.05f, new ConfigDescription("SkillDeathFactor", (AcceptableValueBase)null, new object[3] { new AcceptableValueRange<float>(0f, 0.1f), null, (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); StaffMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "StaffMessage", "", new ConfigDescription("StaffMessage", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); DungeonPrefabs = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "DungeonPrefabs", "dungeon_forestcrypt_door,dungeon_sunkencrypt_irongate", new ConfigDescription("DungeonPrefabs", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); BlockedBosses = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "BlockedBosses", "batata banana", new ConfigDescription("BlockedBosses", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WolvesAreTameable = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "WolvesAreTameable", false, new ConfigDescription("WolvesAreTameable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); LoxTameable = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "LoxTameable", false, new ConfigDescription("LoxTameable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SafeArea = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "SafeArea", 1500, new ConfigDescription("SafeArea", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardChargeDurationInSec = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "WardChargeDurationInSec", 86400, new ConfigDescription("WardChargeDurationInSec", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); PortalLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "PortalLimit", 2, new ConfigDescription("PortalLimit", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); PortalLimitVip = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "PortalLimitVip", 6, new ConfigDescription("PortalLimitVip", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "WardLimit", 3, new ConfigDescription("WardLimit", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardLimitVip = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "WardLimitVip", 5, new ConfigDescription("WardLimitVip", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); DropPercentagePerItem = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "DropPercentagePerItem", 5, new ConfigDescription("DropPercentagePerItem", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "WardRadius", 150, new ConfigDescription("WardRadius", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); BoatWindSpeedmultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "boatWindSpeedmultiplier", 1f, new ConfigDescription("boatWindSpeedmultiplier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); BoatRudderSpeedmultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "BoatRudderSpeedmultiplier", 1f, new ConfigDescription("BoatRudderSpeedmultiplier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); CapeRunicRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "CapeRunicRegen", 1.25f, new ConfigDescription("CapeRunicRegen", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); CapeRunicSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "CapeRunicSpeed", 0.05f, new ConfigDescription("CapeRunicSpeed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SkillMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "SkillMultiplier", 0.5f, new ConfigDescription("SkillMultiplier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ResetWorldDay = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "ResetWorldDay", false, new ConfigDescription("ResetWorldDay", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); _harmony.PatchAll(); ClonedItems.LoadAssets(); } } [HarmonyPatch] public class ClonedItems { [HarmonyPatch(typeof(ItemDrop), "DropItem")] public static class DropItem { [HarmonyPriority(800)] private static void Prefix(ItemDrop __instance, ItemData item) { if (!((Object)(object)item.m_dropPrefab != (Object)null)) { if (item != null && item.m_shared != null && item.m_shared.m_name.Equals(" Basic Armor Kit I", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit1"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Good Armor Kit II", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit2"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Great Armor Kit III", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit3"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Superior Armor Kit IV", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit4"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Basic Weapon Kit I", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit1"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Good Weapon Kit II", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit2"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Great Weapon Kit III", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit3"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Superior Weapon Kit IV", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit4"); } } } } public static void LoadAssets() { PrefabManager.OnPrefabsRegistered += AddClonedItems; PieceManager.OnPiecesRegistered += AddClonedPieces; CreatureManager.OnVanillaCreaturesAvailable += AddVanillaClonedCreatures; } private static void AddClonedItems() { AddPortalToken(); AddEsqueletaoItems(); AddItemKits(); PrefabManager.OnPrefabsRegistered -= AddClonedItems; } private static void AddClonedPieces() { AddAesirChest(); AddAdminWards(); PieceManager.OnPiecesRegistered -= AddClonedPieces; } private static void AddVanillaClonedCreatures() { AddBatzao(); AddNomTameableWolf(); AddPorcoLox(); AddSkeletao(); CreatureManager.OnVanillaCreaturesAvailable -= AddVanillaClonedCreatures; } private static void AddAdminWards() { AddBigdminWard(); AddSmallAdminWard(); AddRaidWard(); } private static void AddItemKits() { AddArmorKit("ArmorKit1", "piece_chest_wood", "Basic Armor Kit I", "Kit de itens utilizados para fabricar armaduras de menor qualidade pertencente a era do bronze.", "Wood", "Guck", "armorkit1.png"); AddArmorKit("ArmorKit2", "piece_chest_wood", "Good Armor Kit II", "Kit de itens utilizados para fabricar armaduras de refinadas de qualidade pertencente a era do ferro.", "Wood", "Blueberries", "armorkit2.png"); AddArmorKit("ArmorKit3", "piece_chest_wood", "Great Armor Kit III", "Kit de itens utilizados para fabricar armaduras reluzentes beirando a perfeição, sua qualidade pertence a era da prata.", "Wood", "Amber", "armorkit3.png"); AddArmorKit("ArmorKit4", "piece_chest_wood", "Superior Armor Kit IV", "Kit de itens utilizados para fabricar armaduras de maior qualidade dentro os mortais beirando o divino pertencentes a era do linho.", "Wood", "Ruby", "armorkit4.png"); AddArmorKit("WeaponKit1", "piece_chest_wood", "Basic Weapon Kit I", "Kit de itens utilizados para fabricar armas mais simples de qualidade duvidosa, muito utilizada na era do bronze.", "FineWood", "Guck", "weaponkit1.png"); AddArmorKit("WeaponKit2", "piece_chest_wood", "Good Weapon Kit II", "Kit de itens utilizados para fabricar armas maior refinaria, muito utilizada na era do ferro.", "FineWood", "Blueberries", "weaponkit2.png"); AddArmorKit("WeaponKit3", "piece_chest_wood", "Great Weapon Kit III", "Kit de itens utilizados para fabricar armas prateadas com brilhos que afligem os olhos, muito utilizada na era da prata.", "FineWood", "Amber", "weaponkit3.png"); AddArmorKit("WeaponKit4", "piece_chest_wood", "Superior Weapon Kit IV", "Kit de itens utilizados para fabricar armas negras, extremamente laminadas capazes de perfurar a grossa pele de um Lox utilizada por aqueles que chegaram na era do metal negro.", "FineWood", "Ruby", "weaponkit4.png"); } private static T CopyComponent<T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } return (T)(object)((val is T) ? val : null); } private static void AddArmorKit(string prefabName, string prefabToCopy, string name, string description, string firstShaderPrefabName, string secondShaderPrefabName, string icon) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) ItemDrop component = PrefabManager.Instance.GetPrefab("Resin").GetComponent<ItemDrop>(); GameObject val = PrefabManager.Instance.CreateClonedPrefab(prefabName, prefabToCopy); Object.Destroy((Object)(object)val.GetComponent<Piece>()); Object.Destroy((Object)(object)val.GetComponent<Container>()); Object.Destroy((Object)(object)val.GetComponent<WearNTear>()); Object.Destroy((Object)(object)val.GetComponent<ZNetView>()); val.AddComponent<ZNetView>(); ItemDrop val2 = val.AddComponent<ItemDrop>(); val2.m_floating = val.AddComponent<Floating>(); val2.m_body = val.AddComponent<Rigidbody>(); val2.m_itemData.m_shared = new SharedData(); val2.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Util.LoadSprite(icon, 64, 64) }; val2.m_itemData.m_shared.m_name = name; val2.m_itemData.m_shared.m_description = description; val2.m_itemData.m_shared.m_maxStackSize = 25; Vector3 localScale = val.transform.localScale; localScale.x *= 0.3f; localScale.y *= 0.3f; localScale.z *= 0.3f; val.transform.localScale = localScale; MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val3 in array) { List<Material> list = new List<Material>(); if ((Object)(object)val3 == (Object)(object)componentsInChildren[0]) { list.Add(((Renderer)PrefabManager.Instance.GetPrefab(firstShaderPrefabName).GetComponentInChildren<MeshRenderer>()).materials[0]); } else { list.Add(((Renderer)PrefabManager.Instance.GetPrefab(secondShaderPrefabName).GetComponentInChildren<MeshRenderer>()).materials[0]); } ((Renderer)val3).materials = list.ToArray(); } val.GetComponent<ItemDrop>().m_itemData.m_dropPrefab = val; ItemManager.Instance.RegisterItemInObjectDB(val); } private static void AddRaidWard() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("RaidWard", "guard_stone"); Piece component = val.GetComponent<Piece>(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent<ItemDrop>(); component.m_resources[0].m_recover = false; component.m_description = "Raid Ward"; component.m_name = "RaidWard"; PrivateArea component2 = ((Component)component).GetComponent<PrivateArea>(); component2.m_radius = 80f; component2.m_name = "RaidWard"; MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(); List<Material> list = new List<Material>(); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("Stone").GetComponentInChildren<MeshRenderer>()).materials[0]); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("Stone").GetComponentInChildren<MeshRenderer>()).materials[0]); ((Renderer)componentInChildren).materials = list.ToArray(); PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static void AddSmallAdminWard() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AdminWardSmall", "guard_stone"); Piece component = val.GetComponent<Piece>(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent<ItemDrop>(); component.m_resources[0].m_recover = false; component.m_description = "Admin Ward small"; component.m_name = "Admin Ward small"; PrivateArea component2 = ((Component)component).GetComponent<PrivateArea>(); component2.m_radius = 40f; component2.m_name = "AdminWardSmall"; MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(); List<Material> list = new List<Material>(); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("FreezeGland").GetComponentInChildren<MeshRenderer>()).materials[0]); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("FreezeGland").GetComponentInChildren<MeshRenderer>()).materials[0]); ((Renderer)componentInChildren).materials = list.ToArray(); PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static void AddBigdminWard() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AdminWard", "guard_stone"); Piece component = val.GetComponent<Piece>(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent<ItemDrop>(); component.m_resources[0].m_recover = false; component.m_description = "Admin Ward"; component.m_name = "Admin Ward"; PrivateArea component2 = ((Component)component).GetComponent<PrivateArea>(); component2.m_radius = 150f; component2.m_name = "AdminWard"; MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(); List<Material> list = new List<Material>(); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("Tar").GetComponentInChildren<MeshRenderer>()).materials[0]); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("SurtlingCore").GetComponentInChildren<MeshRenderer>()).materials[0]); ((Renderer)componentInChildren).materials = list.ToArray(); PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static void AddAesirChest() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AesirChest", "piece_chest_private"); Piece component = val.GetComponent<Piece>(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("Bronze").GetComponent<ItemDrop>(); component.m_resources[1].m_resItem = PrefabManager.Instance.GetPrefab("Wood").GetComponent<ItemDrop>(); component.m_description = "Aesir Chest"; component.m_name = "Aesir Chest"; PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Furniture"); } private static void AddEsqueletaoItems() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown ItemConfig val = new ItemConfig(); val.Name = "Espadada do esqueletão."; val.Description = "Espadada do esqueletão."; val.Icons = (Sprite[])(object)new Sprite[1] { Util.LoadSprite("esqueletaosword.png", 64, 64) }; val.RepairStation = "forge"; val.MinStationLevel = 1; val.CraftingStation = "forge"; CustomItem val2 = new CustomItem("SkeletaoSword", "SwordBronze", val); val2.ItemDrop.m_itemData.m_shared.m_damages.m_slash = 56f; ((Renderer)val2.ItemPrefab.GetComponentInChildren<MeshRenderer>()).materials = ((Renderer)PrefabManager.Instance.GetPrefab("Tar").GetComponentInChildren<MeshRenderer>()).materials; val = new ItemConfig(); val.Name = "Escudo do esqueletão."; val.Description = "Escudo do esqueletão."; val.Icons = (Sprite[])(object)new Sprite[1] { Util.LoadSprite("esqueletaoshield.png", 64, 64) }; val.RepairStation = "forge"; val.MinStationLevel = 1; val.CraftingStation = "forge"; CustomItem val3 = new CustomItem("SkeletaoShield", "ShieldBoneTower", val); val3.ItemDrop.m_itemData.m_shared.m_blockPower = 49f; ((Renderer)val3.ItemPrefab.GetComponentInChildren<MeshRenderer>()).materials = ((Renderer)PrefabManager.Instance.GetPrefab("Tar").GetComponentInChildren<MeshRenderer>()).materials; ItemManager.Instance.AddItem(val2); ItemManager.Instance.AddItem(val3); } private static void AddPortalToken() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown CustomItem val = new CustomItem("PortalToken", "Thunderstone"); ItemDrop itemDrop = val.ItemDrop; itemDrop.m_itemData.m_shared.m_name = "Portal Token"; itemDrop.m_itemData.m_shared.m_description = "Me compre para o Detalhes poder manter seu vício."; itemDrop.m_itemData.m_shared.m_maxStackSize = 10; ItemManager.Instance.AddItem(val); } private static void AddNomTameableWolf() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown CustomCreature val = new CustomCreature("LoboNaoDomavel", "Wolf", new CreatureConfig()); Humanoid component = val.Prefab.GetComponent<Humanoid>(); ((Character)component).m_name = "Lobo nao domavel"; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent<Tameable>()); Object.Destroy((Object)(object)val.Prefab.GetComponent<Procreation>()); } private static void AddSkeletao() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) CustomCreature val = new CustomCreature("Skeletao", "Skeleton", new CreatureConfig { Faction = (Faction)3 }); Humanoid component = val.Prefab.GetComponent<Humanoid>(); ((Character)component).m_name = "Esqueletão"; ((Character)component).m_boss = true; ((Character)component).m_health = 500f; SkinnedMeshRenderer[] componentsInChildren = val.Prefab.GetComponentsInChildren<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val2 in array) { ((Renderer)val2).material.color = Color.black; ((Renderer)val2).sharedMaterial.color = Color.black; } Vector3 localScale = val.Prefab.transform.localScale; localScale.x *= 1.3f; localScale.y *= 1.3f; localScale.z *= 1.3f; val.Prefab.transform.localScale = localScale; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent<Tameable>()); Object.Destroy((Object)(object)val.Prefab.GetComponent<Procreation>()); } private static void AddPorcoLox() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0067: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) CustomCreature val = new CustomCreature("PorcoLox", "Lox", new CreatureConfig { Faction = (Faction)2 }); Humanoid component = val.Prefab.GetComponent<Humanoid>(); GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("PorcoLoxRagDoll", "lox_ragdoll"); ((Character)component).m_name = "PorcoLox"; ((Character)component).m_boss = true; ((Character)component).m_health = 300f; ColorRenderers(val.Prefab, Color.black); Vector3 localScale = val.Prefab.transform.localScale; localScale.x *= 0.5f; localScale.y *= 0.5f; localScale.z *= 0.5f; val2.transform.localScale = localScale; int index = ((Character)component).m_deathEffects.m_effectPrefabs.ToList().FindIndex((EffectData x) => ((Object)x.m_prefab).name == "lox_ragdoll"); ((Character)val.Prefab.GetComponent<Humanoid>()).m_deathEffects.m_effectPrefabs.ToList()[index].m_prefab = val2; ColorRenderers(val2, Color.black); val.Prefab.transform.localScale = localScale; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent<Tameable>()); Object.Destroy((Object)(object)val.Prefab.GetComponent<Procreation>()); } public static void ColorRenderers(GameObject gameObject, Color color) { //IL_001a: 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) SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { ((Renderer)val).material.color = color; ((Renderer)val).sharedMaterial.color = color; } } private static void AddBatzao() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) CreatureConfig val = new CreatureConfig(); val.DropConfigs = (DropConfig[])(object)new DropConfig[1] { new DropConfig { Item = "Coins", Chance = 100f, MinAmount = 50, MaxAmount = 100, OnePerPlayer = false, LevelMultiplier = false } }; val.Faction = (Faction)3; CustomCreature val2 = new CustomCreature("Morcegao", "Bat", val); Vector3 localScale = val2.Prefab.transform.localScale; localScale.x *= 3f; localScale.y *= 3f; localScale.z *= 3f; val2.Prefab.transform.localScale = localScale; Humanoid component = val2.Prefab.GetComponent<Humanoid>(); ((Character)component).m_name = "Morcegão"; ((Character)component).m_health = 500f; ((Character)component).m_boss = true; CreatureManager.Instance.AddCreature(val2); } } [HarmonyPatch] public class Patches : MonoBehaviour { [HarmonyPatch(typeof(Player), "SetPlayerID")] internal class SetPlayerID { private static void Postfix(long playerID, string name) { try { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Plugin.PlayerName = ((Character)Player.m_localPlayer).m_nview.GetZDO().GetString("playerName", ""); } } catch { } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetSceneAwake { [HarmonyPriority(0)] private static void Postfix(ZNetScene __instance) { GameObject prefab = __instance.GetPrefab("Bonemass"); GameObject prefab2 = __instance.GetPrefab("Dragon"); GameObject prefab3 = __instance.GetPrefab("GoblinKing"); foreach (GameObject item in new List<GameObject> { prefab, prefab2, prefab3 }) { BaseAI component = item.GetComponent<BaseAI>(); component.m_spawnMessage = ""; component.m_deathMessage = ""; } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class ZNet__OnNewConnection { public static void Postfix(ZNet __instance, ZNetPeer peer) { if (!__instance.IsServer()) { Plugin.steamId = PlayFabManager.m_customId; Debug.LogError((object)("Meu ID: " + Plugin.steamId)); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static class Inventory_Constructor_Patch { public static void Prefix(string name, ref int w, ref int h) { if ((h == 4 && w == 8) || name == "Inventory") { h = 6; } } } [HarmonyPatch(typeof(InventoryGui), "Show")] public class InventoryGui_Show_Patch { private const float oneRowSize = 70.5f; private const float containerOriginalY = -90f; private const float containerHeight = -340f; private static float lastValue; public static void Postfix(ref InventoryGui __instance) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) RectTransform container = __instance.m_container; RectTransform player = __instance.m_player; GameObject gameObject = ((Component)InventoryGui.instance.m_playerGrid).gameObject; int num = Math.Min(6, Math.Max(4, 8)); float num2 = -90f - 70.5f * (float)num; player.SetSizeWithCurrentAnchors((Axis)1, (float)num * 70.5f); container.offsetMax = new Vector2(610f, num2); container.offsetMin = new Vector2(40f, num2 + -340f); if (!Object.op_Implicit((Object)(object)gameObject.GetComponent<InventoryGrid>().m_scrollbar)) { GameObject val = Object.Instantiate<GameObject>(((Component)InventoryGui.instance.m_containerGrid.m_scrollbar).gameObject, gameObject.transform.parent); ((Object)val).name = "PlayerScroll"; ((Behaviour)gameObject.GetComponent<RectMask2D>()).enabled = true; ScrollRect val2 = gameObject.AddComponent<ScrollRect>(); gameObject.GetComponent<RectTransform>().offsetMax = new Vector2(800f, gameObject.GetComponent<RectTransform>().offsetMax.y); gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 1f); val2.content = gameObject.GetComponent<InventoryGrid>().m_gridRoot; val2.viewport = ((Component)__instance.m_player).GetComponentInChildren<RectTransform>(); val2.verticalScrollbar = val.GetComponent<Scrollbar>(); gameObject.GetComponent<InventoryGrid>().m_scrollbar = val.GetComponent<Scrollbar>(); val2.horizontal = false; val2.movementType = (MovementType)2; val2.scrollSensitivity = 70.5f; val2.inertia = false; val2.verticalScrollbarVisibility = (ScrollbarVisibility)1; Scrollbar component = val.GetComponent<Scrollbar>(); lastValue = component.value; } } } [HarmonyPatch(typeof(Chat), "OnNewChatMessage")] internal class OnNewChatMessage { private static bool Prefix(string user, string text) { if (text.ToLower().Contains("i have arrived")) { return false; } return true; } } [HarmonyPatch(typeof(Player), "HaveSeenTutorial")] public class Player_HaveSeenTutorial_Patch { [HarmonyPrefix] private static void Prefix(Player __instance, ref string name) { if (!__instance.m_shownTutorials.Contains(name)) { __instance.m_shownTutorials.Add(name); } } } [HarmonyPatch(typeof(SE_Stats), "Setup")] public static class SE_Stats_Setup_Patch { private static void Postfix(ref SE_Stats __instance) { int num = 200; if (__instance.m_addMaxCarryWeight > 0f) { __instance.m_addMaxCarryWeight = __instance.m_addMaxCarryWeight - 150f + (float)num; } } } [HarmonyPatch(typeof(Player), "Update")] public static class PlayerUpdate { [HarmonyPriority(0)] private static void Postfix(Player __instance) { if (Plugin.StaffMessage.Value != "") { ((Character)Player.m_localPlayer).Message((MessageType)2, Plugin.StaffMessage.Value, 0, (Sprite)null); } } } [HarmonyPatch(typeof(Minimap), "UpdatePlayerPins")] private class UpdatePlayerPins { [HarmonyPriority(0)] private static void Postfix(Minimap __instance) { if (SynchronizationManager.Instance.PlayerIsAdmin) { return; } foreach (PinData playerPin in __instance.m_playerPins) { List<PlayerReference> list = API.GroupPlayers(); if (!list.Exists((PlayerReference x) => x.name == playerPin.m_name)) { __instance.RemovePin(playerPin); } } } } [HarmonyPatch(typeof(SteamGameServer), "SetMaxPlayerCount")] public static class ChangeSteamServerVariables { private static void Prefix(ref int cPlayersMax) { int maxPlayers = Plugin.maxPlayers; if (maxPlayers >= 1) { cPlayersMax = maxPlayers; } } } [HarmonyPatch(typeof(CraftingStation), "Start")] public static class WorkbenchRangeIncrease { public static void Prefix(ref CraftingStation __instance, ref float ___m_rangeBuild, GameObject ___m_areaMarker) { try { ___m_rangeBuild = 30f; ___m_areaMarker.GetComponent<CircleProjector>().m_radius = ___m_rangeBuild; } catch { } } } [HarmonyPatch(typeof(Player), "OnDeath")] [HarmonyPriority(800)] private static class OnDeath { private static bool Prefix(Player __instance, Inventory ___m_inventory, ZNetView ___m_nview, Skills ___m_skills, SEMan ___m_seman, HitData ___m_lastHit) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Invalid comparison between Unknown and I4 //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) if (SynchronizationManager.Instance.PlayerIsAdmin) { return false; } List<ItemData> list = new List<ItemData>(); List<ItemData> value = Traverse.Create((object)___m_inventory).Field("m_inventory").GetValue<List<ItemData>>(); ___m_nview.GetZDO().Set("dead", true); ___m_nview.InvokeRPC(ZNetView.Everybody, "OnDeath", new object[0]); Game.instance.IncrementPlayerStat((PlayerStatType)0, 1f); Traverse.Create((object)__instance).Method("CreateDeathEffects", Array.Empty<object>()).GetValue(); setDeathStat(___m_lastHit); Game.instance.GetPlayerProfile().SetDeathPoint(((Component)__instance).transform.position); Random random = new Random(); for (int num = value.Count - 1; num >= 0; num--) { ItemData val = value[num]; if (!val.m_equipped && !val.m_shared.m_questItem && ((random.Next(1, 100) <= Plugin.DropPercentagePerItem.Value && val.m_durability > 0f) || (int)val.m_shared.m_itemType == 1)) { list.Add(val); value.RemoveAt(num); } } Traverse.Create((object)___m_inventory).Method("Changed", Array.Empty<object>()).GetValue(); if (list.Any()) { GameObject val2 = Object.Instantiate<GameObject>(__instance.m_tombstone, ((Character)__instance).GetCenterPoint(), ((Component)__instance).transform.rotation); val2.GetComponent<Container>().GetInventory().RemoveAll(); int value2 = Traverse.Create((object)___m_inventory).Field("m_width").GetValue<int>(); int value3 = Traverse.Create((object)___m_inventory).Field("m_height").GetValue<int>(); Traverse.Create((object)val2.GetComponent<Container>().GetInventory()).Field("m_width").SetValue((object)value2); Traverse.Create((object)val2.GetComponent<Container>().GetInventory()).Field("m_height").SetValue((object)value3); Traverse.Create((object)val2.GetComponent<Container>().GetInventory()).Field("m_inventory").SetValue((object)list); Traverse.Create((object)val2.GetComponent<Container>().GetInventory()).Method("Changed", Array.Empty<object>()).GetValue(); TombStone component = val2.GetComponent<TombStone>(); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); component.Setup(playerProfile.GetName(), playerProfile.GetPlayerID()); } float num2 = Plugin.SkillDeathFactor.Value; if (num2 > 0.1f) { num2 = 0.01f; } ___m_skills.LowerAllSkills(num2); Player.m_localPlayer.ClearFood(); Game.instance.RequestRespawn(10f, false); ___m_seman.RemoveAllStatusEffects(false); Minimap.instance.AddPin(((Component)__instance).transform.position, (PinType)4, $"$hud_mapday {EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds())}", true, false, 0L, ""); if (((Character)__instance).m_onDeath != null) { ((Character)__instance).m_onDeath(); } Biome currentBiome = __instance.GetCurrentBiome(); string text = "biome:" + ((object)(Biome)(ref currentBiome)).ToString(); Gogan.LogEvent("Game", "Death", text, 0L); return false; } } [HarmonyPatch(typeof(Skills), "RaiseSkill")] public static class RaiseSkill { private static bool Prefix(ref Skills __instance, ref SkillType skillType, ref float factor) { Skill skill = __instance.GetSkill(skillType); if (skill.m_level >= (float)Plugin.SkillCap.Value) { return false; } factor *= Plugin.SkillMultiplier.Value; return true; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] public static class TeleportWorldAesir { private static bool Prefix(TeleportWorld __instance) { if (Plugin.Vip.Value.Contains(Plugin.steamId)) { return true; } if (!Plugin.VipPortalNames.Value.Contains(__instance.GetText())) { return true; } ((Character)Player.m_localPlayer).Message((MessageType)2, "Only Aesir's can access this portal.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(InventoryGui), "CanRepair")] public static class CanRepair { private static void Postfix(InventoryGui __instance, ref bool __result, ItemData item) { if (((Object)item.m_dropPrefab).name.Contains("SkeletaoSword") || ((Object)item.m_dropPrefab).name.Contains("SkeletaoShield")) { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if (((Object)((Component)currentCraftingStation).gameObject).name.Contains("forge")) { __result = true; } } } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(0)] private static bool Prefix(Piece piece, Player __instance) { if (Plugin.Vip.Value.Contains(Plugin.steamId)) { return true; } if (((Object)((Component)piece).gameObject).name == "AesirChest") { ((Character)__instance).Message((MessageType)2, "Esse báu é apenas para Aesir's", 0, (Sprite)null); return false; } return true; } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "OnSpawned")] private static void OnSpawnedPostfix() { ((Character)Player.m_localPlayer).m_nview.GetZDO().Set("playerName", Plugin.PlayerName + " " + EpicMMOApi.GetLevel()); } [HarmonyPostfix] [HarmonyPatch(typeof(Game), "Update")] private static void GameUpdate() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ZNet.instance.SetPublicReferencePosition(true); ((Selectable)InventoryGui.instance.m_pvp).interactable = false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Awake_Postfix(ref Player __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (ZRoutedRpc.instance != null) { ItemService.SetWardFirePlace(); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "Sync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(Player), "EdgeOfWorldKill")] [HarmonyPrefix] public static bool EdgeOfWorldKill() { return false; } public static void setDeathStat(HitData ___m_lastHit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_005c: Expected I4, but got Unknown HitType hitType = ___m_lastHit.m_hitType; HitType val = hitType; switch ((int)val) { case 0: Game.instance.IncrementPlayerStat((PlayerStatType)55, 1f); break; case 1: Game.instance.IncrementPlayerStat((PlayerStatType)56, 1f); break; case 2: Game.instance.IncrementPlayerStat((PlayerStatType)57, 1f); break; case 3: Game.instance.IncrementPlayerStat((PlayerStatType)58, 1f); break; case 4: Game.instance.IncrementPlayerStat((PlayerStatType)59, 1f); break; case 5: Game.instance.IncrementPlayerStat((PlayerStatType)60, 1f); break; case 6: Game.instance.IncrementPlayerStat((PlayerStatType)61, 1f); break; case 7: Game.instance.IncrementPlayerStat((PlayerStatType)62, 1f); break; case 8: Game.instance.IncrementPlayerStat((PlayerStatType)64, 1f); break; case 9: Game.instance.IncrementPlayerStat((PlayerStatType)63, 1f); break; case 10: Game.instance.IncrementPlayerStat((PlayerStatType)65, 1f); break; case 11: Game.instance.IncrementPlayerStat((PlayerStatType)66, 1f); break; case 12: Game.instance.IncrementPlayerStat((PlayerStatType)67, 1f); break; case 13: Game.instance.IncrementPlayerStat((PlayerStatType)68, 1f); break; case 14: Game.instance.IncrementPlayerStat((PlayerStatType)69, 1f); break; case 15: Game.instance.IncrementPlayerStat((PlayerStatType)70, 1f); break; case 16: Game.instance.IncrementPlayerStat((PlayerStatType)71, 1f); break; case 17: Game.instance.IncrementPlayerStat((PlayerStatType)72, 1f); break; case 18: Game.instance.IncrementPlayerStat((PlayerStatType)73, 1f); break; default: ZLog.LogWarning((object)("Not implemented death type " + ((object)(HitType)(ref ___m_lastHit.m_hitType)).ToString())); break; } } } [HarmonyPatch] internal class Smelters { [HarmonyPatch(typeof(Smelter), "Awake")] public static class Smelter_Awake_Patch { private static void Prefix(ref Smelter __instance) { string value = "$piece_charcoalkiln"; string value2 = "$piece_smelter"; string value3 = "$piece_blastfurnace"; if (__instance.m_name.Equals(value)) { __instance.m_maxOre = 100; __instance.m_secPerProduct = 20f; } else if (__instance.m_name.Equals(value2)) { __instance.m_maxOre = 50; __instance.m_maxFuel = 100; __instance.m_secPerProduct = 20f; __instance.m_fuelPerProduct = 2; } else if (__instance.m_name.Equals(value3)) { __instance.m_maxOre = 50; __instance.m_maxFuel = 100; __instance.m_secPerProduct = 20f; __instance.m_fuelPerProduct = 2; } } } } } namespace Deadheim.world { internal class World { [HarmonyPatch(typeof(ZNet), "SaveWorldThread")] internal class SaveWorldThread { private static void Prefix(ref ZNet __instance) { if (Plugin.ResetWorldDay.Value) { __instance.m_netTime = 2040.0; } } } } } namespace Deadheim.EnhancedWards { [HarmonyPatch] public class Ward { [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] public static class RPC_Damage { [HarmonyPriority(800)] private static bool Prefix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) try { if (___m_nview == null) { return false; } if (!CheckInPrivateArea(((Component)__instance).transform.position)) { return true; } if (((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return false; } if (((Object)((Component)__instance).gameObject).name.Contains("AdminWard")) { return false; } if (Vector3.Distance(new Vector3(0f, 0f), ((Component)Player.m_localPlayer).transform.position) <= (float)Plugin.SafeArea.Value) { return false; } return true; } catch (Exception ex) { Debug.LogError((object)(ex.Message + " - " + ex.StackTrace)); return false; } } } [HarmonyPatch(typeof(Door), "CanInteract")] public static class DoorCanInteract { private static void Postfix(Door __instance, ref bool __result) { string name = ((Object)((Component)__instance).gameObject).name; name = name.Replace("(Clone)", ""); if (Plugin.DungeonPrefabs.Value.Split(new char[1] { ',' }).Contains(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", ""))) { __result = true; } } } [HarmonyPatch(typeof(PrivateArea), "IsEnabled")] public static class PrivateAreaCheckAccess { private static void Postfix(PrivateArea __instance, ref bool __result) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)localPlayer.m_hovering)) { return; } Interactable componentInParent = localPlayer.m_hovering.GetComponentInParent<Interactable>(); if (componentInParent == null) { return; } Door val = null; Container val2 = null; if (((object)componentInParent).GetType().Name == "Door") { val = (Door)componentInParent; } if (((object)componentInParent).GetType().Name == "Container") { val2 = (Container)componentInParent; } if (val == null && val2 == null) { return; } string text = ""; if (val != null) { text = ((Object)((Component)val).gameObject).name; } if (Object.op_Implicit((Object)(object)val2)) { text = ((Object)((Component)val2).gameObject).name; } if (!(text == "")) { text = text.Replace("(Clone)", ""); if (Plugin.DungeonPrefabs.Value.Split(new char[1] { ',' }).Contains(text)) { __result = false; } } } } [HarmonyPatch(typeof(Fireplace), "UpdateState")] public static class FireplaceUpdateState { private static bool Prefix(Fireplace __instance) { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } return false; } } [HarmonyPatch(typeof(Fireplace), "Awake")] public static class FireplaceAwake { private static bool Prefix(Fireplace __instance) { try { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } __instance.m_nview = ((Component)__instance).gameObject.GetComponent<ZNetView>(); __instance.m_piece = ((Component)__instance).gameObject.GetComponent<Piece>(); if (__instance.m_nview.GetZDO() == null) { return false; } if (__instance.m_nview.IsOwner() && (double)__instance.m_nview.GetZDO().GetFloat("fuel", -1f) == -1.0) { __instance.m_nview.GetZDO().Set("fuel", __instance.m_startFuel); } __instance.m_nview.Register("AddFuel", (Action<long>)__instance.RPC_AddFuel); ((MonoBehaviour)__instance).InvokeRepeating("UpdateFireplace", 0f, 10f); return false; } catch { return false; } } } [HarmonyPatch(typeof(Fireplace), "UpdateFireplace")] public static class UpdateFireplace { private static bool Prefix(Fireplace __instance) { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } if (!__instance.m_nview.IsValid()) { return false; } Piece component = ((Component)__instance).gameObject.GetComponent<Piece>(); if (__instance.m_nview.IsOwner()) { if (__instance.m_fuelItem == null) { __instance.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent<ItemDrop>(); } __instance.m_secPerFuel = Plugin.WardChargeDurationInSec.Value; __instance.m_maxFuel = 10f; PrivateArea component2 = ((Component)__instance).gameObject.GetComponent<PrivateArea>(); float @float = __instance.m_nview.GetZDO().GetFloat("fuel", 0f); double timeSinceLastUpdate = __instance.GetTimeSinceLastUpdate(); float num = (float)timeSinceLastUpdate / __instance.m_secPerFuel; float num2 = @float - num; if ((double)num2 <= 0.0) { num2 = 0f; if (component2.IsEnabled()) { component2.SetEnabled(false); } } if (num2 > 10f) { num2 = 10f; } __instance.m_nview.GetZDO().Set("fuel", num2); } return false; } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(800)] private static bool Prefix(Piece piece, Player __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (SynchronizationManager.Instance.PlayerIsAdmin) { return true; } bool flag = ((Object)((Component)piece).gameObject).name.Contains("guard_stone"); bool flag2 = false; Vector3 position = __instance.m_placementGhost.transform.position; if (flag) { List<ZDO> zDOList = GetZDOList(StringExtensionMethods.GetStableHashCode(((Object)((Component)piece).gameObject).name)); foreach (ZDO item in zDOList) { if (Vector3.Distance(new Vector3(position.x, 0f, position.z), new Vector3(item.m_position.x, 0f, item.m_position.z)) <= ((Component)piece).GetComponent<PrivateArea>().m_radius * 3f && !IsBuilderPermitted(item, __instance)) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Não é possível construir wards próximo da área de outros wards.", 0, (Sprite)null); return false; } } } if (!flag) { return true; } int wardCount = GetWardCount(); if (Plugin.Vip.Value.Contains(Plugin.steamId)) { if (wardCount >= Plugin.WardLimitVip.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar wards.", 0, (Sprite)null); return false; } } else if (wardCount >= Plugin.WardLimit.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar wards.", 0, (Sprite)null); return false; } Minimap.instance.AddPin(((Component)__instance).transform.position, (PinType)9, "WARD", true, false, 0L, ""); ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return true; } } [HarmonyPatch(typeof(Player), "Update")] public static class Update { private static void Postfix(ref Player __instance) { //IL_0064: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance.m_hovering)) { return; } Interactable componentInParent = __instance.m_hovering.GetComponentInParent<Interactable>(); if (componentInParent == null) { return; } PrivateArea val = (PrivateArea)(object)((componentInParent is PrivateArea) ? componentInParent : null); if (val == null) { return; } Fireplace componentInParent2 = ((Component)val).GetComponentInParent<Fireplace>(); StringBuilder stringBuilder = new StringBuilder(256); KeyCode val2 = (KeyCode)107; KeyCode val3 = (KeyCode)121; if (val.IsPermitted(__instance.GetPlayerID()) || val.m_piece.m_creator == __instance.GetPlayerID()) { if (Object.op_Implicit((Object)(object)componentInParent2)) { stringBuilder.Append("\n[<color=yellow><b>" + ((object)(KeyCode)(ref val3)).ToString() + "</b></color>] Fuel: " + Math.Round(componentInParent2.m_nview.GetZDO().GetFloat("fuel", 0f), 2) + "/" + componentInParent2.m_maxFuel); } stringBuilder.Append("\n[<color=yellow><b>" + ((object)(KeyCode)(ref val2)).ToString() + "</b></color>]"); val.m_name = stringBuilder.ToString(); val.AddUserList(stringBuilder); if (Input.GetKeyDown(val2)) { Interact(__instance, __instance.m_hovering, val); } if (Input.GetKeyDown(val3)) { FuelWard(__instance, componentInParent2); } } } public static void FuelWard(Player player, Fireplace fireplace) { if (!((double)fireplace.m_holdRepeatInterval <= 0.0) && !(Time.time - fireplace.m_lastUseTime < fireplace.m_holdRepeatInterval)) { if (!fireplace.m_nview.HasOwner()) { fireplace.m_nview.ClaimOwnership(); } if (fireplace.m_fuelItem == null) { fireplace.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent<ItemDrop>(); } fireplace.Interact((Humanoid)(object)player, false, false); } } public static void Interact(Player player, GameObject go, PrivateArea privateArea) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_006d: Unknown result type (might be due to invalid IL or missing references) player.m_lastHoverInteractTime = Time.time; privateArea.m_nview.InvokeRPC("ToggleEnabled", new object[1] { privateArea.m_piece.GetCreator() }); Vector3 val = go.transform.position - ((Component)player).transform.position; val.y = 0f; ((Vector3)(ref val)).Normalize(); ((Component)player).transform.rotation = Quaternion.LookRotation(val); ((Character)player).m_zanim.SetTrigger("interact"); } } public static bool CheckInPrivateArea(Vector3 point, bool flash = false) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) foreach (PrivateArea allArea in PrivateArea.m_allAreas) { if (allArea.IsEnabled() && allArea.IsInside(point, 0f)) { if (flash) { allArea.FlashShield(false); } return true; } } return false; } private static int GetWardCount() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (SynchronizationManager.Instance.PlayerIsAdmin) { return 0; } ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return Plugin.PlayerWardCount; } private static List<ZDO> GetZDOList(int prefabHash) { List<ZDO> list = new List<ZDO>(); List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List<ZDO> list2 in objectsBySector) { if (list2 == null) { continue; } for (int j = 0; j < list2.Count; j++) { ZDO val = list2[j]; if (val.GetPrefab() == prefabHash) { list.Add(val); } } } return list; } private static bool IsBuilderPermitted(ZDO zdo, Player player) { List<KeyValuePair<long, string>> list = new List<KeyValuePair<long, string>>(); long @long = zdo.GetLong(Util.CREATORHASH, 0L); if (@long == player.GetPlayerID()) { return true; } int @int = zdo.GetInt("permitted", 0); for (int i = 0; i < @int; i++) { long long2 = zdo.GetLong("pu_id" + i, 0L); string @string = zdo.GetString("pu_name" + i, ""); if (long2 != 0) { list.Add(new KeyValuePair<long, string>(long2, @string)); } } foreach (KeyValuePair<long, string> item in list) { if (item.Key == player.GetPlayerID()) { return true; } } return false; } } } namespace Deadheim.Craft { public class CraftPatches { [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private class FasterCrafting { private static void Prefix(ref InventoryGui __instance) { __instance.m_craftDuration = 0.25f; } } } }
DeadLogger.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace DeadLogger { internal class Patches { [HarmonyPatch(typeof(Player), "PlacePiece")] public static class PlacePiece { private static void Postfix(Player __instance, Piece piece, bool __result) { if (__result) { Util.PrepareLog("Construiu: ", __instance, ((Component)piece).gameObject); } } } [HarmonyPatch(typeof(Player), "RemovePiece")] public static class RemovePiece { public static Piece pieceRemoved; public static string portalTag = ""; private static void Postfix(Player __instance, bool __result) { if (!__result) { return; } string textToAppend = "Destruiu: "; try { TeleportWorld component = ((Component)pieceRemoved).gameObject.GetComponent<TeleportWorld>(); if (Object.op_Implicit((Object)(object)component)) { textToAppend = "Destruiu Portal " + portalTag + " : "; } PrivateArea component2 = ((Component)pieceRemoved).gameObject.GetComponent<PrivateArea>(); Fireplace component3 = ((Component)pieceRemoved).gameObject.GetComponent<Fireplace>(); if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component2)) { textToAppend = "Destruiu Totem Combustivel " + component3.m_nview.GetZDO().GetFloat("fuel", -1f) + " : "; } } catch { } Util.PrepareLog(textToAppend, __instance, ((Component)pieceRemoved).gameObject); } private static void Finalizer() { pieceRemoved = null; portalTag = ""; } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] public static class PieceRemoved { private static void Postfix(Piece piece) { RemovePiece.pieceRemoved = piece; TeleportWorld component = ((Component)piece).gameObject.GetComponent<TeleportWorld>(); if (Object.op_Implicit((Object)(object)component)) { RemovePiece.portalTag = component.GetText() + " : "; } } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] public static class RPC_Damage { private static void Postfix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown if (___m_nview != null && Object.op_Implicit((Object)(object)hit.GetAttacker()) && hit.GetAttacker().IsPlayer()) { float totalDamage = hit.GetTotalDamage(); string textToAppend = "Destruiu Hit: "; TeleportWorld component = ((Component)__instance).gameObject.GetComponent<TeleportWorld>(); if (Object.op_Implicit((Object)(object)component)) { textToAppend = "Destruiu Hit Portal " + component.GetText() + " : "; } PrivateArea component2 = ((Component)__instance).gameObject.GetComponent<PrivateArea>(); Fireplace component3 = ((Component)__instance).gameObject.GetComponent<Fireplace>(); if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component2)) { textToAppend = "Destruiu Totem Combustivel " + component3.m_nview.GetZDO().GetFloat("fuel", -1f) + " : "; } if (__instance.m_health <= totalDamage) { Util.PrepareLog(textToAppend, (Player)hit.GetAttacker(), ((Component)__instance).gameObject); } } } } [HarmonyPatch(typeof(Door), "Interact")] public static class DoorCanInteract { private static void Postfix(Door __instance, ref bool __result, Humanoid character) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (__result && ((Character)character).IsPlayer()) { Util.PrepareLog("Interagiu Porta: ", (Player)character, ((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(Container), "Interact")] public static class ContainerInteract { private static void Postfix(Container __instance, ref bool __result, Humanoid character) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (__result && ((Character)character).IsPlayer()) { Util.PrepareLog("Interagiu Container: ", (Player)character, ((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(PrivateArea), "Interact")] public static class PrivateAreaInteract { private static void Postfix(PrivateArea __instance, ref bool __result, Humanoid human) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown if (__result && ((Character)human).IsPlayer()) { string textToAppend = "Interagiu Totem: "; PrivateArea component = ((Component)__instance).gameObject.GetComponent<PrivateArea>(); Fireplace component2 = ((Component)__instance).gameObject.GetComponent<Fireplace>(); if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component)) { textToAppend = "Interagiu Totem Combustivel " + component2.m_nview.GetZDO().GetFloat("fuel", -1f) + " : "; } Util.PrepareLog(textToAppend, (Player)human, ((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(TeleportWorld), "Interact")] public static class TeleportInteract { private static void Postfix(TeleportWorld __instance, ref bool __result, Humanoid human) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (__result && ((Character)human).IsPlayer()) { Util.PrepareLog("Interagiu Portal " + __instance.GetText() + " : ", (Player)human, ((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] public static class TeleportTeleport { private static void Postfix(TeleportWorld __instance, Player player) { if (__instance.TargetFound() && !ZoneSystem.instance.GetGlobalKey("noportals") && ((Humanoid)player).IsTeleportable() && ((Character)player).IsPlayer()) { PlayerTeleportTo.PortalName = __instance.GetText(); } } } [HarmonyPatch(typeof(Player), "TeleportTo")] public static class PlayerTeleportTo { public static string PortalName = ""; private static void Postfix(Player __instance, ref bool __result, Vector3 pos) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (__result) { Util.PrepareLog("Teleportou com portal" + PortalName + " para x " + (int)pos.x + "," + (int)pos.z + ": ", __instance, ((Component)__instance).gameObject); } } private static void Finalizer() { PortalName = ""; } } } [BepInPlugin("Detalhes.DeadLogger", "Detalhes.DeadLogger", "1.0.0")] public class DeadLogger : BaseUnityPlugin { public const string PluginGUID = "Detalhes.DeadLogger"; public const string Name = "DeadLogger"; public const string Version = "1.0.0"; private ConfigSync configSync = new ConfigSync("Detalhes.DeadLogger") { DisplayName = "DeadLogger", CurrentVersion = "1.0.0", MinimumRequiredVersion = "1.0.0" }; private Harmony _harmony = new Harmony("Detalhes.DeadLogger"); public static ConfigEntry<string> PrefabsToLog; public static GameObject Menu; public static string FileDirectory = Paths.ConfigPath + "/DeadLogger/"; public void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown PrefabsToLog = config("Server config", "PrefabsToLog", "", new ConfigDescription("PrefabsToLog", (AcceptableValueBase)null, Array.Empty<object>())); _harmony.PatchAll(); } private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } } [HarmonyPatch] internal class RPC { [HarmonyPatch(typeof(Game), "Start")] public static class GameStart { public static void Postfix() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("DeadLogger_SaveLog", (Action<long, ZPackage>)RPC_DeadLogger_SaveLog); } } } public static void RPC_DeadLogger_SaveLog(long sender, ZPackage pkg) { if (ZNet.instance.IsServer()) { string[] array = pkg.ReadString().Split(new char[1] { '|' }); string text = array[0]; string text2 = array[1]; string text3 = array[2]; string path = DeadLogger.FileDirectory + "generalLog.txt"; string text4 = text + "_" + text2 + ".txt"; string path2 = DeadLogger.FileDirectory + text4; if (!Directory.Exists(DeadLogger.FileDirectory)) { Directory.CreateDirectory(DeadLogger.FileDirectory); } DateTime dateTime = DateTime.UtcNow.AddHours(-3.0); string text5 = dateTime.Hour + ":" + dateTime.Minute + " " + dateTime.Day + "/" + dateTime.Month + "/" + dateTime.Year; text3 = text3 + " " + text5; File.AppendAllText(path2, text3 + Environment.NewLine); File.AppendAllText(path, text + " " + text2 + " " + text3 + Environment.NewLine); } } } public class Util { public static void SendLog(string description, Vector3 pos, string nick, long peerId, long creatorId) { //IL_0015: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown description = description + " Posição: " + (int)pos.x + "," + (int)pos.z; description = description + " CreatorId: " + creatorId; ZPackage val = new ZPackage(); string text = nick + "|"; text = text + peerId + "|"; text = text + description + "|"; val.Write(text); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "DeadLogger_SaveLog", new object[1] { val }); } public static void PrepareLog(string textToAppend, Player __instance, GameObject gameObject) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00e4: Unknown result type (might be due to invalid IL or missing references) if (!(DeadLogger.PrefabsToLog.Value != "") || DeadLogger.PrefabsToLog.Value.Contains(((Object)gameObject).name)) { List<PlayerInfo> list = new List<PlayerInfo>(); ZNet.instance.GetOtherPublicPlayers(list); long peerId = ((Character)__instance).m_nview.m_zdo.GetOwner(); PlayerInfo val = ((IEnumerable<PlayerInfo>)list).FirstOrDefault((Func<PlayerInfo, bool>)((PlayerInfo x) => ((ZDOID)(ref x.m_characterID)).UserID == peerId)); string nick = val.m_name; if (__instance.GetPlayerID() == Player.m_localPlayer.GetPlayerID()) { nick = Game.instance.GetPlayerProfile().m_playerName; } long creatorId = 0L; Piece component = gameObject.GetComponent<Piece>(); if (Object.op_Implicit((Object)(object)component)) { creatorId = component.m_creator; } SendLog(textToAppend + ((Object)gameObject).name, ((Component)__instance).transform.position, nick, __instance.GetPlayerID(), creatorId); } } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [PublicAPI] internal abstract class OwnConfigEntryBase { public object? LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] internal class SyncedConfigEntry<T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } internal abstract class CustomSyncedValueBase { public object? LocalBaseValue; public readonly string Identifier; public readonly Type Type; private object? boxedValue; protected bool localIsOwner; public readonly int Priority; public object? BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action? ValueChanged; protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [PublicAPI] internal class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { public static ZRpc? currentRpc; [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } static IEnumerator WatchAdminListChanges() { SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = (from p in ZNet.instance.GetPeers() where adminList.Contains(p.m_rpc.GetSocket().GetHostName()) select p).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } private class ParsedConfigs { public readonly Dictionary<OwnConfigEntryBase, object?> configValues = new Dictionary<OwnConfigEntryBase, object>(); public readonly Dictionary<CustomSyncedValueBase, object?> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private class SendConfigsAfterLogin { private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix(ref Dictionary<Assembly, BufferingSocket>? __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZRpc rpc2 = rpc; ZNet __instance2 = __instance; Dictionary<Assembly, BufferingSocket> __state2 = __state; ZNetPeer peer; if (__instance2.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance2).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc2.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc2, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state2[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc2.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc2.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select((OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance2).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } private class PackageEntry { public string section = null; public string key = null; public Type type = null; public object? value; } [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] private static class PreventSavingServerInfo { [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, ref string __result) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase)) { return true; } __result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType); return false; } } [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] private static class PreventConfigRereadChangingValues { [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, string value) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null) { return true; } try { ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType); } catch (Exception ex) { Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}"); } return false; } } private class InvalidDeserializationTypeException : Exception { public string expected = null; public string received = null; public string field = ""; } public static bool ProcessingServerUpdate; public readonly string Name; public string? DisplayName; public string? CurrentVersion; public string? MinimumRequiredVersion; public bool ModRequired = false; private bool? forceConfigLocking; private bool isSourceOfTruth = true; private static readonly HashSet<ConfigSync> configSyncs; private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>(); private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>(); private static bool isServer; private static bool lockExempt; private OwnConfigEntryBase? lockedConfig = null; private const byte PARTIAL_CONFIGS = 1; private const byte FRAGMENTED_CONFIG = 2; private const byte COMPRESSED_CONFIG = 4; private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>(); private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>(); private static long packageCounter; public bool IsLocked { get { bool? flag = forceConfigLocking; bool num; if (!flag.HasValue) { if (lockedConfig == null) { goto IL_0052; } num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0; } else { num = flag.GetValueOrDefault(); } if (!num) { goto IL_0052; } int result = ((!lockExempt) ? 1 : 0); goto IL_0053; IL_0053: return (byte)result != 0; IL_0052: result = 0; goto IL_0053; } set { forceConfigLocking = value; } } public bool IsAdmin => lockExempt || isSourceOfTruth; public bool IsSourceOfTruth { get { return isSourceOfTruth; } private set { if (value != isSourceOfTruth) { isSourceOfTruth = value; this.SourceOfTruthChanged?.Invoke(value); } } } public bool InitialSyncDone { get; private set; } = false; public event Action<bool>? SourceOfTruthChanged; private event Action? lockedConfigChanged; static ConfigSync() { ProcessingServerUpdate = false; configSyncs = new HashSet<ConfigSync>(); lockExempt = false; packageCounter = 0L; RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle); } public ConfigSync(string name) { Name = name; configSyncs.Add(this); new VersionCheck(this); } public SyncedConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry) { ConfigEntry<T> configEntry2 = configEntry; OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry2); SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>; if (syncedEntry == null) { syncedEntry = new SyncedConfigEntry<T>(configEntry2); AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry2).Description, new object[1] { new ConfigurationManagerAttributes() }.Concat(((ConfigEntryBase)configEntry2).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray()); configEntry2.SettingChanged += delegate { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry2); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) { throw new Exception("Cannot initialize locking ConfigEntry twice"); } lockedConfig = AddConfigEntry<T>(lockingConfig); lockingConfig.SettingChanged += delegate { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { CustomSyncedValueBase customValue2 = customValue; if (allCustomValues.Select((CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue2.Identifier)) { throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)"); } allCustomValues.Add(customValue2); allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending((CustomSyncedValueBase v) => v.Priority)); customValue2.ValueChanged += delegate { if (!ProcessingServerUpdate) { Broadcast(ZRoutedRpc.Everybody, customValue2); } }; } private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package) { lockedConfigChanged += serverLockedSettingChanged; IsSourceOfTruth = false; if (HandleConfigSyncRPC(0L, package, clientUpdate: false)) { InitialSyncDone = true; } } private void RPC_FromOtherClientConfigSync(long sender, ZPackage package) { HandleConfigSyncRPC(sender, package, clientUpdate: true); } private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown try { if (isServer && IsLocked) { ZRpc? currentRpc = SnatchCurrentlyHandlingRPC.currentRpc; object obj; if (currentRpc == null) { obj = null; } else { ISocket socket = currentRpc.GetSocket(); obj = ((socket != null) ? socket.GetHostName() : null); } string text = (string)obj; if (text != null) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text })))) { return false; } } } cacheExpirations.RemoveAll(delegate(KeyValuePair<long, string> kv) { if (kv.Key < DateTimeOffset.Now.Ticks) { configValueCache.Remove(kv.Value); return true; } return false; }); byte b = package.ReadByte(); if ((b & 2u) != 0) { long num = package.ReadLong(); string text2 = sender.ToString() + num; if (!configValueCache.TryGetValue(text2, out SortedDictionary<int, byte[]> value)) { value = new SortedDictionary<int, byte[]>(); configValueCache[text2] = value; cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2)); } int key = package.ReadInt(); int num2 = package.ReadInt(); value.Add(key, package.ReadByteArray()); if (value.Count < num2) { return false; } configValueCache.Remove(text2); package = new ZPackage(value.Values.SelectMany((byte[] a) => a).ToArray()); b = package.ReadByte(); } ProcessingServerUpdate = true; if ((b & 4u) != 0) { byte[] buffer = package.ReadByteArray(); MemoryStream stream = new MemoryStream(buffer); MemoryStream memoryStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } package = new ZPackage(memoryStream.ToArray()); b = package.ReadByte(); } if ((b & 1) == 0) { resetConfigsFromServer(); } ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package); foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues) { if (!isServer && configValue.Key.LocalBaseValue == null) { configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue; } configValue.Key.BaseConfig.BoxedValue = configValue.Value; } foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues) { if (!isServer) { CustomSyncedValueBase key2 = customValue.Key; if (key2.LocalBaseValue == null) { key2.LocalBaseValue = customValue.Key.BoxedValue; } } customValue.Key.BoxedValue = customValue.Value; } Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name)); if (!isServer) { serverLockedSettingChanged(); } return true; } finally { ProcessingServerUpdate = false; } } private ParsedConfigs ReadConfigsFromPackage(ZPackage package) { ParsedConfigs parsedConfigs = new ParsedConfigs(); Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where((OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary((OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary((CustomSyncedValueBase c) => c.Identifier, (CustomSyncedValueBase c) => c); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string text = package.ReadString(); string text2 = package.ReadString(); string text3 = package.ReadString(); Type type = Type.GetType(text3); if (text3 == "" || type != null) { object obj; try { obj = ((text3 == "") ? null : ReadValueWithTypeFromZPackage(package, type)); } catch (InvalidDeserializationTypeException ex) { Debug.LogWarning((object)("Got unexpected struct internal type " + ex.received + " for field " + ex.field + " struct " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + ex.expected)); continue; } OwnConfigEntryBase value2; if (text == "Internal") { CustomSyncedValueBase value; if (text2 == "serverversion") { if (obj?.ToString() != CurrentVersion) { Debug.LogWarning((object)("Received server version is not equal: server version = " + (obj?.ToString() ?? "null") + "; local version = " + (CurrentVersion ?? "unknown"))); } } else if (text2 == "lockexempt") { if (obj is bool flag) { lockExempt = flag; } } else if (dictionary2.TryGetValue(text2, out value)) { if ((text3 == "" && (!value.Type.IsValueType || Nullable.GetUnderlyingType(value.Type) != null)) || GetZPackageTypeString(value.Type) == text3) { parsedConfigs.customValues[value] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for internal value " + text2 + " for mod " + (DisplayName ?? Name) + ", expecting " + value.Type.AssemblyQualifiedName)); } } else if (dictionary.TryGetValue(text + "_" + text2, out value2)) { Type type2 = configType(value2.BaseConfig); if ((text3 == "" && (!type2.IsValueType || Nullable.GetUnderlyingType(type2) != null)) || GetZPackageTypeString(type2) == text3) { parsedConfigs.configValues[value2] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + type2.AssemblyQualifiedName)); } else { Debug.LogWarning((object)("Received unknown config entry " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ". This may happen if client and server versions of the mod do not match.")); } continue; } Debug.LogWarning((object)("Got invalid type " + text3 + ", abort reading of received configs")); return new ParsedConfigs(); } return parsedConfigs; } private static bool isWritableConfig(OwnConfigEntryBase config) { OwnConfigEntryBase config2 = config; ConfigSync configSync = configSyncs.FirstOrDefault((ConfigSync cs) => cs.allConfigs.Contains(config2)); if (configSync == null) { return true; } return configSync.IsSourceOfTruth || !config2.SynchronizedConfig || config2.LocalBaseValue == null || (!configSync.IsLocked && (config2 != configSync.lockedConfig || lockExempt)); } private void serverLockedSettingChanged() { foreach (OwnConfigEntryBase allConfig in allConfigs) { configAttribute<ConfigurationManagerAttributes>(allConfig.BaseConfig).ReadOnly = !isWritableConfig(allConfig); } } private void resetConfigsFromServer() { foreach (OwnConfigEntryBase item in allConfigs.Where((OwnConfigEntryBase config) => config.LocalBaseValue != null)) { item.BaseConfig.BoxedValue = item.LocalBaseValue; item.LocalBaseValue = null; } foreach (CustomSyncedValueBase item2 in allCustomValues.Where((CustomSyncedValueBase config) => config.LocalBaseValue != null)) { item2.BoxedValue = item2.LocalBaseValue; item2.LocalBaseValue = null; } lockedConfigChanged -= serverLockedSettingChanged; serverLockedSettingChanged(); } private IEnumerator<bool> distributeConfigToPeers(ZNetPeer peer, ZPackage package) { ZNetPeer peer2 = peer; ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc == null) { yield break; } byte[] data = package.GetArray(); if (data != null && data.LongLength > 250000) { int fragments = (int)(1 + (data.LongLength - 1) / 250000); long packageIdentifier = ++packageCounter; int fragment = 0; while (fragment < fragments) { foreach (bool item in waitForQueue()) { yield return item; } if (peer2.m_socket.IsConnected()) { ZPackage fragmentedPackage = new ZPackage(); fragmentedPackage.Write((byte)2); fragmentedPackage.Write(packageIdentifier); fragmentedPackage.Write(fragment); fragmentedPackage.Write(fragments); fragmentedPackage.Write(data.Skip(250000 * fragment).Take(250000).ToArray()); SendPackage(fragmentedPackage); if (fragment != fragments - 1) { yield return true; } int num = fragment + 1; fragment = num; continue; } break; } yield break; } foreach (bool item2 in waitForQueue()) { yield return item2; } SendPackage(package); void SendPackage(ZPackage pkg) { string text = Name + " ConfigSync"; if (isServer) { peer2.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer2.m_server ? 0 : peer2.m_uid, text, new object[1] { pkg }); } } IEnumerable<bool> waitForQueue() { float timeout = Time.time + 30f; while (peer2.m_socket.GetSendQueueSize() > 20000) { if (Time.time > timeout) { Debug.Log((object)$"Disconnecting {peer2.m_uid} after 30 seconds config sending timeout"); peer2.m_rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)5 }); ZNet.instance.Disconnect(peer2); break; } yield return false; } } } private IEnumerator sendZPackage(long target, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return Enumerable.Empty<object>().GetEnumerator(); } List<ZNetPeer> list = (List<ZNetPeer>)AccessTools.DeclaredField(typeof(ZRoutedRpc), "m_peers").GetValue(ZRoutedRpc.instance); if (target != ZRoutedRpc.Everybody) { list = list.Where((ZNetPeer p) => p.m_uid == target).ToList(); } return sendZPackage(list, package); } private IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { ZPackage package2 = package; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package2.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write((byte)4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package2 = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select distributeConfigToPeers(p, package2)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private void Broadcast(long target, params ConfigEntryBase[] configs) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(configs); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private void Broadcast(long target, params CustomSyncedValueBase[] customValues) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(null, customValues); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private static OwnConfigEntryBase? configData(ConfigEntryBase config) { return config.Description.Tags?.OfType<OwnConfigEntryBase>().SingleOrDefault(); } public static SyncedConfigEntry<T>? ConfigData<T>(ConfigEntry<T> config) { return ((ConfigEntryBase)config).Description.Tags?.OfType<SyncedConfigEntry<T>>().SingleOrDefault(); } private static T configAttribute<T>(ConfigEntryBase config) { return config.Description.Tags.OfType<T>().First(); } private static Type configType(ConfigEntryBase config) { return configType(config.SettingType); } private static Type configType(Type type) { return type.IsEnum ? Enum.GetUnderlyingType(type) : type; } private static ZPackage ConfigsToPackage(IEnumerable<ConfigEntryBase>? configs = null, IEnumerable<CustomSyncedValueBase>? customValues = null, IEnumerable<PackageEntry>? packageEntries = null, bool partial = true) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown List<ConfigEntryBase> list = configs?.Where((ConfigEntryBase config) => configData(config).SynchronizedConfig).ToList() ?? new List<ConfigEntryBase>(); List<CustomSyncedValueBase> list2 = customValues?.ToList() ?? new List<CustomSyncedValueBase>(); ZPackage val = new ZPackage(); val.Write((byte)(partial ? 1 : 0)); val.Write(list.Count + list2.Count + (packageEntries?.Count() ?? 0)); foreach (PackageEntry item in packageEntries ?? Array.Empty<PackageEntry>()) { AddEntryToPackage(val, item); } foreach (CustomSyncedValueBase item2 in list2) { AddEntryToPackage(val, new PackageEntry { section = "Internal", key = item2.Identifier, type = item2.Type, value = item2.BoxedValue }); } foreach (ConfigEntryBase item3 in list) { AddEntryToPackage(val, new PackageEntry { section = item3.Definition.Section, key = item3.Definition.Key, type = configType(item3), value = item3.BoxedValue }); } return val; } private static void AddEntryToPackage(ZPackage package, PackageEntry entry) { package.Write(entry.section); package.Write(entry.key); package.Write((entry.value == null) ? "" : GetZPackageTypeString(entry.type)); AddValueToZPackage(package, entry.value); } private static string GetZPackageTypeString(Type type) { return type.AssemblyQualifiedName; } private static void AddValueToZPackage(ZPackage package, object? value) { Type type = value?.GetType(); if (value is Enum) { value = ((IConvertible)value).ToType(Enum.GetUnderlyingType(value.GetType()), CultureInfo.InvariantCulture); } else { if (value is ICollection collection) { package.Write(collection.Count); { foreach (object item in collection) { AddValueToZPackage(package, item); } return; } } if ((object)type != null && type.IsValueType && !type.IsPrimitive) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); package.Write(fields.Length); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { package.Write(GetZPackageTypeString(fieldInfo.FieldType)); AddValueToZPackage(package, fieldInfo.GetValue(value)); } return; } } ZRpc.Serialize(new object[1] { value }, ref package); } private static object ReadValueWithTypeFromZPackage(ZPackage package, Type type) { if ((object)type != null && type.IsValueType && !type.IsPrimitive && !type.IsEnum) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num = package.ReadInt(); if (num != fields.Length) { throw new InvalidDeserializationTypeException { received = $"(field count: {num})", expected = $"(field count: {fields.Length})" }; } object uninitializedObject = FormatterServices.GetUninitializedObject(type); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { string text = package.ReadString(); if (text != GetZPackageTypeString(fieldInfo.FieldType)) { throw new InvalidDeserializationTypeException { received = text, expected = GetZPackageTypeString(fieldInfo.FieldType), field = fieldInfo.Name }; } fieldInfo.SetValue(uninitializedObject, ReadValueWithTypeFromZPackage(package, fieldInfo.FieldType)); } return uninitializedObject; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<, >)) { int num2 = package.ReadInt(); IDictionary dictionary = (IDictionary)Activator.CreateInstance(type); Type type2 = typeof(KeyValuePair<, >).MakeGenericType(type.GenericTypeArguments); FieldInfo field = type2.GetField("key", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = type2.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic); for (int j = 0; j < num2; j++) { object obj = ReadValueWithTypeFromZPackage(package, type2); dictionary.Add(field.GetValue(obj), field2.GetValue(obj)); } return dictionary; } if (type != typeof(List<string>) && type.IsGenericType) { Type type3 = typeof(ICollection<>).MakeGenericType(type.GenericTypeArguments[0]); if ((object)type3 != null && type3.IsAssignableFrom(type)) { int num3 = package.ReadInt(); object obj2 = Activator.CreateInstance(type); MethodInfo method = type3.GetMethod("Add"); for (int k = 0; k < num3; k++) { method.Invoke(obj2, new object[1] { ReadValueWithTypeFromZPackage(package, type.GenericTypeArguments[0]) }); } return obj2; } } ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo)); AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl").SetValue(parameterInfo, type); List<object> source = new List<object>(); ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, package, ref source); return source.First(); } } [HarmonyPatch] [PublicAPI] internal class VersionCheck { private static readonly HashSet<VersionCheck> versionChecks; private static readonly Dictionary<string, string> notProcessedNames; public string Name; private string? displayName; private string? currentVersion; private string? minimumRequiredVersion; public bool ModRequired = true; private string? ReceivedCurrentVersion; private string? ReceivedMinimumRequiredVersion; private readonly List<ZRpc> ValidatedClients = new List<ZRpc>(); private ConfigSync? ConfigSync; public string DisplayName { get { return displayName ?? Name; } set { displayName = value; } } public string CurrentVersion { get { return currentVersion ?? "0.0.0"; } set { currentVersion = value; } } public string MinimumRequiredVersion { get { return minimumRequiredVersion ?? (ModRequired ? CurrentVersion : "0.0.0"); } set { minimumRequiredVersion = value; } } private static void PatchServerSync() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Patches patchInfo = PatchProcessor.GetPatchInfo((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null)); if (patchInfo != null && patchInfo.Postfixes.Count((Patch p) => p.PatchMethod.DeclaringType == typeof(ConfigSync.RegisterRPCPatch)) > 0) { return; } Harmony val = new Harmony("org.bepinex.helpers.ServerSync"); foreach (Type item in from t in typeof(ConfigSync).GetNestedTypes(BindingFlags.NonPublic).Concat(new Type[1] { typeof(VersionCheck) }) where t.IsClass select t) { val.PatchAll(item); } } static VersionCheck() { versionChecks = new HashSet<VersionCheck>(); notProcessedNames = new Dictionary<string, string>(); typeof(ThreadingHelper).GetMethod("StartSyncInvoke").Invoke(ThreadingHelper.Instance, new object[1] { new Action(PatchServerSync) }); } public VersionCheck(string name) { Name = name; ModRequired = true; versionChecks.Add(this); } public VersionCheck(ConfigSync configSync) { ConfigSync = configSync; Name = ConfigSync.Name; versionChecks.Add(this); } public void Initialize() { ReceivedCurrentVersion = null; ReceivedMinimumRequiredVersion = null; if (ConfigSync != null) { Name = ConfigSync.Name; DisplayName = ConfigSync.DisplayName; CurrentVersion = ConfigSync.CurrentVersion; MinimumRequiredVersion = ConfigSync.MinimumRequiredVersion; ModRequired = ConfigSync.ModRequired; } } private bool IsVersionOk() { if (ReceivedMinimumRequiredVersion == null || ReceivedCurrentVersion == null) { return !ModRequired; } bool flag = new Version(CurrentVersion) >= new Version(ReceivedMinimumRequiredVersion); bool flag2 = new Version(ReceivedCurrentVersion) >= new Version(MinimumRequiredVersion); return flag && flag2; } private string ErrorClient() { if (ReceivedMinimumRequiredVersion == null) { return "Mod " + DisplayName + " must not be installed."; } return (new Version(CurrentVersion) >= new Version(ReceivedMinimumRequiredVersion)) ? ("Mod " + DisplayName + " requires maximum " + ReceivedCurrentVersion + ". Installed is version " + CurrentVersion + ".") : ("Mod " + DisplayName + " requires minimum " + ReceivedMinimumRequiredVersion + ". Installed is version " + CurrentVersion + "."); } private string ErrorServer(ZRpc rpc) { return "Disconnect: The client (" + rpc.GetSocket().GetHostName() + ") doesn't have the correct " + DisplayName + " version " + MinimumRequiredVersion; } private string Error(ZRpc? rpc = null) { return (rpc == null) ? ErrorClient() : ErrorServer(rpc); } private static VersionCheck[] GetFailedClient() { return versionChecks.Where((VersionCheck check) => !check.IsVersionOk()).ToArray(); } private static VersionCheck[] GetFailedServer(ZRpc rpc) { ZRpc rpc2 = rpc; return versionChecks.Where((VersionCheck check) => check.ModRequired && !check.ValidatedClients.Contains(rpc2)).ToArray(); } private static void Logout() { Game.instance.Logout(true, true); AccessTools.DeclaredField(typeof(ZNet), "m_connectionStatus").SetValue(null, (object)(ConnectionStatus)3); } private static void DisconnectClient(ZRpc rpc) { rpc.Invoke("Error", new object[1] { 3 }); } private static void CheckVersion(ZRpc rpc, ZPackage pkg) { CheckVersion(rpc, pkg, null); } private static void CheckVersion(ZRpc rpc, ZPackage pkg, Action<ZRpc, ZPackage>? original) { string text = pkg.ReadString(); string text2 = pkg.ReadString(); string text3 = pkg.ReadString(); bool flag = false; foreach (VersionCheck versionCheck in versionChecks) { if (!(text != versionCheck.Name)) { Debug.Log((object)("Received " + versionCheck.DisplayName + " version " + text3 + " and minimum version " + text2 + " from the " + (ZNet.instance.IsServer() ? "client" : "server") + ".")); versionCheck.ReceivedMinimumRequiredVersion = text2; versionCheck.ReceivedCurrentVersion = text3; if (ZNet.instance.IsServer() && versionCheck.IsVersionOk()) { versionCheck.ValidatedClients.Add(rpc); } flag = true; } } if (flag) { return; } pkg.SetPos(0); if (original != null) { original(rpc, pkg); if (pkg.GetPos() == 0) { notProcessedNames.Add(text, text3); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private static bool RPC_PeerInfo(ZRpc rpc, ZNet __instance) { VersionCheck[] array = (__instance.IsServer() ? GetFailedServer(rpc) : GetFailedClient()); if (array.Length == 0) { return true; } VersionCheck[] array2 = array; foreach (VersionCheck versionCheck in array2) { Debug.LogWarning((object)versionCheck.Error(rpc)); } if (__instance.IsServer()) { DisconnectClient(rpc); } else { Logout(); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static void RegisterAndCheckVersion(ZNetPeer peer, ZNet __instance) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown notProcessedNames.Clear(); IDictionary dictionary = (IDictionary)typeof(ZRpc).GetField("m_functions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(peer.m_rpc); if (dictionary.Contains(StringExtensionMethods.GetStableHashCode("ServerSync VersionCheck"))) { object obj = dictionary[StringExtensionMethods.GetStableHashCode("ServerSync VersionCheck")]; Action<ZRpc, ZPackage> action = (Action<ZRpc, ZPackage>)obj.GetType().GetField("m_action", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj); peer.m_rpc.Register<ZPackage>("ServerSync VersionCheck", (Action<ZRpc, ZPackage>)delegate(ZRpc rpc, ZPackage pkg) { CheckVersion(rpc, pkg, action); }); } else { peer.m_rpc.Register<ZPackage>("ServerSync VersionCheck", (Action<ZRpc, ZPackage>)CheckVersion); } foreach (VersionCheck versionCheck in versionChecks) { versionCheck.Initialize(); if (versionCheck.ModRequired || __instance.IsServer()) { Debug.Log((object)("Sending " + versionCheck.DisplayName + " version " + versionCheck.CurrentVersion + " and minimum version " + versionCheck.MinimumRequiredVersion + " to the " + (__instance.IsServer() ? "client" : "server") + ".")); ZPackage val = new ZPackage(); val.Write(versionCheck.Name); val.Write(versionCheck.MinimumRequiredVersion); val.Write(versionCheck.CurrentVersion); peer.m_rpc.Invoke("ServerSync VersionCheck", new object[1] { val }); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "Disconnect")] private static void RemoveDisconnected(ZNetPeer peer, ZNet __instance) { if (!__instance.IsServer()) { return; } foreach (VersionCheck versionCheck in versionChecks) { versionCheck.ValidatedClients.Remove(peer.m_rpc); } } [HarmonyPostfix] [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] private static void ShowConnectionError(FejdStartup __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (!__instance.m_connectionFailedPanel.activeSelf || (int)ZNet.GetConnectionStatus() != 3) { return; } VersionCheck[] failedClient = GetFailedClient(); if (failedClient.Length != 0) { string text = string.Join("\n", failedClient.Select((VersionCheck check) => check.Error())); TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + text; } foreach (KeyValuePair<string, string> item in notProcessedNames.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> kv) => kv.Key)) { if (!__instance.m_connectionFailedError.text.Contains(item.Key)) { TMP_Text connectionFailedError2 = __instance.m_connectionFailedError; connectionFailedError2.text = connectionFailedError2.text + "\n" + item.Key + " (Version: " + item.Value + ")"; } } } } }
DonationShop.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace DonationShop; [BepInPlugin("Detalhes.DonationShop", "Detalhes.DonationShop", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class DonationShop : BaseUnityPlugin { public const string PluginGUID = "Detalhes.DonationShop"; public const string Name = "DonationShop"; public const string Version = "2.0.0"; public static bool IsBuying = false; public static string PlayerName = ""; public static Dictionary<string, GameObject> menuItems = new Dictionary<string, GameObject>(); private Harmony harmony = new Harmony("Detalhes.DonationShop"); public static GameObject Menu; public static ConfigEntry<KeyCode> KeyboardShortcut; public static ConfigEntry<string> ShopItems; public void Awake() { InitConfigs(); SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { if (attr.InitialSynchronization) { Logger.LogMessage((object)"Initial Config sync event received"); } else { Logger.LogMessage((object)"Config sync event received"); } }; harmony.PatchAll(); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (Input.GetKeyDown(KeyboardShortcut.Value)) { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting()) { GUI.ToggleMenu(); ZPackage val = new ZPackage(); val.Write(PlayFabManager.m_customId); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "GetGoldServer", new object[1] { val }); } } } public void InitConfigs() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; KeyboardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Client config", "KeyboardShortcutConfig", (KeyCode)278, new ConfigDescription("Client side KeyboardShortcut", (AcceptableValueBase)null, new object[2] { null, (object)new ConfigurationManagerAttributes { IsAdminOnly = false } })); ShopItems = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "ShopItems", "prefabs=Blueberriesamount=50;price=150|prefab=Raspberry;amount=50;price=150|prefab=Thistle;amount=50;price=200|prefab=Cloudberry;amount=50;price=100|prefab=Wood;amount=50;price=100|prefab=Stone;amount=50;price=100|prefab=RoundLog;amount=50;price=100|prefab=FineWood;amount=50;price=150|prefab=IronNails;amount=10;price=110|prefab=IronOre;amount=50;price=700|prefab=SilverOre;amount=50;price=1000|prefab=GreydwarfEye;amount=500;price=250|prefab=SurtlingCore;amount=100;price=100|prefab=PortalToken;amount=1;price=750|prefab=ResetToken;amount=1;price=250|prefab=Coins;amount=1000;price=500", new ConfigDescription("ShopItems", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } } internal class GUI { public static void ToggleMenu() { if (!Object.op_Implicit((Object)(object)DonationShop.Menu) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (GUIManager.Instance == null) { Debug.LogError((object)"GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Debug.LogError((object)"GUIManager CustomGUI is null"); return; } LoadMenu(); } bool active = !DonationShop.Menu.activeSelf; DonationShop.Menu.SetActive(active); } public static void DestroyMenu() { DonationShop.Menu.SetActive(false); } public static void LoadMenu() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00ce: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown if (!((Object)(object)Player.m_localPlayer == (Object)null)) { DonationShop.Menu = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 600f, 700f, true); DonationShop.Menu.SetActive(false); GameObject val = GUIManager.Instance.CreateScrollView(DonationShop.Menu.transform, false, true, 8f, 50f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1568628f, 0.1019608f, 0.0627451f, 1f), 500f, 450f); RectTransform val2 = (RectTransform)val.transform; val2.anchoredPosition = new Vector2(0f, 25f); val.SetActive(true); GameObject value = GUIManager.Instance.CreateText("Deadcoins : 0", DonationShop.Menu.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-85f, -100f), GUIManager.Instance.AveriaSerifBold, 25, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 80f, false); DonationShop.menuItems.Add("coinText", value); CreateItems(val); ((Component)val.transform.Find("Scroll View")).GetComponent<ScrollRect>().verticalNormalizedPosition = 1f; GameObject val3 = GUIManager.Instance.CreateButton("Close", DonationShop.Menu.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -300f), 170f, 45f); val3.SetActive(true); GameObject value2 = GUIManager.Instance.CreateText("", DonationShop.Menu.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -600f), GUIManager.Instance.AveriaSerifBold, 14, Color.red, true, Color.black, 500f, 30f, false); DonationShop.menuItems.Add("errorText", value2); Button component = val3.GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener(new UnityAction(DestroyMenu)); } } private static void CreateItems(GameObject scrollView) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) GameObject val = GUIManager.Instance.CreateText("\n", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 10, GUIManager.Instance.ValheimOrange, true, Color.black, 150f, 30f, false); string[] array = DonationShop.ShopItems.Value.Trim(new char[1] { ' ' }).Split(new char[1] { '|' }); foreach (string text in array) { string[] array2 = text.Split(new char[1] { ';' }); string text2 = array2[0].Split(new char[1] { '=' })[1]; string amount = array2[1].Split(new char[1] { '=' })[1]; string price = array2[2].Split(new char[1] { '=' })[1]; GameObject originalPrefab = PrefabManager.Instance.GetPrefab(text2); if (originalPrefab == null) { Debug.LogError((object)("prefab cagado" + text2)); continue; } GameObject val2 = GUIManager.Instance.CreateText(text2.ToString(), scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimOrange, true, Color.black, 150f, 18f, false); GameObject val3 = GUIManager.Instance.CreateText(amount + "x", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimOrange, true, Color.black, 60f, 18f, false); GameObject value = GUIManager.Instance.CreateText(price + " Deadcoins", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimOrange, true, Color.black, 250f, 18f, false); GameObject val4 = GUIManager.Instance.CreateButton(" Comprar ", val2.transform, new Vector2(0.5f, -0.8f), new Vector2(0.5f, -0.8f), new Vector2(220f, 0f), 80f, 50f); val4.SetActive(true); Button component = val4.GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { Shopper.BuyItem(originalPrefab, Convert.ToInt32(amount), Convert.ToInt32(price)); }); DonationShop.menuItems.Add(text2 + "Text", value); GameObject val5 = GUIManager.Instance.CreateText("", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, -5f), new Vector2(0.5f, -5f), new Vector2(0f, -20f), GUIManager.Instance.AveriaSerifBold, 10, GUIManager.Instance.ValheimOrange, true, Color.black, 150f, 10f, false); } } } [HarmonyPatch] public class RPC { public static string Folder = "/DonationShop/"; [HarmonyPatch(typeof(Game), "Start")] [HarmonyPrefix] public static void Prefix() { ZRoutedRpc.instance.Register<ZPackage>("GetGoldServer", (Action<long, ZPackage>)RPC_GetGoldServer); ZRoutedRpc.instance.Register<ZPackage>("GetGoldClient", (Action<long, ZPackage>)RPC_GetGoldClient); ZRoutedRpc.instance.Register<ZPackage>("BuyItemServer", (Action<long, ZPackage>)RPC_BuyItemServer); ZRoutedRpc.instance.Register<ZPackage>("BuyItemClient", (Action<long, ZPackage>)RPC_BuyItemClient); ZRoutedRpc.instance.Register<ZPackage>("DontHaveGold", (Action<long, ZPackage>)RPC_DontHaveGold); } public static void RPC_GetGoldServer(long sender, ZPackage pkg) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { return; } ZNetPeer peer = ZNet.instance.GetPeer(sender); Debug.LogError((object)"RPC_GetGoldServer"); if (peer != null) { string[] array = pkg.ReadString().Split(new char[1] { ',' }); string text = array[0]; string playerName = peer.m_playerName; string path = Paths.ConfigPath + Folder + playerName + "-" + text + ".json"; ZPackage val = new ZPackage(); if (!File.Exists(path)) { Directory.CreateDirectory(Paths.ConfigPath + Folder); File.WriteAllText(path, "0"); val.Write("0"); } val.Write(File.ReadAllText(path)); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "GetGoldClient", new object[1] { val }); } } public static void RPC_GetGoldClient(long sender, ZPackage pkg) { if (DonationShop.menuItems.TryGetValue("coinText", out var value)) { value.GetComponent<Text>().text = "Deadcoins: " + pkg.ReadString(); } } public static void RPC_DontHaveGold(long sender, ZPackage pkg) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (DonationShop.menuItems.TryGetValue("errorText", out var value)) { value.GetComponent<Text>().text = "Erro: você não tem deadcoins suficientes"; } DonationShop.IsBuying = false; } } public static void RPC_BuyItemServer(long sender, ZPackage pkg) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown if (ZNet.instance.IsServer()) { ZNetPeer peer = ZNet.instance.GetPeer(sender); string[] array = pkg.ReadString().Split(new char[1] { ',' }); int num = Convert.ToInt32(array[0]); int num2 = Convert.ToInt32(array[1]); string text = array[2]; string text2 = array[3]; string playerName = peer.m_playerName; string path = Paths.ConfigPath + Folder + playerName + "-" + text2 + ".json"; int num3 = Convert.ToInt32(File.ReadAllText(path)); if (num > num3) { ZRoutedRpc.instance.InvokeRoutedRPC(sender, "DontHaveGold", new object[1] { (object)new ZPackage() }); return; } File.WriteAllText(path, (num3 - num).ToString()); Directory.CreateDirectory(Paths.ConfigPath + Folder + "/log/"); File.AppendAllText(Paths.ConfigPath + Folder + "/log/log.txt", text2 + "-" + playerName + "buyed " + num2 + " " + text + "for " + num + " coins"); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "BuyItemClient", new object[1] { pkg }); } } public static void RPC_BuyItemClient(long sender, ZPackage pkg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(PlayFabManager.m_customId); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "GetGoldServer", new object[1] { val }); string[] array = pkg.ReadString().Split(new char[1] { ',' }); int num = Convert.ToInt32(array[0]); int num2 = Convert.ToInt32(array[1]); string text = array[2]; GameObject prefab = PrefabManager.Instance.GetPrefab(text); if ((Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null) { ((Humanoid)Player.m_localPlayer).m_inventory.AddItem(prefab, num2); } else { Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity); } DonationShop.IsBuying = false; } } internal class Shopper { public static void BuyItem(GameObject prefab, int amount, int price) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (DonationShop.menuItems.TryGetValue("errorText", out var value)) { value.GetComponent<Text>().text = ""; } if (DonationShop.IsBuying) { value.GetComponent<Text>().text = "Aguarde o processamento da última compra."; } DonationShop.IsBuying = true; ZPackage val = new ZPackage(); val.Write(price + "," + amount + "," + ((Object)prefab).name + "," + PlayFabManager.m_customId); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "BuyItemServer", new object[1] { val }); } }
Hearthstone.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.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Hearthstone { [BepInPlugin("Detalhes.Hearthstone", "Hearthstone", "2.0.4")] public class Hearthstone : BaseUnityPlugin { public const string PluginGUID = "Detalhes.Hearthstone"; public const string Version = "2.0.4"; private Harmony harmony = new Harmony("Detalhes.Hearthstone"); public static ConfigEntry<string> item1; public static ConfigEntry<string> item2; public static ConfigEntry<string> item3; public static ConfigEntry<int> itemCost1; public static ConfigEntry<int> itemCost2; public static ConfigEntry<int> itemCost3; public static ConfigEntry<bool> allowTeleportWithoutRestriction; private ConfigSync configSync = new ConfigSync("Detalhes.Hearthstone") { DisplayName = "Hearthstone", CurrentVersion = "2.0.4", MinimumRequiredVersion = "2.0.4" }; private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } private void Awake() { allowTeleportWithoutRestriction = config("General", "allowTeleportWithoutRestriction", value: false, "Allow teleport without restriction"); Item item = new Item("hearthstone", "Hearthstone"); item.RequiredItems.Add("Crystal", 3); item.RequiredItems.Add("Coins", 30); item.RequiredItems.Add("BoneFragments", 20); item.Name.English("Hearthstone"); item.Description.English("Brings you back home."); item.Crafting.Add(CraftingTable.ArtisanTable, 1); harmony.PatchAll(); } private void Update() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)(object)Player.m_localPlayer == (Object)null || !Object.op_Implicit((Object)(object)localPlayer.m_hovering)) { return; } Interactable componentInParent = localPlayer.m_hovering.GetComponentInParent<Interactable>(); if (componentInParent != null && componentInParent is Bed) { Bed val = (Bed)componentInParent; if (val.IsMine() && Input.GetKeyDown((KeyCode)112)) { SetHearthStonePosition(); ((Character)Player.m_localPlayer).Message((MessageType)2, "Here is your new Hearthstone spawn", 0, (Sprite)null); } } } public static Vector3 GetHearthStonePosition() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (!Player.m_localPlayer.m_knownTexts.ContainsKey("positionX")) { return Vector3.zero; } Vector3 result = default(Vector3); result.x = float.Parse(Player.m_localPlayer.m_knownTexts["positionX"]); result.y = float.Parse(Player.m_localPlayer.m_knownTexts["positionY"]); result.z = float.Parse(Player.m_localPlayer.m_knownTexts["positionZ"]); return result; } public static void SetHearthStonePosition() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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) if (!Player.m_localPlayer.m_knownTexts.ContainsKey("positionX")) { Dictionary<string, string> knownTexts = Player.m_localPlayer.m_knownTexts; string key = "positionX"; knownTexts.Add(key, ((Component)Player.m_localPlayer).transform.position.x.ToString()); } else { Dictionary<string, string> knownTexts2 = Player.m_localPlayer.m_knownTexts; string key2 = "positionX"; knownTexts2[key2] = ((Component)Player.m_localPlayer).transform.position.x.ToString(); } if (!Player.m_localPlayer.m_knownTexts.ContainsKey("positionY")) { Dictionary<string, string> knownTexts3 = Player.m_localPlayer.m_knownTexts; string key3 = "positionY"; knownTexts3.Add(key3, ((Component)Player.m_localPlayer).transform.position.y.ToString()); } else { Dictionary<string, string> knownTexts4 = Player.m_localPlayer.m_knownTexts; string key4 = "positionY"; knownTexts4[key4] = ((Component)Player.m_localPlayer).transform.position.y.ToString(); } if (!Player.m_localPlayer.m_knownTexts.ContainsKey("positionZ")) { Dictionary<string, string> knownTexts5 = Player.m_localPlayer.m_knownTexts; string key5 = "positionZ"; knownTexts5.Add(key5, ((Component)Player.m_localPlayer).transform.position.z.ToString()); } else { Dictionary<string, string> knownTexts6 = Player.m_localPlayer.m_knownTexts; string key6 = "positionZ"; knownTexts6[key6] = ((Component)Player.m_localPlayer).transform.position.z.ToString(); } } } internal class Patches { [HarmonyPatch(typeof(Player), "ConsumeItem")] public static class ConsumePatch { private static bool Prefix(ItemData item) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (item.m_shared.m_name.Equals("$item_Hearthstone")) { if (!((Humanoid)Player.m_localPlayer).IsTeleportable() && !Hearthstone.allowTeleportWithoutRestriction.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "You can't teleport carrying those items", 0, (Sprite)null); return false; } Vector3 hearthStonePosition = Hearthstone.GetHearthStonePosition(); if (hearthStonePosition == Vector3.zero) { ((Character)Player.m_localPlayer).Message((MessageType)2, "You need to set hearthstone spawn point", 0, (Sprite)null); return false; } ((Character)Player.m_localPlayer).TeleportTo(hearthStonePosition, ((Component)Player.m_localPlayer).transform.rotation, true); } return true; } } [HarmonyPatch(typeof(Bed), "GetHoverText")] private static class Bed_GetHoverText_Patch { private static void Postfix(Bed __instance, ref string __result, ZNetView ___m_nview) { if ((__instance.IsMine() && ___m_nview.GetZDO().GetLong("owner", 0L) != 0L) || Traverse.Create((object)__instance).Method("IsCurrent", Array.Empty<object>()).GetValue<bool>()) { __result += Localization.instance.Localize("\n[<color=yellow><b>P</b></color>] Set hearthstone"); } } } } } namespace Microsoft.CodeAnalysis { [<d39298f9-e504-440e-9f53-186c573f2321>Embedded] [CompilerGenerated] internal sealed class <d39298f9-e504-440e-9f53-186c573f2321>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<d39298f9-e504-440e-9f53-186c573f2321>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <4a7ee84e-7b68-4de8-8799-41495be68eb2>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <4a7ee84e-7b68-4de8-8799-41495be68eb2>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <4a7ee84e-7b68-4de8-8799-41495be68eb2>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<d39298f9-e504-440e-9f53-186c573f2321>Embedded] [CompilerGenerated] internal sealed class <91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContextAttribute : Attribute { public readonly byte Flag; public <91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<d39298f9-e504-440e-9f53-186c573f2321>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <8b4931b0-9496-4f98-85db-1796b7266924>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <8b4931b0-9496-4f98-85db-1796b7266924>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ItemManager { [PublicAPI] internal enum CraftingTable { Disabled, Inventory, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("blackforge")] BlackForge, Custom } [PublicAPI] internal enum ConversionPiece { Disabled, [InternalName("smelter")] Smelter, [InternalName("charcoal_kiln")] CharcoalKiln, [InternalName("blastfurnace")] BlastFurnace, [InternalName("windmill")] Windmill, [InternalName("piece_spinningwheel")] SpinningWheel, [InternalName("eitrrefinery")] EitrRefinery, Custom } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] internal class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] [PublicAPI] [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] internal class RequiredResourceList { public readonly List<Requirement> Requirements = new List<Requirement>(); public bool Free; public void Add(string itemName, int amount, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amount = amount, quality = quality }); } public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amountConfig = amountConfig, quality = quality }); } } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] [PublicAPI] internal class CraftingStationList { public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>(); public void Add(CraftingTable table, int level) { Stations.Add(new CraftingStationConfig { Table = table, level = level }); } public void Add(string customTable, int level) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, level = level, custom = customTable }); } } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] [PublicAPI] internal class ItemRecipe { public readonly RequiredResourceList RequiredItems = new RequiredResourceList(); public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList(); public readonly CraftingStationList Crafting = new CraftingStationList(); public int CraftAmount = 1; public bool RequireOnlyOneIngredient; public float QualityResultAmountMultiplier = 1f; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public ConfigEntryBase RecipeIsActive; } [PublicAPI] internal class Trade { public Trader Trader; public uint Price; public uint Stack = 1u; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public string RequiredGlobalKey; } [PublicAPI] [Flags] internal enum Trader { None = 0, Haldor = 1, Hildir = 2 } internal struct Requirement { [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(1)] public string itemName; public int amount; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public ConfigEntry<int> amountConfig; [Description("Set to a non-zero value to apply the requirement only for a specific quality")] public int quality; } internal struct CraftingStationConfig { public CraftingTable Table; public int level; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public string custom; } [Flags] internal enum Configurability { Disabled = 0, Recipe = 1, Stats = 2, Drop = 4, Trader = 8, Full = 0xF } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] [PublicAPI] [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] internal class DropTargets { public readonly List<DropTarget> Drops = new List<DropTarget>(); public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true) { Drops.Add(new DropTarget { creature = creatureName, chance = chance, min = min, max = (max ?? min), levelMultiplier = levelMultiplier }); } } internal struct DropTarget { [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(1)] public string creature; public int min; public int max; public float chance; public bool levelMultiplier; } internal enum Toggle { On = 1, Off = 0 } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(1)] [PublicAPI] internal class Item { [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] private class ItemConfig { [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 2, 1 })] public ConfigEntry<string> craft; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 2, 1 })] public ConfigEntry<string> upgrade; public ConfigEntry<CraftingTable> table; public ConfigEntry<int> tableLevel; public ConfigEntry<string> customTable; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public ConfigEntry<int> maximumTableLevel; public ConfigEntry<Toggle> requireOneIngredient; public ConfigEntry<float> qualityResultAmountMultiplier; } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] private class TraderConfig { public ConfigEntry<Trader> trader; public ConfigEntry<uint> price; public ConfigEntry<uint> stack; public ConfigEntry<string> requiredGlobalKey; } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] private class RequirementQuality { public int quality; } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(2)] [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action<ConfigEntryBase> CustomDrawer; public Func<bool> browsability; } [PublicAPI] [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] public enum DamageModifier { Normal, Resistant, Weak, Immune, Ignore, VeryResistant, VeryWeak, None } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] private delegate void setDmgFunc(ref DamageTypes dmg, float value); [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] private class SerializedRequirements { public readonly List<Requirement> Reqs; public SerializedRequirements(List<Requirement> reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) : this(reqs.Split(new char[1] { ',' }).Select([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0); return result; }).ToList()) { } public override string ToString() { return string.Join(",", Reqs.Select([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : ""))); } [return: <4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)obj == (Object)null) { Debug.LogWarning((object)("The required item '" + name + "' does not exist.")); } return obj; } public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0194: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Requirement r) => { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown ItemDrop val6 = ResItem(r); return (val6 != null) ? new Requirement { m_amount = (r.amountConfig?.Value ?? r.amount), m_resItem = val6, m_amountPerLevel = 0 } : ((Requirement)null); })); List<Requirement> list = dictionary.Values.Where([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Requirement v) => v != null).ToList(); foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != "")) { if (item.quality > 0) { ItemDrop val = ResItem(item); if (val != null) { Requirement val2 = new Requirement { m_resItem = val, m_amountPerLevel = (item.amountConfig?.Value ?? item.amount), m_amount = 0 }; list.Add(val2); requirementQuality.Add(val2, new RequirementQuality { quality = item.quality }); } continue; } if (!dictionary.TryGetValue(item.itemName, out var value) || value == null) { ItemDrop val3 = ResItem(item); if (val3 != null) { string itemName = item.itemName; Requirement val4 = new Requirement { m_resItem = val3, m_amount = 0 }; Requirement val5 = val4; dictionary[itemName] = val4; value = val5; list.Add(value); } } if (value != null) { value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount; } } return list.ToArray(); [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(2)] ItemDrop ResItem(Requirement r) { return fetchByName(objectDB, r.itemName); } } } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] private class SerializedDrop { public readonly List<DropTarget> Drops; public SerializedDrop(List<DropTarget> drops) { Drops = drops; } public SerializedDrop(string drops) { Drops = ((drops == "") ? ((IEnumerable<string>)Array.Empty<string>()) : ((IEnumerable<string>)drops.Split(new char[1] { ',' }))).Select([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); if (array.Length <= 2 || !int.TryParse(array[2], out var result)) { result = 1; } if (array.Length <= 3 || !int.TryParse(array[3], out var result2)) { result2 = result; } bool levelMultiplier = array.Length <= 4 || array[4] != "0"; DropTarget result3 = default(DropTarget); result3.creature = array[0]; result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f); result3.min = result; result3.max = result2; result3.levelMultiplier = levelMultiplier; return result3; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0"))); } [return: <4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static Character fetchByName(ZNetScene netScene, string name) { GameObject prefab = netScene.GetPrefab(name); Character obj = ((prefab != null) ? prefab.GetComponent<Character>() : null); if ((Object)(object)obj == (Object)null) { Debug.LogWarning((object)("The drop target character '" + name + "' does not exist.")); } return obj; } public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item) { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_006f: Expected O, but got Unknown Dictionary<Character, Drop> dictionary = new Dictionary<Character, Drop>(); foreach (DropTarget drop in Drops) { Character val = fetchByName(netScene, drop.creature); if (val != null) { dictionary[val] = new Drop { m_prefab = item, m_amountMin = drop.min, m_amountMax = drop.max, m_chance = drop.chance, m_levelMultiplier = drop.levelMultiplier }; } } return dictionary; } } private static readonly List<Item> registeredItems = new List<Item>(); private static readonly Dictionary<ItemDrop, Item> itemDropMap = new Dictionary<ItemDrop, Item>(); private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>(); [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>(); [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary<Recipe, ConfigEntryBase> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>(); private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>(); private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>(); private Dictionary<CharacterDrop, Drop> characterDrops = new Dictionary<CharacterDrop, Drop>(); private readonly Dictionary<ConfigEntryBase, Action> statsConfigs = new Dictionary<ConfigEntryBase, Action>(); private static readonly ConditionalWeakTable<Requirement, RequirementQuality> requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>(); public static Configurability DefaultConfigurability = Configurability.Full; public Configurability? Configurable; private Configurability configurationVisible = Configurability.Full; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private TraderConfig traderConfig; public readonly GameObject Prefab; [Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")] public int MaximumRequiredStationLevel = int.MaxValue; [Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")] public readonly DropTargets DropsFrom = new DropTargets(); [Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")] public readonly Trade Trade = new Trade(); internal List<Conversion> Conversions = new List<Conversion>(); internal List<ItemConversion> conversions = new List<ItemConversion>(); public Dictionary<string, ItemRecipe> Recipes = new Dictionary<string, ItemRecipe>(); [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private LocalizeKey _name; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private LocalizeKey _description; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static object configManager; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static Localization _english; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static object _configSync; private Configurability configurability => Configurable ?? DefaultConfigurability; [Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")] public RequiredResourceList RequiredItems => this[""].RequiredItems; [Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")] public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems; [Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")] public CraftingStationList Crafting => this[""].Crafting; [Description("Specifies a config entry which toggles whether a recipe is active.")] [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] public ConfigEntryBase RecipeIsActive { [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(2)] get { return this[""].RecipeIsActive; } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(2)] set { this[""].RecipeIsActive = value; } } [Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")] public int CraftAmount { get { return this[""].CraftAmount; } set { this[""].CraftAmount = value; } } public bool RequireOnlyOneIngredient { get { return this[""].RequireOnlyOneIngredient; } set { this[""].RequireOnlyOneIngredient = value; } } public float QualityResultAmountMultiplier { get { return this[""].QualityResultAmountMultiplier; } set { this[""].QualityResultAmountMultiplier = value; } } public ItemRecipe this[string name] { get { if (Recipes.TryGetValue(name, out var value)) { return value; } return Recipes[name] = new ItemRecipe(); } } public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; if (shared.m_name.StartsWith("$")) { _name = new LocalizeKey(shared.m_name); } else { string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(shared.m_name); shared.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; if (shared.m_description.StartsWith("$")) { _description = new LocalizeKey(shared.m_description); } else { string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_"); _description = new LocalizeKey(text).English(shared.m_description); shared.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(2)] private static object configSync { [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(2)] get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Item(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Item(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true) { } public Item(GameObject prefab, bool skipRegistering = false) { if (!skipRegistering) { PrefabManager.RegisterPrefab(prefab, addToObjectDb: true); } Prefab = prefab; registeredItems.Add(this); itemDropMap[Prefab.GetComponent<ItemDrop>()] = this; Prefab.GetComponent<ItemDrop>().m_itemData.m_dropPrefab = Prefab; } public void ToggleConfigurationVisibility(Configurability visible) { configurationVisible = visible; if (itemDropConfigs.TryGetValue(this, out var value)) { Toggle((ConfigEntryBase)(object)value, Configurability.Drop); } if (itemCraftConfigs.TryGetValue(this, out var value2)) { foreach (ItemConfig value4 in value2.Values) { ToggleObj(value4, Configurability.Recipe); } } foreach (Conversion conversion in Conversions) { if (conversion.config != null) { ToggleObj(conversion.config, Configurability.Recipe); } } foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs) { Toggle(statsConfig.Key, Configurability.Stats); if ((visible & Configurability.Stats) != 0) { statsConfig.Value(); } } reloadConfigDisplay(); void Toggle(ConfigEntryBase cfg, Configurability check) { object[] tags = cfg.Description.Tags; for (int j = 0; j < tags.Length; j++) { if (tags[j] is ConfigurationManagerAttributes configurationManagerAttributes) { configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability()); } } } void ToggleObj(object obj, Configurability check) { FieldInfo[] fields = obj.GetType().GetFields(); for (int i = 0; i < fields.Length; i++) { object? value3 = fields[i].GetValue(obj); ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null); if (val != null) { Toggle(val, check); } } } } internal static void reloadConfigDisplay() { configManager?.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>()); } private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue) { if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value)) { value.First().m_enabled = table != CraftingTable.Disabled; if ((uint)table <= 1u) { value.First().m_craftingStation = null; } else if (table == CraftingTable.Custom) { Recipe obj = value.First(); GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null); } else { value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent<CraftingStation>(); } } } private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value)) { return; } foreach (Recipe item in value) { item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements); } } internal static void Patch_FejdStartup() { //IL_0e99: Unknown result type (might be due to invalid IL or missing references) //IL_0e9e: Unknown result type (might be due to invalid IL or missing references) //IL_2164: Unknown result type (might be due to invalid IL or missing references) //IL_216e: Expected O, but got Unknown //IL_0f62: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Unknown result type (might be due to invalid IL or missing references) //IL_0fbb: Expected I4, but got Unknown //IL_0b88: Unknown result type (might be due to invalid IL or missing references) //IL_0b92: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_10ef: Unknown result type (might be due to invalid IL or missing references) //IL_10f2: Unknown result type (might be due to invalid IL or missing references) //IL_10f4: Invalid comparison between Unknown and I4 //IL_10f6: Unknown result type (might be due to invalid IL or missing references) //IL_10fa: Invalid comparison between Unknown and I4 //IL_0cab: Unknown result type (might be due to invalid IL or missing references) //IL_0cb5: Expected O, but got Unknown //IL_0d56: Unknown result type (might be due to invalid IL or missing references) //IL_0d60: Expected O, but got Unknown //IL_10fc: Unknown result type (might be due to invalid IL or missing references) //IL_1100: Invalid comparison between Unknown and I4 //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Expected O, but got Unknown //IL_0e0a: Unknown result type (might be due to invalid IL or missing references) //IL_0e14: Expected O, but got Unknown //IL_12fb: Unknown result type (might be due to invalid IL or missing references) //IL_12fe: Unknown result type (might be due to invalid IL or missing references) //IL_1300: Invalid comparison between Unknown and I4 //IL_1302: Unknown result type (might be due to invalid IL or missing references) //IL_1306: Unknown result type (might be due to invalid IL or missing references) //IL_1308: Invalid comparison between Unknown and I4 //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Expected O, but got Unknown //IL_130a: Unknown result type (might be due to invalid IL or missing references) //IL_130e: Invalid comparison between Unknown and I4 //IL_13e3: Unknown result type (might be due to invalid IL or missing references) //IL_13e8: Unknown result type (might be due to invalid IL or missing references) //IL_13ea: Unknown result type (might be due to invalid IL or missing references) //IL_13ed: Invalid comparison between Unknown and I4 //IL_13ef: Unknown result type (might be due to invalid IL or missing references) //IL_13f3: Invalid comparison between Unknown and I4 //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Expected O, but got Unknown //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Expected O, but got Unknown //IL_1462: Unknown result type (might be due to invalid IL or missing references) //IL_1465: Unknown result type (might be due to invalid IL or missing references) //IL_1467: Invalid comparison between Unknown and I4 //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Expected O, but got Unknown //IL_1469: Unknown result type (might be due to invalid IL or missing references) //IL_146d: Unknown result type (might be due to invalid IL or missing references) //IL_146f: Invalid comparison between Unknown and I4 //IL_1471: Unknown result type (might be due to invalid IL or missing references) //IL_1475: Invalid comparison between Unknown and I4 //IL_15b2: Unknown result type (might be due to invalid IL or missing references) //IL_15b5: Invalid comparison between Unknown and I4 //IL_17b2: Unknown result type (might be due to invalid IL or missing references) //IL_17b9: Invalid comparison between Unknown and I4 //IL_1882: Unknown result type (might be due to invalid IL or missing references) //IL_1887: Unknown result type (might be due to invalid IL or missing references) //IL_1889: Unknown result type (might be due to invalid IL or missing references) //IL_188d: Unknown result type (might be due to invalid IL or missing references) //IL_188f: Invalid comparison between Unknown and I4 //IL_18fe: Unknown result type (might be due to invalid IL or missing references) //IL_1901: Unknown result type (might be due to invalid IL or missing references) //IL_1903: Invalid comparison between Unknown and I4 //IL_1528: Unknown result type (might be due to invalid IL or missing references) //IL_152d: Unknown result type (might be due to invalid IL or missing references) //IL_1905: Unknown result type (might be due to invalid IL or missing references) //IL_1909: Invalid comparison between Unknown and I4 //IL_190b: Unknown result type (might be due to invalid IL or missing references) //IL_190f: Invalid comparison between Unknown and I4 //IL_1d7c: Unknown result type (might be due to invalid IL or missing references) //IL_1d7f: Invalid comparison between Unknown and I4 Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); if (DefaultConfigurability != 0) { bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Item item4 in registeredItems.Where([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled)) { Item item3 = item4; string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name; string englishName = new Regex("['\\[\"\\]]").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; if ((item3.configurability & Configurability.Recipe) != 0) { itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>(); foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty("")) { string configKey = item5; string text = ((configKey == "") ? "" : (" (" + configKey + ")")); if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0) { continue; } ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig()); ItemConfig cfg = itemConfig2; List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>(); cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = CustomTableBrowsability, Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TableLevelBrowsability, Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes); cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); cfg.tableLevel.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6)) { value6.First().m_minStationLevel = cfg.tableLevel.Value; } }; if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1) { cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = QualityResultBrowsability, Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.requireOneIngredient.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5)) { foreach (Recipe item6 in value5) { item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On; } } qualityResultAttributes.Browsable = QualityResultBrowsability(); reloadConfigDisplay(); }; cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes })); cfg.qualityResultAmountMultiplier.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4)) { foreach (Recipe item7 in value4) { item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value; } } }; if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false); } if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true); } if (cfg.craft != null) { cfg.craft.SettingChanged += ConfigChanged; } if (cfg.upgrade != null) { cfg.upgrade.SettingChanged += ConfigChanged; } void ConfigChanged(object o, EventArgs e) { item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? "")); } bool CustomTableBrowsability() { return cfg.table.Value == CraftingTable.Custom; } bool ItemBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } bool QualityResultBrowsability() { return cfg.requireOneIngredient.Value == Toggle.On; } void TableConfigChanged(object o, EventArgs e) { item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value); customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes) { item8.Browsable = cfg.table.Value != CraftingTable.Disabled; } reloadConfigDisplay(); } bool TableLevelBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } ConfigEntry<string> itemConfig(string name, string value, string desc, bool isUpgrade) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes { CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade), Order = (order -= 1), browsability = ItemBrowsability, Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes3); return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 })); } } if ((item3.configurability & Configurability.Drop) != 0) { ConfigEntry<string> val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = drawDropsConfigTable, Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Drop) != 0) } }))); val3.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { item3.UpdateCharacterDrop(); }; } for (int j = 0; j < item3.Conversions.Count; j++) { string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = item3.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.input.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { if (index < item3.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value); item3.conversions[index].m_from = from; UpdatePiece(); } } }; conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.piece.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.customPiece.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; void UpdatePiece() { if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance)) { string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value))); string activePiece = conversion.config.activePiece; if (conversion.config.activePiece != null) { int num = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent<Smelter>().m_conversion.IndexOf(item3.conversions[index]); if (num >= 0) { Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>(); foreach (Smelter val4 in array3) { if (Utils.GetPrefabName(((Component)val4).gameObject) == activePiece) { val4.m_conversion.RemoveAt(num); } } } conversion.config.activePiece = null; } if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0) { GameObject prefab = ZNetScene.instance.GetPrefab(text3); if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null) { conversion.config.activePiece = text3; Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>(); foreach (Smelter val5 in array3) { if (Utils.GetPrefabName(((Component)val5).gameObject) == text3) { val5.m_conversion.Add(item3.conversions[index]); } } } } } } } } if ((item3.configurability & Configurability.Stats) != 0) { item3.statsConfigs.Clear(); SharedData shared2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; ItemType itemType = shared2.m_itemType; statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value) { shared.m_weight = value; }); statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value) { shared.m_value = value; }); bool flag; switch (itemType - 3) { case 0: case 1: case 2: case 3: case 4: case 8: case 9: case 11: case 14: case 16: case 19: flag = true; break; default: flag = false; break; } if (flag) { statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value) { shared.m_maxDurability = value; }); statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value) { shared.m_durabilityPerLevel = value; }); statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value) { shared.m_movementModifier = value; }); } if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value) { shared.m_blockPower = value; }); statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value) { shared.m_blockPowerPerLevel = value; }); statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value) { shared.m_deflectionForce = value; }); statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value) { shared.m_deflectionForcePerLevel = value; }); statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value) { shared.m_timedBlockBonus = value; }); } else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value) { shared.m_armor = value; }); statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value) { shared.m_armorPerLevel = value; }); } SkillType skillType = shared2.m_skillType; if (((int)skillType == 7 || (int)skillType == 12) ? true : false) { statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value) { shared.m_toolTier = value; }); } if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { Dictionary<DamageType, DamageModifier> modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier); DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType)); DamageType[] array = new DamageType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); foreach (DamageType item9 in first.Except((IEnumerable<DamageType>)(object)array)) { DamageType damageType = item9; statcfg<DamageModifier>(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => (!modifiers.TryGetValue(damageType, out var value3)) ? DamageModifier.None : value3, delegate(SharedData shared, DamageModifier value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) DamageModPair val6 = default(DamageModPair); val6.m_type = damageType; val6.m_modifier = (DamageModifier)value; DamageModPair val7 = val6; for (int n = 0; n < shared.m_damageModifiers.Count; n++) { if (shared.m_damageModifiers[n].m_type == damageType) { if (value == DamageModifier.None) { shared.m_damageModifiers.RemoveAt(n); } else { shared.m_damageModifiers[n] = val7; } return; } } if (value != DamageModifier.None) { shared.m_damageModifiers.Add(val7); } }); } } if ((int)itemType == 2 && shared2.m_food > 0f) { statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value) { shared.m_food = value; }); statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value) { shared.m_foodStamina = value; }); statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value) { shared.m_foodEitr = value; }); statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value) { shared.m_foodBurnTime = value; }); statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value) { shared.m_foodRegen = value; }); } if ((int)shared2.m_skillType == 10) { statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealth = value; }); statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealthPercentage = value; }); } skillType = shared2.m_skillType; if (skillType - 9 <= 1) { statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value) { shared.m_attack.m_attackEitr = value; }); } if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value) { shared.m_attackForce = value; }); statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value) { shared.m_backstabBonus = value; }); statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value) { shared.m_attack.m_attackStamina = value; }); SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val) { dmg.m_damage = val; }); SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val) { dmg.m_slash = val; }); SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val) { dmg.m_pierce = val; }); SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val) { dmg.m_blunt = val; }); SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val) { dmg.m_chop = val; }); SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val) { dmg.m_pickaxe = val; }); SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val) { dmg.m_fire = val; }); SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val) { dmg.m_poison = val; }); SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val) { dmg.m_frost = val; }); SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val) { dmg.m_lightning = val; }); SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val) { dmg.m_spirit = val; }); if ((int)itemType == 4) { statcfg<int>("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value) { shared.m_attack.m_projectileBursts = value; }); statcfg<float>("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value) { shared.m_attack.m_burstInterval = value; }); statcfg<float>("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracyMin = value; }); statcfg<float>("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracy = value; }); statcfg<float>("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVelMin = value; }); statcfg<float>("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVel = value; }); statcfg<float>("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value) { shared.m_attack.m_drawDurationMin = value; }); statcfg<float>("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value) { shared.m_attack.m_drawStaminaDrain = value; }); } } } List<ConfigurationManagerAttributes> traderAttributes; if ((item3.configurability & Configurability.Trader) != 0) { traderAttributes = new List<ConfigurationManagerAttributes>(); item3.traderConfig = new TraderConfig { trader = config(englishName, "Trader Selling", item3.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName } })) }; item3.traderConfig.trader.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); foreach (ConfigurationManagerAttributes item10 in traderAttributes) { item10.Browsable = TraderBrowsability(); } reloadConfigDisplay(); }; item3.traderConfig.price = traderConfig<uint>("Trader Price", item3.Trade.Price, "Price of " + englishName + " at the trader."); item3.traderConfig.stack = traderConfig<uint>("Trader Stack", item3.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction."); item3.traderConfig.requiredGlobalKey = traderConfig<string>("Trader Required Global Key", item3.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader."); if (item3.traderConfig.trader.Value != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.traderConfig.trader.Value, item3.traderConfig.price.Value, item3.traderConfig.stack.Value, item3.traderConfig.requiredGlobalKey.Value); } } else if (item3.Trade.Trader != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.Trade.Trader, item3.Trade.Price, item3.Trade.Stack, item3.Trade.RequiredGlobalKey); } void SetDmg(string dmgType, Func<DamageTypes, float> readDmg, setDmgFunc setDmg) { statcfg<float>(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg(shared.m_damages), delegate(SharedData shared, float val) { setDmg(ref shared.m_damages, val); }); statcfg<float>(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg(shared.m_damagesPerLevel), delegate(SharedData shared, float val) { setDmg(ref shared.m_damagesPerLevel, val); }); } bool TraderBrowsability() { return item3.traderConfig.trader.Value != Trader.None; } void statcfg<T>(string configName, string description, [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 1, 0 })] Func<SharedData, T> readDefault, [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 1, 0 })] Action<SharedData, T> setValue) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown SharedData shared3 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; ConfigEntry<T> cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Stats) != 0) } })); if ((item3.configurationVisible & Configurability.Stats) != 0) { setValue(shared3, cfg2.Value); } item3.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig); cfg2.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { if ((item3.configurationVisible & Configurability.Stats) != 0) { ApplyConfig(); } }; void ApplyConfig() { item3.ApplyToAllInstances(delegate(ItemData item) { setValue(item.m_shared, cfg2.Value); }); } } [return: <4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 0 })] ConfigEntry<T> traderConfig<T>(string name, [<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(0)] T value, string desc) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TraderBrowsability, Browsable = (TraderBrowsability() && (item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName }; traderAttributes.Add(configurationManagerAttributes2); ConfigEntry<T> obj = config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 })); obj.SettingChanged += [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); }; return obj; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } } configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); foreach (Item registeredItem in registeredItems) { Item item2 = registeredItem; foreach (KeyValuePair<string, ItemRecipe> recipe in item2.Recipes) { KeyValuePair<string, ItemRecipe> kv = recipe; RequiredResourceList[] array2 = new RequiredResourceList[2] { kv.Value.RequiredItems, kv.Value.RequiredUpgradeItems }; foreach (RequiredResourceList requiredResourceList in array2) { for (int l = 0; l < requiredResourceList.Requirements.Count; l++) { ConfigEntry<int> amountCfg; int resourceIndex; if ((item2.configurability & Configurability.Recipe) != 0) { amountCfg = requiredResourceList.Requirements[l].amountConfig; if (amountCfg != null) { resourceIndex = l; amountCfg.SettingChanged += ConfigChanged; } } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(kv.Key, out var value2)) { foreach (Recipe item11 in value2) { item11.m_resources[resourceIndex].m_amount = amountCfg.Value; } } } } } } item2.InitializeNewRegisteredItem(); } } private void InitializeNewRegisteredItem() { foreach (KeyValuePair<string, ItemRecipe> recipe in Recipes) { KeyValuePair<string, ItemRecipe> kv = recipe; ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive; if (enabledCfg != null) { ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(kv.Key, out var value)) { foreach (Recipe item in value) { item.m_enabled = (int)enabledCfg.BoxedValue != 0; } } } } } public void ReloadCraftingConfiguration() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name)) == null) { registerRecipesInObjectDB(ObjectDB.instance); ObjectDB.instance.m_items.Add(Prefab); ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); ZNetScene.instance.m_prefabs.Add(Prefab); ZNetScene.instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); } foreach (string item in Recipes.Keys.DefaultIfEmpty("")) { if (Recipes.TryGetValue(item, out var value) && value.Crafting.Stations.Count > 0) { UpdateItemTableConfig(item, value.Crafting.Stations.First().Table, value.Crafting.Stations.First().custom ?? ""); UpdateCraftConfig(item, new SerializedRequirements(value.RequiredItems.Requirements), new SerializedRequirements(value.RequiredUpgradeItems.Requirements)); } } } private void ReloadTraderConfiguration() { if (traderConfig.trader.Value == Trader.None) { PrefabManager.RemoveItemFromTrader(Prefab); } else { PrefabManager.AddItemToTrader(Prefab, traderConfig.trader.Value, traderConfig.price.Value, traderConfig.stack.Value, traderConfig.requiredGlobalKey.Value); } } public static void ApplyToAllInstances(GameObject prefab, Action<ItemData> callback) { callback(prefab.GetComponent<ItemDrop>().m_itemData); string name = prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name; Inventory[] source = (from c in Player.s_players.Select([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType<Container>() select c.GetInventory()) where c != null select c).ToArray(); foreach (ItemData item in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent<ItemDrop>() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent<ZNetView>()) select c).Concat(ItemDrop.s_instances) select i.m_itemData).Concat(source.SelectMany([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Inventory i) => i.GetAllItems()))) { if (item.m_shared.m_name == name) { callback(item); } } } public void ApplyToAllInstances(Action<ItemData> callback) { ApplyToAllInstances(Prefab, callback); } [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] [return: <4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(1)] private static string getInternalName<T>(T value) where T : struct { return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; } private void registerRecipesInObjectDB(ObjectDB objectDB) { //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Expected O, but got Unknown activeRecipes[this] = new Dictionary<string, List<Recipe>>(); itemCraftConfigs.TryGetValue(this, out var value); foreach (KeyValuePair<string, ItemRecipe> recipe in Recipes) { List<Recipe> list = new List<Recipe>(); foreach (CraftingStationConfig station in recipe.Value.Crafting.Stations) { ItemConfig itemConfig = value?[recipe.Key]; Recipe val = ScriptableObject.CreateInstance<Recipe>(); string name = ((Object)Prefab).name; CraftingTable table = station.Table; ((Object)val).name = name + "_Recipe_" + table; val.m_amount = recipe.Value.CraftAmount; bool enabled; if (itemConfig != null) { enabled = itemConfig.table.Value != CraftingTable.Disabled; } else { ConfigEntryBase recipeIsActive = recipe.Value.RecipeIsActive; enabled = (int)(((recipeIsActive != null) ? recipeIsActive.BoxedValue : null) ?? ((object)1)) != 0; } val.m_enabled = enabled; val.m_item = Prefab.GetComponent<ItemDrop>(); val.m_resources = SerializedRequirements.toPieceReqs(objectDB, (itemConfig?.craft == null) ? new SerializedRequirements(recipe.Value.RequiredItems.Requirements) : new SerializedRequirements(itemConfig.craft.Value), (itemConfig?.upgrade == null) ? new SerializedRequirements(recipe.Value.RequiredUpgradeItems.Requirements) : new SerializedRequirements(itemConfig.upgrade.Value)); table = ((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value); if ((uint)table <= 1u) { val.m_craftingStation = null; } else if (((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value) == CraftingTable.Custom) { GameObject prefab = ZNetScene.instance.GetPrefab((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value); if (prefab != null) { val.m_craftingStation = prefab.GetComponent<CraftingStation>(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value) + "' does not exist")); } } else { val.m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value)).GetComponent<CraftingStation>(); } val.m_minStationLevel = ((itemConfig == null || list.Count > 0) ? station.level : itemConfig.tableLevel.Value); val.m_requireOnlyOneIngredient = ((itemConfig == null) ? recipe.Value.RequireOnlyOneIngredient : (itemConfig.requireOneIngredient.Value == Toggle.On)); val.m_qualityResultAmountMultiplier = itemConfig?.qualityResultAmountMultiplier.Value ?? recipe.Value.QualityResultAmountMultiplier; list.Add(val); RequiredResourceList requiredItems = recipe.Value.RequiredItems; if (requiredItems != null && !requiredItems.Free) { List<Requirement> requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenCraftRecipes.Add(val, recipe.Value.RecipeIsActive); } } requiredItems = recipe.Value.RequiredUpgradeItems; if (requiredItems != null && !requiredItems.Free) { List<Requirement> requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenUpgradeRecipes.Add(val, recipe.Value.RecipeIsActive); } } } activeRecipes[this].Add(recipe.Key, list); objectDB.m_recipes.AddRange(list); } conversions = new List<ItemConversion>(); for (int i = 0; i < Conversions.Count; i++) { Conversion conversion = Conversions[i]; conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = Prefab.GetComponent<ItemDrop>() }); ConversionPiece conversionPiece = conversion.config?.piece.Value ?? conversion.Piece; string text = null; if (conversionPiece != 0 && conversions[i].m_from != null) { text = ((conversionPiece != ConversionPiece.Custom) ? getInternalName(conversionPiece) : (conversion.config?.customPiece.Value ?? conversion.customPiece)); GameObject prefab2 = ZNetScene.instance.GetPrefab(text); Smelter val2 = ((prefab2 != null) ? prefab2.GetComponent<Smelter>() : null); if (val2 != null) { val2.m_conversion.Add(conversions[i]); } else { text = null; } } if (conversion.config != null) { conversion.config.activePiece = text; } } } [HarmonyPriority(0)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { if ((Object)(object)__instance.GetItemPrefab("Wood") == (Object)null) { return; } hiddenCraftRecipes.Clear(); hiddenUpgradeRecipes.Clear(); foreach (Item registeredItem in registeredItems) { registeredItem.registerRecipesInObjectDB(__instance); } } internal static void Patch_TraderGetAvailableItems(Trader __instance, ref List<TradeItem> __result) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); Trader trader2 = ((prefabName == "Haldor") ? Trader.Haldor : ((prefabName == "Hildir") ? Trader.Hildir : Trader.None)); Trader trader = trader2; __result.AddRange(from tuple in PrefabManager.CustomTradeItems.Values where (tuple.Item1 & trader) != 0 select tuple.Item2 into tradeItem where string.IsNullOrEmpty(tradeItem.m_requiredGlobalKey) || ZoneSystem.instance.GetGlobalKey(tradeItem.m_requiredGlobalKey) select tradeItem); } internal static void Patch_OnAddSmelterInput(ItemData item, bool __result) { if (__result) { ((Humanoid)Player.m_localPlayer).UnequipItem(item, true); } } internal static void Patch_MaximumRequiredStationLevel(Recipe __instance, ref int __result, int quality) { if (!itemDropMap.TryGetValue(__instance.m_item, out var value)) { return; } IEnumerable<ItemConfig> source; if (!itemCraftConfigs.TryGetValue(value, out var value2)) { source = Enumerable.Empty<ItemConfig>(); } else { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if (currentCraftingStation != null) { string stationName = Utils.GetPrefabName(((Component)currentCraftingStation).gameObject); source = from c in value2.Where([<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (KeyValuePair<string, ItemConfig> c) => { switch (c.Value.table.Value) { case CraftingTable.Disabled: case CraftingTable.Inventory: return false; case CraftingTable.Custom: return c.Value.customTable.Value == stationName; default: return getInternalName(c.Value.table.Value) == stationName; } }) select c.Value; } else { source = value2.Values; } } __result = Mathf.Min(Mathf.Max(1, __instance.m_minStationLevel) + (quality - 1), (from cfg in source where cfg.maximumTableLevel != null select cfg.maximumTableLevel.Value).DefaultIfEmpty(value.MaximumRequiredStationLevel).Max()); } internal static void Patch_GetAvailableRecipesPrefix([<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 2, 1, 1, 1, 2 })] ref Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>> __state) { if (__state == null) { __state = new Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>>(); } Dictionary<Recipe, ConfigEntryBase> dictionary; if (InventoryGui.instance.InCraftTab()) { dictionary = hiddenCraftRecipes; } else { if (!InventoryGui.instance.InUpradeTab()) { return; } dictionary = hiddenUpgradeRecipes; } foreach (Recipe key in dictionary.Keys) { key.m_enabled = false; } __state[Assembly.GetExecutingAssembly()] = dictionary; } internal static void Patch_GetAvailableRecipesFinalizer([<4a7ee84e-7b68-4de8-8799-41495be68eb2>Nullable(new byte[] { 1, 1, 1, 1, 2 })] Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>> __state) { if (!__state.TryGetValue(Assembly.GetExecutingAssembly(), out var value)) { return; } foreach (KeyValuePair<Recipe, ConfigEntryBase> item in value) { Recipe key = item.Key; ConfigEntryBase value2 = item.Value; key.m_enabled = (int)(((value2 != null) ? value2.BoxedValue : null) ?? ((object)1)) != 0; } } internal static IEnumerable<CodeInstruction> Transpile_SetupRequirementList(IEnumerable<CodeInstruction> instructionsEnumerable, ILGenerator ilg) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown List<CodeInstruction> list = instructionsEnumerable.ToList(); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(InventoryGui), "SetupRequirement", (Type[])null, (Type[])null); CodeInstruction val = null; CodeInstruction val2 = null; LocalBuilder localBuilder = ilg.DeclareLocal(typeof(int)); Dictionary<Label, int> dictionary = new Dictionary<Label, int>(); bool flag = false; int num = 0; int value = 0; Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { val = list[i + 2]; val2 = list[i + 5]; flag = true; } if (flag) { if (CodeInstructionExtensions.Branches(list[i], ref label) && dictionary.TryGetValue(label.Value, out value)) { num = i; break; } continue; } foreach (Label label4 in list[i].labels) { dictionary[label4] = i; } } if (list[value - 3].opcode == OpCodes.Dup) { return list; } Label label2 = ilg.DefineLabel(); Label label3 = ilg.DefineLabel(); list[num + 1].labels.Add(label2); list.InsertRange(num + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[11] { new CodeInstruction(OpCodes.Ldloc, (object)localBuilder), new CodeInstruction(OpCodes.Brfalse, (object)label2), val.Clone(), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.DeclaredField(typeof(InventoryGui), "m_recipeRequirementList")), new CodeInstruction(OpCodes.Ldlen, (object)null), new CodeInstruction(OpCodes.Bgt, (object)label2), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), val2.Clone(), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Br, (object)label3) }); list.InsertRange(value - 2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Dup, (object)null) { labels = new List<Label> { label3 } }, new CodeInstruction(OpCodes.Stloc, (object)localBuilder) }); return list; } internal static bool Patch_RequirementGetAmount(Requirement __instance, int qualityLevel, ref int __result) { if (requirementQuality.TryGetValue(__instance, out var value)) { __result = ((value.quality == qualityLevel) ? __instance.m_amountPerLevel : 0); return false; } return true; } internal static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (Item registeredItem in registeredItems) { registeredItem.AssignDropToCreature(); } } public void AssignDropToCreature() { foreach (KeyValuePair<CharacterDrop, Drop> characterDrop in characterDrops) { if (Object.op_Implicit((Object)(object)characterDrop.Key)) { characterDrop.Key.m_drops.Remove(characterDrop.Value); } } characterDrops.Clear(); SerializedDrop serializedDrop = new SerializedDrop(DropsFrom.Drops); if (itemDropConfigs.TryGetValue(this, out var value)) { serializedDrop = new SerializedDrop(value.Value); } foreach (KeyValuePair<Character, Drop> item in serializedDrop.toCharacterDrops(ZNetScene.s_instance, Prefab)) { CharacterDrop val = ((Component)item.Key).GetComponent<CharacterDrop>(); if (val == null) { val = ((Component)item.Key).gameObject.AddComponent<CharacterDrop>(); } val.m_drops.Add(item.Value); characterDrops.Add(val, item.Value); } } public void UpdateCharacterDrop() { if (Object.op_Implicit((Object)(object)ZNetScene.instance)) { AssignDropToCreature(); } } public void Snapshot(float lightIntensity = 1.3f, Quaternion? cameraRotation = null, Quaternion? itemRotation = null) { SnapshotItem(Prefab.GetComponent<ItemDrop>(), lightIntensity, cameraRotation, itemRotation); } public static void SnapshotItem(ItemDrop item, float lightIntensity = 1.3f, Quaternion? cameraRotation = null, Quaternion? itemRotation = null) { if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { Do(); } else { ((MonoBehaviour)plugin).StartCoroutine(Delay()); } IEnumerator Delay() { yield return null; Do(); } void Do() { //IL_0018: 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) //IL_0085: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) Camera component = new GameObject("Camera", new Type[1] { typeof(Camera) }).GetComponent<Camera>(); component.backgroundColor = Color.clear; component.clearFlags = (CameraClearFlags)2; component.fieldOfView = 0.5f; component.farClipPlane = 10000000f; component.cullingMask = 1073741824; ((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(90f, 0f, 45f)); Light component2 = new GameObject("Light", new Type[1] { typeof(Light) }).GetComponent<Light>(); ((Component)component2).transform.rotation = Quaternion.Euler(150f, 0f, -5f); component2.type = (LightType)1; component2.cullingMask = 1073741824; component2.intensity = lightIntensity; Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, 64f, 64f); Transform val2 = ((Component)item).transform.Find("attach"); GameObject val3; if (val2 != null) { val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject); } else { ZNetView.m_forceDisableInit = true; val3 = Object.Instantiate<GameObject>(((Component)item).gameObject); ZNetView.m_forceDisableInit = false; } if (itemRotation.HasValue) { val3.transform.rotation = itemRotation.Value; } Transform[] componentsInChildren = val3.GetComponentsInChildren<Transform>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = 30; } Renderer[] componentsInChildren2 = val3.GetComponentsInChildren<Renderer>(); Vector3 val4 = componentsInChildren2.Aggregate<Renderer, Vector3>(Vector3.positiveInfinity, [<91376b64-3ed2-4138-910e-fa4e01f025c4>NullableContext(0)] (Vector3 cur, Renderer renderer) => { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown resul
RaidSystem.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using SimpleJson; using Steamworks; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] public class dWebHook : IDisposable { private readonly WebClient dWebClient; private static NameValueCollection discordValues = new NameValueCollection(); public string WebHook { get; set; } public string UserName { get; set; } public string ProfilePicture { get; set; } public dWebHook() { dWebClient = new WebClient(); } public void SendMessage(string msgSend) { Task.Run(async delegate { discordValues = new NameValueCollection(); ProfilePicture = "https://www.diariodepernambuco.com.br/static/app/noticia_127983242361/2016/09/06/663700/20160906094608464704o.jpg"; UserName = "Cachorro"; WebHook = "https://discord.com/api/webhooks/973618519159762974/O_jAehuGpNSdUlKiiG-CSxpFiuIYK_kCtdZVrW5dgIFOqB51A2GXI4tJawjGofur3DMa"; discordValues.Add("username", UserName); discordValues.Add("avatar_url", ProfilePicture); discordValues.Add("content", msgSend); dWebClient.UploadValues(WebHook, discordValues); }); } public void Dispose() { dWebClient.Dispose(); } } namespace RaidSystem; internal class GUI { public static void ToggleMenu() { if (RaidSystem.Menu == null || (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)RaidSystem.Menu) && !RaidSystem.Menu.activeSelf)) { if (GUIManager.Instance == null) { Debug.LogError((object)"GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Debug.LogError((object)"GUIManager CustomGUI is null"); return; } if (!RaidSystem.HasTeam) { GUIChooseTeam.CreateChooseTeamMenu(); return; } LoadMenu(); } bool active = !RaidSystem.Menu.activeSelf; RaidSystem.Menu.SetActive(active); } public static void DestroyMenu() { RaidSystem.Menu.SetActive(false); } public static void LoadMenu() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: 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_02a9: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Expected O, but got Unknown //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Expected O, but got Unknown if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Object.Destroy((Object)(object)RaidSystem.Menu); foreach (KeyValuePair<string, GameObject> menuItem in RaidSystem.menuItems) { Object.Destroy((Object)(object)menuItem.Value); } RaidSystem.menuItems = new Dictionary<string, GameObject>(); RaidSystem.Menu = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 500f, 700f, true); RaidSystem.Menu.SetActive(false); GameObject val = GUIManager.Instance.CreateScrollView(RaidSystem.Menu.transform, false, true, 8f, 50f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1568628f, 0.1019608f, 0.0627451f, 1f), 400f, 380f); RectTransform val2 = (RectTransform)val.transform; val2.anchoredPosition = new Vector2(-20f, -50f); val.SetActive(true); RaidSystem.menuItems.Add("scrollView", val); string text = ((RaidSystem.localPlayerInfo.Team == "Blue") ? RaidSystem.TeamBlueAlias.Value : RaidSystem.TeamRedAlias.Value); GameObject value = GUIManager.Instance.CreateText(text, RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(200f, 650f), GUIManager.Instance.AveriaSerifBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 40f, false); RaidSystem.menuItems.Add("teamText", value); GameObject value2 = GUIManager.Instance.CreateText(RaidSystem.TerritoriesConquestedText.Value + " " + Util.GetTerritoriesConquestedText(RaidSystem.localPlayerInfo.Team), RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(370f, 617f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 40f, false); RaidSystem.menuItems.Add("realmsConquestedText", value2); ZPackage val3 = new ZPackage(); val3.Write(RaidSystem.localPlayerInfo.Team); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "TerritoriesSyncRaidSystem", new object[1] { val3 }); GameObject value3 = GUIManager.Instance.CreateText(RaidSystem.localPlayerInfo.Nick, RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(200f, 590f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 50f, false); RaidSystem.menuItems.Add("playerNameText", value3); GUIManager instance = GUIManager.Instance; string description = RaidSystem.localPlayerInfo.Description; GameObject val4 = instance.CreateInputField(RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(160f, 555f), (ContentType)0, description, 18, 270f, 33f); RaidSystem.menuItems.Add("descriptionInputObj", val4); GameObject val5 = GUIManager.Instance.CreateButton(RaidSystem.ButtonUpdateText.Value, RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(360f, 555f), 90f, 35f); val5.SetActive(true); RaidSystem.menuItems.Add("buttonUpdate", val5); InputField inputComponent = val4.GetComponent<InputField>(); inputComponent.text = RaidSystem.localPlayerInfo.Description; Button component = val5.GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { new PlayerInfoService().UpdatePlayer(inputComponent); }); CreateItems(val); ((Component)val.transform.Find("Scroll View")).GetComponent<ScrollRect>().verticalNormalizedPosition = 1f; GameObject value4 = GUIManager.Instance.CreateText(RaidSystem.TeamMemberListText.Value, RaidSystem.Menu.transform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(200f, 496f), GUIManager.Instance.AveriaSerifBold, 25, GUIManager.Instance.ValheimOrange, true, Color.black, 350f, 40f, false); RaidSystem.menuItems.Add("textRealmLIst", value4); GameObject val6 = GUIManager.Instance.CreateButton("Close", RaidSystem.Menu.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -300f), 170f, 45f); val6.SetActive(true); RaidSystem.menuItems.Add("buttonObject", val6); Button component2 = val6.GetComponent<Button>(); ((UnityEvent)component2.onClick).AddListener(new UnityAction(DestroyMenu)); } private static void CreateItems(GameObject scrollView) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024b: 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_0267: Unknown result type (might be due to invalid IL or missing references) GameObject value = GUIManager.Instance.CreateText("\n", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 10, GUIManager.Instance.ValheimOrange, true, Color.black, 150f, 30f, false); RaidSystem.menuItems.Add("x", value); foreach (PlayerInfoService.PlayerInfo item in RaidSystem.PlayerInfoList.Where((PlayerInfoService.PlayerInfo x) => x.Team == RaidSystem.localPlayerInfo.Team).ToList()) { GameObject value2 = GUIManager.Instance.CreateText(item.Nick, scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 25f, false); RaidSystem.menuItems.Add("nameText" + Guid.NewGuid(), value2); GameObject value3 = GUIManager.Instance.CreateText(item.Description, scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 20f, false); RaidSystem.menuItems.Add("descriptionText" + Guid.NewGuid(), value3); GameObject value4 = GUIManager.Instance.CreateText("", scrollView.transform.Find("Scroll View/Viewport/Content"), new Vector2(0.5f, -5f), new Vector2(0.5f, -5f), new Vector2(0f, -20f), GUIManager.Instance.AveriaSerifBold, 10, GUIManager.Instance.ValheimOrange, true, Color.black, 150f, 10f, false); RaidSystem.menuItems.Add("spacador" + Guid.NewGuid(), value4); } } public static void SetTerritoriesConquestText(string text) { GameObject val = RaidSystem.menuItems["realmsConquestedText"]; Text component = val.GetComponent<Text>(); component.text = RaidSystem.TerritoriesConquestedText.Value + " " + text; } } public class GUIChooseTeam { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__1_0; public static UnityAction <>9__1_1; internal void <CreateChooseTeamMenu>b__1_0() { new PlayerInfoService().PreparePlayerToSend("Blue"); } internal void <CreateChooseTeamMenu>b__1_1() { new PlayerInfoService().PreparePlayerToSend("Red"); } } public static GameObject menu; public static void CreateChooseTeamMenu() { //IL_0045: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)menu) && menu.activeSelf) { DestroyMenu(); return; } menu = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 380f, 220f, true); GameObject val = GUIManager.Instance.CreateText(RaidSystem.ChooseTeamMessage.Value, menu.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -60f), GUIManager.Instance.AveriaSerifBold, 25, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 40f, false); GameObject val2 = GUIManager.Instance.CreateButton(RaidSystem.TeamBlueAlias.Value, menu.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(90f, -30f), 150f, 50f); val2.SetActive(true); Button component = val2.GetComponent<Button>(); ButtonClickedEvent onClick = component.onClick; object obj = <>c.<>9__1_0; if (obj == null) { UnityAction val3 = delegate { new PlayerInfoService().PreparePlayerToSend("Blue"); }; <>c.<>9__1_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); GameObject val4 = GUIManager.Instance.CreateButton(RaidSystem.TeamRedAlias.Value, menu.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-90f, -30f), 150f, 50f); val4.SetActive(true); Button component2 = val4.GetComponent<Button>(); ButtonClickedEvent onClick2 = component2.onClick; object obj2 = <>c.<>9__1_1; if (obj2 == null) { UnityAction val5 = delegate { new PlayerInfoService().PreparePlayerToSend("Red"); }; <>c.<>9__1_1 = val5; obj2 = (object)val5; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); menu.SetActive(true); } public static void DestroyMenu() { try { menu.SetActive(false); } catch { } } } public static class MapDrawer { private static Dictionary<string, Color> Colors = new Dictionary<string, Color> { { "blue", Color.blue }, { "red", Color.red }, { "white", Color.white }, { "green", Color.green }, { "cyan", Color.cyan }, { "clear", Color.clear }, { "grey", Color.grey }, { "magenta", Color.magenta }, { "black", Color.black }, { "yellow", Color.yellow }, { "gray", Color.gray } }; public static void CreateMapDrawing(string[] teamPositions) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) int value = RaidSystem.RadiusDrawMap.Value; if (value == 0) { return; } MapDrawing mapDrawing = MinimapManager.Instance.GetMapDrawing("RaidSystem"); foreach (string text in teamPositions) { if (!(text == "")) { string text2 = text.Split(new char[1] { ',' })[0]; Color col = ((!(text2 == "Blue")) ? Colors[RaidSystem.TeamRedColorOverlap.Value] : Colors[RaidSystem.TeamBlueColorOverlap.Value]); col.a = RaidSystem.ColorAlfa.Value; string s = text.Split(new char[1] { ',' })[1]; string s2 = text.Split(new char[1] { ',' })[2]; string s3 = text.Split(new char[1] { ',' })[3]; Vector2 val = MinimapManager.Instance.WorldToOverlayCoords(new Vector3(float.Parse(s), float.Parse(s2), float.Parse(s3)), ((MapOverlayBase)mapDrawing).TextureSize); Circle(mapDrawing.MainTex, (int)val.x, (int)val.y, value, col); Circle(mapDrawing.HeightFilter, (int)val.x, (int)val.y, value, MinimapManager.MeadowHeight); Circle(mapDrawing.ForestFilter, (int)val.x, (int)val.y, value, MinimapManager.FilterOff); } } mapDrawing.MainTex.Apply(); mapDrawing.ForestFilter.Apply(); mapDrawing.HeightFilter.Apply(); } public static void Circle(Texture2D tex, int cx, int cy, int r, Color col) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i <= r; i++) { int num = (int)Mathf.Ceil(Mathf.Sqrt((float)(r * r - i * i))); for (int j = 0; j <= num; j++) { int num2 = cx + i; int num3 = cx - i; int num4 = cy + j; int num5 = cy - j; tex.SetPixel(num2, num4, col); tex.SetPixel(num3, num4, col); tex.SetPixel(num2, num5, col); tex.SetPixel(num3, num5, col); } } } } [HarmonyPatch] public class Patches { [HarmonyPatch(typeof(WearNTear), "Destroy")] public static class Destroy { private static void Postfix(WearNTear __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)__instance.m_piece).gameObject).name.Contains("RaidWard")) { Util.RespawnPrefab("RaidWard", "Castelo Consquitado", ((Component)__instance).transform.position, ((Component)__instance).transform.rotation); } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class ZNet__OnNewConnection { public static void Postfix(ZNet __instance, ZNetPeer peer) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsServer()) { CSteamID steamID = SteamUser.GetSteamID(); RaidSystem.SteamId = ((object)(CSteamID)(ref steamID)).ToString(); } } } [HarmonyPatch(typeof(Game), "Logout")] public static class Logout { private static void Postfix() { hasAwake = false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class OnSpawned { private static void Postfix() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (!hasAwake) { hasAwake = true; ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "FileSyncRaidSystem", new object[1] { (object)new ZPackage() }); } } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] public static class CheckCanRemovePiece { [HarmonyPriority(0)] private static bool Prefix(Piece piece, Player __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return SynchronizationManager.Instance.PlayerIsAdmin || !Util.IsRaidEnabledHere(((Component)piece).transform.position); } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(800)] private static bool Prefix(Piece piece, Player __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return SynchronizationManager.Instance.PlayerIsAdmin || !Util.IsRaidEnabledHere(((Component)__instance).transform.position) || Object.op_Implicit((Object)(object)((Component)piece).gameObject.GetComponent<Door>()); } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] public static class RPC_Damage { [HarmonyPriority(0)] private static bool Prefix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)___m_nview == (Object)null) { return false; } bool flag = Util.IsRaidEnabledHere(((Component)__instance).transform.position); if (!Util.CheckInPrivateArea(((Component)__instance).transform.position) && !flag) { return true; } if (!flag || Util.IsRaidDisabledThisTime() || (!((Object)((Component)__instance).gameObject).name.Contains("RaidWard") && !Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<Door>()))) { return false; } hit.ApplyModifier((float)(1.0 - (double)RaidSystem.WardReductionDamage.Value / 100.0)); return true; } catch (Exception ex) { Debug.LogError((object)(ex.Message + " - " + ex.StackTrace)); return false; } } } [HarmonyPatch(typeof(Character), "ApplyDamage")] public static class ApplyDamage { public static void Postfix(Character __instance, HitData hit) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) try { if ((double)__instance.GetHealth() > 0.0 || !Object.op_Implicit((Object)(object)hit.GetAttacker()) || !hit.GetAttacker().IsPlayer() || !__instance.IsPlayer()) { return; } Player killer = (Player)hit.GetAttacker(); PlayerInfoService.PlayerInfo playerInfo = RaidSystem.PlayerInfoList.FirstOrDefault((PlayerInfoService.PlayerInfo x) => x.PlayerId == killer.GetPlayerID().ToString()); if (playerInfo != null) { Player deadPlayer = (Player)__instance; PlayerInfoService.PlayerInfo playerInfo2 = RaidSystem.PlayerInfoList.FirstOrDefault((PlayerInfoService.PlayerInfo x) => x.PlayerId == deadPlayer.GetPlayerID().ToString()); if (playerInfo2 != null && !(playerInfo.Team == playerInfo2.Team)) { Object.Instantiate<GameObject>((playerInfo2.Team == "Blue") ? RaidSystem.blueTrophy : RaidSystem.redTrophy, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity); } } } catch (Exception ex) { Debug.Log((object)("Error droping player trophy " + ex.Message)); } } } public static bool hasAwake; } public class PlayerInfoService { public class PlayerInfo { public string Nick { get; set; } public string SteamId { get; set; } public string PlayerId { get; set; } public string Description { get; set; } public string Team { get; set; } } public List<PlayerInfo> GetPlayerInfoList(string json) { if (json == "") { return new List<PlayerInfo>(); } return SimpleJson.DeserializeObject<List<PlayerInfo>>(json); } public void SetPlayerInfoList(string json) { List<PlayerInfo> playerInfoList = SimpleJson.DeserializeObject<List<PlayerInfo>>(json); RaidSystem.PlayerInfoList = playerInfoList; PlayerInfo playerInfo = RaidSystem.PlayerInfoList.FirstOrDefault((PlayerInfo x) => x.PlayerId == Player.m_localPlayer.GetPlayerID().ToString()); if (playerInfo != null) { RaidSystem.HasTeam = true; } RaidSystem.localPlayerInfo = playerInfo; } public void PreparePlayerToSend(string team, string description = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); string text = ((Character)Player.m_localPlayer).m_nview.GetZDO().GetString("playerName", "") + ","; text = text + RaidSystem.SteamId + ","; text = text + Player.m_localPlayer.GetPlayerID() + ","; text = text + description + ","; text += team; val.Write(text); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "UpdateOrSaveDataRaidSystem", new object[1] { val }); GUIChooseTeam.DestroyMenu(); } public void UpdatePlayer(InputField input) { PreparePlayerToSend(RaidSystem.localPlayerInfo.Team, input.text); } } [BepInPlugin("Detalhes.RaidSystem", "Detalhes.RaidSystem", "1.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class RaidSystem : BaseUnityPlugin { public const string PluginGUID = "Detalhes.RaidSystem"; public const string Version = "1.3.2"; private Harmony harmony = new Harmony("Detalhes.RaidSystem"); public static readonly string ModPath = Path.GetDirectoryName(typeof(RaidSystem).Assembly.Location); public static ConfigEntry<string> TeamBluePrefab; public static ConfigEntry<string> TeamRedPrefab; public static ConfigEntry<string> TeamBlueAlias; public static ConfigEntry<string> TeamRedAlias; public static ConfigEntry<float> ColorAlfa; public static ConfigEntry<int> RadiusDrawMap; public static ConfigEntry<string> TeamBlueColorOverlap; public static ConfigEntry<string> TeamRedColorOverlap; public static ConfigEntry<string> WebhookUrl; public static ConfigEntry<string> AdminList; public static ConfigEntry<string> RaidTimeToAllowUtc; public static ConfigEntry<string> RaidEnabledPositions; public static ConfigEntry<string> ConquestMessage; public static ConfigEntry<string> ChooseTeamMessage; public static ConfigEntry<string> ButtonUpdateText; public static ConfigEntry<string> TeamMemberListText; public static ConfigEntry<string> TerritoriesConquestedText; public static ConfigEntry<string> Cost; public static ConfigEntry<int> HitPoints; public static ConfigEntry<int> AreaRadius; public static ConfigEntry<int> SpawnDelayMS; public static ConfigEntry<int> Scale; public static ConfigEntry<float> WardReductionDamage; public static ConfigEntry<bool> RespawnOtherTeamWard; public static ConfigEntry<bool> OnlyAdminCanBuild; public static ConfigEntry<bool> RemoveTokenCost; public static ConfigEntry<KeyCode> KeyboardShortcut; public static List<PlayerInfoService.PlayerInfo> PlayerInfoList = new List<PlayerInfoService.PlayerInfo>(); public static bool HasTeam = false; public static PlayerInfoService.PlayerInfo localPlayerInfo; public static GameObject blueTrophy; public static GameObject redTrophy; public static Dictionary<string, GameObject> menuItems = new Dictionary<string, GameObject>(); public static GameObject Menu; public static string FileDirectory = Paths.ConfigPath + "/RaidSystem/"; public static string FileName = "Detalhes.RaidSystem.json"; public static string SteamId = "xxxxxx"; private void Awake() { //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_003b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00a9: 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_00b7: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0129: 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_0137: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Expected O, but got Unknown //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Expected O, but got Unknown //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Expected O, but got Unknown //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Expected O, but got Unknown //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Expected O, but got Unknown //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Expected O, but got Unknown //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Expected O, but got Unknown //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Expected O, but got Unknown //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Expected O, but got Unknown //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Expected O, but got Unknown //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Expected O, but got Unknown //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Expected O, but got Unknown //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Expected O, but got Unknown //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Expected O, but got Unknown //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Expected O, but got Unknown //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Expected O, but got Unknown //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Expected O, but got Unknown //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Expected O, but got Unknown //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Expected O, but got Unknown //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Expected O, but got Unknown //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Expected O, but got Unknown //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Expected O, but got Unknown //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Expected O, but got Unknown //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Expected O, but got Unknown //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Expected O, but got Unknown //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; RemoveTokenCost = ((BaseUnityPlugin)this).Config.Bind<bool>("Craft Server config", "RemoveTokenCost", false, new ConfigDescription("RemoveTokenCost", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); OnlyAdminCanBuild = ((BaseUnityPlugin)this).Config.Bind<bool>("Craft Server config", "OnlyAdminCanBuild", true, new ConfigDescription("OnlyAdminCanBuild", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Cost = ((BaseUnityPlugin)this).Config.Bind<string>("Craft Server config", "Cost", "wood:1000:false,stone:1000:false", new ConfigDescription("Cost", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamBluePrefab = ((BaseUnityPlugin)this).Config.Bind<string>("Craft Server config", "TeamBluePrefab", "$custompiece_wolf", new ConfigDescription("TeamBluePrefab", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamRedPrefab = ((BaseUnityPlugin)this).Config.Bind<string>("Craft Server config", "TeamRedPrefab", "$custompiece_elk", new ConfigDescription("TeamRedPrefab", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RadiusDrawMap = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "RadiusDrawMap", 30, new ConfigDescription("300", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ColorAlfa = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "ColorAlfa", 0.7f, new ConfigDescription("0.1f,1f", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamRedColorOverlap = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "TeamRedColorOverlap", "red", new ConfigDescription("blue,red,blue,green,cyan,clear,grey,magentawhite,black,yellow,gray", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamBlueColorOverlap = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "TeamBlueColorOverlap", "blue", new ConfigDescription("blue,red,blue,green,cyan,clear,grey,magentawhite,black,yellow,gray", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamMemberListText = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "TeamMemberListText", "Realm Members: ", new ConfigDescription("TeamMemberListText", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TerritoriesConquestedText = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "TerritoriesConquestedText", "Cities under control:", new ConfigDescription("TerritoriesConquestedText", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamMemberListText = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "TeamMemberListText", "Realm Members: ", new ConfigDescription("TeamMemberListText", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ButtonUpdateText = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "ButtonUpdateText", "Update", new ConfigDescription("ButtonUpdateText", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ChooseTeamMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "ChooseTeamMessage", "Choose Realm", new ConfigDescription("ChooseTeamMessage", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ConquestMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Text Server config", "ConquestMessage", "Has conquest the base located at:", new ConfigDescription("ConquestMessage", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RaidTimeToAllowUtc = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "RaidTimeToAllowUtc", "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24", new ConfigDescription("Utc hours that raids will be enabled", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RaidEnabledPositions = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "RaidEnabledPositions", "", new ConfigDescription("RaidEnabledPositions", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); AreaRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "AreaRadius", 150, new ConfigDescription("AreaRadius", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardReductionDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "WardReductionDamage", 99f, new ConfigDescription("WardReductionDamage", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); AdminList = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "AdminList", "steamid steamid", new ConfigDescription("AdminList", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamBlueAlias = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "TeamBlueAlias", "Bretonnia", new ConfigDescription("TeamBlueAlias", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TeamRedAlias = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "TeamRedAlias", "Kattegat", new ConfigDescription("TeamRedAlias", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); HitPoints = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "HitPoints", 10000, new ConfigDescription("HitPoints", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SpawnDelayMS = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "SpawnDelayMS", 5000, new ConfigDescription("SpawnDelayMS", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Scale = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "Scale", 3, new ConfigDescription("Scale", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); RespawnOtherTeamWard = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "RespawnOtherTeamWard", true, new ConfigDescription("RespawnOtherTeamWard", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WebhookUrl = ((BaseUnityPlugin)this).Config.Bind<string>("Server config", "WebhookUrl", "", new ConfigDescription("WebhookUrl", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); KeyboardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Client config", "KeyboardShortcutConfig", (KeyCode)280, new ConfigDescription("Client side KeyboardShortcut", (AcceptableValueBase)null, new object[2] { null, (object)new ConfigurationManagerAttributes { IsAdminOnly = false } })); harmony.PatchAll(); Cloning.LoadAssets(); SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { if (attr.InitialSynchronization) { Cloning.AddCustomPrivateAreas(); Cloning.AddTrophies(); } else { Logger.LogMessage((object)"Config sync event received"); } }; } private void Update() { //IL_0006: 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_006d: Expected O, but got Unknown if (Input.GetKeyDown(KeyboardShortcut.Value)) { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting()) { GUI.ToggleMenu(); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "GetGoldServer", new object[1] { (object)new ZPackage() }); } } } } [HarmonyPatch] internal class RPC { [HarmonyPatch(typeof(Game), "Start")] public static class GameStart { public static void Postfix() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("FileSyncRaidSystem", (Action<long, ZPackage>)RPC_FileSync); ZRoutedRpc.instance.Register<ZPackage>("FileSyncClientRaidSystem", (Action<long, ZPackage>)RPC_FileSyncClient); ZRoutedRpc.instance.Register<ZPackage>("UpdateOrSaveDataRaidSystem", (Action<long, ZPackage>)RPC_UpdateOrSaveData); ZRoutedRpc.instance.Register<ZPackage>("TerritoriesSyncRaidSystem", (Action<long, ZPackage>)RPC_TerritoriesSync); ZRoutedRpc.instance.Register<ZPackage>("TerritoriesClientRaidSystem", (Action<long, ZPackage>)RPC_TerritoriesSyncClient); ZRoutedRpc.instance.Register<ZPackage>("GetTerritoriesInfoToDraw", (Action<long, ZPackage>)RPC_GetTerritoriesInfoToDraw); ZRoutedRpc.instance.Register<ZPackage>("GetTerritoriesInfoToDrawClient", (Action<long, ZPackage>)RPC_GetTerritoriesInfoToDrawClient); } } } private static string FileLocation = RaidSystem.FileDirectory + RaidSystem.FileName; public static void RPC_FileSync(long sender, ZPackage pkg) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (ZNet.instance.IsServer()) { ZPackage val = new ZPackage(); if (!Directory.Exists(RaidSystem.FileDirectory)) { Directory.CreateDirectory(RaidSystem.FileDirectory); } if (File.Exists(FileLocation)) { val.Write(File.ReadAllText(FileLocation)); } else { pkg.Write(""); } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "FileSyncClientRaidSystem", new object[1] { val }); } } public static void RPC_TerritoriesSync(long sender, ZPackage pkg) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (ZNet.instance.IsServer()) { string playerTeam = pkg.ReadString(); ZPackage val = new ZPackage(); val.Write(Util.GetTerritoriesConquestedText(playerTeam)); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "TerritoriesClientRaidSystem", new object[1] { val }); } } public static void RPC_TerritoriesSyncClient(long sender, ZPackage pkg) { if (!ZNet.instance.IsServer()) { GUI.SetTerritoriesConquestText(pkg.ReadString()); } } public static void RPC_GetTerritoriesInfoToDraw(long sender, ZPackage pkg) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (ZNet.instance.IsServer()) { ZPackage val = new ZPackage(); val.Write(Util.GetTerritoriesInfoInString()); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "GetTerritoriesInfoToDrawClient", new object[1] { val }); } } public static void RPC_GetTerritoriesInfoToDrawClient(long sender, ZPackage pkg) { if (!ZNet.instance.IsServer()) { pkg.ReadString().Split(new char[1] { '|' }); } } public static void RPC_FileSyncClient(long sender, ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { string text = pkg.ReadString(); if (!(text == "")) { new PlayerInfoService().SetPlayerInfoList(text); GUI.LoadMenu(); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "GetTerritoriesInfoToDraw", new object[1] { (object)new ZPackage() }); } } } public static void RPC_UpdateOrSaveData(long sender, ZPackage pkg) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown if (ZNet.instance.IsServer()) { List<PlayerInfoService.PlayerInfo> list = new List<PlayerInfoService.PlayerInfo>(); string[] array = pkg.ReadString().Split(new char[1] { ',' }); string nick = array[0]; string steamId = array[1]; string playerId = array[2]; string description = array[3]; string team = array[4]; if (!Directory.Exists(RaidSystem.FileDirectory)) { Directory.CreateDirectory(RaidSystem.FileDirectory); } if (!File.Exists(FileLocation)) { File.Create(FileLocation); } else { list = new PlayerInfoService().GetPlayerInfoList(File.ReadAllText(FileLocation)); } PlayerInfoService.PlayerInfo playerInfo = list.FirstOrDefault((PlayerInfoService.PlayerInfo x) => x.PlayerId == playerId); if (playerInfo == null) { playerInfo = new PlayerInfoService.PlayerInfo(); list.Add(playerInfo); } playerInfo.Nick = nick; playerInfo.SteamId = steamId; playerInfo.PlayerId = playerId; playerInfo.Description = description; playerInfo.Team = team; string text = SimpleJson.SerializeObject((object)list); File.WriteAllText(FileLocation, text); ZPackage val = new ZPackage(); val.Write(text); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "FileSyncClientRaidSystem", new object[1] { val }); } } } public class Cloning { public static void LoadAssets() { PrefabManager.OnPrefabsRegistered += AddTeamTokens; } public static void AddTrophies() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown CustomItem val = new CustomItem(RaidSystem.TeamRedAlias.Value + "PlayerTrophy", "TrophySkeleton"); ItemDrop itemDrop = val.ItemDrop; itemDrop.m_itemData.m_shared.m_name = RaidSystem.TeamRedAlias.Value + " Player Trophy"; itemDrop.m_itemData.m_shared.m_description = "Someone has died."; itemDrop.m_itemData.m_shared.m_maxStackSize = 10; RaidSystem.redTrophy = val.ItemPrefab; ItemManager.Instance.AddItem(val); CustomItem val2 = new CustomItem(RaidSystem.TeamRedAlias.Value + "BluePlayerTrophy", "TrophySkeleton"); ItemDrop itemDrop2 = val2.ItemDrop; itemDrop2.m_itemData.m_shared.m_name = RaidSystem.TeamRedAlias.Value + " Player Trophy"; itemDrop2.m_itemData.m_shared.m_description = "Someone has died."; itemDrop2.m_itemData.m_shared.m_maxStackSize = 10; RaidSystem.blueTrophy = val2.ItemPrefab; ItemManager.Instance.AddItem(val2); } public static void AddCustomPrivateAreas() { //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown GameObject val = ((IEnumerable<GameObject>)ObjectDB.instance.m_items).FirstOrDefault((Func<GameObject, bool>)((GameObject x) => ((Object)x).name == "Hammer")); PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces; foreach (string item in new List<string> { RaidSystem.TeamBluePrefab.Value, RaidSystem.TeamRedPrefab.Value }) { string newName = "RS_" + item; if (buildPieces.m_pieces.Exists((GameObject x) => ((Object)x).name == newName)) { continue; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(newName, item); if (!Object.op_Implicit((Object)(object)val2)) { Debug.LogError((object)("original prefab not found for " + item)); continue; } Piece val3 = val2.GetComponent<Piece>(); if (val3 == null) { val3 = val2.AddComponent<Piece>(); } WearNTear component = val2.GetComponent<WearNTear>(); if (!Object.op_Implicit((Object)(object)component)) { val2.AddComponent<WearNTear>(); } component.m_health = RaidSystem.HitPoints.Value; val3.m_description = ((RaidSystem.TeamBluePrefab.Value == item) ? RaidSystem.TeamBlueAlias.Value : RaidSystem.TeamRedAlias.Value); val3.m_name = ((Object)val2).name; List<Requirement> list = new List<Requirement>(); string[] array = RaidSystem.Cost.Value.Split(new char[1] { ',' }); foreach (string text in array) { string text2 = text.Split(new char[1] { ':' })[0]; int amount = Convert.ToInt32(text.Split(new char[1] { ':' })[1]); bool recover = Convert.ToBoolean(text.Split(new char[1] { ':' })[2]); Requirement val4 = new Requirement(); val4.m_resItem = PrefabManager.Instance.GetPrefab(text2).GetComponent<ItemDrop>(); val4.m_amount = amount; val4.m_recover = recover; list.Add(val4); } if (!RaidSystem.RemoveTokenCost.Value) { Requirement val5 = new Requirement(); val5.m_recover = false; val5.m_amount = 1; string text3 = ((item == RaidSystem.TeamBluePrefab.Value) ? "BlueToken" : "RedToken"); val5.m_resItem = PrefabManager.Instance.GetPrefab(text3).GetComponent<ItemDrop>(); list.Add(val5); } val3.m_resources = list.ToArray(); PrivateArea val6 = val2.AddComponent<PrivateArea>(); PrivateArea component2 = PrefabManager.Instance.GetPrefab("guard_stone").GetComponent<PrivateArea>(); val6.m_radius = RaidSystem.AreaRadius.Value; val6.m_name = newName; val6.m_removedPermittedEffect = component2.m_removedPermittedEffect; val6.m_flashEffect = component2.m_flashEffect; val6.m_activateEffect = component2.m_activateEffect; val6.m_addPermittedEffect = component2.m_addPermittedEffect; val6.m_connectEffect = component2.m_connectEffect; val6.m_deactivateEffect = component2.m_deactivateEffect; val6.m_model = component2.m_model; val6.m_connectEffect = component2.m_connectEffect; val6.m_inRangeEffect = component2.m_inRangeEffect; val6.m_areaMarker = component2.m_areaMarker; val6.m_enabledEffect = component2.m_enabledEffect; Vector3 localScale = ((Component)((Component)val3).transform).transform.localScale; localScale.x *= RaidSystem.Scale.Value; localScale.y *= RaidSystem.Scale.Value; localScale.z *= RaidSystem.Scale.Value; ((Component)val3).transform.localScale = localScale; PieceManager.Instance.RegisterPieceInPieceTable(val2, "Hammer", "RaidSystem"); if (RaidSystem.OnlyAdminCanBuild.Value && !SynchronizationManager.Instance.PlayerIsAdmin) { buildPieces.m_pieces.Remove(val2); } } } private static void AddTeamTokens() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown try { CustomItem val = new CustomItem("BlueToken", "Thunderstone"); ItemDrop itemDrop = val.ItemDrop; itemDrop.m_itemData.m_shared.m_name = "Blue Token"; itemDrop.m_itemData.m_shared.m_description = "Create your team ward."; itemDrop.m_itemData.m_shared.m_maxStackSize = 10; ItemManager.Instance.AddItem(val); CustomItem val2 = new CustomItem("RedToken", "Thunderstone"); ItemDrop itemDrop2 = val2.ItemDrop; itemDrop2.m_itemData.m_shared.m_name = "Red Token"; itemDrop2.m_itemData.m_shared.m_description = "Create your team ward."; itemDrop2.m_itemData.m_shared.m_maxStackSize = 10; ItemManager.Instance.AddItem(val2); } catch (Exception ex) { Logger.LogError((object)("Error while adding cloned item: " + ex.Message)); } finally { PrefabManager.OnPrefabsRegistered -= AddTeamTokens; } } } public static class Util { public static string GetTerritoriesConquestedText(string playerTeam) { string text = "RS_" + RaidSystem.TeamRedPrefab.Value; string text2 = "RS_" + RaidSystem.TeamBluePrefab.Value; int prefabCount = GetPrefabCount(StringExtensionMethods.GetStableHashCode(text)); int prefabCount2 = GetPrefabCount(StringExtensionMethods.GetStableHashCode(text2)); int num = prefabCount + prefabCount2; return ((playerTeam == "Blue") ? prefabCount2 : prefabCount) + "/" + num; } public static string GetTerritoriesInfoInString() { string text = ""; int stableHashCode = StringExtensionMethods.GetStableHashCode("RS_" + RaidSystem.TeamRedPrefab.Value); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("RS_" + RaidSystem.TeamBluePrefab.Value); List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List<ZDO> list in objectsBySector) { if (list == null) { continue; } for (int j = 0; j < list.Count; j++) { ZDO val = list[j]; if (val.GetPrefab() == stableHashCode) { text = string.Concat(text + "Red," + (int)val.m_position.x + "," + (int)val.m_position.y + "," + (int)val.m_position.z, "|"); } else if (val.GetPrefab() == stableHashCode2) { text = string.Concat(text + "Blue," + (int)val.m_position.x + "," + (int)val.m_position.y + "," + (int)val.m_position.z, "|"); } } } return text; } private static int GetPrefabCount(int prefabHash) { int num = 0; List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List<ZDO> list in objectsBySector) { if (list == null) { continue; } for (int j = 0; j < list.Count; j++) { if (list[j].GetPrefab() == prefabHash) { num++; } } } return num; } public static void RespawnPrefab(string prefab, string alias, Vector3 position, Quaternion rotation, string crafterName = "") { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) Task.Run(async delegate { await Task.Delay(RaidSystem.SpawnDelayMS.Value); GameObject bluePrefab = PrefabManager.Instance.GetPrefab(prefab); GameObject instatiated = Object.Instantiate<GameObject>(bluePrefab, position, rotation); if (!(crafterName == "")) { instatiated.GetComponent<ItemDrop>().m_itemData.m_crafterName = crafterName; } new dWebHook().SendMessage("**" + alias + " - " + RaidSystem.ConquestMessage.Value + " X: " + (int)position.x + " Z:" + (int)position.z + "**"); }); } public static bool IsRaidDisabledThisTime() { if (RaidSystem.RaidTimeToAllowUtc.Value == "") { return true; } string value = RaidSystem.RaidTimeToAllowUtc.Value; char[] separator = new char[1] { ',' }; string[] array = value.Split(separator); foreach (string text in array) { if (!(text == "") && DateTime.UtcNow.Hour == Convert.ToInt32(text)) { return false; } } return true; } public static bool IsRaidEnabledHere(Vector3 position) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (RaidSystem.RaidEnabledPositions.Value == "") { return true; } string value = RaidSystem.RaidEnabledPositions.Value; char[] separator = new char[1] { '|' }; string[] array = value.Split(separator); foreach (string text in array) { if (!(text == "")) { string[] array2 = text.Split(new char[1] { ',' }); int num = Convert.ToInt32(array2[0]); int num2 = Convert.ToInt32(array2[1]); int num3 = Convert.ToInt32(array2[2]); if ((double)Utils.DistanceXZ(position, new Vector3((float)num, 0f, (float)num2)) < (double)num3) { return true; } } } return false; } public static bool CheckInPrivateArea(Vector3 point, bool flash = false) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) foreach (PrivateArea allArea in PrivateArea.m_allAreas) { Debug.LogError((object)((Object)((Component)allArea.m_piece).gameObject).name); if (((Object)((Component)allArea.m_piece).gameObject).name.Contains("dverger_guardstone") || !allArea.IsEnabled() || !allArea.IsInside(point, 0f)) { continue; } if (flash) { allArea.FlashShield(false); } return true; } return false; } }