using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; 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("Automatically closes doors")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL.AutoDoors")] [assembly: AssemblyTitle("ServersideQoL.AutoDoors")] [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.AutoDoors { [BepInPlugin("ArgusMagnus.ServersideQoL.AutoDoors", "ServersideQoL.AutoDoors", "1.99.8")] public sealed class AutoDoorsPlugin : ServersideQoLPluginBase { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.AutoDoors"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.AutoDoors"; public const string PluginVersion = "1.99.8"; public const string PluginInformationalVersion = "1.99.8-beta"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507820225253L, 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() { ServersideQoLPluginBase.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 { private const string Section = "AutoDoors"; public override ConfigEntry Enabled { get; } = ConfigBase.BindEx(cfg, "AutoDoors", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated)null, "Enabled"); public ConfigEntry AutoCloseMinPlayerDistance { get; } = ConfigBase.BindEx(cfg, "AutoDoors", 4f, FormattableString.Invariant($"Minimum distance all players must have to the door before it is closed."), (AcceptableValueBase)null, (Deprecated)null, "AutoCloseMinPlayerDistance"); public ConfigEntry AutoCloseMinOpenSeconds { get; } = ConfigBase.BindEx(cfg, "AutoDoors", 2f, FormattableString.Invariant($"Minimum time the door must have been open before it is closed."), (AcceptableValueBase)null, (Deprecated)null, "AutoCloseMinOpenSeconds"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("f91beb92-c76b-43d5-91d4-82c1f7de2929")] public sealed class DoorProcessor : Processor { public sealed record PrefabInfo(Door Door) : ProcessorPrefabInfo() { public override bool IsValid { get { Door door = Door; if (door != null && door.m_keyItem == null) { return !door.m_canNotBeClosed; } return false; } } [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("Door = "); builder.Append(Door); return true; } [CompilerGenerated] public override int GetHashCode() { return ((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer.Default.GetHashCode(Door); } [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)) { return EqualityComparer.Default.Equals(Door, other.Door); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { Door = original.Door; } } private readonly Dictionary _closeAfter = new Dictionary(); protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList peers, PrefabInfo prefabInfo) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00f4: Unknown result type (might be due to invalid IL or missing references) ZDOVars vars = zdo.Vars; if (((ZDOVars)(ref vars)).GetCreator(0L) != 0L) { vars = zdo.Vars; if (((ZDOVars)(ref vars)).GetState(0) == 0) { if (_closeAfter.Remove(zdo)) { zdo.Destroyed -= OnDoorDestroyed; } return (ProcessResult)0; } if (Processor.CheckMinDistance(peers, zdo, ConfigBase.Instance.AutoCloseMinPlayerDistance.Value)) { Timestamp now; if (!_closeAfter.TryGetValue(zdo, out var value)) { Dictionary closeAfter = _closeAfter; now = Timestamp.Now; closeAfter.Add(zdo, value = ((Timestamp)(ref now)).AddSeconds(ConfigBase.Instance.AutoCloseMinOpenSeconds.Value)); zdo.Destroyed += OnDoorDestroyed; zdo.DelaySchedulingFor(ConfigBase.Instance.AutoCloseMinOpenSeconds.Value); return (ProcessResult)32; } float seconds = ((Timestamp)(ref value)).Seconds; now = Timestamp.Now; float num = seconds - ((Timestamp)(ref now)).Seconds; if (num > 0f) { zdo.DelaySchedulingFor(num); return (ProcessResult)32; } vars = zdo.Vars; ((ZDOVars)(ref vars)).SetState(0, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoDoors\\DoorProcessor.cs", 45); if (_closeAfter.Remove(zdo)) { zdo.Destroyed -= OnDoorDestroyed; } return (ProcessResult)0; } return (ProcessResult)32; } return (ProcessResult)2; } private void OnDoorDestroyed(ServersideQoLZDO zdo) { _closeAfter.Remove(zdo); } } }