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 REXOffshootInheritance v1.1.1
REXOffshootInheritance.dll
Decompiled a day agousing 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 Microsoft.CodeAnalysis; using RoR2; 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("REXOffshootInheritance")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REXOffshootInheritance")] [assembly: AssemblyTitle("REXOffshootInheritance")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 REXOffshootInheritance { [BepInPlugin("com.pelham.rexoffshootinheritance", "REX Offshoot Inheritance", "1.1.1")] public class Plugin : BaseUnityPlugin { private const string TurretBodyName = "ProliferationFlowerTurretBody"; private readonly HashSet<CharacterBody> trackedTurrets = new HashSet<CharacterBody>(); private readonly Dictionary<CharacterMaster, string> lastInventoryState = new Dictionary<CharacterMaster, string>(); private float checkTimer; private void OnEnable() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"REX Offshoot Inheritance loaded!"); CharacterBody.onBodyStartGlobal += OnBodyStart; } private void OnDisable() { CharacterBody.onBodyStartGlobal -= OnBodyStart; trackedTurrets.Clear(); lastInventoryState.Clear(); } private void OnBodyStart(CharacterBody body) { if (!((Object)(object)body == (Object)null) && !((Object)(object)((Component)body).gameObject == (Object)null) && ((Object)((Component)body).gameObject).name.Contains("ProliferationFlowerTurretBody")) { trackedTurrets.Add(body); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Found REX Offshoot turret: " + ((Object)((Component)body).gameObject).name)); SyncTurret(body); } } private void Update() { checkTimer += Time.deltaTime; if (checkTimer < 1f) { return; } checkTimer = 0f; trackedTurrets.RemoveWhere((CharacterBody turret) => (Object)(object)turret == (Object)null); foreach (CharacterBody trackedTurret in trackedTurrets) { if ((Object)(object)trackedTurret == (Object)null || (Object)(object)trackedTurret.master == (Object)null) { continue; } CharacterMaster master = trackedTurret.master; if ((Object)(object)master.minionOwnership == (Object)null) { continue; } CharacterMaster ownerMaster = master.minionOwnership.ownerMaster; if (!((Object)(object)ownerMaster == (Object)null) && !((Object)(object)ownerMaster.inventory == (Object)null)) { string inventoryState = GetInventoryState(ownerMaster); if (!lastInventoryState.TryGetValue(ownerMaster, out var value) || value != inventoryState) { lastInventoryState[ownerMaster] = inventoryState; SyncTurret(trackedTurret); } } } } private unsafe string GetInventoryState(CharacterMaster master) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected I4, but got Unknown Inventory inventory = master.inventory; if ((Object)(object)inventory == (Object)null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; int itemCount = inventory.GetItemCount(current); if (itemCount > 0) { stringBuilder.Append((int)current); stringBuilder.Append(':'); stringBuilder.Append(itemCount); stringBuilder.Append(';'); } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } return stringBuilder.ToString(); } private void SyncTurret(CharacterBody turret) { if ((Object)(object)turret == (Object)null || (Object)(object)turret.inventory == (Object)null) { return; } CharacterMaster master = turret.master; if (!((Object)(object)master == (Object)null) && !((Object)(object)master.minionOwnership == (Object)null)) { CharacterMaster ownerMaster = master.minionOwnership.ownerMaster; if (!((Object)(object)ownerMaster == (Object)null) && !((Object)(object)ownerMaster.inventory == (Object)null)) { turret.inventory.CopyItemsFrom(ownerMaster.inventory); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Synchronized items to REX Offshoot: " + ((Object)((Component)turret).gameObject).name)); } } } } }