Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ServersideQoL BETA v1.99.8
patchers\ServersideQoL.Patchers.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArgusMagnus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("ArgusMagnus")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL.Patchers")] [assembly: AssemblyTitle("ServersideQoL.Patchers")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("1.99.8.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 ServersideQoL.Patchers { internal static class Patcher { private const string AssemblyName = "assembly_valheim.dll"; public static IEnumerable<string> TargetDLLs => new <>z__ReadOnlySingleElementList<string>("assembly_valheim.dll"); public static void Patch(AssemblyDefinition assembly) { AddProperty(assembly, "ZDO", "ServersideQoL", "ServersideQoLZDO", "ServersideQoLZDO"); AddProperty(assembly, "ZNetPeer", "ServersideQoL", "Peer", "ServersideQoLPeer"); static void AddProperty(AssemblyDefinition val, string typeToExtendName, string propertyTypeNamespace, string propertyTypeName, string propertyName) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01c5: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) ModuleDefinition mainModule = val.MainModule; TypeDefinition val2 = mainModule.GetType(typeToExtendName) ?? throw new Exception("Type " + typeToExtendName + " not found"); AssemblyNameReference val3 = new AssemblyNameReference("ServersideQoL.Patchers".Replace(".Patchers", ""), new Version("1.99.8")); mainModule.AssemblyReferences.Add(val3); TypeReference val4 = mainModule.ImportReference(new TypeReference(propertyTypeNamespace, propertyTypeName, mainModule, (IMetadataScope)(object)val3)); TypeReference val5 = mainModule.ImportReference(new TypeReference("System.Runtime.CompilerServices", "NullableAttribute", mainModule, mainModule.TypeSystem.CoreLibrary)); FieldDefinition val6 = new FieldDefinition("<" + propertyName + ">k__BackingField", (FieldAttributes)33, val4); val2.Fields.Add(val6); MethodDefinition val7 = new MethodDefinition("get_" + propertyName, (MethodAttributes)2182, val4); ILProcessor iLProcessor = val7.Body.GetILProcessor(); iLProcessor.Append(iLProcessor.Create(OpCodes.Ldarg_0)); iLProcessor.Append(iLProcessor.Create(OpCodes.Ldfld, (FieldReference)(object)val6)); iLProcessor.Append(iLProcessor.Create(OpCodes.Ret)); val2.Methods.Add(val7); PropertyDefinition val8 = new PropertyDefinition(propertyName, (PropertyAttributes)0, val4) { GetMethod = val7 }; val2.Properties.Add(val8); MethodDefinition val9 = ((IEnumerable<MethodDefinition>)val2.Methods).Single((MethodDefinition m) => m.IsConstructor && !m.IsStatic); iLProcessor = val9.Body.GetILProcessor(); Instruction val10 = val9.Body.Instructions[0]; MethodReference val11 = new MethodReference(".ctor", mainModule.TypeSystem.Void, val4) { HasThis = true }; val11.Parameters.Add(new ParameterDefinition((TypeReference)(object)val2)); MethodReference val12 = mainModule.ImportReference(val11); iLProcessor.InsertBefore(val10, iLProcessor.Create(OpCodes.Ldarg_0)); iLProcessor.InsertBefore(val10, iLProcessor.Create(OpCodes.Ldarg_0)); iLProcessor.InsertBefore(val10, iLProcessor.Create(OpCodes.Newobj, val12)); iLProcessor.InsertBefore(val10, iLProcessor.Create(OpCodes.Stfld, (FieldReference)(object)val6)); } } } public sealed class PatchersPlugin { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.Patchers"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.Patchers"; public const string PluginVersion = "1.99.8"; public const string PluginInformationalVersion = "1.99.8-beta"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507592029843L, default(TimeSpan)); } }
plugins\ServersideQoL.dll
Decompiled a week 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using MonoMod.Utils; using ServersideQoL.CodeAnalysis; using SoftReferenceableAssets; using UnityEngine; using YamlDotNet.Serialization; using YamlDotNet.Serialization.TypeInspectors; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArgusMagnus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("ArgusMagnus")] [assembly: AssemblyDescription("Serverside-only QoL mod, compatible with vanilla (e.g. XBox) clients. Stack from player inventories into nearby chests, generated portal hub, auto-sort chests, refuel smelters from containers, disable rain damage, infinite building/farming stamina and more")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL")] [assembly: AssemblyTitle("ServersideQoL")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("1.99.8.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } [CompilerGenerated] internal sealed class <>z__ReadOnlyList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Count; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Count; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Count; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyList(List<T> items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return _items.Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { _items.CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return _items.IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [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] [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] [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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class ExtensionMarkerAttribute : Attribute { private readonly string <Name>k__BackingField; public string Name => <Name>k__BackingField; public ExtensionMarkerAttribute(string name) { <Name>k__BackingField = name; } } } namespace ServersideQoL { public sealed class Config : ConfigBase<Config> { public sealed class AdvancedConfig { public sealed class ProcessingDelaysConfig { public float WhenNoNearbyPlayers { get; init; } = 2f; public float AfterContainerOwnershipRequest { get; init; } = 0.1f; } public sealed class ContainersConfig { public float MinOwnershipRequestInterval { get; init; } = 1f; } public sealed class PlayersConfig { public float UpdateStaminaInterval { get; init; } = 0.2f; } public ProcessingDelaysConfig ProcessingDelays { get; init; } = new ProcessingDelaysConfig(); public ContainersConfig Containers { get; init; } = new ContainersConfig(); public PlayersConfig Players { get; init; } = new PlayersConfig(); } private const string Section = "General"; public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: true, "Enables/disables the entire mod", null, null, "Enabled"); public ConfigEntry<bool> DiagnosticLogs { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: false, "Enables/disables diagnostic logs", null, null, "DiagnosticLogs"); public ConfigEntry<bool> IgnoreGameVersionCheck { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: true, "True to ignore the game version check. Turning this off may lead to the mod being run in an untested version and may lead to data loss/world corruption", null, null, "IgnoreGameVersionCheck"); public ConfigEntry<bool> IgnoreNetworkVersionCheck { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: false, "True to ignore the network version check. Turning this off may lead to the mod being run in an untested version and may lead to data loss/world corruption", null, null, "IgnoreNetworkVersionCheck"); public ConfigEntry<bool> IgnoreItemDataVersionCheck { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: false, "True to ignore the item data version check. Turning this off may lead to the mod being run in an untested version and may lead to data loss/world corruption", null, null, "IgnoreItemDataVersionCheck"); public ConfigEntry<bool> IgnoreWorldVersionCheck { get; } = ConfigBase<Config>.BindEx(cfg, "General", defaultValue: false, "True to ignore the world version check. Turning this off may lead to the mod being run in an untested version and may lead to data loss/world corruption", null, null, "IgnoreWorldVersionCheck"); public ConfigEntry<float> FarMessageRange { get; } = ConfigBase<Config>.BindEx(cfg, "General", 64f, $"Max distance a player can have to a modified object to receive messages of type {MessageTypes.TopLeftFar} or {MessageTypes.CenterFar}", null, null, "FarMessageRange"); public YamlConfigEntry<AdvancedConfig> Advanced { get; } = ConfigBase<Config>.BindYaml<AdvancedConfig>(cfg, "Advanced"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } internal interface IConfig { IServersideQoLPlugin Plugin { get; set; } ConfigEntry<bool> Enabled { get; } ConfigFile ConfigFile { get; } event EventHandler<SettingChangedEventArgs>? ConfigChanged; void RaiseInitialized(); } public abstract class ConfigBase { protected static class Shared { [CompilerGenerated] private static ConfigEntry<bool>? <AutoPickup>k__BackingField; [CompilerGenerated] private static ConfigEntry<int>? <AutoPickupMaxRange>k__BackingField; [CompilerGenerated] private static ConfigEntry<bool>? <FeedFromContainers>k__BackingField; [CompilerGenerated] private static ConfigEntry<int>? <FeedFromContainersMaxRange>k__BackingField; public static ConfigEntry<bool>? AutoPickup { [CompilerGenerated] get { return <AutoPickup>k__BackingField; } set { Set(ref <AutoPickup>k__BackingField, value, "AutoPickup"); } } public static ConfigEntry<int>? AutoPickupMaxRange { [CompilerGenerated] get { return <AutoPickupMaxRange>k__BackingField; } set { Set(ref <AutoPickupMaxRange>k__BackingField, value, "AutoPickupMaxRange"); } } public static ConfigEntry<bool>? FeedFromContainers { [CompilerGenerated] get { return <FeedFromContainers>k__BackingField; } set { Set(ref <FeedFromContainers>k__BackingField, value, "FeedFromContainers"); } } public static ConfigEntry<int>? FeedFromContainersMaxRange { [CompilerGenerated] get { return <FeedFromContainersMaxRange>k__BackingField; } set { Set(ref <FeedFromContainersMaxRange>k__BackingField, value, "FeedFromContainersMaxRange"); } } private static void Set<T>(ref T? field, T? value, [CallerMemberName] string configName = null) where T : class { if (field != null) { throw new Exception("Shared config " + configName + " already set"); } field = value; } } private protected interface IYamlConfigEntry { object Value { get; set; } } public sealed class YamlConfigEntry<T>(T value) : IYamlConfigEntry where T : notnull { public T Value { [CompilerGenerated] get { return <Value>k__BackingField; } private set { IsDefault = value.Equals(<Value>k__BackingField); <Value>k__BackingField = value; } } public bool IsDefault { get; private set; } = true; object IYamlConfigEntry.Value { get { return Value; } set { Value = (T)value; } } } private protected sealed class MyTypeInspector(ITypeInspector inner) : TypeInspectorSkeleton() { private readonly ITypeInspector _inner = inner; public override string GetEnumName(Type enumType, string name) { return inner.GetEnumName(enumType, name); } public override string GetEnumValue(object enumValue) { return inner.GetEnumValue(enumValue); } public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container) { foreach (IPropertyDescriptor property in inner.GetProperties(type, container)) { if (!(property.Type == typeof(Type)) || !(property.Name == "EqualityContract")) { yield return property; } } } } public sealed class AcceptableEnum<T> : AcceptableValueBase where T : unmanaged, Enum { private readonly T _default; public static AcceptableEnum<T> Default { get; } = new AcceptableEnum<T>(GetDefaultValues()); public IReadOnlyList<T> AcceptableValues { get; } private static IEnumerable<T> GetDefaultValues() { HashSet<T> added = new HashSet<T>(); T[] array = (T[])Enum.GetValues(typeof(T)); foreach (T val in array) { if (added.Add(val)) { yield return val; } } } public AcceptableEnum(IEnumerable<T> values) : base(typeof(T)) { if (EnumUtils.IsBitSet<T>()) { List<T> list = new List<T>(); list.AddRange(values.Where((T x) => x.ExactlyOneBitSet())); AcceptableValues = new <>z__ReadOnlyList<T>(list); _default = default(T); return; } object obj = values as IReadOnlyList<T>; if (obj == null) { List<T> list2 = new List<T>(); list2.AddRange(values); obj = new <>z__ReadOnlyList<T>(list2); } AcceptableValues = (IReadOnlyList<T>)obj; _default = AcceptableValues.FirstOrDefault(); } public override object Clamp(object value) { if (value is T) { T e = (T)value; if (EnumUtils.IsBitSet<T>()) { ulong val = e.ToUInt64(); ulong num = 0uL; foreach (ulong item in from x in AcceptableValues select x.ToUInt64() into x where (val & x) == x select x) { num |= item; } return EnumUtils.ToEnum<T>(num); } if (!AcceptableValues.Any((T x) => x.Equals(e))) { return _default; } return e; } return _default; } public override bool IsValid(object value) { return object.Equals(value, ((AcceptableValueBase)this).Clamp(value)); } public override string ToDescriptionString() { if (!EnumUtils.IsBitSet<T>()) { return "# Acceptable values: " + string.Join(", ", AcceptableValues); } return FormattableString.Invariant(FormattableStringFactory.Create("# Acceptable values: {0}\r\n# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning)", string.Join(", ", AcceptableValues))); } } protected sealed class AcceptableFormatString(object[] testArgs) : AcceptableValueBase(typeof(string)) { public override bool IsValid(object value) { if (!(value is string format)) { return false; } try { string.Format(format, testArgs); } catch (FormatException) { return false; } return true; } public override object Clamp(object value) { return value; } public override string ToDescriptionString() { return FormattableString.Invariant(FormattableStringFactory.Create("# Acceptable value formats: .NET Format strings for {0} arguments ({1}): https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-string-format#get-started-with-the-stringformat-method", testArgs.Length, string.Join(", ", testArgs.Select((object x) => x.GetType().Name)))); } } public const Emotes DisabledEmote = (Emotes)(-1); public const Emotes AnyEmote = (Emotes)(-2); protected static IReadOnlyDictionary<string, PieceTable> PieceTablesByPieceName => ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Instance.PieceTablesByPieceName; private protected ConfigBase() { } } public abstract class ConfigBase<TSelf>(ConfigFile configFile, Logger logger) : ConfigBase(), IConfig where TSelf : ConfigBase<TSelf> { public sealed record Deprecated(string Reason, Action<TSelf> AdjustConfig); private static readonly HashSet<ConfigEntryBase> __deprecatedEntries = new HashSet<ConfigEntryBase>(); private static Dictionary<string, IYamlConfigEntry>? __yaml = new Dictionary<string, IYamlConfigEntry>(); private EventHandler<SettingChangedEventArgs>? _configChanged; IServersideQoLPlugin IConfig.Plugin { get { return <ServersideQoL.IConfig.Plugin>k__BackingField; } set { <ServersideQoL.IConfig.Plugin>k__BackingField = value; } } public static TSelf Instance { get { return <Instance>k__BackingField ?? throw new InvalidOperationException("Config has not been initialized yet"); } [CompilerGenerated] private set { <Instance>k__BackingField = value; } } protected static IReadOnlyDictionary<Biome, Character> BossesByBiome => Processor.BossesByBiome; public ConfigFile ConfigFile { get; } = configFile; protected Logger Logger { get; } = logger; public abstract ConfigEntry<bool> Enabled { get; } private static event Action<ConfigFile, TSelf>? Initialized; public event EventHandler<SettingChangedEventArgs>? ConfigChanged { add { if (_configChanged == null) { ConfigFile.SettingChanged += OnSettingsChanged; } _configChanged = (EventHandler<SettingChangedEventArgs>)Delegate.Combine(_configChanged, value); } remove { _configChanged = (EventHandler<SettingChangedEventArgs>)Delegate.Remove(_configChanged, value); if (_configChanged == null) { ConfigFile.SettingChanged -= OnSettingsChanged; } } } private void OnSettingsChanged(object? sender, SettingChangedEventArgs args) { _configChanged?.Invoke(this, args); } void IConfig.RaiseInitialized() { Instance = (TSelf)this; foreach (var (configPath, entry) in __yaml) { BindYaml(configPath, entry); } __yaml = null; ConfigBase<TSelf>.Initialized?.Invoke(ConfigFile, (TSelf)this); } public static bool IsDeprecated(ConfigEntryBase entry) { return __deprecatedEntries.Contains(entry); } protected static ConfigEntry<T> BindEx<T>(ConfigFile config, string section, T defaultValue, string description, AcceptableValueBase? acceptableValues = null, Deprecated? deprecated = null, [CallerMemberName] string key = null) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown if ((object)deprecated != null) { description = string.Join(Environment.NewLine, "DEPRECATED: " + deprecated.Reason, description); } ConfigEntry<T> cfg = config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())); if ((object)deprecated != null) { __deprecatedEntries.Add((ConfigEntryBase)(object)cfg); Initialized += OnInitialized; } return cfg; void OnInitialized(ConfigFile cfgFile, TSelf modConfig) { if (cfgFile == ((ConfigEntryBase)cfg).ConfigFile) { Initialized -= OnInitialized; cfg.SettingChanged += delegate { OnSettingChanged(deprecated, cfg, modConfig); }; OnSettingChanged(deprecated, cfg, modConfig); } } static void OnSettingChanged(Deprecated deprecated2, ConfigEntry<T> val, TSelf modCfg) { if (!EqualityComparer<T>.Default.Equals(val.Value, (T)((ConfigEntryBase)val).DefaultValue)) { deprecated2.AdjustConfig(modCfg); modCfg.Logger.LogWarning("[" + ((ConfigEntryBase)val).Definition.Section + "].[" + ((ConfigEntryBase)val).Definition.Key + "] is deprecated: " + deprecated2.Reason); } } } protected static YamlConfigEntry<T> BindYaml<T>(ConfigFile cfg, [CallerMemberName] string fileName = null) where T : notnull, new() { if (__yaml == null) { throw new InvalidOperationException("Config alredy initialized"); } string path = Path.Combine(Path.GetDirectoryName(cfg.ConfigFilePath), "ArgusMagnus.ServersideQoL"); string key = Path.Combine(path, Path.GetFileNameWithoutExtension(cfg.ConfigFilePath) + "." + fileName + ".yml"); YamlConfigEntry<T> yamlConfigEntry = new YamlConfigEntry<T>(new T()); __yaml.Add(key, yamlConfigEntry); return yamlConfigEntry; } private static void BindYaml(string configPath, IYamlConfigEntry entry) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(configPath); ISerializer val = ((BuilderSkeleton<SerializerBuilder>)(object)((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).IncludeNonPublicProperties()).WithTypeInspector<MyTypeInspector>((Func<ITypeInspector, MyTypeInspector>)((ITypeInspector x) => new MyTypeInspector(x))).Build(); Directory.CreateDirectory(directoryName); string path = Path.ChangeExtension(configPath, "default.yml"); using (StreamWriter streamWriter = new StreamWriter(path, append: false)) { streamWriter.WriteLine("# " + Path.GetFileName(path) + " contains the default values and is overwritten regularly.\r\n# Rename it to " + Path.GetFileName(configPath) + " if you want to change values."); streamWriter.WriteLine(); WriteYamlHeader(streamWriter); val.Serialize((TextWriter)streamWriter, entry.Value); } if (!File.Exists(configPath)) { return; } try { IDeserializer val2 = ((BuilderSkeleton<DeserializerBuilder>)(object)((BuilderSkeleton<DeserializerBuilder>)(object)((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IncludeNonPublicProperties()).EnablePrivateConstructors()).WithTypeInspector<MyTypeInspector>((Func<ITypeInspector, MyTypeInspector>)((ITypeInspector x) => new MyTypeInspector(x))).Build(); using (StreamReader streamReader = new StreamReader(configPath)) { entry.Value = val2.Deserialize((TextReader)streamReader, entry.Value.GetType()) ?? entry.Value; } ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Logger.LogInfo("Advanced config loaded from " + Path.GetFileName(configPath)); } catch (Exception arg) { ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Logger.LogWarning($"{Path.GetFileName(configPath)}: {arg}"); } } private static void WriteYamlHeader(StreamWriter writer) { writer.WriteLine("# IMPORTANT:\r\n# This file is for advanced tweaks.\r\n# You are expected to be familiar with YAML and its pitfalls if you decide to edit it.\r\n# Check the log for warnings related to this file.\r\n"); } } [Processor("fe73690f-6790-4cfa-9795-f93136d57286", OnlyWhenDependedOn = true)] public sealed class ContainerRegistryProcessor : Processor<ContainerRegistryProcessor.PrefabInfo> { public sealed record PrefabInfo(Container Container, Piece Piece, PieceTable PieceTable) : ProcessorPrefabInfo(); private sealed class ContainerStateImpl(ServersideQoLZDO zdo, Container container) : ContainerState(), ContainerState.IInventory { private Inventory? _inventory; private readonly ServersideQoLZDO _zdo = zdo; private readonly Container _container = container; private List<ItemData>? _items; private uint _dataRevision = uint.MaxValue; private byte[]? _data; private static readonly ZPackage _pkg = new ZPackage(); public DateTimeOffset NextOwnershipRequest { get; set; } public bool WaitingForResponse { get; set; } public long PreviousOwner { get; set; } public bool AddedToContainers { get; set; } public override Container Container => container; public override ServersideQoLZDO ZDO => zdo; Inventory IInventory.Inventory => _inventory; List<ItemData> IInventory.Items { get { if (_items == null) { _items = _inventory.GetAllItems(); } else if (_items != _inventory.GetAllItems()) { throw new Exception("Assumption violated"); } return _items; } } [MemberNotNull("_inventory")] public override IInventory GetInventory() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown if (_inventory != null && _dataRevision == zdo.ZDO.DataRevision) { return this; } byte[] items = zdo.Vars.GetItems(); if (_inventory != null) { if (items == _data) { return this; } if (items != null && _data != null && ((ReadOnlySpan<byte>)items).SequenceEqual((ReadOnlySpan<byte>)_data)) { return this; } } ServersideQoLZDO.ComponentFieldAccessor<Container> componentFieldAccessor = zdo.Fields<Container>(); int num = componentFieldAccessor.GetInt(() => (Container x) => x.m_width, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\ContainerRegistryProcessor.cs", 227); int num2 = componentFieldAccessor.GetInt(() => (Container x) => x.m_height, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\ContainerRegistryProcessor.cs", 228); if (_inventory == null || _inventory.GetWidth() != num || _inventory.GetHeight() != num2) { _inventory = new Inventory(container.m_name, container.m_bkg, num, num2); _items = null; } if (items == null || items.Length <= 0) { ((IInventory)this).Items.Clear(); } else { _pkg.Load(items); _inventory.Load(_pkg); } _dataRevision = zdo.ZDO.DataRevision; _data = items; return this; } void IInventory.Save() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) _pkg.Clear(); _inventory.Save(_pkg); uint dataRevision = zdo.ZDO.DataRevision; byte[] array = _pkg.GetArray(); zdo.Vars.SetItems(array, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\ContainerRegistryProcessor.cs", 268); if (dataRevision != zdo.ZDO.DataRevision) { if (zdo.PrefabInfo?.HasComponent<ZSyncTransform>() ?? false) { ZDO zDO = zdo.ZDO; zDO.DataRevision += 120; } ZDOMan.instance.ForceSendZDO(zdo.ZDO.m_uid); } _dataRevision = zdo.ZDO.DataRevision; _data = array; } } private readonly Dictionary<ServersideQoLZDO, ContainerStateImpl> _states = new Dictionary<ServersideQoLZDO, ContainerStateImpl>(); private readonly Dictionary<float, WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>>> _containersByItemName = new Dictionary<float, WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>>>(); private readonly Dictionary<float, WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>>> _containers = new Dictionary<float, WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>>>(); private bool _openResponseRegistered; private static int __returnContentToCreatorHash = ServersideQoLPluginBase<ServersideQoLPlugin, Config>.RegisterServerVar("ReturnContentToCreator"); public event Action<ServersideQoLZDO, ContainerState>? ContainerChanged; public SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>> GetContainersByItemName(float sectorWidth) { SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>> target; if (!_containersByItemName.TryGetValue(sectorWidth, out WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>> value)) { _containersByItemName.Add(sectorWidth, new WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>>(target = new SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>(sectorWidth))); } else if (!value.TryGetTarget(out target)) { value.SetTarget(target = new SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>(sectorWidth)); } return target; } public SectorDictionary<HashSet<ServersideQoLZDO>> GetContainers(float sectorWidth) { SectorDictionary<HashSet<ServersideQoLZDO>> target; if (!_containers.TryGetValue(sectorWidth, out WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>> value)) { _containers.Add(sectorWidth, new WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>>(target = new SectorDictionary<HashSet<ServersideQoLZDO>>(sectorWidth))); } else if (!value.TryGetTarget(out target)) { value.SetTarget(target = new SectorDictionary<HashSet<ServersideQoLZDO>>(sectorWidth)); } return target; } public ContainerState? GetState(ServersideQoLZDO zdo) { Container val = zdo.PrefabInfo?.GetComponent<Container>(); if (val == null) { return null; } return GetStateCore(zdo, val); } public ContainerState GetState(ServersideQoLZDO zdo, Container container) { return GetStateCore(zdo, container); } public void SetReturnContentToCreator(ServersideQoLZDO zdo, bool value) { zdo.ZDO.Set(__returnContentToCreatorHash, value); } public bool GetReturnContentToCreator(ServersideQoLZDO zdo, bool defaultValue = false) { return zdo.ZDO.GetBool(__returnContentToCreatorHash, defaultValue); } private ContainerStateImpl GetStateCore(ServersideQoLZDO zdo, Container container) { if (!_states.TryGetValue(zdo, out ContainerStateImpl value)) { _states.Add(zdo, value = new ContainerStateImpl(zdo, container)); zdo.Destroyed += delegate(ServersideQoLZDO x) { _states.Remove(x); }; } return value; } public float RequestOwnership(ServersideQoLZDO zdo, long playerID, [CallerFilePath] string caller = null, [CallerLineNumber] int callerLineNo = 0) { return RequestOwnership(zdo, playerID, _states[zdo], caller, callerLineNo); } public float RequestOwnership(ServersideQoLZDO zdo, long playerID, ContainerState state, [CallerFilePath] string caller = null, [CallerLineNumber] int callerLineNo = 0) { if (zdo.IsOwnerOrUnassigned() || !(state is ContainerStateImpl containerStateImpl) || DateTimeOffset.UtcNow < containerStateImpl.NextOwnershipRequest) { return ConfigBase<Config>.Instance.Advanced.Value.ProcessingDelays.AfterContainerOwnershipRequest; } if (!_openResponseRegistered && Player.m_localPlayer != null) { RPC.Intercept.UpdateInterception("OpenRespons", new Func<ServersideQoLZDO, bool, bool>(RPC_OpenResponse), _openResponseRegistered = true); } containerStateImpl.NextOwnershipRequest = DateTimeOffset.UtcNow.AddSeconds(ConfigBase<Config>.Instance.Advanced.Value.Containers.MinOwnershipRequestInterval); containerStateImpl.WaitingForResponse = true; containerStateImpl.PreviousOwner = zdo.ZDO.GetOwner(); RPC.RequestOpen(zdo, playerID); return ConfigBase<Config>.Instance.Advanced.Value.ProcessingDelays.AfterContainerOwnershipRequest; } protected internal override void Initialize() { _states.Clear(); RPC.Intercept.UpdateInterception("OpenRespons", new Func<ServersideQoLZDO, bool, bool>(RPC_OpenResponse), _openResponseRegistered = false); } protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) long num = 0L; if ((int)prefabInfo.Container.m_privacy == 0 || (num = zdo.Vars.GetCreator(0L)) == 0L) { return ProcessResult.UnregisterProcessor; } ContainerStateImpl containerStateImpl = null; if (GetReturnContentToCreator(zdo)) { PlayerState stateForPlayerID = Processor.Instance<PlayerRegistryProcessor>().GetStateForPlayerID(num); if (stateForPlayerID != null) { containerStateImpl = GetStateCore(zdo, prefabInfo.Container); if (containerStateImpl.GetInventory().Items.Count == 0) { return ProcessResult.DestroyZDO; } if (zdo.ZDO.GetOwner() != stateForPlayerID.Owner) { zdo.ZDO.SetOwner(stateForPlayerID.Owner); } else { RPC.TakeAllResponse(zdo, granted: true); } } return ProcessResult.ScheduleReprocessing; } if (zdo.Vars.GetInUse()) { return ProcessResult.Default; } if (containerStateImpl == null) { containerStateImpl = GetStateCore(zdo, prefabInfo.Container); } List<float> list = null; float key; if (_containers.Count != 0 && !containerStateImpl.AddedToContainers) { containerStateImpl.AddedToContainers = true; foreach (KeyValuePair<float, WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>>> container in _containers) { container.Deconstruct(out key, out var value); float item = key; WeakReference<SectorDictionary<HashSet<ServersideQoLZDO>>> weakReference = value; if (!weakReference.TryGetTarget(out var target)) { (list ?? (list = new List<float>())).Add(item); } else { target.Add(zdo); } } if (list != null) { foreach (float item3 in list) { _containers.Remove(item3); } } } if (_containersByItemName.Count != 0) { ContainerState.IInventory inventory = null; list?.Clear(); foreach (KeyValuePair<float, WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>>> item4 in _containersByItemName) { item4.Deconstruct(out key, out var value2); float item2 = key; WeakReference<SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>> weakReference2 = value2; if (!weakReference2.TryGetTarget(out var target2)) { (list ?? (list = new List<float>())).Add(item2); continue; } if (inventory == null) { inventory = containerStateImpl.GetInventory(); } foreach (ItemData item5 in inventory.Items) { target2.TryAdd(item5.m_shared, zdo); } } if (list != null) { foreach (float item6 in list) { _containersByItemName.Remove(item6); } } } this.ContainerChanged?.Invoke(zdo, containerStateImpl); return ProcessResult.Default; } private bool RPC_OpenResponse(ServersideQoLZDO? zdo, bool granted) { if (zdo == null || !_states.TryGetValue(zdo, out ContainerStateImpl value) || !value.WaitingForResponse) { return true; } value.WaitingForResponse = false; return false; } } public abstract class ContainerState { public interface IInventory { Inventory Inventory { get; } List<ItemData> Items { get; } void Save(); } public abstract Container Container { get; } public abstract ServersideQoLZDO ZDO { get; } public float? PickupRange { get; set; } public float? FeedRange { get; set; } private protected ContainerState() { } public abstract IInventory GetInventory(); } internal sealed class DummySocket : ISocket { public ISocket Accept() { throw new NotImplementedException(); } public void Close() { } public void Dispose() { } public bool Flush() { throw new NotImplementedException(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { throw new NotImplementedException(); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { throw new NotImplementedException(); } public int GetCurrentSendRate() { throw new NotImplementedException(); } public string GetEndPointString() { throw new NotImplementedException(); } public string GetHostName() { return ""; } public int GetHostPort() { throw new NotImplementedException(); } public int GetSendQueueSize() { throw new NotImplementedException(); } public bool GotNewData() { throw new NotImplementedException(); } public bool IsConnected() { return true; } public bool IsHost() { throw new NotImplementedException(); } public ZPackage Recv() { throw new NotImplementedException(); } public void Send(ZPackage pkg) { throw new NotImplementedException(); } public void VersionMatch() { throw new NotImplementedException(); } } public static class EmptyReadOnlyCollections<TKey, TValue> { public static IReadOnlyDictionary<TKey, TValue> Dictionary { get; } = new ReadOnlyDictionary<TKey, TValue>(new Dictionary<TKey, TValue>(0)); } public static class EnumUtils { private static class Generic<T> where T : unmanaged, Enum { public static bool IsBitSet { get; } = OfType(typeof(T)).IsBitSet; public static Func<T, ulong> EnumToUInt64 { get; } public static Func<ulong, T> UInt64ToEnum { get; } public static Func<T, long> EnumToInt64 { get; } public static Func<long, T> Int64ToEnum { get; } static Generic() { ParameterExpression parameterExpression = Expression.Parameter(typeof(T)); EnumToUInt64 = Expression.Lambda<Func<T, ulong>>(Expression.ConvertChecked(parameterExpression, typeof(ulong)), new ParameterExpression[1] { parameterExpression }).Compile(); ParameterExpression parameterExpression2 = Expression.Parameter(typeof(ulong)); UInt64ToEnum = Expression.Lambda<Func<ulong, T>>(Expression.ConvertChecked(parameterExpression2, typeof(T)), new ParameterExpression[1] { parameterExpression2 }).Compile(); ParameterExpression parameterExpression3 = Expression.Parameter(typeof(T)); EnumToInt64 = Expression.Lambda<Func<T, long>>(Expression.ConvertChecked(parameterExpression3, typeof(long)), new ParameterExpression[1] { parameterExpression3 }).Compile(); ParameterExpression parameterExpression4 = Expression.Parameter(typeof(long)); Int64ToEnum = Expression.Lambda<Func<long, T>>(Expression.ConvertChecked(parameterExpression4, typeof(T)), new ParameterExpression[1] { parameterExpression4 }).Compile(); } } public sealed class ObjectEnumUtils { public bool IsBitSet { get; } = enumType.GetCustomAttribute<FlagsAttribute>() != null; public Func<object, ulong> EnumToUInt64 { get; } public Func<ulong, object> UInt64ToEnum { get; } public Func<object, long> EnumToInt64 { get; } public Func<long, object> Int64ToEnum { get; } public ObjectEnumUtils(Type enumType) { ParameterExpression parameterExpression = Expression.Parameter(typeof(object)); EnumToUInt64 = Expression.Lambda<Func<object, ulong>>(Expression.ConvertChecked(Expression.Convert(parameterExpression, enumType), typeof(ulong)), new ParameterExpression[1] { parameterExpression }).Compile(); ParameterExpression parameterExpression2 = Expression.Parameter(typeof(ulong)); UInt64ToEnum = Expression.Lambda<Func<ulong, object>>(Expression.Convert(Expression.ConvertChecked(parameterExpression2, enumType), typeof(object)), new ParameterExpression[1] { parameterExpression2 }).Compile(); ParameterExpression parameterExpression3 = Expression.Parameter(typeof(object)); EnumToInt64 = Expression.Lambda<Func<object, long>>(Expression.ConvertChecked(Expression.Convert(parameterExpression3, enumType), typeof(long)), new ParameterExpression[1] { parameterExpression3 }).Compile(); ParameterExpression parameterExpression4 = Expression.Parameter(typeof(long)); Int64ToEnum = Expression.Lambda<Func<long, object>>(Expression.Convert(Expression.ConvertChecked(parameterExpression4, enumType), typeof(object)), new ParameterExpression[1] { parameterExpression4 }).Compile(); base..ctor(); } } private static readonly ConcurrentDictionary<Type, ObjectEnumUtils> __isBitSet = new ConcurrentDictionary<Type, ObjectEnumUtils>(); public static ObjectEnumUtils OfType(Type type) { return __isBitSet.GetOrAdd(type, (Type t) => new ObjectEnumUtils(t)); } public static bool IsBitSet<T>() where T : unmanaged, Enum { return Generic<T>.IsBitSet; } public static ulong ToUInt64<T>(this T value) where T : unmanaged, Enum { return Generic<T>.EnumToUInt64(value); } public static T ToEnum<T>(ulong value) where T : unmanaged, Enum { return Generic<T>.UInt64ToEnum(value); } public static long ToInt64<T>(this T value) where T : unmanaged, Enum { return Generic<T>.EnumToInt64(value); } public static T ToEnum<T>(long value) where T : unmanaged, Enum { return Generic<T>.Int64ToEnum(value); } public static bool ExactlyOneBitSet<T>(this T value) where T : unmanaged, Enum { bool flag = false; for (ulong num = value.ToUInt64(); num != 0L; num &= num - 1) { if (flag) { return false; } flag = true; } return flag; } } public static class Extensions { [SpecialName] public sealed class <G>$C4EAF3E49419DCB8F1AA1FAC028204B4 { [SpecialName] public static class <M>$FF334B291A5568FFD90BBDD3AE876A53 { } [ExtensionMarker("<M>$FF334B291A5568FFD90BBDD3AE876A53")] public int ActiveArea { [ExtensionMarker("<M>$FF334B291A5568FFD90BBDD3AE876A53")] get { throw new NotSupportedException(); } } [ExtensionMarker("<M>$FF334B291A5568FFD90BBDD3AE876A53")] public int LoadedArea { [ExtensionMarker("<M>$FF334B291A5568FFD90BBDD3AE876A53")] get { throw new NotSupportedException(); } } } public static float GetHeight(this Heightmap hmap, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = default(int); int num2 = default(int); hmap.WorldToVertex(pos, ref num, ref num2); return hmap.GetHeight(num, num2); } public static int get_ActiveArea(ZoneSystem zoneSystem) { return zoneSystem.m_activeArea - 1; } public static int get_LoadedArea(ZoneSystem zoneSystem) { return zoneSystem.m_activeArea; } } public readonly record struct GlobalKey(string Key) { public GlobalKey(string Key) { this.Key = Key; } public unsafe GlobalKey(GlobalKeys key) : this(((object)(*(GlobalKeys*)(&key))/*cast due to .constrained prefix*/).ToString().ToLower()) { } public static implicit operator string(in GlobalKey key) { return key.Key; } } public readonly record struct ItemDataKey(string Name, int Quality, int Variant) { public ItemDataKey(string Name, int Quality, int Variant) { this.Name = Name; this.Quality = Quality; this.Variant = Variant; } public static implicit operator ItemDataKey(ItemData data) { return new ItemDataKey(data); } public ItemDataKey(ItemData data) : this(data.m_shared.m_name, data.m_quality, data.m_variant) { } } public readonly record struct SharedItemDataKey(string Name) { public static implicit operator SharedItemDataKey(SharedData data) { return new SharedItemDataKey(data.m_name); } public static implicit operator SharedItemDataKey(ItemData data) { return new SharedItemDataKey(data.m_shared.m_name); } } public sealed class ItemDataKeyComparer : EqualityComparer<ItemData> { public static ItemDataKeyComparer Instance { get; } = new ItemDataKeyComparer(); public override bool Equals(ItemData x, ItemData y) { return new ItemDataKey(x) == y; } public override int GetHashCode(ItemData obj) { return new ItemDataKey(obj).GetHashCode(); } } public sealed class SharedItemDataKeyComparer : EqualityComparer<ItemData> { public static SharedItemDataKeyComparer Instance { get; } = new SharedItemDataKeyComparer(); public override bool Equals(ItemData x, ItemData y) { return (SharedItemDataKey)x == (SharedItemDataKey)y; } public override int GetHashCode(ItemData obj) { return ((SharedItemDataKey)obj/*cast due to .constrained prefix*/).GetHashCode(); } } public static class ListExtensions { public readonly struct ListEnumerable<T> { public struct Enumerator : IEnumerator<T>, IEnumerator, IDisposable { private readonly IReadOnlyList<T> _list; private readonly int _count; private int _index; public T Current { get; private set; } readonly object? IEnumerator.Current => Current; public Enumerator(IReadOnlyList<T> list) { _list = list; _count = list.Count; _index = -1; Current = default(T); } public void Dispose() { Current = default(T); } public bool MoveNext() { if (++_index < _count) { Current = _list[_index]; return true; } Current = default(T); return false; } public void Reset() { _index = -1; } } private readonly IReadOnlyList<T> _list; public ListEnumerable(IReadOnlyList<T> list) { _list = list; } public Enumerator GetEnumerator() { return new Enumerator(_list); } } public static ListEnumerable<T> Enumerate<T>(this IReadOnlyList<T> list) { return new ListEnumerable<T>(list); } public static void InsertSorted<T>(this List<T> list, T item) where T : IComparable<T> { int num = list.BinarySearch(item); if (num < 0) { num = ~num; } list.Insert(num, item); } } public sealed class Logger : ILogSource, IDisposable { private readonly ManualLogSource _logger = Logger.CreateLogSource(sourceName); public string SourceName => _logger.SourceName; public event EventHandler<LogEventArgs> LogEvent { add { _logger.LogEvent += value; } remove { _logger.LogEvent -= value; } } public Logger(string sourceName) { } public void Dispose() { _logger.Dispose(); } public void Log(LogLevel level, object data) { //IL_003d: 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) double realtimeSinceStartupAsDouble = Time.realtimeSinceStartupAsDouble; TimeSpan timeSpan = TimeSpan.FromSeconds(realtimeSinceStartupAsDouble); if (realtimeSinceStartupAsDouble < 86400.0) { _logger.Log(level, (object)$"[{timeSpan:hh\\:mm\\:ss\\.fff}] {data}"); } else { _logger.Log(level, (object)$"[{timeSpan:d\\.hh\\:mm\\:ss\\.fff}] {data}"); } } public void LogFatal(object data) { Log((LogLevel)1, data); } public void LogError(object data) { Log((LogLevel)2, data); } public void LogWarning(object data) { Log((LogLevel)4, data); } public void LogMessage(object data) { Log((LogLevel)8, data); } public void LogInfo(object data) { Log((LogLevel)16, data); } public void LogDebug(object data) { Log((LogLevel)32, data); } [Conditional("DEBUG")] public void DevLog(string text, LogLevel logLevel = (LogLevel)4) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Log(logLevel, text); } [Conditional("DEBUG")] public void DevLogIf(bool condition, string text, LogLevel logLevel = (LogLevel)4) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (condition) { Log(logLevel, text); } } } public enum MessageTypes { None, TopLeftNear, TopLeftFar, CenterNear, CenterFar, InWorld } public sealed class Peer(ZNetPeer peer) { [CompilerGenerated] private PlayerState? <PlayerState>k__BackingField; public ZNetPeer ZNetPeer { get; } = peer; public Vector3 RefPos { get { //IL_0020: 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) PlayerState? playerState = PlayerState; if (playerState == null) { return ZNetPeer.m_refPos; } return playerState.ZDO.ZDO.GetPosition(); } } public IReadOnlyDictionary<string, string> ServerSyncedPlayerData { get { ZNetPeer zNetPeer = ZNetPeer; if (zNetPeer == null || zNetPeer.m_server) { return ZNet.instance.m_serverSyncedPlayerData; } return ZNetPeer.m_serverSyncedPlayerData; } } public PlayerState? PlayerState { get { if (<PlayerState>k__BackingField == null) { <PlayerState>k__BackingField = Processor.Instance<PlayerRegistryProcessor>().GetStateForPeerID(ZNetPeer.m_uid); PlayerState? playerState = <PlayerState>k__BackingField; if (playerState != null) { playerState.ZDO.Destroyed += delegate { <PlayerState>k__BackingField = null; }; } } return <PlayerState>k__BackingField; } } public Vector2s GetSector() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ZoneSystem.GetZone(RefPos); } public string GetHostName() { return ZNetPeer.m_socket.GetHostName() ?? ""; } public override bool Equals(object obj) { return object.Equals(ZNetPeer, obj); } public override int GetHashCode() { return ((object)ZNetPeer).GetHashCode(); } } public sealed class PeersEnumerable(ZNetPeer? localPeer) : IEnumerable<Peer>, IEnumerable { public struct Enumerator : IEnumerator<Peer>, IEnumerator, IDisposable { private readonly PeersEnumerable _enumerable; private int _index; public Peer Current { get; private set; } readonly object IEnumerator.Current => Current; public Enumerator(PeersEnumerable enumerable) { _enumerable = enumerable; _index = -2; Current = null; } public void Dispose() { Current = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { if (++_index < 0) { if (_enumerable.localPeer != null) { Current = _enumerable.localPeer.ServersideQoLPeer; return true; } _index++; } if (_index < _enumerable._peers.Count) { Current = _enumerable._peers[_index].ServersideQoLPeer; return true; } Current = null; return false; } public void Reset() { _index = -2; } } private readonly ZNetPeer? _localPeer = localPeer; private List<ZNetPeer> _peers = new List<ZNetPeer>(); public int Count => _peers.Count + ((localPeer != null) ? 1 : 0); internal void Update() { //IL_0013: 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) if (localPeer != null) { localPeer.m_refPos = ZNet.instance.GetReferencePosition(); } _peers = ZNet.instance.GetPeers(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { return new Enumerator(this); } IEnumerator<Peer> IEnumerable<Peer>.GetEnumerator() { return GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } [Processor("b5107f88-1c1f-4323-bfce-9205ae4dfcd9", OnlyWhenDependedOn = true)] public sealed class PlayerRegistryProcessor : Processor<ProcessorPrefabInfo<Player>> { public delegate void ItemUsedHandler(PlayerState state, string animationTriggerName); private sealed class PlayerStateImpl(ServersideQoLZDO zdo, ProcessorPrefabInfo<Player> prefabInfo, PlayerRegistryProcessor processor) : PlayerState() { private readonly ServersideQoLZDO _zdo = zdo; private readonly ProcessorPrefabInfo<Player> _prefabInfo = prefabInfo; private readonly PlayerRegistryProcessor _processor = processor; private readonly ZNetPeer? _peer = ZNet.instance.GetPeer(zdo.ZDO.GetOwner()); private string? _playerName; private bool? _isAdmin; private int _stamina; private Timestamp _staminaTimestamp; private int _eitr; private Timestamp _eitrTimestamp; private ItemDrop? _lastUsedItem; [CompilerGenerated] private Dictionary<SkillType, float> <EstimatedSkillLevels>k__BackingField; [CompilerGenerated] private Dictionary<SkillType, (Queue<float> Queue, List<float> List)> <EstimatedSkillLevelHistories>k__BackingField; private bool _hasChangedGlobalKeyModifications; private Dictionary<GlobalKey, bool>? _globalKeyModifications; public override ServersideQoLZDO ZDO => zdo; public override ProcessorPrefabInfo<Player> PrefabInfo => prefabInfo; public override long Owner { get; } = zdo.ZDO.GetOwner(); public override long PlayerID { get; } = zdo.Vars.GetPlayerID(0L); public override string PlayerName => _playerName ?? (_playerName = ZDO.Vars.GetPlayerName()); public override bool IsAdmin { get { //IL_0030: 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_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) bool valueOrDefault = _isAdmin == true; if (!_isAdmin.HasValue) { Player localPlayer = Player.m_localPlayer; ZDOID? val = ((localPlayer != null) ? new ZDOID?(((Character)localPlayer).GetZDOID()) : ((ZDOID?)null)); ZDOID uid = ZDO.ZDO.m_uid; int num; if (!val.HasValue || !(val.GetValueOrDefault() == uid)) { ZNet instance = ZNet.instance; ZNetPeer? peer = _peer; num = (instance.IsAdmin(((peer != null) ? peer.m_socket.GetHostName() : null) ?? "") ? 1 : 0); } else { num = 1; } valueOrDefault = (byte)num != 0; _isAdmin = valueOrDefault; return valueOrDefault; } return valueOrDefault; } } public int LastEmoteId { get; set; } public Timestamp NextStaminaCheck { get; set; } public override int Stamina => _stamina; public Timestamp StaminaTimestamp => _staminaTimestamp; public override int Eitr => _eitr; public Timestamp EitrTimestamp => _eitrTimestamp; public override ItemDrop? LastUsedItem => _lastUsedItem; public ItemDrop? CheckSkillItem { get; set; } public float CheckSkillStaminaEitr { get; set; } public Dictionary<SkillType, float> EstimatedSkillLevels => <EstimatedSkillLevels>k__BackingField ?? (<EstimatedSkillLevels>k__BackingField = new Dictionary<SkillType, float>()); public Dictionary<SkillType, (Queue<float> Queue, List<float> List)> EstimatedSkillLevelHistories => <EstimatedSkillLevelHistories>k__BackingField ?? (<EstimatedSkillLevelHistories>k__BackingField = new Dictionary<SkillType, (Queue<float>, List<float>)>()); public override IReadOnlyDictionary<GlobalKey, bool> GlobalKeyModifications { get { IReadOnlyDictionary<GlobalKey, bool> globalKeyModifications = _globalKeyModifications; return globalKeyModifications ?? EmptyReadOnlyCollections<GlobalKey, bool>.Dictionary; } } public bool UpdateStamina(int value, Timestamp timestamp) { if (_stamina == value) { return false; } _stamina = value; _staminaTimestamp = timestamp; return true; } public bool UpdateEitr(int value, Timestamp timestamp) { if (_eitr == value) { return false; } _eitr = value; _eitrTimestamp = timestamp; return true; } public void SetLastUsedItem(ItemDrop item) { _lastUsedItem = item; } public override float GetEstimatedSkillLevel(SkillType skillType) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!processor._estimateSkillLevels) { throw new InvalidOperationException("EnableSkillLevelEstimation(true) must be called before calling GetEstimatedSkillLevel"); } if (!EstimatedSkillLevels.TryGetValue(skillType, out var value)) { EstimatedSkillLevels.Add(skillType, value = PlayerRegistryProcessor.GetEstimatedSkillLevel(PlayerID, skillType, float.NaN)); } return value; } public override void AddGlobalKeyModification(GlobalKey key, bool add) { if (_globalKeyModifications == null) { _globalKeyModifications = new Dictionary<GlobalKey, bool>(); } if (_globalKeyModifications.TryAdd(key, add)) { _hasChangedGlobalKeyModifications = true; } } public override void RemoveGlobalKeyModification(GlobalKey key) { if (_globalKeyModifications?.Remove(key) ?? false) { _hasChangedGlobalKeyModifications = true; } } public void SendGlobalKeyModifications() { if (_hasChangedGlobalKeyModifications) { ZoneSystem.instance.SendGlobalKeys(ZDO.ZDO.GetOwner()); _hasChangedGlobalKeyModifications = false; } } } private readonly Dictionary<long, PlayerStateImpl> _statesByPeerID = new Dictionary<long, PlayerStateImpl>(); private readonly Dictionary<long, PlayerStateImpl> _statesByPlayerID = new Dictionary<long, PlayerStateImpl>(); private readonly Dictionary<ZDOID, PlayerStateImpl> _statesByCharacterID = new Dictionary<ZDOID, PlayerStateImpl>(); private readonly HashSet<(string, int)> _estimateSkillLevelsFor = new HashSet<(string, int)>(); private bool _estimateSkillLevels; private ItemUsedHandler? _itemUsed; public IReadOnlyCollection<PlayerState> PlayerStates => _statesByPeerID.Values; public event Action<PlayerState, Emotes>? EmoteDetected; public event Action<PlayerState>? StaminaUpdated; public event ItemUsedHandler? ItemUsed { add { if (_itemUsed == null && value != null && !_estimateSkillLevels) { RPC.Intercept.UpdateInterception("SetTrigger", new Action<RoutedRPCData, string>(OnZSyncAnimationSetTrigger), enable: true); } _itemUsed = (ItemUsedHandler)Delegate.Combine(_itemUsed, value); } remove { bool flag = _itemUsed != null; _itemUsed = (ItemUsedHandler)Delegate.Remove(_itemUsed, value); if (_itemUsed == null && flag && !_estimateSkillLevels) { RPC.Intercept.UpdateInterception("SetTrigger", new Action<RoutedRPCData, string>(OnZSyncAnimationSetTrigger), enable: false); } } } public PlayerState? GetStateForPeerID(long peerID) { if (!_statesByPeerID.TryGetValue(peerID, out PlayerStateImpl value)) { return null; } return value; } public PlayerState? GetStateForPlayerID(long playerID) { if (!_statesByPlayerID.TryGetValue(playerID, out PlayerStateImpl value)) { return null; } return value; } public PlayerState? GetStateForCharacterID(ZDOID characterID) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!_statesByCharacterID.TryGetValue(characterID, out PlayerStateImpl value)) { return null; } return value; } public PlayerState GetState(ServersideQoLZDO playerZdo) { ProcessorPrefabInfo<Player> processorPrefabInfo = Processor<ProcessorPrefabInfo<Player>>.GetProcessorPrefabInfo(playerZdo); return GetStateCore(playerZdo, processorPrefabInfo); } public void EnableSkillLevelEstimation(bool enable, [CallerMemberName] string filename = null, [CallerLineNumber] int lineNo = 0) { if ((enable ? _estimateSkillLevelsFor.Add((filename, lineNo)) : _estimateSkillLevelsFor.Remove((filename, lineNo))) && _estimateSkillLevels != (_estimateSkillLevelsFor.Count != 0)) { _estimateSkillLevels = !_estimateSkillLevels; if (_estimateSkillLevels && _itemUsed == null) { RPC.Intercept.UpdateInterception("SetTrigger", new Action<RoutedRPCData, string>(OnZSyncAnimationSetTrigger), enable: true); } else if (!_estimateSkillLevels && _itemUsed == null) { RPC.Intercept.UpdateInterception("SetTrigger", new Action<RoutedRPCData, string>(OnZSyncAnimationSetTrigger), enable: false); } } } protected internal override void Initialize() { _statesByPeerID.Clear(); _statesByPlayerID.Clear(); _statesByCharacterID.Clear(); } protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, ProcessorPrefabInfo<Player> prefabInfo) { //IL_003b: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_004c: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) PlayerStateImpl stateCore = GetStateCore(zdo, prefabInfo); if (this.EmoteDetected != null) { int emoteID = zdo.Vars.GetEmoteID(); if (emoteID != stateCore.LastEmoteId) { stateCore.LastEmoteId = emoteID; Emotes emote = zdo.Vars.GetEmote((Emotes)(-1)); if ((int)emote != -1) { this.EmoteDetected(stateCore, emote); } } } if (this.StaminaUpdated != null || _estimateSkillLevels) { Timestamp now = Timestamp.Now; if (stateCore.NextStaminaCheck < now) { stateCore.NextStaminaCheck = now.AddSeconds(ConfigBase<Config>.Instance.Advanced.Value.Players.UpdateStaminaInterval); int value = Mathf.FloorToInt(zdo.Vars.GetStamina()); if (stateCore.UpdateStamina(value, now)) { this.StaminaUpdated?.Invoke(stateCore); } stateCore.UpdateEitr(Mathf.FloorToInt(zdo.Vars.GetEitr()), now); } } if (_estimateSkillLevels && stateCore.CheckSkillItem != null) { bool flag = stateCore.CheckSkillItem.m_itemData.m_shared.m_attack.m_attackEitr > 0f; float num = (flag ? zdo.Vars.GetEitr() : zdo.Vars.GetStamina()); if (num < stateCore.CheckSkillStaminaEitr) { SharedData shared = stateCore.CheckSkillItem.m_itemData.m_shared; float num2 = (flag ? shared.m_attack.m_attackEitr : shared.m_attack.m_attackStamina); float num3 = stateCore.CheckSkillStaminaEitr - num; float num4 = num2 - num3; float num5 = num4 / (num2 * 0.33f); if (num5 >= 0f && num5 <= 1f) { float estimatedSkillLevel = stateCore.GetEstimatedSkillLevel(shared.m_skillType); if (!stateCore.EstimatedSkillLevelHistories.TryGetValue(shared.m_skillType, out (Queue<float>, List<float>) value2)) { Dictionary<SkillType, (Queue<float> Queue, List<float> List)> estimatedSkillLevelHistories = stateCore.EstimatedSkillLevelHistories; SkillType skillType = shared.m_skillType; value2 = (new Queue<float>(7), new List<float>(7)); estimatedSkillLevelHistories.Add(skillType, value2); if (!float.IsNaN(estimatedSkillLevel)) { for (int i = 0; i < 7; i++) { value2.Item1.Enqueue(estimatedSkillLevel); value2.Item2.Add(estimatedSkillLevel); } } } while (value2.Item1.Count >= 7) { value2.Item2.Remove(value2.Item1.Dequeue()); } value2.Item1.Enqueue(num5); value2.Item2.InsertSorted(num5); num5 = value2.Item2[value2.Item2.Count / 2]; stateCore.EstimatedSkillLevels[shared.m_skillType] = num5; SetEstimatedSkillLevel(stateCore.PlayerID, shared.m_skillType, num5); float num6 = Mathf.Floor(num5 * 100f); float num7 = Mathf.Floor(estimatedSkillLevel * 100f); if (num6 != num7) { base.Logger.Log((LogLevel)((num6 - num7 > 1f) ? 4 : 16), $"Player {stateCore.PlayerName}: Estimated {shared.m_skillType} skill level: {num6}, Previous estimate: {num7} (Item: {((Object)stateCore.CheckSkillItem).name}, max stamina: {num2}, used stamina: {num3})"); } } stateCore.CheckSkillItem = null; } } stateCore.SendGlobalKeyModifications(); return ProcessResult.Default; } private PlayerStateImpl GetStateCore(ServersideQoLZDO zdo, ProcessorPrefabInfo<Player> prefabInfo) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) long owner = zdo.ZDO.GetOwner(); if (!_statesByPeerID.TryGetValue(owner, out PlayerStateImpl value)) { _statesByPeerID.Add(owner, value = new PlayerStateImpl(zdo, prefabInfo, this)); _statesByPlayerID[value.PlayerID] = value; _statesByCharacterID[zdo.ZDO.m_uid] = value; zdo.Destroyed += OnPlayerDestroyed; } return value; } private void OnPlayerDestroyed(ServersideQoLZDO zdo) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (_statesByPeerID.Remove(((ZDOID)(ref zdo.ZDO.m_uid)).UserID, out PlayerStateImpl value)) { _statesByCharacterID.Remove(zdo.ZDO.m_uid); if (_statesByPlayerID.Remove(value.PlayerID, out PlayerStateImpl value2) && value2 != value) { _statesByPlayerID.Add(value.PlayerID, value2); } } } private void OnZSyncAnimationSetTrigger(RoutedRPCData data, string name) { //IL_0006: 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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) if (!(Processor.Instance<PlayerRegistryProcessor>().GetStateForCharacterID(data.m_targetZDO) is PlayerStateImpl playerStateImpl)) { return; } ItemDrop val = GetItem(playerStateImpl.ZDO.Vars.GetRightItem(), playerStateImpl, name) ?? GetItem(playerStateImpl.ZDO.Vars.GetLeftItem(), playerStateImpl, name); if (val == null) { return; } playerStateImpl.SetLastUsedItem(val); _itemUsed?.Invoke(playerStateImpl, name); if (!_estimateSkillLevels) { return; } playerStateImpl.CheckSkillItem = null; Timestamp now = Timestamp.Now; SharedData shared = val.m_itemData.m_shared; bool flag; if (shared != null) { Attack attack = shared.m_attack; if (attack != null) { float attackStamina = attack.m_attackStamina; if (attackStamina > 0f) { SkillType skillType = shared.m_skillType; if ((int)skillType == 1) { DamageTypes damages = shared.m_damages; float slash = damages.m_slash; if (!(slash > 0f)) { goto IL_00eb; } } flag = true; goto IL_00ee; } } } goto IL_00eb; IL_00ee: if (flag) { if (playerStateImpl.StaminaTimestamp < now.AddSeconds(-1.5f * playerStateImpl.PrefabInfo.Component.m_staminaRegenDelay)) { float stamina = playerStateImpl.ZDO.Vars.GetStamina(); int value = Mathf.FloorToInt(stamina); if (playerStateImpl.UpdateStamina(value, now)) { this.StaminaUpdated?.Invoke(playerStateImpl); } else if (stamina >= 2f * val.m_itemData.m_shared.m_attack.m_attackStamina) { playerStateImpl.CheckSkillStaminaEitr = stamina; playerStateImpl.CheckSkillItem = val; } } } else if (val.m_itemData.m_shared.m_attack.m_attackEitr > 0f && playerStateImpl.EitrTimestamp < now.AddSeconds(-1.5f * playerStateImpl.PrefabInfo.Component.m_eitrRegenDelay)) { float eitr = playerStateImpl.ZDO.Vars.GetEitr(); int value2 = Mathf.FloorToInt(eitr); if (!playerStateImpl.UpdateEitr(value2, now)) { playerStateImpl.CheckSkillStaminaEitr = eitr; playerStateImpl.CheckSkillItem = val; } } return; IL_00eb: flag = false; goto IL_00ee; } private ItemDrop? GetItem(int prefab, PlayerStateImpl state, string triggerName) { if (prefab == 0) { return null; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefab); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if (val == null) { base.Logger.LogWarning($"Player {state.PlayerName}: SetTrigger({triggerName}): Item prefab '{prefab}' not found"); return null; } Attack val2 = val?.m_itemData.m_shared.m_attack; if (val2 == null) { return null; } if (val2.m_attackChainLevels > 1 || val2.m_attackRandomAnimations >= 2) { if (Regex.IsMatch(triggerName, "^" + Regex.Escape(val2.m_attackAnimation) + "\\d+$")) { return val; } } else if (triggerName == val2.m_attackAnimation) { return val; } return null; } private static float GetEstimatedSkillLevel(long playerID, SkillType skill, float defaultValue = 0f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return Processor.DataZDO.ZDO.GetFloat($"player{playerID}_EstimatedSkillLevel_{skill}", defaultValue); } private static void SetEstimatedSkillLevel(long playerID, SkillType skill, float value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Processor.DataZDO.ZDO.Set($"player{playerID}_EstimatedSkillLevel_{skill}", value); } } public abstract class PlayerState { public abstract ServersideQoLZDO ZDO { get; } public abstract ProcessorPrefabInfo<Player> PrefabInfo { get; } public abstract long Owner { get; } public abstract long PlayerID { get; } public abstract string PlayerName { get; } public abstract bool IsAdmin { get; } public abstract int Stamina { get; } public abstract int Eitr { get; } public abstract ItemDrop? LastUsedItem { get; } public abstract IReadOnlyDictionary<GlobalKey, bool> GlobalKeyModifications { get; } private protected PlayerState() { } public abstract float GetEstimatedSkillLevel(SkillType skillType); public abstract void AddGlobalKeyModification(GlobalKey key, bool add); public abstract void RemoveGlobalKeyModification(GlobalKey key); } public interface IPrefabInfo { int PrefabHash { get; } string PrefabName { get; } IReadOnlyDictionary<Type, IReadOnlyList<MonoBehaviour>> Components { get; } } [DebuggerDisplay("{PrefabName}: Processors: {EnabledProcessors.Count}")] public abstract class PrefabInfo : IPrefabInfo { public GameObject? Prefab { get; private set; } public int PrefabHash { get; private set; } public string PrefabName { get; private set; } public IReadOnlyDictionary<Type, IReadOnlyList<MonoBehaviour>> Components { get; private set; } public bool ReleaseOwnershipOnRecreate { get; private set; } internal List<Processor> AvailableProcessors { get; } = new List<Processor>(); internal List<Processor> EnabledProcessors { get; } = new List<Processor>(); internal void Init(GameObject prefab, int prefabHash, string prefabName, IReadOnlyDictionary<Type, IReadOnlyList<MonoBehaviour>>? components) { Prefab = prefab; PrefabHash = prefabHash; PrefabName = prefabName; Components = (IReadOnlyDictionary<Type, IReadOnlyList<MonoBehaviour>>)((components != null && components.Count > 0) ? ((IEnumerable)components) : ((IEnumerable)EmptyReadOnlyCollections<Type, IReadOnlyList<MonoBehaviour>>.Dictionary)); ReleaseOwnershipOnRecreate = Components.TryGetValue(typeof(ZSyncTransform), out IReadOnlyList<MonoBehaviour> value) && value.Cast<ZSyncTransform>().Any((ZSyncTransform x) => x.m_syncPosition || x.m_syncRotation || x.m_syncBodyVelocity); } public bool HasComponent<T>() where T : MonoBehaviour { return Components.ContainsKey(typeof(T)); } public T? GetComponent<T>() where T : MonoBehaviour { if (!Components.TryGetValue(typeof(T), out IReadOnlyList<MonoBehaviour> value)) { return default(T); } return (T)(object)value[0]; } public T GetRequiredComponent<T>() where T : MonoBehaviour { return (T)(object)Components[typeof(T)][0]; } } public abstract record ProcessorPrefabInfo { public virtual bool IsValid => true; public PrefabInfo PrefabInfo { get; internal set; } } public sealed record ProcessorPrefabInfo<T>(T Component) : ProcessorPrefabInfo(); internal interface IProcessorPrefabInfo<TPrefabInfo> : IPrefabInfo where TPrefabInfo : ProcessorPrefabInfo { TPrefabInfo? PrefabInfo { get; set; } } internal static class PrefabInfoExtensions { public static T GetExtension<T>(this IPrefabInfo prefabInfo) where T : class, IPrefabInfo { return (T)prefabInfo; } } public static class PrefabNames { public const string Megingjord = "BeltStrength"; public const string CryptKey = "CryptKey"; public const string Wishbone = "Wishbone"; public const string TornSpirit = "YagluthDrop"; public const string BlackmetalChest = "piece_chest_blackmetal"; public const string ReinforcedChest = "piece_chest"; public const string WoodChest = "piece_chest_wood"; public const string Barrel = "piece_chest_barrel"; public const string Incinerator = "incinerator"; public const string GiantBrain = "giant_brain"; public const string Hoe = "Hoe"; } public static class Prefabs { public static int Hammer { get; } = StringExtensionMethods.GetStableHashCode("Hammer", true); public static int Hoe { get; } = StringExtensionMethods.GetStableHashCode("Hoe", true); public static int GraustenFloor4x4 { get; } = StringExtensionMethods.GetStableHashCode("Piece_grausten_floor_4x4", true); public static int GraustenWall4x2 { get; } = StringExtensionMethods.GetStableHashCode("Piece_grausten_wall_4x2", true); public static int PortalWood { get; } = StringExtensionMethods.GetStableHashCode("portal_wood", true); public static int Portal { get; } = StringExtensionMethods.GetStableHashCode("portal", true); public static int Sconce { get; } = StringExtensionMethods.GetStableHashCode("piece_walltorch", true); public static int DvergerGuardstone { get; } = StringExtensionMethods.GetStableHashCode("dverger_guardstone", true); public static int Sign { get; } = StringExtensionMethods.GetStableHashCode("sign", true); public static int Candle { get; } = StringExtensionMethods.GetStableHashCode("Candle_resin", true); public static int BlackmetalChest { get; } = StringExtensionMethods.GetStableHashCode("piece_chest_blackmetal", true); public static int ReinforcedChest { get; } = StringExtensionMethods.GetStableHashCode("piece_chest", true); public static int Barrel { get; } = StringExtensionMethods.GetStableHashCode("piece_chest_barrel", true); public static int WoodChest { get; } = StringExtensionMethods.GetStableHashCode("piece_chest_wood", true); public static int Incinerator { get; } = StringExtensionMethods.GetStableHashCode("incinerator", true); public static int CargoCrate { get; } = StringExtensionMethods.GetStableHashCode("CargoCrate", true); public static int PrivateChest { get; } = StringExtensionMethods.GetStableHashCode("piece_chest_private", true); public static int StandingIronTorch { get; } = StringExtensionMethods.GetStableHashCode("piece_groundtorch", true); public static int StandingIronTorchGreen { get; } = StringExtensionMethods.GetStableHashCode("piece_groundtorch_green", true); public static int StandingIronTorchBlue { get; } = StringExtensionMethods.GetStableHashCode("piece_groundtorch_blue", true); public static int MountainRemainsBuried { get; } = StringExtensionMethods.GetStableHashCode("Pickable_MountainRemains01_buried", true); } public static class PrivateAccessor { private const BindingFlags AccessFlags = BindingFlags.Public | BindingFlags.NonPublic; [CompilerGenerated] private static Func<ConsoleCommand, ConsoleEvent?> <GetCommandAction>k__BackingField; [CompilerGenerated] private static Func<ConsoleCommand, ConsoleEventFailable?> <GetCommandActionFailable>k__BackingField; [CompilerGenerated] private static Func<IReadOnlyList<KeyButton>> <GetServerOptionsGUIPresets>k__BackingField; [CompilerGenerated] private static Func<IReadOnlyList<KeyUI>> <GetServerOptionsGUIModifiers>k__BackingField; [CompilerGenerated] private static Func<ZDOMan, Dictionary<ZDOID, ZDO>> <GetZDOManObjectsByID>k__BackingField; [CompilerGenerated] private static Func<Localization, IReadOnlyDictionary<string, string>> <GetLocalizationStrings>k__BackingField; [CompilerGenerated] private static Func<RandEventSystem, RandomEvent?> <GetCurrentEventFunc>k__BackingField; [CompilerGenerated] private static Func<ZoneSystem, IReadOnlyDictionary<int, ZoneLocation>> <GetLocationsByHashFunc>k__BackingField; [CompilerGenerated] private static Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, GameObject> <SpawnLocationFunc>k__BackingField; [CompilerGenerated] private static Action<ZoneSystem, long> <SendGlobalKeysAction>k__BackingField; private static Func<ConsoleCommand, ConsoleEvent?> GetCommandAction { get { Func<ConsoleCommand, ConsoleEvent?> func = <GetCommandAction>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ConsoleCommand)); func = (<GetCommandAction>k__BackingField = Expression.Lambda<Func<ConsoleCommand, ConsoleEvent>>(Expression.Field(parameterExpression, typeof(ConsoleCommand).GetField("action", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } private static Func<ConsoleCommand, ConsoleEventFailable?> GetCommandActionFailable { get { Func<ConsoleCommand, ConsoleEventFailable?> func = <GetCommandActionFailable>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ConsoleCommand)); func = (<GetCommandActionFailable>k__BackingField = Expression.Lambda<Func<ConsoleCommand, ConsoleEventFailable>>(Expression.Field(parameterExpression, typeof(ConsoleCommand).GetField("actionFailable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } public static Func<IReadOnlyList<KeyButton>> GetServerOptionsGUIPresets => <GetServerOptionsGUIPresets>k__BackingField ?? (<GetServerOptionsGUIPresets>k__BackingField = Expression.Lambda<Func<IReadOnlyList<KeyButton>>>(Expression.Field(null, typeof(ServerOptionsGUI).GetField("m_presets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), Array.Empty<ParameterExpression>()).Compile()); public static Func<IReadOnlyList<KeyUI>> GetServerOptionsGUIModifiers => <GetServerOptionsGUIModifiers>k__BackingField ?? (<GetServerOptionsGUIModifiers>k__BackingField = Expression.Lambda<Func<IReadOnlyList<KeyUI>>>(Expression.Field(null, typeof(ServerOptionsGUI).GetField("m_modifiers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), Array.Empty<ParameterExpression>()).Compile()); private static Func<ZDOMan, Dictionary<ZDOID, ZDO>> GetZDOManObjectsByID { get { Func<ZDOMan, Dictionary<ZDOID, ZDO>> func = <GetZDOManObjectsByID>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ZDOMan)); func = (<GetZDOManObjectsByID>k__BackingField = Expression.Lambda<Func<ZDOMan, Dictionary<ZDOID, ZDO>>>(Expression.Field(parameterExpression, typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } private static Func<Localization, IReadOnlyDictionary<string, string>> GetLocalizationStrings { get { Func<Localization, IReadOnlyDictionary<string, string>> func = <GetLocalizationStrings>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(Localization)); func = (<GetLocalizationStrings>k__BackingField = Expression.Lambda<Func<Localization, IReadOnlyDictionary<string, string>>>(Expression.Field(parameterExpression, typeof(Localization).GetField("m_translations", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } private static Func<RandEventSystem, RandomEvent?> GetCurrentEventFunc { get { Func<RandEventSystem, RandomEvent?> func = <GetCurrentEventFunc>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(RandEventSystem)); func = (<GetCurrentEventFunc>k__BackingField = Expression.Lambda<Func<RandEventSystem, RandomEvent>>(Expression.Field(parameterExpression, typeof(RandEventSystem).GetField("m_randomEvent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } private static Func<ZoneSystem, IReadOnlyDictionary<int, ZoneLocation>> GetLocationsByHashFunc { get { Func<ZoneSystem, IReadOnlyDictionary<int, ZoneLocation>> func = <GetLocationsByHashFunc>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ZoneSystem)); func = (<GetLocationsByHashFunc>k__BackingField = Expression.Lambda<Func<ZoneSystem, IReadOnlyDictionary<int, ZoneLocation>>>(Expression.Field(parameterExpression, typeof(ZoneSystem).GetField("m_locationsByHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)), new ParameterExpression[1] { parameterExpression }).Compile()); } return func; } } private static Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, GameObject> SpawnLocationFunc { get { Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, GameObject> func = <SpawnLocationFunc>k__BackingField; if (func == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ZoneSystem)); MethodInfo? method = typeof(ZoneSystem).GetMethod("SpawnLocation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Expression[] array = new Expression[6]; ParameterExpression parameterExpression2 = (ParameterExpression)(array[0] = Expression.Parameter(typeof(ZoneLocation))); ParameterExpression parameterExpression3 = (ParameterExpression)(array[1] = Expression.Parameter(typeof(int))); ParameterExpression parameterExpression4 = (ParameterExpression)(array[2] = Expression.Parameter(typeof(Vector3))); ParameterExpression parameterExpression5 = (ParameterExpression)(array[3] = Expression.Parameter(typeof(Quaternion))); ParameterExpression parameterExpression6 = (ParameterExpression)(array[4] = Expression.Parameter(typeof(SpawnMode))); ParameterExpression parameterExpression7 = (ParameterExpression)(array[5] = Expression.Parameter(typeof(List<GameObject>))); func = (<SpawnLocationFunc>k__BackingField = Expression.Lambda<Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, GameObject>>(Expression.Call(parameterExpression, method, array), new ParameterExpression[7] { parameterExpression, parameterExpression2, parameterExpression3, parameterExpression4, parameterExpression5, parameterExpression6, parameterExpression7 }).Compile()); } return func; } } private static Action<ZoneSystem, long> SendGlobalKeysAction { get { Action<ZoneSystem, long> action = <SendGlobalKeysAction>k__BackingField; if (action == null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(ZoneSystem)); MethodInfo? method = typeof(ZoneSystem).GetMethod("SendGlobalKeys", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Expression[] array = new Expression[1]; ParameterExpression parameterExpression2 = (ParameterExpression)(array[0] = Expression.Parameter(typeof(long))); action = (<SendGlobalKeysAction>k__BackingField = Expression.Lambda<Action<ZoneSystem, long>>(Expression.Call(parameterExpression, method, array), new ParameterExpression[2] { parameterExpression, parameterExpression2 }).Compile()); } return action; } } public static int ZSyncAnimationZDOSalt { get; } = (int)typeof(ZSyncAnimation).GetField("c_ZDOSalt", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetRawConstantValue(); public static int CharacterAnimationHashEncumbered { get; } = (int)typeof(Character).GetField("s_encumbered", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null); public static int CharacterAnimationHashInWater { get; } = (int)typeof(Character).GetField("s_inWater", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null); public static int PlayerAnimationHashCrouching { get; } = (int)typeof(Player).GetField("s_crouching", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null); public static ConsoleEvent? GetAction(this ConsoleCommand command) { return GetCommandAction(command); } public static ConsoleEventFailable? GetActionFailable(this ConsoleCommand command) { return GetCommandActionFailable(command); } private static Dictionary<ZDOID, ZDO> GetObjectsByIDCore(this ZDOMan instance) { return GetZDOManObjectsByID(instance); } public static Dictionary<ZDOID, ZDO>.ValueCollection GetObjects(this ZDOMan instance) { return instance.GetObjectsByIDCore().Values; } public static IReadOnlyDictionary<string, string> GetStrings(this Localization instance) { return GetLocalizationStrings(instance); } public static RandomEvent? GetCurrentEvent(this RandEventSystem instance) { return GetCurrentEventFunc(instance); } public static IReadOnlyDictionary<int, ZoneLocation> GetLocationsByHash(this ZoneSystem instance) { return GetLocationsByHashFunc(instance); } public static GameObject SpawnLocation(this ZoneSystem instance, ZoneLocation location, int seed, Vector3 pos, Quaternion rot, SpawnMode mode, List<GameObject>? spawnedGhostObjects = null) { //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_000b: Unknown result type (might be due to invalid IL or missing references) return SpawnLocationFunc(instance, location, seed, pos, rot, mode, spawnedGhostObjects ?? new List<GameObject>()); } public static void SendGlobalKeys(this ZoneSystem instance, long peerID) { SendGlobalKeysAction(instance, peerID); } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public sealed class ProcessorAttribute : Attribute { public Guid Id { get; } = new Guid(id); public bool OnlyWhenDependedOn { get; init; } public int Priority { get; init; } public ProcessorAttribute(string id) { } } public abstract class ProcessorDependencyAttribute : Attribute { public Guid ProcessorId { get; } public bool Required { get; init; } public bool? RunBefore { get; } private ProcessorDependencyAttribute(Guid processorId, bool required, bool? runBefore) { ProcessorId = processorId; Required = required; RunBefore = runBefore; } private protected ProcessorDependencyAttribute(string processorId, bool? runBefore) : this(new Guid(processorId), required: false, runBefore) { } private protected ProcessorDependencyAttribute(Type processorType, bool? runBefore) : this(processorType.GetCustomAttribute<ProcessorAttribute>()?.Id ?? default(Guid), required: true, runBefore) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class DependsOnAttribute : ProcessorDependencyAttribute { public DependsOnAttribute(string processorId) : base(processorId, null) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class DependsOnAttribute<T> : ProcessorDependencyAttribute where T : Processor, new() { public DependsOnAttribute() : base(typeof(T), null) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class RunBeforeAttribute : ProcessorDependencyAttribute { public RunBeforeAttribute(string processorId) : base(processorId, true) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class RunBeforeAttribute<T> : ProcessorDependencyAttribute where T : Processor, new() { public RunBeforeAttribute() : base(typeof(T), true) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class RunAfterAttribute : ProcessorDependencyAttribute { public RunAfterAttribute(string processorId) : base(processorId, false) { } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class RunAfterAttribute<T> : ProcessorDependencyAttribute where T : Processor, new() { public RunAfterAttribute() : base(typeof(T), false) { } } public abstract class Processor { private static class InstanceCache<T> where T : Processor, new() { public static readonly T Instance = new T(); } [Flags] protected internal enum ProcessResult { Default = 0, UnregisterProcessor = 2, DestroyZDO = 4, RecreateZDO = 8, SkipOtherProcessors = 0x10, ScheduleReprocessing = 0x20 } [Flags] public enum CreatorMarkers : uint { None = 0u, DataZDO = 1u, ProcessorOwned = 2u } private static class HeightmapUtils { private static readonly List<(Vector2s ZoneId, GameObject Root)> _zoneRoots = new List<(Vector2s, GameObject)>(); private static DateTimeOffset __nextCleanup; public static Heightmap CreateHeightmap(Vector2s zoneId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 zonePos = ZoneSystem.GetZonePos(zoneId); GameObject val = Object.Instantiate<GameObject>(ZoneSystem.instance.m_zonePrefab, zonePos, Quaternion.identity); _zoneRoots.Add((zoneId, val)); return val.GetComponentInChildren<Heightmap>(); } public static Heightmap CreateHeightmap(Vector3 refPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return CreateHeightmap(ZoneSystem.GetZone(refPos)); } public static void CleanUp(PeersEnumerable peers) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (__nextCleanup > DateTimeOffset.UtcNow) { return; } for (int num = _zoneRoots.Count - 1; num >= 0; num--) { var (zone, val) = _zoneRoots[num]; if (!peers.Any((Peer x) => ZNetScene.InActiveArea(zone, x.RefPos))) { _zoneRoots.RemoveAt(num); Object.Destroy((Object)(object)val); } } __nextCleanup = DateTimeOffset.UtcNow.AddSeconds(2.0); } } private static ServersideQoLZDO? __dataZDO; private static bool __enableProcessingTimeMonitoring; private static int __processorId = ServersideQoLPluginBase<ServersideQoLPlugin, Config>.RegisterServerVar("ProcessorId"); [CompilerGenerated] private static IReadOnlyDictionary<Biome, Character> <BossesByBiome>k__BackingField; internal ProcessorAttribute Attribute { get; } internal IServersideQoLPlugin Plugin { get; private set; } protected Logger Logger { get; private set; } protected HashSet<ServersideQoLZDO> PlacedObjects { get; } = new HashSet<ServersideQoLZDO>(); public double ProcessingTimeSeconds { get; private set; } public double TotalProcessingTimeSeconds { get; private set; } protected static IReadOnlyDictionary<string, PieceTable> PieceTablesByPieceName => ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Instance.PieceTablesByPieceName; protected internal static IReadOnlyDictionary<Biome, Character> BossesByBiome => <BossesByBiome>k__BackingField ?? (<BossesByBiome>k__BackingField = ((Func<IReadOnlyDictionary<Biome, Character>>)delegate { //IL_0067: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) Dictionary<Biome, Character> dictionary = new Dictionary<Biome, Character>(); foreach (bool item in (IEnumerable<bool>)new <>z__ReadOnlyArray<bool>(new bool[2] { false, true })) { foreach (ZoneLocation location in ZoneSystem.instance.m_locations) { bool flag = !location.m_enable || !location.m_prioritized; bool flag2 = flag; if (!flag2) { Biome biome = location.m_biome; bool flag3 = (((int)biome == 0 || (int)biome == 256 || (int)biome == 895) ? true : false); flag2 = flag3; } if (!flag2 && !dictionary.ContainsKey(location.m_biome)) { try { location.m_prefab.Load(); } catch (Exception arg) { ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Logger.LogWarning($"Loading location asset {location.m_prefabName} failed: {arg}"); continue; } GameObject asset = location.m_prefab.Asset; if (asset == null) { ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Logger.LogWarning("Loading location asset " + location.m_prefabName + " failed"); } else { OfferingBowl componentInChildren = asset.GetComponentInChildren<OfferingBowl>(); if (item && componentInChildren == null) { DungeonGenerator componentInChildren2 = asset.GetComponentInChildren<DungeonGenerator>(); if (componentInChildren2 != null) { SoftReference<GameObject>[] availableRoomPrefabs = componentInChildren2.GetAvailableRoomPrefabs(); for (int i = 0; i < availableRoomPrefabs.Length; i++) { SoftReference<GameObject> val = availableRoomPrefabs[i]; val.Load(); Room component = val.Asset.GetComponent<Room>(); componentInChildren = ((Component)component).GetComponentInChildren<OfferingBowl>(); if (componentInChildren != null) { break; } } } } if (componentInChildren != null) { dictionary.Add(location.m_biome, componentInChildren.m_bossPrefab.GetComponent<Character>()); } } } } } return dictionary; })()); protected static ServersideQoLZDO DataZDO { get { //IL_001e: Unknown result type (might be due to invalid IL or missing refe