Decompiled source of ServersideQoL WorldOptions BETA v1.99.8

ServersideQoL.WorldOptions.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;

[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("Remove Mistland's mist. And more to come (maybe).")]
[assembly: AssemblyFileVersion("1.99.8.0")]
[assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")]
[assembly: AssemblyProduct("ServersideQoL.WorldOptions")]
[assembly: AssemblyTitle("ServersideQoL.WorldOptions")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")]
[assembly: AssemblyVersion("1.99.8.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.WorldOptions
{
	public sealed class Config : ConfigBase<Config>
	{
		public enum RemoveMistlandsMistOptions
		{
			Never,
			Always,
			AfterQueenKilled
		}

		private const string Section = "WorldOptions";

		public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx<bool>(cfg, "WorldOptions", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated<Config>)null, "Enabled");

		public ConfigEntry<RemoveMistlandsMistOptions> RemoveMistlandsMist { get; } = ConfigBase<Config>.BindEx<RemoveMistlandsMistOptions>(cfg, "WorldOptions", RemoveMistlandsMistOptions.AfterQueenKilled, "Condition to remove the mist from the mistlands.\r\nBeware that there are a few cases of mist (namely mist around POIs like ancient bones/skulls)\r\nthat cannot be removed by this mod and will remain regardless of this setting.", (AcceptableValueBase)(object)AcceptableEnum<RemoveMistlandsMistOptions>.Default, (Deprecated<Config>)null, "RemoveMistlandsMist");

		public Config(ConfigFile cfg, Logger logger)
			: base(cfg, logger)
		{
		}
	}
	[Processor("edd9c927-c22e-413d-b6d9-a67c0a3268b9")]
	public sealed class MisterProcessor : Processor<ProcessorPrefabInfo<Mister>>
	{
		private const string QueenDefeatedKey = "defeated_queen";

		private bool _queenDefeated;

		private readonly HashSet<ServersideQoLZDO> _misters = new HashSet<ServersideQoLZDO>();

		protected override void Initialize()
		{
			_queenDefeated = ZoneSystem.instance.GetGlobalKey("defeated_queen");
			_misters.Clear();
			ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Instance.GlobalKeysChanged -= OnGlobalKeysChanged;
			if (!_queenDefeated)
			{
				ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Instance.GlobalKeysChanged += OnGlobalKeysChanged;
			}
		}

		protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, ProcessorPrefabInfo<Mister> prefabInfo)
		{
			switch (ConfigBase<Config>.Instance.RemoveMistlandsMist.Value)
			{
			case Config.RemoveMistlandsMistOptions.Always:
				if (zdo.Fields<Mister>().UpdateValue((Func<Expression<Func<Mister, float>>>)(() => (Mister x) => x.m_radius), float.MinValue, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.WorldOptions\\MisterProcessor.cs", 30))
				{
					return (ProcessResult)10;
				}
				break;
			case Config.RemoveMistlandsMistOptions.AfterQueenKilled:
				if (_queenDefeated)
				{
					if (zdo.Fields<Mister>().UpdateValue((Func<Expression<Func<Mister, float>>>)(() => (Mister x) => x.m_radius), float.MinValue, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.WorldOptions\\MisterProcessor.cs", 37))
					{
						return (ProcessResult)10;
					}
					break;
				}
				_misters.Add(zdo);
				return (ProcessResult)0;
			}
			return (ProcessResult)2;
		}

		private void OnGlobalKeysChanged()
		{
			_queenDefeated = ZoneSystem.instance.GetGlobalKey("defeated_queen");
			if (!_queenDefeated)
			{
				return;
			}
			ServersideQoLPluginBase<ServersideQoLPlugin, Config>.Instance.GlobalKeysChanged -= OnGlobalKeysChanged;
			foreach (ServersideQoLZDO mister in _misters)
			{
				((Processor)this).ScheduleReprocessing(mister);
			}
			_misters.Clear();
		}
	}
	[BepInPlugin("ArgusMagnus.ServersideQoL.WorldOptions", "ServersideQoL.WorldOptions", "1.99.8")]
	public sealed class WorldOptionsPlugin : ServersideQoLPluginBase<WorldOptionsPlugin, Config>
	{
		public const string Author = "ArgusMagnus";

		public const string PluginName = "ServersideQoL.WorldOptions";

		public const string PluginGuid = "ArgusMagnus.ServersideQoL.WorldOptions";

		public const string PluginVersion = "1.99.8";

		public const string PluginInformationalVersion = "1.99.8-beta";

		private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507693665868L, default(TimeSpan));

		protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger)
		{
			return new Config(configFile, logger);
		}

		protected override void RegisterProcessors(IProcessorCollection processors)
		{
			processors.Add<MisterProcessor>();
		}

		private void Awake()
		{
			ServersideQoLPluginBase<WorldOptionsPlugin, Config>.Logger.LogWarning((object)string.Format("You are running a pre-release version: {0} ({1})", "1.99.8-beta", BuildTimestamp.LocalDateTime));
		}
	}
}