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 v2.5.1
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 System.Security; using System.Security.Permissions; 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("2.5.1.0")] [assembly: AssemblyInformationalVersion("2.5.1+50a2d79d10d8f52c59a18f4ca854667464c9ca9b")] [assembly: AssemblyProduct("ServersideQoL.Patchers")] [assembly: AssemblyTitle("ServersideQoL.Patchers")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.5.1.0")] [module: UnverifiableCode] [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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01cf: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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("2.5.1".Split('-')[0])); 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 = "2.5.1"; public const string PluginInformationalVersion = "2.5.1"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639286779444097001L, 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.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; 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 ServersideQoL.Processors; using ServersideQoL.Utilities; 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/console (e.g. XBox, PS, Switch) clients. Stack player inventories into chests, generated portal hub, auto-sort chests, refuel smelters from containers, infinite building/farming stamina and much more")] [assembly: AssemblyFileVersion("2.5.1.0")] [assembly: AssemblyInformationalVersion("2.5.1+50a2d79d10d8f52c59a18f4ca854667464c9ca9b")] [assembly: AssemblyProduct("ServersideQoL")] [assembly: AssemblyTitle("ServersideQoL")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.5.1.0")] [module: UnverifiableCode] [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 enum MessageRecipients { Noone, Admins, Everybody } public sealed class AdvancedConfig { public sealed class ProcessingDelaysConfig { public float WhenNoNearbyPlayers { get; init; } = 2f; public float AfterContainerOwnershipRequest { get; init; } = 0.1f; } public sealed class RpcThrottleConfig { public float WindowInSeconds { get; init; } = 1f; public int MaxCallsPerWindow { get; init; } = 100; } 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 RpcThrottleConfig RpcThrottle { get; init; } = new RpcThrottleConfig(); public ContainersConfig Containers { get; init; } = new ContainersConfig(); public PlayersConfig Players { get; init; } = new PlayersConfig(); } public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx(cfg, defaultValue: true, "Enables/disables the entire mod", (IAcceptableValueBase<bool>?)null, (ConfigBase<Config>.Deprecated?)null, "Enabled"); public ConfigEntry<bool> DiagnosticLogs { get; } = ConfigBase<Config>.BindEx(cfg, defaultValue: false, "Enables/disables diagnostic logs", (IAcceptableValueBase<bool>?)null, (ConfigBase<Config>.Deprecated?)null, "DiagnosticLogs"); public ConfigEntry<bool> AutoReload { get; } = ConfigBase<Config>.BindEx(cfg, defaultValue: true, "True to automatically reload config files when they are changed.\r\nThis value is only respected during initial startup and changing it later while the server is running has no effect.", (IAcceptableValueBase<bool>?)null, (ConfigBase<Config>.Deprecated?)null, "AutoReload"); public ConfigEntry<float> AutoReloadPollingIntervalSeconds { get; } = ConfigBase<Config>.BindEx(cfg, 0f, "If > 0, config files will be polled every x seconds in addition to listening for file system events.\r\nThis should help on file systems for which file system events don't work reliably (e.g. NFS).", (IAcceptableValueBase<float>?)null, (ConfigBase<Config>.Deprecated?)null, "AutoReloadPollingIntervalSeconds"); public ConfigEntry<bool> UnifiedConfig { get; } = ConfigBase<Config>.BindEx(cfg, defaultValue: false, "True to use a single config file for all SQoL mods.\r\nDO NOT turn this on unless you've updated all SQoL mods to v2.0.11 minimum.", (IAcceptableValueBase<bool>?)null, (ConfigBase<Config>.Deprecated?)null, "UnifiedConfig"); public ConfigEntry<bool> ConfigPerWorld { get; } = ConfigBase<Config>.BindEx(cfg, defaultValue: false, "True to save the config files for each world separately in the world save directory", (IAcceptableValueBase<bool>?)null, (ConfigBase<Config>.Deprecated?)null, "ConfigPerWorld"); public ConfigEntry<float> FarMessageRange { get; } = ConfigBase<Config>.BindEx(cfg, 64f, $"Max distance a player can have to a modified object to receive messages of type {MessageTypes.TopLeftFar} or {MessageTypes.CenterFar}", (IAcceptableValueBase<float>?)null, (ConfigBase<Config>.Deprecated?)null, "FarMessageRange"); public ConfigEntry<string>? Language { get; } = (!ZNet.instance.IsDedicated()) ? null : ConfigBase<Config>.BindEx(cfg, Localization.instance.GetSelectedLanguage(), "The language used for item names, etc.", (IAcceptableValueBase<string>?)new AcceptableValueList<string>(Localization.instance.GetLanguages().ToArray()), (ConfigBase<Config>.Deprecated?)null, "Language"); public ConfigEntry<MessageRecipients> CheckLogMessageRecipients { get; } = ConfigBase<Config>.BindEx(cfg, MessageRecipients.Noone, "Which players should receive in-game messages to check the server log when an error is logged", (IAcceptableValueBase<MessageRecipients>?)null, (ConfigBase<Config>.Deprecated?)null, "CheckLogMessageRecipients"); public ConfigEntry<MessageType> CheckLogMessageType { get; } = ConfigBase<Config>.BindEx(cfg, (MessageType)2, "The message type shown to players", (IAcceptableValueBase<MessageType>?)null, (ConfigBase<Config>.Deprecated?)null, "CheckLogMessageType"); 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; } ConfigEntry<bool> Enabled { get; } ConfigFile ConfigFile { get; } event EventHandler<SettingChangedEventArgs>? ConfigChanged; void RaiseInitialized(IServersideQoLPlugin plugin); } public abstract class ConfigBase { protected static class Shared { [CompilerGenerated] private static ConfigEntry<bool>? <AutoStorePickup>k__BackingField; [CompilerGenerated] private static ConfigEntry<int>? <AutoStorePickupMaxRange>k__BackingField; [CompilerGenerated] private static ConfigEntry<string>? <AutoStorePickupRangeSignPrefix>k__BackingField; [CompilerGenerated] private static ConfigEntry<bool>? <AutoProcessFeedFromContainers>k__BackingField; [CompilerGenerated] private static ConfigEntry<int>? <AutoProcessFeedFromContainersMaxRange>k__BackingField; [CompilerGenerated] private static ConfigEntry<string>? <AutoProcessFeedFromContainersRangeSignPrefix>k__BackingField; [CompilerGenerated] private static ConfigEntry<bool>? <TameAssistFeedFromContainers>k__BackingField; [CompilerGenerated] private static ConfigEntry<int>? <TameAssistFeedFromContainersMaxRange>k__BackingField; [CompilerGenerated] private static ConfigEntry<string>? <TameAssistFeedFromContainersRangeSignPrefix>k__BackingField; public static ConfigEntry<bool>? AutoStorePickup { [CompilerGenerated] get { return <AutoStorePickup>k__BackingField; } set { Set(ref <AutoStorePickup>k__BackingField, value, "AutoStorePickup"); } } public static ConfigEntry<int>? AutoStorePickupMaxRange { [CompilerGenerated] get { return <AutoStorePickupMaxRange>k__BackingField; } set { Set(ref <AutoStorePickupMaxRange>k__BackingField, value, "AutoStorePickupMaxRange"); } } public static ConfigEntry<string>? AutoStorePickupRangeSignPrefix { [CompilerGenerated] get { return <AutoStorePickupRangeSignPrefix>k__BackingField; } set { Set(ref <AutoStorePickupRangeSignPrefix>k__BackingField, value, "AutoStorePickupRangeSignPrefix"); } } public static ConfigEntry<bool>? AutoProcessFeedFromContainers { [CompilerGenerated] get { return <AutoProcessFeedFromContainers>k__BackingField; } set { Set(ref <AutoProcessFeedFromContainers>k__BackingField, value, "AutoProcessFeedFromContainers"); } } public static ConfigEntry<int>? AutoProcessFeedFromContainersMaxRange { [CompilerGenerated] get { return <AutoProcessFeedFromContainersMaxRange>k__BackingField; } set { Set(ref <AutoProcessFeedFromContainersMaxRange>k__BackingField, value, "AutoProcessFeedFromContainersMaxRange"); } } public static ConfigEntry<string>? AutoProcessFeedFromContainersRangeSignPrefix { [CompilerGenerated] get { return <AutoProcessFeedFromContainersRangeSignPrefix>k__BackingField; } set { Set(ref <AutoProcessFeedFromContainersRangeSignPrefix>k__BackingField, value, "AutoProcessFeedFromContainersRangeSignPrefix"); } } public static ConfigEntry<bool>? TameAssistFeedFromContainers { [CompilerGenerated] get { return <TameAssistFeedFromContainers>k__BackingField; } set { Set(ref <TameAssistFeedFromContainers>k__BackingField, value, "TameAssistFeedFromContainers"); } } public static ConfigEntry<int>? TameAssistFeedFromContainersMaxRange { [CompilerGenerated] get { return <TameAssistFeedFromContainersMaxRange>k__BackingField; } set { Set(ref <TameAssistFeedFromContainersMaxRange>k__BackingField, value, "TameAssistFeedFromContainersMaxRange"); } } public static ConfigEntry<string>? TameAssistFeedFromContainersRangeSignPrefix { [CompilerGenerated] get { return <TameAssistFeedFromContainersRangeSignPrefix>k__BackingField; } set { Set(ref <TameAssistFeedFromContainersRangeSignPrefix>k__BackingField, value, "TameAssistFeedFromContainersRangeSignPrefix"); } } private static void Set<T>(ref T? field, T? value, [CallerMemberName] string configName = null) where T : class { if (!IsGeneratingConfigMarkdown) { if (field != null) { throw new Exception("Shared config " + configName + " already set"); } field = value; } } } protected sealed record PlaceableContainer(string Name, Container Container, Piece Piece); private protected interface IYamlConfigEntry { string FilePath { get; } object Value { get; } void Deserialize(); } public sealed class YamlConfigEntry<T>(string filePath, T value) : IYamlConfigEntry where T : notnull { private readonly string _filePath = filePath; private readonly DebouncedFileWatcher _fileWatcher = new DebouncedFileWatcher(filePath); 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; string IYamlConfigEntry.FilePath => _filePath; object IYamlConfigEntry.Value => Value; public event Action<YamlConfigEntry<T>>? ValueChanged; private void Deserialize() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (!File.Exists(_filePath)) { return; } _fileWatcher.Enabled = false; try { IDeserializer val = ((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(_filePath)) { T val2 = (T)val.Deserialize((TextReader)streamReader, typeof(T)); Value = ((val2 != null) ? val2 : Value); } ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogInfo("Advanced config loaded from " + Path.GetFileName(_filePath)); this.ValueChanged?.Invoke(this); } catch (Exception arg) { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogWarning($"{Path.GetFileName(_filePath)}: {arg}"); } _fileWatcher.Enabled = true; } void IYamlConfigEntry.Deserialize() { Deserialize(); _fileWatcher.FileCreatedOrChanged += OnFileCreatedOrChanged; _fileWatcher.Enabled = true; } private async void OnFileCreatedOrChanged(object sender, FileSystemEventArgs e) { Deserialize(); } } 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 interface IAcceptableValueBase<T> { internal AcceptableValueBase GetAcceptableValue() { AcceptableValueBase val = (AcceptableValueBase)((this is AcceptableValueBase) ? this : null); if (val == null) { throw new Exception(GetType().FullName + " does not derive from AcceptableValueBase"); } if (val.ValueType != typeof(T)) { throw new Exception(GetType().FullName + ": wrong value type: expected: " + typeof(T).Name + ", actual: " + val.ValueType.Name); } return val; } } public sealed class AcceptableValueRange<T> : AcceptableValueRange<T>, IAcceptableValueBase<T> where T : IComparable { public AcceptableValueRange(T minValue, T maxValue) : base(minValue, maxValue) { } } public sealed class AcceptableValueList<T> : AcceptableValueList<T>, IAcceptableValueBase<T> where T : IEquatable<T> { public AcceptableValueList(params T[] acceptableValues) : base(acceptableValues) { } } public sealed class AcceptableValueListOrNull<T> : AcceptableValueBase, IAcceptableValueBase<T?> where T : IEquatable<T> { private readonly AcceptableValueList<T> _inner = new AcceptableValueList<T>(acceptableValues); public AcceptableValueListOrNull(params T[] acceptableValues) : base(typeof(T)) { } public override object? Clamp(object? value) { if (value != null) { return ((AcceptableValueBase)_inner).Clamp((object)(T)value); } return null; } public override bool IsValid(object? value) { if (value != null) { return ((AcceptableValueBase)_inner).IsValid((object)(T)value); } return true; } public override string ToDescriptionString() { return ((AcceptableValueBase)_inner).ToDescriptionString().Replace("# Acceptable values: ", "# Acceptable values: NotSet, "); } } public sealed class AcceptableEnum<T> : AcceptableValueBase, IAcceptableValueBase<T> 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 (SQoLEnumUtils.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(); } private T ClampCore(object value) { if (value is T) { T e = (T)value; if (SQoLEnumUtils.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 SQoLEnumUtils.ToEnum<T>(num); } if (!AcceptableValues.Any((T x) => x.Equals(e))) { return _default; } return e; } return _default; } public override object Clamp(object value) { return ClampCore(value); } public override bool IsValid(object value) { return object.Equals(value, ((AcceptableValueBase)this).Clamp(value)); } public override string ToDescriptionString() { if (!SQoLEnumUtils.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)), IAcceptableValueBase<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)))); } } private protected interface ICustomConfigType { void EnsureConverterAdded(); } public sealed class ConfigArray<T>(IReadOnlyList<T> value) : ICustomConfigType { public static ConfigArray<T> Empty => <Empty>k__BackingField ?? (<Empty>k__BackingField = new ConfigArray<T>(Array.Empty<T>())); public IReadOnlyList<T> Items { get; } = value; public override bool Equals(object obj) { if (this != obj) { if (obj is ConfigArray<T> configArray) { return Items.SequenceEqual(configArray.Items); } return false; } return true; } public override int GetHashCode() { return Items.GetHashCode(); } void ICustomConfigType.EnsureConverterAdded() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown if (TomlTypeConverter.CanConvert(typeof(ConfigArray<T>))) { return; } if (!TomlTypeConverter.CanConvert(typeof(T))) { throw new NotSupportedException(); } TomlTypeConverter.AddConverter(typeof(ConfigArray<T>), new TypeConverter { ConvertToObject = delegate(string str, Type type) { if (!string.IsNullOrWhiteSpace(str)) { List<T> list = new List<T>(); list.AddRange(from x in str.Split(',', StringSplitOptions.RemoveEmptyEntries) select TomlTypeConverter.ConvertToValue<T>(x.Trim())); return new ConfigArray<T>(new <>z__ReadOnlyList<T>(list)); } return Empty; }, ConvertToString = (object obj, Type type) => string.Join(", ", ((ConfigArray<T>)obj).Items.Select((T x) => TomlTypeConverter.ConvertToString((object)x, typeof(T)))) }); } } protected sealed class AcceptableArrayValues<T> : AcceptableValueBase, IAcceptableValueBase<ConfigArray<T>> { private readonly ConfigArray<T> _values = new ConfigArray<T>(values); private readonly HashSet<T> _allowedValues; public AcceptableArrayValues(IReadOnlyList<T> values) { HashSet<T> hashSet = new HashSet<T>(); foreach (T value in values) { hashSet.Add(value); } _allowedValues = hashSet; ((AcceptableValueBase)this)..ctor(typeof(ConfigArray<T>)); } private ConfigArray<T> ClampCore(object value) { if (!(value is ConfigArray<T> configArray)) { return ConfigArray<T>.Empty; } foreach (T item in configArray.Items) { if (!_allowedValues.Contains(item)) { List<T> list = new List<T>(); list.AddRange(configArray.Items.Where(_allowedValues.Contains)); return new ConfigArray<T>(new <>z__ReadOnlyList<T>(list)); } } return configArray; } public override object Clamp(object value) { return ClampCore(value); } public override bool IsValid(object value) { return object.Equals(value, ((AcceptableValueBase)this).Clamp(value)); } public override string ToDescriptionString() { return FormattableString.Invariant($"# Acceptable values: {TomlTypeConverter.ConvertToString((object)_values, _values.GetType())}\r\n# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning)"); } } protected static class AcceptableArrayValues { public static AcceptableArrayValues<T> Get<T>(IReadOnlyList<T> values) { return new AcceptableArrayValues<T>(values); } } public const Emotes DisabledEmote = (Emotes)(-1); public const Emotes AnyEmote = (Emotes)(-2); [CompilerGenerated] private static IReadOnlyList<PlaceableContainer> <PlaceableContainers>k__BackingField; private static readonly bool __configWatcherInstalled = AppDomain.CurrentDomain.GetAssemblies().Any((Assembly x) => !x.IsDynamic && Path.GetFileName(x.Location) == "ConfigWatcher.dll"); private static readonly Dictionary<ConfigFile, DebouncedFileWatcher> __fileWatcher = new Dictionary<ConfigFile, DebouncedFileWatcher>(); private protected static readonly HashSet<ConfigEntryBase> __deprecatedEntries = new HashSet<ConfigEntryBase>(); private protected const string NullableNotSetString = "NotSet"; private protected static bool IsGeneratingConfigMarkdown => false; protected static IReadOnlyDictionary<string, PieceTable> PieceTablesByPieceName => ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.PieceTablesByPieceName; protected static IReadOnlyDictionary<Biome, Character> BossesByBiome => Processor.BossesByBiome; protected static IReadOnlyList<(Character Boss, Biome Biome)> BossesInOrder => Processor.BossesInOrder; protected static IReadOnlyList<PlaceableContainer> PlaceableContainers { get { IReadOnlyList<PlaceableContainer> readOnlyList = <PlaceableContainers>k__BackingField; if (readOnlyList == null) { List<PlaceableContainer> list = new List<PlaceableContainer>(); list.AddRange(from x in ZNetScene.instance.m_prefabs where PieceTablesByPieceName.ContainsKey(((Object)x).name) select new PlaceableContainer(((Object)x).name, x.GetComponentInChildren<Container>(), x.GetComponent<Piece>()) into x where (object)x != null && x.Container != null && x.Piece != null select x); readOnlyList = (<PlaceableContainers>k__BackingField = new <>z__ReadOnlyList<PlaceableContainer>(list)); } return readOnlyList; } } public ConfigFile ConfigFile { get; } protected Logger Logger { get; } public abstract ConfigEntry<bool> Enabled { get; } private protected ConfigBase(ConfigFile configFile, Logger logger) { ConfigFile = configFile; Logger = logger; } public static bool IsDeprecated(ConfigEntryBase entry) { return __deprecatedEntries.Contains(entry); } private protected void InitializeFileWatcher() { if (!__configWatcherInstalled && ConfigBase<Config>.Instance.AutoReload.Value && !__fileWatcher.ContainsKey(ConfigFile)) { DebouncedFileWatcher debouncedFileWatcher = new DebouncedFileWatcher(ConfigFile.ConfigFilePath); debouncedFileWatcher.FileCreatedOrChanged += delegate { ConfigFile configFile = ConfigFile; bool saveOnConfigSet = ConfigFile.SaveOnConfigSet; configFile.SaveOnConfigSet = false; ConfigFile.Reload(); ConfigFile.SaveOnConfigSet = saveOnConfigSet; }; debouncedFileWatcher.Enabled = true; __fileWatcher.Add(ConfigFile, debouncedFileWatcher); } } } public abstract class ConfigBase<TSelf> : ConfigBase, IConfig where TSelf : ConfigBase<TSelf> { public sealed record Deprecated(string Reason, Action<TSelf> AdjustConfig); private static Dictionary<string, IYamlConfigEntry>? __yaml = new Dictionary<string, IYamlConfigEntry>(); private IServersideQoLPlugin _plugin; private static readonly string __section; private EventHandler<SettingChangedEventArgs>? _configChanged; IServersideQoLPlugin IConfig.Plugin => _plugin; internal static bool IsInitialized { get; private set; } 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 string Section { get { if (!(typeof(TSelf) == typeof(Config)) && !ConfigBase.IsGeneratingConfigMarkdown && ConfigBase<Config>.Instance.UnifiedConfig.Value) { return "M." + __section; } return __section; } } private static event Action<ConfigFile, TSelf>? Initialized; public event EventHandler<SettingChangedEventArgs>? ConfigChanged { add { if (_configChanged == null && value != null) { base.ConfigFile.SettingChanged -= OnSettingsChanged; base.ConfigFile.SettingChanged += OnSettingsChanged; } _configChanged = (EventHandler<SettingChangedEventArgs>)Delegate.Combine(_configChanged, value); } remove { _configChanged = (EventHandler<SettingChangedEventArgs>)Delegate.Remove(_configChanged, value); if (_configChanged == null) { base.ConfigFile.SettingChanged -= OnSettingsChanged; } } } protected ConfigBase(ConfigFile configFile, Logger logger) : base(configFile, logger) { } private void OnSettingsChanged(object? sender, SettingChangedEventArgs args) { if (_configChanged == null) { return; } if (ConfigBase<Config>.Instance.UnifiedConfig.Value) { string section = Section; string section2 = args.ChangedSetting.Definition.Section; if (section2 != section && !section2.StartsWith(section + ".")) { return; } } _configChanged(this, args); } [MemberNotNull("_plugin")] void IConfig.RaiseInitialized(IServersideQoLPlugin plugin) { _plugin = plugin; Instance = (TSelf)this; foreach (IYamlConfigEntry value in __yaml.Values) { BindYaml(value); } __yaml = null; IsInitialized = true; ConfigBase<TSelf>.Initialized?.Invoke(base.ConfigFile, (TSelf)this); InitializeFileWatcher(); } protected static ConfigEntry<T> BindEx<T>(ConfigFile config, T defaultValue, string description, IAcceptableValueBase<T>? acceptableValues = null, Deprecated? deprecated = null, [CallerMemberName] string key = null) { return BindExCore(config, Section, defaultValue, description, acceptableValues?.GetAcceptableValue(), deprecated, key); } protected static ConfigEntry<T> BindEx<T>(ConfigFile config, string subSection, T defaultValue, string description, IAcceptableValueBase<T>? acceptableValues = null, Deprecated? deprecated = null, [CallerMemberName] string key = null) { string section = ((!ConfigBase.IsGeneratingConfigMarkdown && ConfigBase<Config>.Instance.UnifiedConfig.Value) ? (Section + "." + subSection) : subSection); return BindExCore(config, section, defaultValue, description, acceptableValues?.GetAcceptableValue(), deprecated, key); } [Obsolete(null, true)] protected static ConfigEntry<T> BindEx<T>(ConfigFile config, T defaultValue, string description, AcceptableValueBase? acceptableValues, Deprecated? deprecated, string key) { return BindExCore(config, Section, defaultValue, description, acceptableValues, deprecated, key); } [Obsolete(null, true)] protected static ConfigEntry<T> BindEx<T>(ConfigFile config, string subSection, T defaultValue, string description, AcceptableValueBase? acceptableValues, Deprecated? deprecated, string key) { string section = ((!ConfigBase.IsGeneratingConfigMarkdown && ConfigBase<Config>.Instance.UnifiedConfig.Value) ? (Section + "." + subSection) : subSection); return BindExCore(config, section, defaultValue, description, acceptableValues, deprecated, key); } private static ConfigEntry<T> BindExCore<T>(ConfigFile config, string section, T defaultValue, string description, AcceptableValueBase? acceptableValues, Deprecated? deprecated, string key) { //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown (defaultValue as ICustomConfigType)?.EnsureConverterAdded(); if (!TomlTypeConverter.CanConvert(typeof(T))) { Type underlyingType = Nullable.GetUnderlyingType(typeof(T)); if ((object)underlyingType != null) { if (!TomlTypeConverter.CanConvert(underlyingType)) { throw new NotSupportedException(); } ParameterExpression parameterExpression = Expression.Parameter(typeof(string)); ParameterExpression parameterExpression2 = Expression.Parameter(typeof(object)); ParameterExpression parameterExpression3 = Expression.Parameter(typeof(Type)); Type? typeFromHandle = typeof(T); TypeConverter val = new TypeConverter(); val.ConvertToObject = Expression.Lambda<Func<string, Type, object>>(Expression.Block(Expression.IfThen(Expression.ReferenceNotEqual(parameterExpression, Expression.Constant(null, typeof(string))), Expression.Assign(parameterExpression, Expression.Call(parameterExpression, "Trim", Array.Empty<Type>()))), Expression.Convert(Expression.Condition(Expression.OrElse(Expression.Call(typeof(string), "IsNullOrEmpty", Array.Empty<Type>(), parameterExpression), Expression.Call(typeof(string), "Equals", Array.Empty<Type>(), parameterExpression, Expression.Constant("NotSet"), Expression.Constant(StringComparison.OrdinalIgnoreCase))), Expression.Default(typeof(T)), Expression.New(typeof(T).GetConstructor(new Type[1] { underlyingType }), Expression.Call(typeof(TomlTypeConverter), "ConvertToValue", new Type[1] { underlyingType }, parameterExpression))), typeof(object))), new ParameterExpression[2] { parameterExpression, parameterExpression3 }).Compile(); val.ConvertToString = Expression.Lambda<Func<object, Type, string>>(Expression.Condition(Expression.ReferenceEqual(parameterExpression2, Expression.Constant(null, typeof(object))), Expression.Constant("NotSet"), Expression.Call(typeof(TomlTypeConverter), "ConvertToString", Array.Empty<Type>(), Expression.Convert(Expression.Property(Expression.Convert(parameterExpression2, typeof(T)), "Value"), typeof(object)), Expression.Constant(underlyingType))), new ParameterExpression[2] { parameterExpression2, parameterExpression3 }).Compile(); TomlTypeConverter.AddConverter(typeFromHandle, val); } } if (acceptableValues == null && typeof(T) == typeof(bool?)) { acceptableValues = (AcceptableValueBase?)(object)new AcceptableValueListOrNull<bool>(false, true); } 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) { ConfigBase.__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> val2, TSelf modCfg) { if (!EqualityComparer<T>.Default.Equals(val2.Value, (T)((ConfigEntryBase)val2).DefaultValue)) { deprecated2.AdjustConfig(modCfg); modCfg.Logger.LogWarning("[" + ((ConfigEntryBase)val2).Definition.Section + "].[" + ((ConfigEntryBase)val2).Definition.Key + "] is deprecated: " + deprecated2.Reason); } } } protected static YamlConfigEntry<T> BindYaml<T>(ConfigFile cfg, [CallerMemberName] string fileName = null) where T : notnull, new() { return BindYaml<T>(cfg, null, fileName); } protected static YamlConfigEntry<T> BindYaml<T>(ConfigFile cfg, Action<T> onChanged, [CallerMemberName] string fileName = null) where T : notnull, new() { if (ConfigBase.IsGeneratingConfigMarkdown) { return null; } if (__yaml == null) { throw new InvalidOperationException("Config alredy initialized"); } if (typeof(TSelf) != typeof(Config) && !ConfigBase.IsGeneratingConfigMarkdown && ConfigBase<Config>.Instance.UnifiedConfig.Value) { fileName = __section + "." + fileName; } string path = Path.Combine(Path.GetDirectoryName(cfg.ConfigFilePath), "ArgusMagnus.ServersideQoL"); string text = Path.Combine(path, Path.GetFileNameWithoutExtension(cfg.ConfigFilePath) + "." + fileName + ".yml"); YamlConfigEntry<T> yamlConfigEntry = new YamlConfigEntry<T>(text, new T()); if (onChanged != null) { yamlConfigEntry.ValueChanged += delegate(YamlConfigEntry<T> x) { onChanged(x.Value); }; } __yaml.Add(text, yamlConfigEntry); return yamlConfigEntry; } private static void BindYaml(IYamlConfigEntry entry) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(entry.FilePath); ISerializer val = ((BuilderSkeleton<SerializerBuilder>)(object)((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).IncludeNonPublicProperties()).WithTypeInspector<MyTypeInspector>((Func<ITypeInspector, MyTypeInspector>)((ITypeInspector x) => new MyTypeInspector(x))).DisableAliases().Build(); string text = Path.Combine(directoryName, "templates"); Directory.CreateDirectory(text); string path = Path.ChangeExtension(entry.FilePath, "default.yml"); try { File.Delete(path); } catch { } path = Path.Combine(text, Path.GetFileName(entry.FilePath)); using (StreamWriter streamWriter = new StreamWriter(path, append: false)) { streamWriter.WriteLine($"# This file contains the default values and is overwritten regularly.\r\n# Copy it to {Path.GetRelativePath(Path.GetDirectoryName(Paths.BepInExRootPath), directoryName)}{Path.DirectorySeparatorChar} if you want to change values."); streamWriter.WriteLine(); WriteYamlHeader(streamWriter); val.Serialize((TextWriter)streamWriter, entry.Value); } entry.Deserialize(); } 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"); } static ConfigBase() { string[] array = typeof(TSelf).Namespace.Split('.'); __section = ((array != null && array.Length > 1) ? array[^1] : "General"); } } public static class Extensions { [SpecialName] public sealed class <G>$6A1219195D713CAD396B57F11B80B7C7 { [SpecialName] public static class <M>$5F195870FB4F4F735FF539448C719B34 { } [ExtensionMarker("<M>$5F195870FB4F4F735FF539448C719B34")] public IEnumerable<ZNetView> ZNetViews { [ExtensionMarker("<M>$5F195870FB4F4F735FF539448C719B34")] get { throw new NotSupportedException(); } } } [SpecialName] public sealed class <G>$BA81FCECEC1CCE673EB0EC23AF67E030 { [SpecialName] public static class <M>$930EE2E3C2B4CFDE5380D43808F55582 { } [ExtensionMarker("<M>$930EE2E3C2B4CFDE5380D43808F55582")] public bool IsItem { [ExtensionMarker("<M>$930EE2E3C2B4CFDE5380D43808F55582")] get { throw new NotSupportedException(); } } } [SpecialName] public sealed class <G>$89A7D4A522B437A8B95320B2CAC6531E { [SpecialName] public static class <M>$2F506E6253043B2E979C4C9C830E560A { } [ExtensionMarker("<M>$2F506E6253043B2E979C4C9C830E560A")] public bool IsItem { [ExtensionMarker("<M>$2F506E6253043B2E979C4C9C830E560A")] get { throw new NotSupportedException(); } } } [SpecialName] public sealed class <G>$3451A0B406ED1684C74CB24CB064EFF6 { [SpecialName] public static class <M>$2A74BCD5C65B9D7F2034D655A517DCF7 { } [ExtensionMarker("<M>$2A74BCD5C65B9D7F2034D655A517DCF7")] public bool IsItem { [ExtensionMarker("<M>$2A74BCD5C65B9D7F2034D655A517DCF7")] 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 IEnumerable<ZNetView> get_ZNetViews(ZNetScene instance) { return from x in ((IEnumerable<GameObject>)instance.m_prefabs).Select((Func<GameObject, ZNetView>)delegate(GameObject x) { ZNetView component = x.GetComponent<ZNetView>(); if (component == null) { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogWarning("GameObject '" + ((Object)x).name + "' was added to ZNetScene.instance.m_prefabs by another mod but is missing the ZNetView component"); return (ZNetView)null; } return component; }) where x != null select x; } public static bool get_IsItem(SharedData sharedData) { Sprite[] icons = sharedData.m_icons; if (icons != null) { return icons.Length > 0; } return false; } public static bool get_IsItem(ItemData itemData) { return get_IsItem(itemData.m_shared); } public static bool get_IsItem(ItemDrop itemDrop) { return get_IsItem(itemDrop.m_itemData); } } 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 LogDiagnostic(LogLevel level, object data) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.Config.DiagnosticLogs.Value) { Log(level, 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); } public void LogDiagnosticFatal(object data) { LogDiagnostic((LogLevel)1, data); } public void LogDiagnosticError(object data) { LogDiagnostic((LogLevel)2, data); } public void LogDiagnosticWarning(object data) { LogDiagnostic((LogLevel)4, data); } public void LogDiagnosticMessage(object data) { LogDiagnostic((LogLevel)8, data); } public void LogDiagnosticInfo(object data) { LogDiagnostic((LogLevel)16, data); } public void LogDiagnosticDebug(object data) { LogDiagnostic((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(); } } 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 GetComponent<T>() ?? throw new InvalidOperationException("Prefab " + PrefabName + " does not have required component " + typeof(T).Name); } public TPrefabInfo? GetProcessorPrefabInfo<TPrefabInfo>() where TPrefabInfo : notnull, ProcessorPrefabInfo { return this.GetExtension<IProcessorPrefabInfo<TPrefabInfo>>().PrefabInfo; } [Conditional("DEBUG")] public void AssertHasProcessorPrefabInfo<TPrefabInfo>() where TPrefabInfo : notnull, ProcessorPrefabInfo { } } 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 PrivateAccessor { private const BindingFlags AccessFlags = BindingFlags.Public | BindingFlags.NonPublic; [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>, bool, GameObject> <SpawnLocationFunc>k__BackingField; 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>, bool, GameObject> SpawnLocationFunc { get { Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, bool, 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[7]; 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>))); ParameterExpression parameterExpression8 = (ParameterExpression)(array[6] = Expression.Parameter(typeof(bool))); func = (<SpawnLocationFunc>k__BackingField = Expression.Lambda<Func<ZoneSystem, ZoneLocation, int, Vector3, Quaternion, SpawnMode, List<GameObject>, bool, GameObject>>(Expression.Call(parameterExpression, method, array), new ParameterExpression[8] { parameterExpression, parameterExpression2, parameterExpression3, parameterExpression4, parameterExpression5, parameterExpression6, parameterExpression7, parameterExpression8 }).Compile()); } return func; } } [Obsolete(null, true)] public static int ZSyncAnimationZDOSalt => 438569; [Obsolete(null, true)] public static int CharacterAnimationHashEncumbered => Character.s_encumbered; [Obsolete(null, true)] public static int CharacterAnimationHashInWater => Character.s_inWater; [Obsolete(null, true)] public static int PlayerAnimationHashCrouching => Player.s_crouching; [Obsolete(null, true)] public static Dictionary<ZDOID, ZDO>.ValueCollection GetObjects(ZDOMan instance) { return instance.m_objectsByID.Values; } public static IReadOnlyDictionary<string, string> GetStrings(this Localization instance) { return GetLocalizationStrings(instance); } [Obsolete(null, true)] public static RandomEvent? GetCurrentEvent(RandEventSystem instance) { return GetCurrentEventFunc(instance); } [Obsolete(null, true)] public static IReadOnlyDictionary<int, ZoneLocation> GetLocationsByHash(ZoneSystem instance) { return GetLocationsByHashFunc(instance); } public static Location GetAndLoadLocationByHash(this ZoneSystem instance, int hash) { if (!instance.m_locationsByHash.TryGetValue(hash, out var value)) { return default(Location); } return new Location(value); } [Obsolete(null, true)] public static GameObject SpawnLocation(ZoneSystem instance, ZoneLocation location, int seed, Vector3 pos, Quaternion rot, SpawnMode mode, List<GameObject>? spawnedGhostObjects = null, bool cheated = false) { //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>(), cheated); } [Obsolete(null, true)] public static void SendGlobalKeys(ZoneSystem instance, long peerID) { instance.SendGlobalKeys(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 bool ReinitializeOnConfigChanged { get; init; } = true; 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, [Obsolete("Use ScheduleReprocessing() instead")] ScheduleReprocessing = 0x20, ReregisterOnRecreated = 0x40 } [Flags] public enum CreatorMarkers : uint { None = 0u, DataZDO = 1u, ProcessorOwned = 2u } [Obsolete("For internal use only", false)] public abstract class ServerVarCore<T> : ServerVar<T> { private static readonly int __serverVarHash = StringExtensionMethods.GetStableHashCode("ArgusMagnus.ServersideQoL.ServerVars" + typeof(T).Name); private static HashSet<int>? __serverVars; protected readonly int _hash; private bool _usageSaved; private protected ServerVarCore(string name) { _hash = StringExtensionMethods.GetStableHashCode(name); } protected abstract void SetCore(ServersideQoLZDO zdo, T value); public sealed override void Set(ServersideQoLZDO zdo, T value) { if (!_usageSaved) { _usageSaved = true; if (__serverVars == null) { __serverVars = new HashSet<int>(); ServersideQoLZDO? _dataZDO = __dataZDO; byte[] array = ((_dataZDO != null) ? _dataZDO.ZDO.GetByteArray(__serverVarHash, (byte[])null) : null); if (array != null && array.Length > 0) { Span<int> span = MemoryMarshal.Cast<byte, int>(array.AsSpan()); for (int i = 0; i < span.Length; i++) { int item = span[i]; __serverVars.Add(item); } } } if (__serverVars.Add(_hash)) { byte[] array2 = new byte[__serverVars.Count * 4]; Span<int> span2 = MemoryMarshal.Cast<byte, int>(array2.AsSpan()); foreach (int _serverVar in __serverVars) { span2[0] = _serverVar; span2 = span2.Slice(1); } DataZDO.ZDO.Set(__serverVarHash, array2); } } SetCore(zdo, value); } internal static HashSet<int>? GetVars() { if (__serverVars == null) { ServersideQoLZDO? _dataZDO = __dataZDO; byte[] array = ((_dataZDO != null) ? _dataZDO.ZDO.GetByteArray(__serverVarHash, (byte[])null) : null); if (array != null && array.Length > 0) { __serverVars = new HashSet<int>(); Span<int> span = MemoryMarshal.Cast<byte, int>(array.AsSpan()); for (int i = 0; i < span.Length; i++) { int item = span[i]; __serverVars.Add(item); } } } return __serverVars; } } 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(x.RefPos, zone))) { _zoneRoots.RemoveAt(num); Object.Destroy((Object)(object)val); } } __nextCleanup = DateTimeOffset.UtcNow.AddSeconds(2.0); } } private static ServersideQoLZDO? __dataZDO; private static bool __enableProcessingTimeMonitoring; private Stopwatch? _processingTimeStopwatch; private static readonly int __oldPluginGuidHash = StringExtensionMethods.GetStableHashCode("argusmagnus.ServersideQoL"); private static readonly ServerVar<Guid> __processorIdVar = ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.RegisterServerVar<Guid>("ProcessorId"); [CompilerGenerated] private static IReadOnlyDictionary<Biome, Character> <BossesByBiome>k__BackingField; [CompilerGenerated] private static IReadOnlyList<(Character Boss, Biome Biome)> <BossesInOrder>k__BackingField; private static List<Predicate<ItemData>>? __isItemTeleportableEvaluationRequest; internal const ProcessResult ScheduleReprocessingConst = ProcessResult.ScheduleReprocessing; internal ProcessorAttribute Attribute { get; } internal IServersideQoLPlugin Plugin { get; private set; } protected Logger Logger { get; private set; } protected HashSet<ServersideQoLZDO> PlacedObjects { get; } = new HashSet<ServersideQoLZDO>(); internal float ScheduleReprocessingDelay { get; private set; } internal bool HasPreProcessor { get; private set; } = true; protected static IReadOnlyDictionary<string, PieceTable> PieceTablesByPieceName => ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.PieceTablesByPieceName; protected internal static IReadOnlyDictionary<Biome, Character> BossesByBiome => <BossesByBiome>k__BackingField ?? (<BossesByBiome>k__BackingField = ((Func<IReadOnlyDictionary<Biome, Character>>)delegate { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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) { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogWarning($"Loading location asset {location.m_prefabName} failed: {arg}"); continue; } GameObject asset = location.m_prefab.Asset; if (asset == null) { ServersideQoLPluginBaseCore<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) { Character boss = componentInChildren.m_bossPrefab.GetComponent<Character>(); if (boss.m_bossOrder < 1) { if (!string.IsNullOrEmpty(boss.m_bossEvent)) { boss = ZNetScene.instance.m_prefabs.Select((GameObject x) => x.GetComponent<Character>()).FirstOrDefault((Func<Character, bool>)((Character x) => x != null && x.m_bossOrder > 0 && x.m_bossEvent == boss.m_bossEvent)) ?? boss; } if (boss.m_bossOrder < 1) { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogWarning(string.Format("Boss {0}: Invalid {1}: {2}", ((Object)boss).name, "m_bossOrder", boss.m_bossOrder)); } } ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogDiagnosticInfo(string.Format("Boss found in {0}: {1} ({2}: {3})", location.m_biome, ((Object)boss).name, "m_bossOrder", boss.m_bossOrder)); dictionary.Add(location.m_biome, boss); } } } } } return dictionary; })()); protected internal static IReadOnlyList<(Character Boss, Biome Biome)> BossesInOrder { get { IReadOnlyList<(Character Boss, Biome Biome)> readOnlyList = <BossesInOrder>k__BackingField; if (readOnlyList == null) { List<(Character, Biome)> list = new List<(Character, Biome)>(); list.AddRange(from x in BossesByBiome orderby x.Value.m_bossOrder select (Value: x.Value, Key: x.Key)); readOnlyList = (<BossesInOrder>k__BackingField = new <>z__ReadOnlyList<(Character, Biome)>(list)); } return readOnlyList; } } protected static ServersideQoLZDO DataZDO { get { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (__dataZDO == null) { int sconce = Prefabs.Sconce; __dataZDO = ZDOMan.instance.CreateNewZDO(new Vector3(105000f, -1000f, 105000f), sconce).ServersideQoLZDO; __dataZDO.ZDO.SetPrefab(sconce); __dataZDO.ZDO.Persistent = true; __dataZDO.ZDO.Distant = false; __dataZDO.ZDO.Type = (ObjectType)0; __dataZDO.SetModAsCreator(CreatorMarkers.DataZDO); __dataZDO.Vars.SetHealth(-1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 263); __dataZDO.PrefabInfo = ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.GetPrefabInfo(sconce); __dataZDO.Fields<Piece>().Set(() => (Piece x) => x.m_canBeRemoved, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 265); __dataZDO.Fields<WearNTear>().Set(() => (WearNTear x) => x.m_noRoofWear, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 267).Set(() => (WearNTear x) => x.m_noSupportWear, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 268) .Set(() => (WearNTear x) => x.m_health, -1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 269); __dataZDO.UnregisterAll(); } return __dataZDO; } } internal event Action<Processor>? ReinitializationRequested; protected static event Predicate<ItemData>? IsItemTeleportableEvaluationRequest { add { if (value != null) { (__isItemTeleportableEvaluationRequest ?? (__isItemTeleportableEvaluationRequest = new List<Predicate<ItemData>>())).Add(value); } } remove { if (value != null) { List<Predicate<ItemData>> _isItemTeleportableEvaluationRequest = __isItemTeleportableEvaluationRequest; if (_isItemTeleportableEvaluationRequest != null && _isItemTeleportableEvaluationRequest.Count > 0) { __isItemTeleportableEvaluationRequest.Remove(value); } } } } private protected Processor() { Attribute = GetType().GetCustomAttribute<ProcessorAttribute>() ?? throw new Exception("Required ProcessorAttribute missing on type " + GetType().FullName); } internal void Init(IServersideQoLPlugin plugin, Logger logger) { Plugin = plugin; Logger = logger; ValidateProcessor(); } private protected abstract void ValidateProcessor(); private protected abstract bool InitializePrefabInfo(PrefabInfo prefabInfo); internal bool InitializePrefabInfoInternal(PrefabInfo prefabInfo) { return InitializePrefabInfo(prefabInfo); } private protected abstract void AddPrefabInfoInterface(TypeExtensionBuilder<IPrefabInfo, PrefabInfo> prefabInfoBuilder); internal void AddPrefabInfoInterfaceInternal(TypeExtensionBuilder<IPrefabInfo, PrefabInfo> prefabInfoBuilder) { AddPrefabInfoInterface(prefabInfoBuilder); } protected void RequestReinitialization() { this.ReinitializationRequested?.Invoke(this); } public static T Instance<T>() where T : Processor, new() { return InstanceCache<T>.Instance; } public static Processor? Instance(Guid id) { if (!ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.Processors.TryGetValue(id, out Processor value)) { return null; } return value; } internal static void StaticInitialize() { if (__enableProcessingTimeMonitoring = ConfigBase<Config>.Instance.DiagnosticLogs.Value) { foreach (Processor value in ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.Processors.Values) { Processor processor = value; if (processor._processingTimeStopwatch == null) { processor._processingTimeStopwatch = new Stopwatch(); } } } __dataZDO = null; foreach (ServersideQoLZDO item in ZDOMan.instance.m_objectsByID.Values.Select((ZDO x) => x.ServersideQoLZDO)) { if (!item.IsModCreator(out var marker)) { if ((int)item.Vars.GetCreator().Value == __oldPluginGuidHash) { item.Destroy(); } continue; } if (marker == CreatorMarkers.None) { item.Destroy(); continue; } if ((marker & CreatorMarkers.DataZDO) != CreatorMarkers.None) { if (__dataZDO == null) { __dataZDO = item; } else { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Logger.LogError("More then one DataZDO found, destroying the second one"); item.Destroy(); } } if ((marker & CreatorMarkers.ProcessorOwned) == 0) { continue; } Processor processor2 = Instance(__processorIdVar.Get(item)); if (processor2 != null) { processor2.PlacedObjects.Add(item); item.Destroyed += processor2.OnPlacedObjectDestroyed; if (processor2.ClaimExclusive(item)) { item.ExclusivityCheckDone = true; item.ExclusivelyClaimedBy = processor2; item.UnregisterAllExcept(processor2); } } } } internal static void StaticPreProcess(PeersEnumerable peers) { HeightmapUtils.CleanUp(peers); } protected internal virtual void Initialize() { } protected void ScheduleReprocessing(ServersideQoLZDO zdo, float delayInSeconds = 0f) { ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.ScheduleReprocessing(zdo, delayInSeconds); } protected ProcessResult ScheduleReprocessing(float delayInSeconds = 0f) { ScheduleReprocessingDelay = delayInSeconds; return ProcessResult.ScheduleReprocessing; } private protected abstract ProcessResult Process(IReadOnlyList<Peer> peers, ServersideQoLZDO zdo); protected virtual void PreProcess(PeersEnumerable peers) { HasPreProcessor = false; } internal ProcessResult ProcessInternal(IReadOnlyList<Peer> peers, ServersideQoLZDO zdo) { if (!__enableProcessingTimeMonitoring) { return Process(peers, zdo); } _processingTimeStopwatch.Start(); ProcessResult result = Process(peers, zdo); _processingTimeStopwatch.Stop(); return result; } internal void PreProcessInternal(PeersEnumerable peers) { if (!__enableProcessingTimeMonitoring) { PreProcess(peers); return; } _processingTimeStopwatch.Start(); PreProcess(peers); _processingTimeStopwatch.Stop(); } internal float GetAndResetProcessingTimeMs() { if (_processingTimeStopwatch == null) { return -1f; } float result = (float)_processingTimeStopwatch.Elapsed.TotalMilliseconds; _processingTimeStopwatch.Reset(); return result; } protected internal virtual bool ClaimExclusive(ServersideQoLZDO zdo) { return PlacedObjects.Contains(zdo); } protected static bool CheckMinDistance(IReadOnlyList<Peer> peers, ServersideQoLZDO zdo, float minDistance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) minDistance *= minDistance; foreach (Peer item in peers.Enumerate()) { if (Utils.DistanceSqr(item.RefPos, zdo.ZDO.GetPosition()) < minDistance) { return false; } } return true; } protected static PrefabInfo GetPrefabInfo(int prefab) { return ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.GetPrefabInfo(prefab); } protected static PrefabInfo GetPrefabInfo(ServersideQoLZDO zdo) { return zdo.PrefabInfo ?? (zdo.PrefabInfo = ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.GetPrefabInfo(zdo.ZDO.GetPrefab())); } protected static ServersideQoLZDO Spawn(int prefab, Vector3 pos, Quaternion rot, long owner = 0L) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) ZDO val = ZDOMan.instance.CreateNewZDO(pos, prefab); val.SetPrefab(prefab); val.Persistent = true; val.Distant = false; val.Type = (ObjectType)0; val.SetRotation(rot); val.SetOwnerInternal(owner); val.ServersideQoLZDO.PrefabInfo = ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.GetPrefabInfo(prefab); return val.ServersideQoLZDO; } private void OnPlacedObjectDestroyed(ServersideQoLZDO zdo) { PlacedObjects.Remove(zdo); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, float rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PlaceObject(pos, prefab, rot, CreatorMarkers.None); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, float rot, CreatorMarkers marker) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PlaceObject(pos, prefab, rot, marker, 0L); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, float rot, CreatorMarkers marker, long owner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return PlaceObject(pos, prefab, Quaternion.Euler(0f, rot, 0f), marker, owner); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return PlaceObject(pos, prefab, rot, CreatorMarkers.None); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, Quaternion rot, CreatorMarkers marker) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return PlaceObject(pos, prefab, rot, marker, 0L); } protected ServersideQoLZDO PlaceObject(Vector3 pos, int prefab, Quaternion rot, CreatorMarkers marker, long owner) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) ServersideQoLZDO serversideQoLZDO = ZDOMan.instance.CreateNewZDO(pos, prefab).ServersideQoLZDO; serversideQoLZDO.ZDO.SetPrefab(prefab); serversideQoLZDO.ZDO.Persistent = true; serversideQoLZDO.ZDO.Distant = false; serversideQoLZDO.ZDO.Type = (ObjectType)0; serversideQoLZDO.ZDO.SetRotation(rot); serversideQoLZDO.SetModAsCreator(marker); serversideQoLZDO.Vars.SetHealth(-1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 377); if (marker.HasFlag(CreatorMarkers.ProcessorOwned)) { __processorIdVar.Set(serversideQoLZDO, Attribute.Id); } serversideQoLZDO.ZDO.SetOwnerInternal(owner); serversideQoLZDO.PrefabInfo = ServersideQoLPluginBaseCore<ServersideQoLPlugin, Config>.Instance.GetPrefabInfo(prefab); PlacedObjects.Add(serversideQoLZDO); serversideQoLZDO.Destroyed += OnPlacedObjectDestroyed; if (ClaimExclusive(serversideQoLZDO)) { serversideQoLZDO.ExclusivityCheckDone = true; serversideQoLZDO.ExclusivelyClaimedBy = this; serversideQoLZDO.UnregisterAllExcept(this); } return serversideQoLZDO; } protected ServersideQoLZDO PlacePiece(Vector3 pos, int prefab, float rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PlacePiece(pos, prefab, rot, CreatorMarkers.None); } protected ServersideQoLZDO PlacePiece(Vector3 pos, int prefab, float rot, CreatorMarkers marker) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return PlacePiece(pos, prefab, Quaternion.Euler(0f, rot, 0f), marker); } protected ServersideQoLZDO PlacePiece(Vector3 pos, int prefab, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return PlacePiece(pos, prefab, rot, CreatorMarkers.None); } protected ServersideQoLZDO PlacePiece(Vector3 pos, int prefab, Quaternion rot, CreatorMarkers marker) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) ServersideQoLZDO serversideQoLZDO = PlaceObject(pos, prefab, rot, marker, 0L); serversideQoLZDO.Fields<Piece>().Set(() => (Piece x) => x.m_canBeRemoved, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 407); serversideQoLZDO.Fields<WearNTear>().Set(() => (WearNTear x) => x.m_noRoofWear, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 409).Set(() => (WearNTear x) => x.m_noSupportWear, value: false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 410) .Set(() => (WearNTear x) => x.m_health, -1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL\\Processor.cs", 411); return serversideQoLZDO; } protected ServersideQoLZDO RecreatePiece(ServersideQoLZDO zdo) { if (!PlacedObjects.Remove(zdo)) { throw new ArgumentException(); } zdo.Destroyed -= OnPlacedObjectDestroyed; PlacedObjects.Add(zdo = zdo.Recreate()); zdo.Destroyed += OnPlacedObjectDestroyed; return zdo; } protected void DestroyObject(ServersideQoLZDO zdo) { if (!TryDestroyObject(zdo)) { throw new ArgumentException("ZDO (" + GetPrefabInfo(zdo).PrefabName + ") not found in PlacedObjects."); } } protected bool TryDestroyObject(ServersideQoLZDO zdo) { if (!PlacedObjects.Remove(zdo)) { return false; } zdo.Destroyed -= OnPlacedObjectDestroyed; zdo.Destroy(); return true; } protected static Heightmap GetHeightmap(Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Heightmap.FindHeightmap(pos) ?? HeightmapUtils.CreateHeightmap(pos); } protected static Biome GetBiome(Vector3 pos) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) return GetHeightmap(pos).GetBiome(pos, 0.02f, false); } protected static float GetHeight(Vector3 pos) { //IL_0000: 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 GetHeightmap(pos).GetHeight(pos); } protected static string ConvertToRegexPattern(string searchPattern) { searchPattern = Regex.Escape(searchPattern); searchPattern = searchPattern.Replace("\\*", ".*").Replace("\\?", ".?"); return "(?i)^" + searchPattern + "$"; } protected static void ForceSend(ServersideQoLZDO zdo) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ZDOMan.instance.ForceSendZDO(zdo.ZDO.m_uid); } protected static void ForceSend(Peer peer, ServersideQoLZDO zdo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ZDOMan.instance.ForceSendZDO(peer.ZNetPeer.m_uid, zdo.ZDO.m_uid); } protected static bool IsItemTeleportable(ItemData item) { if (item.m_shared.m_teleportable || ZoneSystem.instance.GetGlobalKey((GlobalKeys)35)) { return true; } List<Predicate<ItemData>> _isItemTeleportableEvaluationRequest = __isItemTeleportableEvaluationRequest; if (_isItemTeleportableEvaluationRequest != null && _isItemTeleportableEvaluationRequest.Count > 0) { foreach (Predicate<ItemData> item2 in __isItemTeleportableEvaluationRequest) { if (item2(item)) { return true; } } } return false; } protected static bool HasNonTeleportableItem(IEnumerable<ItemData> items) { foreach (ItemData item in items) { if (!IsItemTeleportable(item)) { return true; } } return false; } protected static void ShowMessage(IEnumerable<Peer> peers, Vector3 pos, string message, MessageTypes type, TextType inWorldTextType = (TextType)0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) switch (type) { default: return; case MessageTypes.TopLeftNear: case MessageTypes.CenterNear: case MessageTypes.InWorld: peers = peers.Where((Peer x) => Vector3.Distance(x.RefPos, pos) <= DamageText.instance.m_maxTextDistance); break; case MessageTypes.TopLeftFar: case MessageTypes.CenterFar: peers = peers.Where((Peer x) => Vector3.Distance(x.RefPos, pos) <= ConfigBase<Config>.Instance.FarMessageRange.Value); break; } bool flag; switch (type) { case MessageTypes.InWorld: RPC.ShowInWorldText(peers.Select((Peer x) => x.ZNetPeer.m_uid), inWorldTextType, pos, StringExtensionMethods.RemoveRichTextTags(message)); return; case MessageTypes.TopLeftNear: case MessageTypes.TopLeftFar: flag = true; break; default: flag = false; break; } MessageType type2 = (MessageType)(flag ? 1 : 2); foreach (Peer peer in peers) { RPC.ShowMessage(peer.ZNetPeer.m_uid, type2, message); } } protected static void ShowMessage(IEnumerable<Peer> peers, ServersideQoLZDO zdo, string message, MessageTypes type, TextType inWorldTextType = (TextType)0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ShowMessage(peers, zdo.ZDO.GetPosition(), message, type, inWorldTextType); } [Conditional("DEBUG")] protected static void DevShowMessage(ServersideQoLZDO zdo, string message, TextType type = (TextType)0, [CallerFilePath] string callerFile = null, [CallerLineNumber] int callerLineNo = 0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) RPC.ShowInWorldText(new <>z__ReadOnlySingleElementList<long>(0L), type, zdo.ZDO.GetPosition(), $"{Path.GetFileNameWithoutExtension(callerFile)} L{callerLineNo}: {message}"); } protected internal static (int Width, int Height) GetInventorySize(int slots, bool exact) { int num; int num3; if (exact) { num = 1; for (int num2 = Math.Min(8, slots); num2 > 1; num2--) { if (slots % num2 == 0) { num = num2; break; } } num3 = slots / num; } else { int num4 = ((slots < 16) ? ((slots < 4) ? 1 : ((slots >= 9) ? 3 : 2)) : ((slots <= 32) ? 4 : 0)); num3 = num4; if (num3 > 0) { num = (slots + num3 - 1) / num3; } else { num = 8; num3 = (slots + num - 1) / num; } } return (Width: num, Height: num3); } } public abstract class Processor<TPrefabInfo> : Processor where TPrefabInfo : notnull, ProcessorPrefabInfo { private readonly ConstructorInfo? _prefabInfoCtor; private readonly ParameterInfo[]? _prefabInfoCtorParameters; private readonly bool?[]? _prefabInfoCtorParametersNullable; protected Processor() { ConstructorInfo[] constructors = typeof(TPrefabInfo).GetConstructors(); if (constructors != null && constructors.Length == 1) { _prefabInfoCtor = constructors[0]; _prefabInfoCtorParameters = _prefabInfoCtor.GetParameters(); _prefabInfoCtorParametersNullable = new bool?[_prefabInfoCtorParameters.Length]; } } private protected override void AddPrefabInfoInterface(TypeExtensionBuilder<IPrefabInfo, PrefabInfo> prefabInfoBuilder) { prefabInfoBuilder.AddInterface<IProcessorPrefabInfo<TPrefabInfo>>(); } private protected override bool InitializePrefabInfo(PrefabInfo prefabInfo) { IProcessorPrefabInfo<TPrefabInfo> extension = prefabInfo.GetExtension<IProcessorPrefabInfo<TPrefabInfo>>(); if ((object)extension.PrefabInfo == null) { try { extension.PrefabInfo = CreateProcessorPrefabInfo(