using 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.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.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+cdafe98fecdc9c33d99ba13f064e37dcaca41712")] [assembly: AssemblyProduct("ServersideQoL.SuperWishbone")] [assembly: AssemblyTitle("ServersideQoL.SuperWishbone")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("2.0.0.0")] [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 { private const string Section = "SuperWishbone"; public override ConfigEntry Enabled { get; } = ConfigBase.BindEx(cfg, "SuperWishbone", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated)null, "Enabled"); public ConfigEntry FindDungeons { get; } = ConfigBase.BindEx(cfg, "SuperWishbone", true, "True to make the wishbone find dungeons", (AcceptableValueBase)null, (Deprecated)null, "FindDungeons"); public ConfigEntry FindVegvisir { get; } = ConfigBase.BindEx(cfg, "SuperWishbone", true, "True to make the wishbone find vegvisirs", (AcceptableValueBase)null, (Deprecated)null, "FindVegvisir"); public ConfigEntry FindLocationObjectRegex { get; } = ConfigBase.BindEx(cfg, "SuperWishbone", "", "The wishbone will find locations which contain an object whose (prefab) name matches this regular expression.\r\nExample: Beehive|goblin_totempole|giant_brain|dvergrprops_crate\\w*", (AcceptableValueBase)null, (Deprecated)null, "FindLocationObjectRegex"); public ConfigEntry Range { get; } = ConfigBase.BindEx(cfg, "SuperWishbone", Mathf.Max(Minimap.instance.m_exploreRadius, 64f), "Radius in which the wishbone will react to dungeons/locations", (AcceptableValueBase)(object)new AcceptableValueRange(0f, Mathf.Floor(128f * Mathf.Sqrt(2f))), (Deprecated)null, "Range"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("82b4ec36-75f1-4924-a202-2934d4144915")] public sealed class LocationProxyProcessor : Processor { public sealed record PrefabInfo(LocationProxy? LocationProxy, Beacon? Beacon) : ProcessorPrefabInfo() { public override bool IsValid { get { if (LocationProxy == null) { return ((ProcessorPrefabInfo)this).PrefabInfo.PrefabHash == BeaconPrefabHash; } 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(", Beacon = "); builder.Append(Beacon); return true; } [CompilerGenerated] public override int GetHashCode() { return (((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer.Default.GetHashCode(LocationProxy)) * -1521134295 + EqualityComparer.Default.GetHashCode(Beacon); } [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.Default.Equals(LocationProxy, other.LocationProxy)) { return EqualityComparer.Default.Equals(Beacon, other.Beacon); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { LocationProxy = original.LocationProxy; Beacon = original.Beacon; } } private readonly Dictionary _zdosByBeacon = new Dictionary(); private Regex? _regex; private static readonly ServerVar __beaconFoundVar = ServersideQoLPluginBase.RegisterServerVar("BeaconState"); private static int BeaconPrefabHash => Prefabs.MountainRemainsBuried; protected override void Initialize() { _regex = null; string text = ConfigBase.Instance.FindLocationObjectRegex.Value.Trim(); if (!string.IsNullOrEmpty(text)) { try { _regex = new Regex(text); } catch (Exception arg) { ((Processor)this).Logger.LogError((object)$"Invalid regex pattern: {text}{Environment.NewLine} {arg}"); } } } protected unsafe override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList peers, PrefabInfo prefabInfo) { //IL_0066: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0357: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) if (_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(0f); } if (prefabInfo.LocationProxy == null || ConfigBase.Instance.Range.Value <= 0f) { return (ProcessResult)2; } Config instance = ConfigBase.Instance; if (instance != null) { ConfigEntry findDungeons = instance.FindDungeons; if (findDungeons != null && !findDungeons.Value) { ConfigEntry findVegvisir = instance.FindVegvisir; if (findVegvisir != null && !findVegvisir.Value && _regex == null) { return (ProcessResult)2; } } } if (__beaconFoundVar.Get(zdo, false)) { return (ProcessResult)2; } ZDOVars 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 activeRandomSpawns = null; List positions = null; HashSet hashSet = null; if (ConfigBase.Instance.FindDungeons.Value) { Teleport[] componentsInChildren = prefab.GetComponentsInChildren(); foreach (Teleport val in componentsInChildren) { if ((hashSet ?? (hashSet = new HashSet())).Add(((Component)val).gameObject)) { AddBeaconPosition(ref positions, (Component?)(object)val, ref activeRandomSpawns, prefab, zdo); } } } if (ConfigBase.Instance.FindVegvisir.Value) { Vegvisir[] componentsInChildren2 = prefab.GetComponentsInChildren(); foreach (Vegvisir val2 in componentsInChildren2) { if ((hashSet ?? (hashSet = new HashSet())).Add(((Component)val2).gameObject)) { AddBeaconPosition(ref positions, (Component?)(object)val2, ref activeRandomSpawns, prefab, zdo); } } } if (_regex != null) { Component[] componentsInChildren3 = prefab.GetComponentsInChildren(); foreach (Component val3 in componentsInChildren3) { if ((hashSet ?? (hashSet = new HashSet())).Add(val3.gameObject) && _regex.IsMatch(Utils.GetPrefabName(val3.gameObject))) { AddBeaconPosition(ref positions, val3, ref activeRandomSpawns, prefab, zdo); } } } if (positions == null || positions.Count <= 0) { return (ProcessResult)2; } foreach (Vector3 item3 in positions) { Vector3 val4 = item3; val4.y -= 4f; ServersideQoLZDO val5 = ((Processor)this).PlaceObject(val4, BeaconPrefabHash, 0f, (CreatorMarkers)0, 0L); val5.Fields().Set((Func>>)(() => (Beacon x) => x.m_range), ConfigBase.Instance.Range.Value, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.SuperWishbone\\LocationProxyProcessor.cs", 106); _zdosByBeacon.Add(val5, zdo); } return (ProcessResult)2; } finally { ((IDisposable)(*(Location*)(&andLoadLocationByHash))/*cast due to .constrained prefix*/).Dispose(); } static void AddBeaconPosition(ref List? reference, Component? component, ref List? reference2, GameObject val7, ServersideQoLZDO val6) { //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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b9: 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_00ca: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (component != null) { RandomSpawn component2 = component.GetComponent(); if (component2 == null) { Vector3 item = val6.ZDO.GetPosition() + val6.ZDO.GetRotation() * component.gameObject.transform.position; (reference ?? (reference = new List())).Add(item); } else { if (reference2 == null) { reference2 = new List(); RandomSpawn[] enabledComponentsInChildren = Utils.GetEnabledComponentsInChildren(val7); State state = Random.state; ZDOVars vars2 = val6.Vars; Random.InitState(((ZDOVars)(ref vars2)).GetSeed(0)); Location val8 = null; RandomSpawn[] array = enabledComponentsInChildren; foreach (RandomSpawn val9 in array) { Vector3 position = ((Component)val9).gameObject.transform.position; position = val6.ZDO.GetPosition() + val6.ZDO.GetRotation() * position; val9.Prepare(); val9.Randomize(position, val8 ?? (val8 = val7.GetComponent()), (DungeonGenerator)null); if (((Component)val9).gameObject.activeSelf) { reference2.Add(val9); } val9.Reset(); ZNetView component3 = ((Component)val9).GetComponent(); if (component3 != null) { ((Component)component3).gameObject.SetActive(true); } } Random.state = state; } if (reference2.Contains(component2)) { Vector3 item2 = val6.ZDO.GetPosition() + val6.ZDO.GetRotation() * ((Component)component2).gameObject.transform.position; (reference ?? (reference = new List())).Add(item2); } } } } } } [BepInPlugin("ArgusMagnus.ServersideQoL.SuperWishbone", "ServersideQoL.SuperWishbone", "2.0.0")] public sealed class SuperWishbonePlugin : ServersideQoLPluginBase { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.SuperWishbone"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.SuperWishbone"; public const string PluginVersion = "2.0.0"; public const string PluginInformationalVersion = "2.0.0"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639245732005619012L, default(TimeSpan)); protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger) { return new Config(configFile, logger); } protected override void RegisterProcessors(IProcessorCollection processors) { processors.Add(); } private void Awake() { } } }