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 AdminBuildOptions BETA v1.99.8
ServersideQoL.AdminBuildOptions.dll
Decompiled 10 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; [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("Gives admins the ability to change various build/landscaping options for themselves")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL.AdminBuildOptions")] [assembly: AssemblyTitle("ServersideQoL.AdminBuildOptions")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("1.99.8.0")] [module: RefSafetyRules(11)] [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(); } } 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.AdminBuildOptions { [BepInPlugin("ArgusMagnus.ServersideQoL.AdminBuildOptions", "ServersideQoL.AdminBuildOptions", "1.99.8")] public sealed class AdminBuildOptionsPlugin : ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config> { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.AdminBuildOptions"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.AdminBuildOptions"; public const string PluginVersion = "1.99.8"; public const string PluginInformationalVersion = "1.99.8-beta"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507745126410L, default(TimeSpan)); protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger) { return new Config(configFile, logger); } protected override void RegisterProcessors(IProcessorCollection processors) { processors.Add<PlayerProcessor>().Add<WearNTearProcessor>(); } private void Awake() { ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config>.Logger.LogWarning((object)string.Format("You are running a pre-release version: {0} ({1})", "1.99.8-beta", BuildTimestamp.LocalDateTime)); } } public sealed class Config : ConfigBase<Config> { public sealed class LocalizationConfig { } public sealed class AdvancedConfig { public float ResetTerrainRadius { get; init; } = 3f; } private const string Section = "AdminBuildOptions"; public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx<bool>(cfg, "AdminBuildOptions", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated<Config>)null, "Enabled"); public ConfigEntry<Emotes> ToggleDisableRainDamageEmote { get; } public ConfigEntry<Emotes> ToggleDisableSupportRequirements { get; } public ConfigEntry<Emotes> ToggleMakeIndestructible { get; } public ConfigEntry<Emotes> ToggleNoWorkbench { get; } public ConfigEntry<Emotes> ToggleDungeonBuild { get; } public ConfigEntry<Emotes> ToggleNoBuildCost { get; } public ConfigEntry<Emotes> ToggleAllPiecesUnlocked { get; } public ConfigEntry<Emotes> CycleLevelGroundMode { get; } public YamlConfigEntry<LocalizationConfig> Localization { get; } public YamlConfigEntry<AdvancedConfig> Advanced { get; } public Config(ConfigFile cfg, Logger logger) { string text = $"Emote admins can use to toggle disabling rain damage for newly built pieces.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; List<Emotes> list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleDisableRainDamageEmote = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleDisableRainDamageEmote"); string text2 = $"Emote admins can use to toggle disabling support requirements for newly built pieces.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleDisableSupportRequirements = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text2, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleDisableSupportRequirements"); string text3 = $"Emote admins can use to toggle making newly built pieces indestructible.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleMakeIndestructible = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text3, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleMakeIndestructible"); string text4 = $"Emote admins can use to toggle the workbench requirement for building.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleNoWorkbench = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text4, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleNoWorkbench"); string text5 = $"Emote admins can use to toggle building in dungeons.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleDungeonBuild = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text5, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleDungeonBuild"); string text6 = $"Emote admins can use to toggle no build cost.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleNoBuildCost = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text6, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleNoBuildCost"); string text7 = $"Emote admins can use to toggle unlocking all building pieces.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); ToggleAllPiecesUnlocked = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text7, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "ToggleAllPiecesUnlocked"); string text8 = $"Emote admins can use to cycle between different modes when using the Hoe's \"Level Ground\" option.\r\n{(object)(Emotes)(-1)} to disable this feature, {(object)(Emotes)(-2)} to use any emote as trigger.\r\nIf you use emotes exclusively for this feature, it is recommended to set the value to {(object)(Emotes)(-2)} as it is more reliably detected than specific emotes, especially on bad connection/with crossplay."; list = new List<Emotes>(); list.Add((Emotes)(-1)); list.Add((Emotes)(-2)); list.AddRange(Enum.GetValues(typeof(Emotes)).Cast<Emotes>()); CycleLevelGroundMode = ConfigBase<Config>.BindEx<Emotes>(cfg, "AdminBuildOptions", (Emotes)(-1), text8, (AcceptableValueBase)(object)new AcceptableEnum<Emotes>((IEnumerable<Emotes>)new <>z__ReadOnlyList<Emotes>(list)), (Deprecated<Config>)null, "CycleLevelGroundMode"); Localization = ConfigBase<Config>.BindYaml<LocalizationConfig>(cfg, "Localization"); Advanced = ConfigBase<Config>.BindYaml<AdvancedConfig>(cfg, "Advanced"); base..ctor(cfg, logger); } } [Processor("fff17191-3ccc-4b56-9aa0-03e1c38b4175")] [RunAfter<PlayerRegistryProcessor>] public sealed class PlayerProcessor : Processor<PlayerProcessor.PrefabInfo> { public sealed record PrefabInfo(Player? Player, CamShaker? CamShaker) : ProcessorPrefabInfo() { public override bool IsValid { get { if (Player == null) { return ((ProcessorPrefabInfo)this).PrefabInfo.PrefabHash == __mudRoadPrefab; } return true; } } private static readonly int __mudRoadPrefab = StringExtensionMethods.GetStableHashCode("vfx_Place_mud_road", true); [CompilerGenerated] public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("PrefabInfo"); stringBuilder.Append(" { "); if (((ProcessorPrefabInfo)this).PrintMembers(stringBuilder)) { stringBuilder.Append(' '); } stringBuilder.Append('}'); return stringBuilder.ToString(); } [CompilerGenerated] protected override bool PrintMembers(StringBuilder builder) { if (((ProcessorPrefabInfo)this).PrintMembers(builder)) { builder.Append(", "); } builder.Append("Player = "); builder.Append(Player); builder.Append(", CamShaker = "); builder.Append(CamShaker); return true; } [CompilerGenerated] public override int GetHashCode() { return (((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<Player>.Default.GetHashCode(Player)) * -1521134295 + EqualityComparer<CamShaker>.Default.GetHashCode(CamShaker); } [CompilerGenerated] public sealed override bool Equals(ProcessorPrefabInfo? other) { return ((object)this).Equals((object?)other); } [CompilerGenerated] public bool Equals(PrefabInfo? other) { if ((object)this != other) { if (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other) && EqualityComparer<Player>.Default.Equals(Player, other.Player)) { return EqualityComparer<CamShaker>.Default.Equals(CamShaker, other.CamShaker); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { Player = original.Player; CamShaker = original.CamShaker; } } [Flags] public enum BuildModifiers : uint { None = 0u, DisableRainDamage = 1u, DisableSupportRequirements = 2u, MakeIndestructible = 4u, NoWorkbench = 8u, DungeonBuild = 0x10u, NoBuildCost = 0x20u, AllPiecesUnlocked = 0x40u } public enum LevelGroundModes { Default, FlattenMedium, FlattenLarge, Reset } private sealed class State(PlayerState playerState) { public PlayerState PlayerState { get; } = playerState; public BuildModifiers BuildModifiers { get; set; } public LevelGroundModes LevelGroundMode { get; set; } public Timestamp NextBuildModifierMessage { get; set; } public Timestamp NextLevelGroundModeMessage { get; set; } } private sealed class TerrainCompData { private const int TerrainCompVersion = 1; private readonly ServersideQoLZDO _zdo; private readonly Heightmap _hmap; private bool[]? _modifiedHeight; private float[] _levelDelta; private float[] _smoothDelta; private bool[] _modifiedPaint; private Color[] _paintMask; private int _operations; private Vector3 _lastOpPoint; private float _lastOpRadius; public bool? HasModifications { get; private set; } public static TerrainCompData? Load(ServersideQoLZDO zdo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Heightmap heightmap = Processor.GetHeightmap(zdo.ZDO.GetPosition()); if (heightmap == null) { ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config>.Logger.LogWarning((object)$"Heightmap not found at {zdo.ZDO.GetPosition()}"); return null; } return new TerrainCompData(zdo, heightmap); } private TerrainCompData(ServersideQoLZDO zdo, Heightmap hmap) { _zdo = zdo; _hmap = hmap; } [MemberNotNullWhen(true, "_modifiedHeight")] private bool Load() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) if (_modifiedHeight != null) { return true; } byte[] byteArray = _zdo.ZDO.GetByteArray(ZDOVars.s_TCData, (byte[])null); if (byteArray == null) { return false; } int num = _hmap.m_width + 1; num *= num; ZPackage val = new ZPackage(Utils.Decompress(byteArray)); if (val.ReadInt() != 1) { ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config>.Logger.LogWarning((object)"Terrain data load error, version missmatch"); return false; } _operations = val.ReadInt(); _lastOpPoint = val.ReadVector3(); _lastOpRadius = val.ReadSingle(); int num2 = val.ReadInt(); if (num2 != num) { ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config>.Logger.LogWarning((object)"Terrain data load error, height array missmatch"); return false; } _modifiedHeight = new bool[num]; _levelDelta = new float[num]; _smoothDelta = new float[num]; _modifiedPaint = new bool[num]; _paintMask = (Color[])(object)new Color[num]; HasModifications = false; for (int i = 0; i < num2; i++) { _modifiedHeight[i] = val.ReadBool(); if (_modifiedHeight[i]) { _levelDelta[i] = val.ReadSingle(); _smoothDelta[i] = val.ReadSingle(); HasModifications = true; } else { _levelDelta[i] = 0f; _smoothDelta[i] = 0f; } } int num3 = val.ReadInt(); for (int j = 0; j < num3; j++) { _modifiedPaint[j] = val.ReadBool(); if (_modifiedPaint[j]) { Color val2 = new Color { r = val.ReadSingle(), g = val.ReadSingle(), b = val.ReadSingle(), a = val.ReadSingle() }; _paintMask[j] = val2; HasModifications = true; } else { _paintMask[j] = Color.black; } } if (num3 == _hmap.m_width * _hmap.m_width) { Color[] array = (Color[])(object)new Color[_paintMask.Length]; _paintMask.CopyTo(array, 0); bool[] array2 = new bool[_modifiedPaint.Length]; _modifiedPaint.CopyTo(array2, 0); int num4 = _hmap.m_width + 1; for (int k = 0; k < _paintMask.Length; k++) { int num5 = k / num4; int num6 = (k + 1) / num4; int num7 = k - num5; if (num5 == _hmap.m_width) { num7 -= _hmap.m_width; } if (k > 0 && (k - num5) % _hmap.m_width == 0 && (k + 1 - num6) % _hmap.m_width == 0) { num7--; } _paintMask[k] = array[num7]; _modifiedPaint[k] = array2[num7]; } } return true; } private void Save() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (_modifiedHeight == null) { return; } HasModifications = false; ZPackage val = new ZPackage(); val.Write(1); val.Write(_operations); val.Write(_lastOpPoint); val.Write(_lastOpRadius); val.Write(_modifiedHeight.Length); for (int i = 0; i < _modifiedHeight.Length; i++) { val.Write(_modifiedHeight[i]); if (_modifiedHeight[i]) { val.Write(_levelDelta[i]); val.Write(_smoothDelta[i]); HasModifications = true; } } val.Write(_modifiedPaint.Length); for (int j = 0; j < _modifiedPaint.Length; j++) { val.Write(_modifiedPaint[j]); if (_modifiedPaint[j]) { val.Write(_paintMask[j].r); val.Write(_paintMask[j].g); val.Write(_paintMask[j].b); val.Write(_paintMask[j].a); HasModifications = true; } } byte[] array = Utils.Compress(val.GetArray()); _zdo.ZDO.Set(ZDOVars.s_TCData, array); } public void ResetTerrain(Vector3 pos, float radius) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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); float num3 = pos.y - _zdo.ZDO.GetPosition().y; float num4 = radius / _hmap.m_scale; int num5 = Mathf.CeilToInt(num4); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)num, (float)num2); int num6 = _hmap.m_width + 1; bool flag = false; for (int i = num2 - num5; i <= num2 + num5; i++) { for (int j = num - num5; j <= num + num5; j++) { float num7 = Vector2.Distance(val, new Vector2((float)j, (float)i)); if (!(num7 > num4) && j >= 0 && i >= 0 && j < num6 && i < num6) { if (!Load()) { return; } int num8 = i * num6 + j; _modifiedHeight[num8] = false; _smoothDelta[num8] = 0f; _levelDelta[num8] = 0f; _modifiedPaint[num8] = false; _paintMask[num8] = Color.black; flag = true; } } } if (flag) { Save(); } } } private readonly Dictionary<ServersideQoLZDO, State> _states = new Dictionary<ServersideQoLZDO, State>(); private readonly int _numberOfLevelGroundModes = Enum.GetValues(typeof(LevelGroundModes)).Length; [CompilerGenerated] private ZoneLocation <DevGround1>k__BackingField; [CompilerGenerated] private ZoneLocation <DevGround2>k__BackingField; public BuildModifiers PossibleBuildModifiers { get; private set; } private ZoneLocation DevGround1 => <DevGround1>k__BackingField ?? (<DevGround1>k__BackingField = GetZoneLocation("DevGround1")); private ZoneLocation DevGround2 => <DevGround2>k__BackingField ?? (<DevGround2>k__BackingField = GetZoneLocation("DevGround2")); private static ZoneLocation GetZoneLocation([CallerMemberName] string name = null) { return PrivateAccessor.GetLocationsByHash(ZoneSystem.instance)[StringExtensionMethods.GetStableHashCode(name, true)]; } public BuildModifiers GetBuildModifiers(long playerId) { PlayerState stateForPlayerID = Processor.Instance<PlayerRegistryProcessor>().GetStateForPlayerID(playerId); if (stateForPlayerID == null || !_states.TryGetValue(stateForPlayerID.ZDO, out State value)) { return BuildModifiers.None; } return value.BuildModifiers; } protected override void Initialize() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Invalid comparison between Unknown and I4 //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Invalid comparison between Unknown and I4 PossibleBuildModifiers = BuildModifiers.None; if ((int)ConfigBase<Config>.Instance.ToggleDisableRainDamageEmote.Value != -1) { PossibleBuildModifiers |= BuildModifiers.DisableRainDamage; } if ((int)ConfigBase<Config>.Instance.ToggleDisableSupportRequirements.Value != -1) { PossibleBuildModifiers |= BuildModifiers.DisableSupportRequirements; } if ((int)ConfigBase<Config>.Instance.ToggleMakeIndestructible.Value != -1) { PossibleBuildModifiers |= BuildModifiers.MakeIndestructible; } if ((int)ConfigBase<Config>.Instance.ToggleNoWorkbench.Value != -1) { PossibleBuildModifiers |= BuildModifiers.NoWorkbench; } if ((int)ConfigBase<Config>.Instance.ToggleDungeonBuild.Value != -1) { PossibleBuildModifiers |= BuildModifiers.DungeonBuild; } if ((int)ConfigBase<Config>.Instance.ToggleNoBuildCost.Value != -1) { PossibleBuildModifiers |= BuildModifiers.NoBuildCost; } if ((int)ConfigBase<Config>.Instance.ToggleAllPiecesUnlocked.Value != -1) { PossibleBuildModifiers |= BuildModifiers.AllPiecesUnlocked; } Processor.Instance<PlayerRegistryProcessor>().EmoteDetected += OnEmoteDetected; } protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) State value; Timestamp now; ZDOVars vars; if (prefabInfo.Player != null) { if (!_states.TryGetValue(zdo, out value)) { PlayerState state = Processor.Instance<PlayerRegistryProcessor>().GetState(zdo); if (state != null && state.IsAdmin) { return (ProcessResult)0; } return (ProcessResult)2; } now = Timestamp.Now; if (value.NextBuildModifierMessage == default(Timestamp)) { goto IL_007f; } if (value.BuildModifiers != BuildModifiers.None && value.NextBuildModifierMessage < now) { vars = zdo.Vars; if (((ZDOVars)(ref vars)).GetRightItem(0) == Prefabs.Hammer) { goto IL_007f; } } goto IL_00b7; } if ((int)ConfigBase<Config>.Instance.CycleLevelGroundMode.Value == -1) { return (ProcessResult)2; } State state2 = GetState(zdo.ZDO.GetOwner()); if (state2 == null) { return (ProcessResult)2; } if (state2.LevelGroundMode == LevelGroundModes.Reset) { List<ZDO> list = new List<ZDO>(); ZDOMan.instance.FindSectorObjects(zdo.ZDO.GetSector(), Extensions[ZoneSystem.instance], 0, list, (List<ZDO>)null); foreach (ServersideQoLZDO item in list.Select((ZDO x) => x.ServersideQoLZDO)) { PrefabInfo prefabInfo2 = Processor.GetPrefabInfo(item); if (prefabInfo2.HasComponent<LocationProxy>()) { vars = item.Vars; int location = ((ZDOVars)(ref vars)).GetLocation(0); if (Remove(item, location, zdo.ZDO.GetPosition(), DevGround1)) { _ = 1; } else Remove(item, location, zdo.ZDO.GetPosition(), DevGround2); } else { if (!prefabInfo2.HasComponent<TerrainComp>()) { continue; } TerrainCompData terrainCompData = TerrainCompData.Load(item); if (terrainCompData != null) { terrainCompData.ResetTerrain(zdo.ZDO.GetPosition(), ConfigBase<Config>.Instance.Advanced.Value.ResetTerrainRadius); if ((!terrainCompData.HasModifications) ?? false) { item.Destroy(); } } } } } else { ZoneLocation val = (ZoneLocation)(state2.LevelGroundMode switch { LevelGroundModes.FlattenMedium => DevGround1, LevelGroundModes.FlattenLarge => DevGround2, _ => null, }); if (val != null) { PrivateAccessor.SpawnLocation(ZoneSystem.instance, val, 0, zdo.ZDO.GetPosition(), zdo.ZDO.GetRotation(), (SpawnMode)0, (List<GameObject>)null); List<ZDO> list2 = new List<ZDO>(); ZDOMan.instance.FindSectorObjects(zdo.ZDO.GetSector(), Extensions[ZoneSystem.instance], 0, list2, (List<ZDO>)null); foreach (ServersideQoLZDO item2 in list2.Select((ZDO x) => x.ServersideQoLZDO)) { if (!Processor.GetPrefabInfo(item2).HasComponent<TerrainComp>()) { continue; } TerrainCompData terrainCompData2 = TerrainCompData.Load(item2); if (terrainCompData2 != null) { terrainCompData2.ResetTerrain(zdo.ZDO.GetPosition(), val.m_exteriorRadius); if ((!terrainCompData2.HasModifications) ?? false) { item2.Destroy(); } } } } } goto IL_03e7; IL_03e7: return (ProcessResult)0; IL_007f: value.NextBuildModifierMessage = ((Timestamp)(ref now)).AddSeconds(4f); RPC.ShowMessage(value.PlayerState.Owner, (MessageType)1, $"Build modifiers: {value.BuildModifiers}"); goto IL_00b7; IL_0103: value.NextLevelGroundModeMessage = ((Timestamp)(ref now)).AddSeconds(4f); RPC.ShowMessage(value.PlayerState.Owner, (MessageType)1, $"Level ground mode: {value.LevelGroundMode}"); goto IL_03e7; IL_00b7: if (value.NextLevelGroundModeMessage == default(Timestamp)) { goto IL_0103; } if (value.LevelGroundMode != LevelGroundModes.Default && value.NextLevelGroundModeMessage < now) { vars = zdo.Vars; if (((ZDOVars)(ref vars)).GetRightItem(0) == Prefabs.Hoe) { goto IL_0103; } } goto IL_03e7; static bool Remove(ServersideQoLZDO val3, int hash, Vector3 pos, ZoneLocation val2) { //IL_0009: 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) if (hash != val2.Hash || Utils.DistanceXZ(pos, val3.ZDO.GetPosition()) > val2.m_exteriorRadius) { return false; } val3.Destroy(); return true; } } private void OnEmoteDetected(PlayerState playerState, Emotes emote) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) if (!playerState.IsAdmin) { return; } if (!_states.TryGetValue(playerState.ZDO, out State value)) { _states.Add(playerState.ZDO, value = new State(playerState)); playerState.ZDO.Destroyed += delegate(ServersideQoLZDO x) { _states.Remove(x); }; } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleDisableRainDamageEmote.Value)) { value.BuildModifiers ^= BuildModifiers.DisableRainDamage; value.NextBuildModifierMessage = default(Timestamp); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleDisableSupportRequirements.Value)) { value.BuildModifiers ^= BuildModifiers.DisableSupportRequirements; value.NextBuildModifierMessage = default(Timestamp); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleMakeIndestructible.Value)) { value.BuildModifiers ^= BuildModifiers.MakeIndestructible; value.NextBuildModifierMessage = default(Timestamp); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleNoWorkbench.Value)) { value.BuildModifiers ^= BuildModifiers.NoWorkbench; value.NextBuildModifierMessage = default(Timestamp); UpdateGlobalKeyModification(value, BuildModifiers.NoWorkbench, (GlobalKeys)22); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleDungeonBuild.Value)) { value.BuildModifiers ^= BuildModifiers.DungeonBuild; value.NextBuildModifierMessage = default(Timestamp); UpdateGlobalKeyModification(value, BuildModifiers.DungeonBuild, (GlobalKeys)29); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleNoBuildCost.Value)) { value.BuildModifiers ^= BuildModifiers.NoBuildCost; value.NextBuildModifierMessage = default(Timestamp); UpdateGlobalKeyModification(value, BuildModifiers.NoBuildCost, (GlobalKeys)19); } if (CheckEmote(emote, ConfigBase<Config>.Instance.ToggleAllPiecesUnlocked.Value)) { value.BuildModifiers ^= BuildModifiers.AllPiecesUnlocked; value.NextBuildModifierMessage = default(Timestamp); UpdateGlobalKeyModification(value, BuildModifiers.AllPiecesUnlocked, (GlobalKeys)21); } if (CheckEmote(emote, ConfigBase<Config>.Instance.CycleLevelGroundMode.Value)) { value.LevelGroundMode = (LevelGroundModes)((int)(value.LevelGroundMode + 1) % _numberOfLevelGroundModes); value.NextLevelGroundModeMessage = default(Timestamp); } static bool CheckEmote(Emotes val, Emotes cfg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: 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) if ((int)cfg != -2) { return cfg == val; } return true; } static void UpdateGlobalKeyModification(State state, BuildModifiers modifier, GlobalKeys key) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) if ((state.BuildModifiers & modifier) == 0) { state.PlayerState.RemoveGlobalKeyModification(new GlobalKey(key)); } else { state.PlayerState.AddGlobalKeyModification(new GlobalKey(key), true); } } } private State? GetState(long peerID) { PlayerState stateForPeerID = Processor.Instance<PlayerRegistryProcessor>().GetStateForPeerID(peerID); if (stateForPeerID == null || !_states.TryGetValue(stateForPeerID.ZDO, out State value)) { return null; } return value; } } [Processor("256a8351-08e2-4b0f-9c71-f011c7cf846f")] [DependsOn<PlayerRegistryProcessor>] public sealed class WearNTearProcessor : Processor<WearNTearProcessor.PrefabInfo> { public sealed record PrefabInfo(WearNTear WearNTear, Piece Piece, PieceTable PieceTable) : ProcessorPrefabInfo() { [CompilerGenerated] public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("PrefabInfo"); stringBuilder.Append(" { "); if (((ProcessorPrefabInfo)this).PrintMembers(stringBuilder)) { stringBuilder.Append(' '); } stringBuilder.Append('}'); return stringBuilder.ToString(); } [CompilerGenerated] protected override bool PrintMembers(StringBuilder builder) { if (((ProcessorPrefabInfo)this).PrintMembers(builder)) { builder.Append(", "); } builder.Append("WearNTear = "); builder.Append(WearNTear); builder.Append(", Piece = "); builder.Append(Piece); builder.Append(", PieceTable = "); builder.Append(PieceTable); return true; } [CompilerGenerated] public override int GetHashCode() { return ((((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<WearNTear>.Default.GetHashCode(WearNTear)) * -1521134295 + EqualityComparer<Piece>.Default.GetHashCode(Piece)) * -1521134295 + EqualityComparer<PieceTable>.Default.GetHashCode(PieceTable); } [CompilerGenerated] public sealed override bool Equals(ProcessorPrefabInfo? other) { return ((object)this).Equals((object?)other); } [CompilerGenerated] public bool Equals(PrefabInfo? other) { if ((object)this != other) { if (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other) && EqualityComparer<WearNTear>.Default.Equals(WearNTear, other.WearNTear) && EqualityComparer<Piece>.Default.Equals(Piece, other.Piece)) { return EqualityComparer<PieceTable>.Default.Equals(PieceTable, other.PieceTable); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { WearNTear = original.WearNTear; Piece = original.Piece; PieceTable = original.PieceTable; } } private static readonly int __adminBuildModifiers = ServersideQoLPluginBase<AdminBuildOptionsPlugin, Config>.RegisterServerVar("AdminBuildModifiers"); protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) PlayerProcessor.BuildModifiers adminBuildModifiers = GetAdminBuildModifiers(zdo, (PlayerProcessor.BuildModifiers)4294967295u); ZDOVars vars = zdo.Vars; long creator = ((ZDOVars)(ref vars)).GetCreator(0L); if (adminBuildModifiers != (PlayerProcessor.BuildModifiers)4294967295u) { return (ProcessResult)2; } adminBuildModifiers = Processor.Instance<PlayerProcessor>().GetBuildModifiers(creator); if (adminBuildModifiers != PlayerProcessor.BuildModifiers.None) { SetAdminBuildModifiers(zdo, adminBuildModifiers); } ComponentFieldAccessor<WearNTear> val = zdo.Fields<WearNTear>(); ProcessResult val2 = (ProcessResult)2; if ((adminBuildModifiers & PlayerProcessor.BuildModifiers.DisableRainDamage) != PlayerProcessor.BuildModifiers.None && val.UpdateValue((Func<Expression<Func<WearNTear, bool>>>)(() => (WearNTear x) => x.m_noRoofWear), false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AdminBuildOptions\\WearNTearProcessor.cs", 24)) { val2 = (ProcessResult)(val2 | 8); } if ((adminBuildModifiers & PlayerProcessor.BuildModifiers.DisableSupportRequirements) != PlayerProcessor.BuildModifiers.None && val.UpdateValue((Func<Expression<Func<WearNTear, bool>>>)(() => (WearNTear x) => x.m_noSupportWear), false, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AdminBuildOptions\\WearNTearProcessor.cs", 27)) { val2 = (ProcessResult)(val2 | 8); } if ((adminBuildModifiers & PlayerProcessor.BuildModifiers.MakeIndestructible) != PlayerProcessor.BuildModifiers.None && val.UpdateValue((Func<Expression<Func<WearNTear, float>>>)(() => (WearNTear x) => x.m_health), -1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AdminBuildOptions\\WearNTearProcessor.cs", 30)) { vars = zdo.Vars; ((ZDOVars)(ref vars)).SetHealth(-1f, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AdminBuildOptions\\WearNTearProcessor.cs", 32); val2 = (ProcessResult)(val2 | 8); } return val2; } private static PlayerProcessor.BuildModifiers GetAdminBuildModifiers(ServersideQoLZDO zdo, PlayerProcessor.BuildModifiers defaultValue = PlayerProcessor.BuildModifiers.None) { return (PlayerProcessor.BuildModifiers)zdo.ZDO.GetInt(__adminBuildModifiers, (int)defaultValue); } private static void SetAdminBuildModifiers(ServersideQoLZDO zdo, PlayerProcessor.BuildModifiers value) { zdo.ZDO.Set(__adminBuildModifiers, (int)value, false); } } }