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 AutoProcess BETA v1.99.2
ServersideQoL.AutoProcess.dll
Decompiled 19 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArgusMagnus")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("ArgusMagnus")] [assembly: AssemblyDescription("Automatically feeds processing stations such as smelters, kilns, windmills, shield generators, etc. from nearby containers")] [assembly: AssemblyFileVersion("1.99.2.0")] [assembly: AssemblyInformationalVersion("1.99.2-beta+409ce8a87a5191770ee23cbbde9294d6a844dd0b")] [assembly: AssemblyProduct("ServersideQoL.AutoProcess")] [assembly: AssemblyTitle("ServersideQoL.AutoProcess")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArgusMagnus/ValheimServersideQoL")] [assembly: AssemblyVersion("1.99.2.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { return !_moveNextCalled && (_moveNextCalled = true); } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } 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.AutoProcess { [BepInPlugin("ArgusMagnus.ServersideQoL.AutoProcess", "ServersideQoL.AutoProcess", "1.99.2")] public sealed class AutoProcessPlugin : ServersideQoLPluginBase<AutoProcessPlugin, Config> { public const string Author = "ArgusMagnus"; public const string PluginName = "ServersideQoL.AutoProcess"; public const string PluginGuid = "ArgusMagnus.ServersideQoL.AutoProcess"; public const string PluginVersion = "1.99.2"; public const string PluginInformationalVersion = "1.99.2-beta"; internal const string DependencyDirectory = "C:\\repos\\Valheim.ServersideQoL\\Dependencies\\"; private DateTimeOffset BuildTimestamp { get; } = new DateTimeOffset(639207788837708255L, default(TimeSpan)); protected override Config CreateConfigSingleton(ConfigFile configFile, Logger logger) { return new Config(configFile, logger); } protected override void RegisterProcessors(IProcessorCollection processors) { processors.Add<SmelterProcessor>(); } private void Awake() { bool flag = true; ServersideQoLPluginBase<AutoProcessPlugin, Config>.Logger.LogWarning((object)string.Format("You are running a pre-release version: {0} ({1})", "1.99.2-beta", BuildTimestamp.LocalDateTime)); } } public sealed class Config : ConfigBase<Config> { public sealed class LocalizationConfig { private string FuelAdded { get; init; } = "{0}: $msg_added {1} {2}x"; private string OreAdded { get; init; } = "{0}: $msg_added {1} {2}x"; public string FormatFuelAdded(string smelterName, string itemName, int stack) { return string.Format(FuelAdded, smelterName, itemName, stack); } public string FormatOreAdded(string smelterName, string itemName, int stack) { return string.Format(OreAdded, smelterName, itemName, stack); } } private const string Section = "AutoProcess"; public override ConfigEntry<bool> Enabled { get; } = ConfigBase<Config>.BindEx<bool>(cfg, "AutoProcess", true, "Enables/disables the entire mod", (AcceptableValueBase)null, (Deprecated<Config>)null, "Enabled"); public ConfigEntry<bool> FeedFromContainers { get; } = ConfigBase<Config>.BindEx<bool>(cfg, "AutoProcess", true, "True to automatically feed smelters from nearby containers", (AcceptableValueBase)null, (Deprecated<Config>)null, "FeedFromContainers"); public ConfigEntry<float> FeedFromContainersRange { get; } = ConfigBase<Config>.BindEx<float>(cfg, "AutoProcess", 4f, "Required proximity of a container to a smelter to be used as feeding source.\r\nCan be overridden per chest with the ServersideQoL.ContainerSigns mod.", (AcceptableValueBase)null, (Deprecated<Config>)null, "FeedFromContainersRange"); public int? FeedFromContainersMaxRange => Shared.FeedFromContainersMaxRange?.Value; public ConfigEntry<float> FeedFromContainersMinPlayerDistance { get; } = ConfigBase<Config>.BindEx<float>(cfg, "AutoProcess", 4f, "Min distance all players must have to a processing station", (AcceptableValueBase)null, (Deprecated<Config>)null, "FeedFromContainersMinPlayerDistance"); public ConfigEntry<int> FeedFromContainersLeaveAtLeastFuel { get; } = ConfigBase<Config>.BindEx<int>(cfg, "AutoProcess", 1, "Minimum amount of fuel to leave in a container", (AcceptableValueBase)null, (Deprecated<Config>)null, "FeedFromContainersLeaveAtLeastFuel"); public ConfigEntry<int> FeedFromContainersLeaveAtLeastOre { get; } = ConfigBase<Config>.BindEx<int>(cfg, "AutoProcess", 1, "Minimum amount of ore to leave in a container", (AcceptableValueBase)null, (Deprecated<Config>)null, "FeedFromContainersLeaveAtLeastOre"); public ConfigEntry<MessageTypes> OreOrFuelAddedMessageType { get; } = ConfigBase<Config>.BindEx<MessageTypes>(cfg, "AutoProcess", (MessageTypes)0, "Type of message to show when ore or fuel is added to a smelter", (AcceptableValueBase)(object)AcceptableEnum<MessageTypes>.Default, (Deprecated<Config>)null, "OreOrFuelAddedMessageType"); public ConfigEntry<float> CapacityMultiplier { get; } = ConfigBase<Config>.BindEx<float>(cfg, "AutoProcess", 1f, "Multiply a smelter's ore/fuel capacity by this factor", (AcceptableValueBase)null, (Deprecated<Config>)null, "CapacityMultiplier"); public ConfigEntry<float> TimePerProductMultiplier { get; } = ConfigBase<Config>.BindEx<float>(cfg, "AutoProcess", 1f, "Multiply the time it takes to produce one product by this factor (will not go below 1 second per product).", (AcceptableValueBase)null, (Deprecated<Config>)null, "TimePerProductMultiplier"); public YamlConfigEntry<LocalizationConfig> Localization { get; } = ConfigBase<Config>.BindYaml<LocalizationConfig>(cfg, "Localization"); public Config(ConfigFile cfg, Logger logger) : base(cfg, logger) { } } [Processor("1db73d4d-e930-402f-933e-cb92e5748312")] [RunAfter<ContainerRegistryProcessor>] public sealed class SmelterProcessor : Processor<SmelterProcessor.PrefabInfo> { public sealed record PrefabInfo(Smelter? Smelter, ShieldGenerator? ShieldGenerator) : ProcessorPrefabInfo() { [MemberNotNullWhen(true, "Smelter")] public bool HasProduct { [MemberNotNullWhen(true, "Smelter")] get; } = Smelter?.m_conversion.Any((ItemConversion x) => x.m_to != null) ?? 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("Smelter = "); builder.Append(Smelter); builder.Append(", ShieldGenerator = "); builder.Append(ShieldGenerator); builder.Append(", HasProduct = "); builder.Append(HasProduct.ToString()); return true; } [CompilerGenerated] public override int GetHashCode() { return ((((ProcessorPrefabInfo)this).GetHashCode() * -1521134295 + EqualityComparer<Smelter>.Default.GetHashCode(Smelter)) * -1521134295 + EqualityComparer<ShieldGenerator>.Default.GetHashCode(ShieldGenerator)) * -1521134295 + EqualityComparer<bool>.Default.GetHashCode(HasProduct); } [CompilerGenerated] public sealed override bool Equals(ProcessorPrefabInfo? other) { return ((object)this).Equals((object?)other); } [CompilerGenerated] public bool Equals(PrefabInfo? other) { return (object)this == other || (((ProcessorPrefabInfo)this).Equals((ProcessorPrefabInfo)(object)other) && EqualityComparer<Smelter>.Default.Equals(Smelter, other.Smelter) && EqualityComparer<ShieldGenerator>.Default.Equals(ShieldGenerator, other.ShieldGenerator) && EqualityComparer<bool>.Default.Equals(HasProduct, other.HasProduct)); } [CompilerGenerated] private PrefabInfo(PrefabInfo original) : base((ProcessorPrefabInfo)(object)original) { Smelter = original.Smelter; ShieldGenerator = original.ShieldGenerator; HasProduct = original.HasProduct; } } private SectorDictionary<HashSet<ServersideQoLZDO>>? _smelters; private SectorDictionary<SharedItemDataKey, HashSet<ServersideQoLZDO>>? _containersByItemName; protected override void Initialize() { Processor.Instance<ContainerRegistryProcessor>().ContainerChanged -= OnContainerChanged; if (ConfigBase<Config>.Instance.FeedFromContainers.Value) { _smelters = new SectorDictionary<HashSet<ServersideQoLZDO>>(Mathf.Max(ConfigBase<Config>.Instance.FeedFromContainersRange.Value, (float)ConfigBase<Config>.Instance.FeedFromContainersMaxRange.GetValueOrDefault())); _containersByItemName = Processor.Instance<ContainerRegistryProcessor>().GetContainersByItemName(_smelters.SectorWidth); Processor.Instance<ContainerRegistryProcessor>().ContainerChanged += OnContainerChanged; } else { _smelters = null; _containersByItemName = null; } } protected override ProcessResult Process(ServersideQoLZDO zdo, IReadOnlyList<Peer> peers, PrefabInfo prefabInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0ee9: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0ee4: Unknown result type (might be due to invalid IL or missing references) //IL_0ee5: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_0962: Unknown result type (might be due to invalid IL or missing references) //IL_09d3: Unknown result type (might be due to invalid IL or missing references) //IL_09e4: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Unknown result type (might be due to invalid IL or missing references) //IL_09f7: Unknown result type (might be due to invalid IL or missing references) //IL_09fc: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0e9c: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_0a6a: Unknown result type (might be due to invalid IL or missing references) //IL_0a6f: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_0ac6: Unknown result type (might be due to invalid IL or missing references) //IL_0ad2: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_0d45: Unknown result type (might be due to invalid IL or missing references) //IL_0d4a: Unknown result type (might be due to invalid IL or missing references) //IL_0d8e: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) ProcessResult val = (ProcessResult)0; if (ConfigBase<Config>.Instance.CapacityMultiplier.Value == 1f) { if (prefabInfo.Smelter != null) { zdo.Fields<Smelter>().Reset((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 44).Reset((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxOre), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 45); } else { zdo.Fields<ShieldGenerator>().Reset((Func<Expression<Func<ShieldGenerator, int>>>)(() => (ShieldGenerator x) => x.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 48); } } else if (prefabInfo.ShieldGenerator != null) { if (zdo.Fields<ShieldGenerator>().UpdateValue((Func<Expression<Func<ShieldGenerator, int>>>)(() => (ShieldGenerator x) => x.m_maxFuel), Mathf.RoundToInt(ConfigBase<Config>.Instance.CapacityMultiplier.Value * (float)prefabInfo.ShieldGenerator.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 54)) { val = (ProcessResult)8; } } else if (prefabInfo.Smelter != null) { if (zdo.Fields<Smelter>().UpdateValue((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxFuel), Mathf.RoundToInt(ConfigBase<Config>.Instance.CapacityMultiplier.Value * (float)prefabInfo.Smelter.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 59)) { val = (ProcessResult)8; } if (zdo.Fields<Smelter>().UpdateValue((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxOre), Mathf.RoundToInt(ConfigBase<Config>.Instance.CapacityMultiplier.Value * (float)prefabInfo.Smelter.m_maxOre), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 61)) { val = (ProcessResult)8; } } if (prefabInfo.HasProduct) { if (ConfigBase<Config>.Instance.TimePerProductMultiplier.Value == 1f) { zdo.Fields<Smelter>().Reset((Func<Expression<Func<Smelter, float>>>)(() => (Smelter x) => x.m_secPerProduct), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 69); } else if (zdo.Fields<Smelter>().UpdateValue((Func<Expression<Func<Smelter, float>>>)(() => (Smelter x) => x.m_secPerProduct), Mathf.Max(1f, prefabInfo.Smelter.m_secPerProduct * ConfigBase<Config>.Instance.TimePerProductMultiplier.Value), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 70)) { val = (ProcessResult)8; } } if (_smelters == null || _containersByItemName == null) { return (ProcessResult)(val | 2); } if (!Processor.CheckMinDistance(peers, zdo, ConfigBase<Config>.Instance.FeedFromContainersMinPlayerDistance.Value)) { return (ProcessResult)(val | 0x20); } List<ServersideQoLZDO> list = null; List<ItemData> list2 = null; int num = ((prefabInfo.Smelter != null) ? zdo.Fields<Smelter>().GetInt((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 86) : zdo.Fields<ShieldGenerator>().GetInt((Func<Expression<Func<ShieldGenerator, int>>>)(() => (ShieldGenerator x) => x.m_maxFuel), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 87)); ZDOVars vars = zdo.Vars; float num2 = ((ZDOVars)(ref vars)).GetFuel(0f); int num3 = (int)((float)num - num2); if (num3 > num / 2) { foreach (ItemData fuelItem in prefabInfo.ShieldGenerator?.m_fuelItems.Select((ItemDrop x) => x.m_itemData) ?? new <>z__ReadOnlySingleElementList<ItemData>(prefabInfo.Smelter.m_fuelItem.m_itemData)) { int num4 = 0; AdjacentEnumerator<SharedItemDataKey, HashSet<ServersideQoLZDO>> enumerator2 = _containersByItemName.EnumerateAdjacent((zdo.ZDO.GetPosition(), SharedItemDataKey.op_Implicit(fuelItem.m_shared))).GetEnumerator(); try { while (enumerator2.MoveNext()) { HashSet<ServersideQoLZDO> current = enumerator2.Current; list?.Clear(); foreach (ServersideQoLZDO item in current) { ContainerState state = Processor.Instance<ContainerRegistryProcessor>().GetState(item); if (state == null) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item); continue; } vars = item.Vars; if (((ZDOVars)(ref vars)).GetInUse(false)) { continue; } float num5 = state.FeedRange ?? ConfigBase<Config>.Instance.FeedFromContainersRange.Value; num5 *= num5; if (num5 == 0f || Utils.DistanceSqr(zdo.ZDO.GetPosition(), item.ZDO.GetPosition()) > num5) { continue; } IInventory inventory = state.GetInventory(); list2?.Clear(); int num6 = 0; int num7 = ConfigBase<Config>.Instance.FeedFromContainersLeaveAtLeastFuel.Value; bool flag = false; bool flag2 = false; foreach (ItemData item2 in from x in inventory.Items where new ItemDataKey(x) == ItemDataKey.op_Implicit(fuelItem) orderby x.m_stack select x) { flag = flag || (item2 != null && item2.m_stack > 0); int num8 = Math.Min(num3, item2.m_stack); int num9 = Math.Min(num8, num7); num7 -= num9; num8 -= num9; if (num8 != 0) { if (!item.IsOwnerOrUnassigned()) { flag2 = true; break; } num6 += num8; item2.m_stack -= num8; if (item2.m_stack == 0) { (list2 ?? (list2 = new List<ItemData>())).Add(item2); } num3 -= num8; if (num3 == 0) { break; } } } if (flag2) { Processor.Instance<ContainerRegistryProcessor>().RequestOwnership(item, 0L, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 147); continue; } if (num6 == 0) { if (!flag) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item); } continue; } if (list2 != null && list2.Count > 0) { foreach (ItemData item3 in list2) { inventory.Items.Remove(item3); } List<ItemData> items = inventory.Items; if (items != null && items.Count == 0) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item); } } zdo.ReleaseOwnership(); num2 += (float)num6; vars = zdo.Vars; ((ZDOVars)(ref vars)).SetFuel(num2, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 169); inventory.Save(); num4 += num6; if (num3 != 0) { continue; } break; } if (list != null) { foreach (ServersideQoLZDO item4 in list) { current.Remove(item4); } } if (num3 == 0) { break; } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } if (num4 != 0) { Processor.ShowMessage((IEnumerable<Peer>)peers, zdo, ConfigBase<Config>.Instance.Localization.Value.FormatFuelAdded(prefabInfo.Smelter?.m_name ?? prefabInfo.ShieldGenerator.m_name, fuelItem.m_shared.m_name, num4), ConfigBase<Config>.Instance.OreOrFuelAddedMessageType.Value, (TextType)0); } if (num3 == 0) { break; } } } if (prefabInfo.Smelter != null) { int num10 = zdo.Fields<Smelter>().GetInt((Func<Expression<Func<Smelter, int>>>)(() => (Smelter x) => x.m_maxOre), "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 204); vars = zdo.Vars; int num11 = ((ZDOVars)(ref vars)).GetQueued(0); int num12 = num10 - num11; if (num12 > num10 / 2) { foreach (ItemConversion item5 in prefabInfo.Smelter.m_conversion) { ItemData oreItem = item5.m_from.m_itemData; int num13 = 0; AdjacentEnumerator<SharedItemDataKey, HashSet<ServersideQoLZDO>> enumerator8 = _containersByItemName.EnumerateAdjacent((zdo.ZDO.GetPosition(), SharedItemDataKey.op_Implicit(oreItem.m_shared))).GetEnumerator(); try { while (enumerator8.MoveNext()) { HashSet<ServersideQoLZDO> current7 = enumerator8.Current; list?.Clear(); foreach (ServersideQoLZDO item6 in current7) { ContainerState state2 = Processor.Instance<ContainerRegistryProcessor>().GetState(item6); if (state2 == null) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item6); continue; } vars = item6.Vars; if (((ZDOVars)(ref vars)).GetInUse(false)) { continue; } float num14 = state2.FeedRange ?? ConfigBase<Config>.Instance.FeedFromContainersRange.Value; num14 *= num14; if (num14 == 0f || Utils.DistanceSqr(zdo.ZDO.GetPosition(), item6.ZDO.GetPosition()) > num14) { continue; } IInventory inventory2 = state2.GetInventory(); list2?.Clear(); int num15 = 0; int num16 = ConfigBase<Config>.Instance.FeedFromContainersLeaveAtLeastOre.Value; bool flag3 = false; bool flag4 = false; foreach (ItemData item7 in from x in inventory2.Items where new ItemDataKey(x) == ItemDataKey.op_Implicit(oreItem) orderby x.m_stack select x) { flag3 = flag3 || (item7 != null && item7.m_stack > 0); int num17 = Math.Min(num12, item7.m_stack); int num18 = Math.Min(num17, num16); num16 -= num18; num17 -= num18; if (num17 != 0) { if (!item6.IsOwnerOrUnassigned()) { flag4 = true; break; } num15 += num17; item7.m_stack -= num17; if (item7.m_stack == 0) { (list2 ?? (list2 = new List<ItemData>())).Add(item7); } num12 -= num17; if (num12 == 0) { break; } } } if (flag4) { Processor.Instance<ContainerRegistryProcessor>().RequestOwnership(item6, 0L, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 265); continue; } if (num15 == 0) { if (!flag3) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item6); } continue; } if (list2 != null && list2.Count > 0) { foreach (ItemData item8 in list2) { inventory2.Items.Remove(item8); } List<ItemData> items = inventory2.Items; if (items != null && items.Count == 0) { (list ?? (list = new List<ServersideQoLZDO>())).Add(item6); } } zdo.ReleaseOwnership(); for (int num19 = 0; num19 < num15; num19++) { vars = zdo.Vars; ((ZDOVars)(ref vars)).SetItem(num11 + num19, ((Object)((Component)item5.m_from).gameObject).name, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 287); } num11 += num15; vars = zdo.Vars; ((ZDOVars)(ref vars)).SetQueued(num11, "C:\\repos\\Valheim.ServersideQoL\\ServersideQoL.AutoProcess\\SmelterProcessor.cs", 289); inventory2.Save(); num13 += num15; if (num12 != 0) { continue; } break; } if (list != null) { foreach (ServersideQoLZDO item9 in list) { current7.Remove(item9); } } if (num12 == 0) { break; } } } finally { ((IDisposable)enumerator8/*cast due to .constrained prefix*/).Dispose(); } if (num13 != 0) { Processor.ShowMessage((IEnumerable<Peer>)peers, zdo, ConfigBase<Config>.Instance.Localization.Value.FormatOreAdded(prefabInfo.Smelter.m_name, oreItem.m_shared.m_name, num13), ConfigBase<Config>.Instance.OreOrFuelAddedMessageType.Value, (TextType)0); } if (num12 == 0) { break; } } } } SectorDictionary.TryAdd(_smelters, zdo, true); return val; } private void OnContainerChanged(ServersideQoLZDO containerZdo, ContainerState state) { //IL_0091: 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_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (_smelters == null) { return; } float num = state.FeedRange ?? ConfigBase<Config>.Instance.FeedFromContainersRange.Value; num *= num; if (num == 0f) { return; } IInventory inventory = state.GetInventory(); if (inventory == null) { return; } List<ItemData> items = inventory.Items; if (items == null || items.Count <= 0) { return; } AdjacentEnumerator<HashSet<ServersideQoLZDO>> enumerator = _smelters.EnumerateAdjacent(containerZdo.ZDO.GetPosition()).GetEnumerator(); try { while (enumerator.MoveNext()) { HashSet<ServersideQoLZDO> current = enumerator.Current; foreach (ServersideQoLZDO item in current) { if (Utils.DistanceSqr(item.ZDO.GetPosition(), containerZdo.ZDO.GetPosition()) <= num) { ((Processor)this).ScheduleReprocessing(item); } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } }