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 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("Lets all sinking items float by putting them into cargo crates when they sink too deep")] [assembly: AssemblyFileVersion("1.99.8.0")] [assembly: AssemblyInformationalVersion("1.99.8-beta+328851184cc278c858ffbc70e717af9f9d7b6973")] [assembly: AssemblyProduct("ServersideQoL.LetItFloat")] [assembly: AssemblyTitle("ServersideQoL.LetItFloat")] [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.LetItFloat { public sealed class Config : ConfigBase { private const string Section = "LetItFloat"; public override ConfigEntry Enabled { get; } = ConfigBase.BindEx(cfg, "LetItFloat", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated)null, "Enabled"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("c421a7d8-e547-46b3-9e3c-d71aefa7ada4")] [RunAfter("5f86a765-e449-4047-afc8-a63e4d681a48")] public sealed class ItemDropProcessor : Processor { public sealed record PrefabInfo(ItemDrop ItemDrop) : ProcessorPrefabInfo() { public override bool IsValid { get { if (!((ProcessorPrefabInfo)this).PrefabInfo.HasComponent()) { return !((ProcessorPrefabInfo)this).PrefabInfo.HasComponent(); } 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("ItemDrop = "); builder.Append(ItemDrop); return true; } [CompilerGenerated] public override int GetHashCode() { return ((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer.Default.GetHashCode(ItemDrop); } [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(ItemDrop, other.ItemDrop); } return false; } return true; } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { ItemDrop = original.ItemDrop; } } private readonly SectorDictionary _crates = new SectorDictionary(4f); protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList peers, PrefabInfo prefabInfo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) if (!(zdo.ZDO.GetPosition().y > 30f) && !(Processor.GetHeight(zdo.ZDO.GetPosition()) > 28f)) { ZDOVars vars = zdo.Vars; float num = (float)(((ZDOVars)(ref vars)).GetSpawnTime(default(DateTime)) - ZNet.instance.GetTime()).TotalSeconds + 2f; if (num > 0f) { zdo.DelaySchedulingFor(num); return (ProcessResult)32; } Vector3 position = zdo.ZDO.GetPosition(); position.y += 1f; ContainerState crate = GetCrate(position, zdo.ZDO.GetRotation()); ItemData val = new ItemData { m_shared = prefabInfo.ItemDrop.m_itemData.m_shared }; ItemDrop.LoadFromZDO(val, zdo.ZDO, -1); IInventory inventory = crate.GetInventory(); foreach (ItemData item in inventory.Items) { if (((EqualityComparer)(object)ItemDataKeyComparer.Instance).Equals(item, val)) { int num2 = Math.Min(val.m_stack, item.m_shared.m_maxStackSize - item.m_stack); item.m_stack += num2; val.m_stack -= num2; if (val.m_stack == 0) { break; } } } if (val.m_stack > 0) { val.m_dropPrefab = ((Component)prefabInfo.ItemDrop).gameObject; inventory.Items.Add(val); var (num3, num4) = Processor.GetBackpackSize(inventory.Items.Count); crate.ZDO.Fields().Set((Func>>)(() => (Container x) => x.m_width), num3, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.LetItFloat\\ItemDropProcessor.cs", 56).Set((Func>>)(() => (Container x) => x.m_height), num4, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.LetItFloat\\ItemDropProcessor.cs", 57); using List.Enumerator enumerator2 = inventory.Items.GetEnumerator(); for (int num5 = 0; num5 < num4; num5++) { for (int num6 = 0; num6 < num3; num6++) { if (!enumerator2.MoveNext()) { break; } enumerator2.Current.m_gridPos = new Vector2i(num6, num5); } } } crate.ZDO.ClaimOwnershipInternal(); inventory.Save(); crate.ZDO.ZDO.SetOwnerInternal(zdo.ZDO.GetOwner()); return (ProcessResult)4; } return (ProcessResult)0; } private ContainerState GetCrate(Vector3 pos, Quaternion rot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) ServersideQoLZDO val = default(ServersideQoLZDO); if (!_crates.TryGetValue(pos, ref val)) { _crates.Add(pos, val = ((Processor)this).PlaceObject(pos, Prefabs.CargoCrate, rot, (CreatorMarkers)0, 0L)); ZDOVars vars = val.Vars; ((ZDOVars)(ref vars)).SetCreator(0L, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.LetItFloat\\ItemDropProcessor.cs", 82); } return Processor.Instance().GetState(val); } } [BepInPlugin("ArgusMagnus.ServersideQoL.LetItFloat", "ServersideQoL.LetItFloat", "1.99.8")] public sealed class LetItFloatPlugin : ServersideQoLPluginBase { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.LetItFloat"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.LetItFloat"; public const string PluginVersion = "1.99.8"; public const string PluginInformationalVersion = "1.99.8-beta"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639215507745538155L, 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)); } } }