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 SuperWishbone v2.3.0
ServersideQoL.SuperWishbone.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using ServersideQoL.Utilities; 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("Supercharges the wishbone so it can find dungeons, vegvisirs and configurably more.")] [assembly: AssemblyFileVersion("2.3.0.0")] [assembly: AssemblyInformationalVersion("2.3.0+2e3f9ec58eb6242e0f6159ce758d539a6d41fdf7")] [assembly: AssemblyProduct("ServersideQoL.SuperWishbone")] [assembly: AssemblyTitle("ServersideQoL.SuperWishbone")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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.SuperWishbone { public sealed class Config : ConfigBase<Config> { public sealed class AdvancedConfig { public sealed class Entry { public required string PrefabNamePattern { get; init; } public required bool Enabled { get; init; } = true; public float Range { get; init; } = Mathf.Max(Minimap.instance.m_exploreRadius, 64f); public int MinLevel { get; init; } = 1; public int MinQuality { get; init; } = 1; } [CompilerGenerated] private List<Entry>? <Entries>k__BackingField; public List<Entry>? Entries { get { return <Entries>k__BackingField ?? (<Entries>k__BackingField = GetDefaultEntries()); } [CompilerGenerated] init { <Entries>k__BackingField = value; } } private static List<Entry> GetDefaultEntries() { return new List<Entry>(6) { new Entry { PrefabNamePattern = "Beehive", Enabled = false }, new Entry { PrefabNamePattern = "goblin_totempole", Enabled = false }, new Entry { PrefabNamePattern = "giant_brain", Enabled = false }, new Entry { PrefabNamePattern = "dvergrprops_crate*", Enabled = false }, new Entry { PrefabNamePattern = "Fish*", Enabled = false, MinQuality = 4 }, new Entry { PrefabNamePattern = "Serpent", Enabled = false } }; } } public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx<bool>(cfg, true, "Enables/disables the entire mod", (IAcceptableValueBase<bool>)null, (Deprecated<Config>)null, "Enabled"); public ConfigEntry<bool> FindDungeons { get; } = ConfigBase<Config>.BindEx<bool>(cfg, true, "True to make the wishbone find dungeons", (IAcceptableValueBase<bool>)null, (Deprecated<Config>)null, "FindDungeons"); public ConfigEntry<bool> FindVegvisir { get; } = ConfigBase<Config>.BindEx<bool>(cfg, true, "True to make the wishbone find vegvisirs", (IAcceptableValueBase<bool>)null, (Deprecated<Config>)null, "FindVegvisir"); public ConfigEntry<float> Range { get; } = ConfigBase<Config>.BindEx<float>(cfg, Mathf.Max(Minimap.instance.m_exploreRadius, 64f), "Radius in which the wishbone will react to dungeons/locations", (IAcceptableValueBase<float>)(object)new AcceptableValueRange<float>(0f, Mathf.Floor(128f * Mathf.Sqrt(2f))), (Deprecated<Config>)null, "Range"); public YamlConfigEntry<AdvancedConfig> Advanced { get; } = ConfigBase<Config>.BindYaml<AdvancedConfig>(cfg, "Advanced"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("82b4ec36-75f1-4924-a202-2934d4144915")] public sealed class Processor : Processor<Processor.PrefabInfo> { public sealed record PrefabInfo : ProcessorPrefabInfo { public LocationProxy? LocationProxy { get; private set; } public bool IsBeacon { get; private set; } public ItemDrop? ItemDrop { get; private set; } public Character? Character { get; private set; } public override bool IsValid { get { LocationProxy = ((ProcessorPrefabInfo)this).PrefabInfo.GetComponent<LocationProxy>(); IsBeacon = ((ProcessorPrefabInfo)this).PrefabInfo.PrefabHash == BeaconPrefabHash; ItemDrop = ((ProcessorPrefabInfo)this).PrefabInfo.GetComponent<ItemDrop>(); Character = ((ProcessorPrefabInfo)this).PrefabInfo.GetComponent<Character>(); return 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("LocationProxy = "); builder.Append(LocationProxy); builder.Append(", IsBeacon = "); builder.Append(IsBeacon.ToString()); builder.Append(", ItemDrop = "); builder.Append(ItemDrop); builder.Append(", Character = "); builder.Append(Character); return true; } [CompilerGenerated] public override int GetHashCode() { return (((((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<LocationProxy>.Default.GetHashCode(LocationProxy)) * -1521134295 + EqualityComparer<bool>.Default.GetHashCode(IsBeacon)) * -1521134295 + EqualityComparer<ItemDrop>.Default.GetHashCode(ItemDrop)) * -1521134295 + EqualityComparer<Character>.Default.GetHashCode(Character); } [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<LocationProxy>.Default.Equals(LocationProxy, other.LocationProxy) && EqualityComparer<bool>.Default.Equals(IsBeacon, other.IsBeacon) && EqualityComparer<ItemDrop>.Default.Equals(ItemDrop, other.ItemDrop)) { return EqualityComparer<Character>.Default.Equals(Character, other.Character); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { LocationProxy = original.LocationProxy; IsBeacon = original.IsBeacon; ItemDrop = original.ItemDrop; Character = original.Character; } public PrefabInfo() { } } public const string Id = "82b4ec36-75f1-4924-a202-2934d4144915"; private readonly Dictionary<int, Config.AdvancedConfig.Entry> _advancedConfigEntries = new Dictionary<int, Config.AdvancedConfig.Entry>(); private readonly Dictionary<ServersideQoLZDO, ServersideQoLZDO> _zdosByBeacon = new Dictionary<ServersideQoLZDO, ServersideQoLZDO>(); private readonly Dictionary<ServersideQoLZDO, ServersideQoLZDO> _beaconsByZdo = new Dictionary<ServersideQoLZDO, ServersideQoLZDO>(); private static readonly ServerVar<bool> __beaconFoundVar = ServersideQoLPluginBaseCore<SuperWishbonePlugin, Config>.RegisterServerVar<bool>("BeaconState"); private static int BeaconPrefabHash => Prefabs.MountainRemainsBuried; protected override void Initialize() { ConfigBase<Config>.Instance.Advanced.ValueChanged -= OnAdvancedConfigChanged; foreach (ServersideQoLZDO key in _zdosByBeacon.Keys) { ((Processor)this).DestroyObject(key); } _zdosByBeacon.Clear(); _advancedConfigEntries.Clear(); List<Config.AdvancedConfig.Entry> entries = ConfigBase<Config>.Instance.Advanced.Value.Entries; if (entries != null) { foreach (Config.AdvancedConfig.Entry item in entries) { if (item == null) { continue; } string prefabNamePattern = item.PrefabNamePattern; if (prefabNamePattern == null || prefabNamePattern.Length <= 0 || !item.Enabled) { continue; } string pattern = Processor.ConvertToRegexPattern(item.PrefabNamePattern); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (Regex.IsMatch(((Object)prefab).name, pattern)) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (!_advancedConfigEntries.TryAdd(stableHashCode, item)) { ((Processor)this).Logger.LogWarning((object)("Prefab '" + ((Object)prefab).name + "' matches multiple entries. Only the first is used.")); } ((Processor)this).Logger.LogDiagnosticInfo((object)("Placing beacons for " + ((Object)prefab).name)); } } } } ConfigBase<Config>.Instance.Advanced.ValueChanged += OnAdvancedConfigChanged; } protected unsafe override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) if (prefabInfo.IsBeacon && _zdosByBeacon.TryGetValue(zdo, out ServersideQoLZDO value)) { if (peers.Any((Peer x) => Utils.DistanceXZ(x.RefPos, zdo.ZDO.GetPosition()) < 2f)) { ((Processor)this).DestroyObject(zdo); _zdosByBeacon.Remove(zdo); __beaconFoundVar.Set(value, true); } return ((Processor)this).ScheduleReprocessing(0.1f); } if (_beaconsByZdo.TryGetValue(zdo, out ServersideQoLZDO value2)) { if (Utils.DistanceXZ(zdo.ZDO.GetPosition(), value2.ZDO.GetPosition()) > 4f) { value2.ZDO.SetPosition(GetBeaconPos(zdo.ZDO.GetPosition(), isLocation: false)); ZDOMan.instance.ForceSendZDO(value2.ZDO.m_uid); } return (ProcessResult)0; } ZDOVars vars; if (_advancedConfigEntries.TryGetValue(zdo.ZDO.GetPrefab(), out Config.AdvancedConfig.Entry value3)) { if (value3.MinLevel > 1 && prefabInfo.Character != null) { vars = zdo.Vars; if (((ZDOVars)(ref vars)).GetLevel(1) < value3.MinLevel) { return (ProcessResult)2; } } else if (value3.MinQuality > 1 && prefabInfo.ItemDrop != null) { ItemData val = prefabInfo.ItemDrop.m_itemData.Clone(); ItemDrop.LoadFromZDO(val, zdo.ZDO, -1); if (val.m_quality < value3.MinQuality) { return (ProcessResult)2; } } bool flag = ((ProcessorPrefabInfo)prefabInfo).PrefabInfo.GetComponent<ZSyncTransform>()?.m_syncPosition ?? false; if (!flag && __beaconFoundVar.Get(zdo, false)) { return (ProcessResult)2; } value2 = ((Processor)this).PlaceObject(GetBeaconPos(zdo.ZDO.GetPosition(), isLocation: false), BeaconPrefabHash, 0f); value2.Fields<Beacon>().Set((Func<Expression<Func<Beacon, float>>>)(() => (Beacon x) => x.m_range), value3.Range, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.SuperWishbone\\Processor.cs", 113); if (!flag) { _zdosByBeacon.Add(value2, zdo); return (ProcessResult)2; } _beaconsByZdo.Add(zdo, value2); zdo.Destroyed += delegate(ServersideQoLZDO key) { if (_beaconsByZdo.Remove(key, out ServersideQoLZDO value4)) { ((Processor)this).DestroyObject(value4); } }; return (ProcessResult)0; } if (prefabInfo.LocationProxy != null) { if (ConfigBase<Config>.Instance.Range.Value <= 0f) { return (ProcessResult)2; } Config instance = ConfigBase<Config>.Instance; if (instance != null) { ConfigEntry<bool> findDungeons = instance.FindDungeons; if (findDungeons != null && !findDungeons.Value) { ConfigEntry<bool> findVegvisir = instance.FindVegvisir; if (findVegvisir != null && !findVegvisir.Value) { return (ProcessResult)2; } } } if (__beaconFoundVar.Get(zdo, false)) { return (ProcessResult)2; } vars = zdo.Vars; int location = ((ZDOVars)(ref vars)).GetLocation(0); if (location == 0) { return (ProcessResult)0; } Location andLoadLocationByHash = PrivateAccessor.GetAndLoadLocationByHash(ZoneSystem.instance, location); try { if (!((Location)(ref andLoadLocationByHash)).IsValid) { return (ProcessResult)2; } GameObject prefab = ((Location)(ref andLoadLocationByHash)).Prefab; if (prefab == null) { return ((Processor)this).ScheduleReprocessing(0f); } List<RandomSpawn> activeRandomSpawns = null; List<(Vector3, bool)> positions = null; HashSet<GameObject> hashSet = null; if (ConfigBase<Config>.Instance.FindDungeons.Value) { Teleport[] componentsInChildren = prefab.GetComponentsInChildren<Teleport>(); foreach (Teleport val2 in componentsInChildren) { if ((hashSet ?? (hashSet = new HashSet<GameObject>())).Add(((Component)val2).gameObject)) { AddBeaconPosition(ref positions, isLocation: true, (Component?)(object)val2, ref activeRandomSpawns, prefab, zdo); } } } if (ConfigBase<Config>.Instance.FindVegvisir.Value) { Vegvisir[] componentsInChildren2 = prefab.GetComponentsInChildren<Vegvisir>(); foreach (Vegvisir val3 in componentsInChildren2) { if ((hashSet ?? (hashSet = new HashSet<GameObject>())).Add(((Component)val3).gameObject)) { AddBeaconPosition(ref positions, isLocation: false, (Component?)(object)val3, ref activeRandomSpawns, prefab, zdo); } } } if (positions == null || positions.Count <= 0) { return (ProcessResult)2; } foreach (var item5 in positions) { Vector3 item = item5.Item1; bool item2 = item5.Item2; value2 = ((Processor)this).PlaceObject(GetBeaconPos(item, item2), BeaconPrefabHash, 0f); value2.Fields<Beacon>().Set((Func<Expression<Func<Beacon, float>>>)(() => (Beacon x) => x.m_range), ConfigBase<Config>.Instance.Range.Value, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.SuperWishbone\\Processor.cs", 178); _zdosByBeacon.Add(value2, zdo); } return (ProcessResult)2; } finally { ((IDisposable)(*(Location*)(&andLoadLocationByHash))/*cast due to .constrained prefix*/).Dispose(); } } return (ProcessResult)2; static void AddBeaconPosition(ref List<(Vector3, bool)>? reference, bool isLocation, Component? component, ref List<RandomSpawn>? reference2, GameObject val5, ServersideQoLZDO val4) { //IL_0015: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0147: Unknown result type (might be due to invalid IL or missing references) if (component != null) { RandomSpawn component2 = component.GetComponent<RandomSpawn>(); if (component2 == null) { Vector3 item3 = val4.ZDO.GetPosition() + val4.ZDO.GetRotation() * component.gameObject.transform.position; (reference ?? (reference = new List<(Vector3, bool)>())).Add((item3, isLocation)); } else { if (reference2 == null) { reference2 = new List<RandomSpawn>(); RandomSpawn[] enabledComponentsInChildren = Utils.GetEnabledComponentsInChildren<RandomSpawn>(val5); State state = Random.state; ZDOVars vars2 = val4.Vars; Random.InitState(((ZDOVars)(ref vars2)).GetSeed(0)); Location val6 = null; RandomSpawn[] array = enabledComponentsInChildren; foreach (RandomSpawn val7 in array) { Vector3 position = ((Component)val7).gameObject.transform.position; position = val4.ZDO.GetPosition() + val4.ZDO.GetRotation() * position; val7.Prepare(); val7.Randomize(position, val6 ?? (val6 = val5.GetComponent<Location>()), (DungeonGenerator)null); if (((Component)val7).gameObject.activeSelf) { reference2.Add(val7); } val7.Reset(); ZNetView component3 = ((Component)val7).GetComponent<ZNetView>(); if (component3 != null) { ((Component)component3).gameObject.SetActive(true); } } Random.state = state; } if (reference2.Contains(component2)) { Vector3 item4 = val4.ZDO.GetPosition() + val4.ZDO.GetRotation() * ((Component)component2).gameObject.transform.position; (reference ?? (reference = new List<(Vector3, bool)>())).Add((item4, isLocation)); } } } } static Vector3 GetBeaconPos(Vector3 pos, bool isLocation) { //IL_0003: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (isLocation || Character.InInterior(pos) || pos.y < 28f) { pos.y -= 4f; } else { pos.y = Processor.GetHeight(pos) - 2f; } return pos; } } private void OnAdvancedConfigChanged(YamlConfigEntry<Config.AdvancedConfig> cfg) { if (!((ConfigBase)ConfigBase<Config>.Instance).Enabled.Value) { ConfigBase<Config>.Instance.Advanced.ValueChanged -= OnAdvancedConfigChanged; } else { ((Processor)this).RequestReinitialization(); } } } [BepInPlugin("ArgusMagnus.ServersideQoL.SuperWishbone", "ServersideQoL.SuperWishbone", "2.3.0")] public sealed class SuperWishbonePlugin : ServersideQoLPluginBase<SuperWishbonePlugin, Config> { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.SuperWishbone"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.SuperWishbone"; public const string PluginVersion = "2.3.0"; public const string PluginInformationalVersion = "2.3.0"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639273810401357882L, default(TimeSpan)); protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger) { return new Config(configFile, logger); } protected override void RegisterProcessors(IProcessorCollection processors) { processors.Add<Processor>(); } private void Awake() { } } }