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 Summon Inheritance v1.0.0
plugins\SummonInheritance\SummonInheritance.dll
Decompiled 19 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HG; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("SummonInheritance")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SummonInheritance")] [assembly: AssemblyTitle("SummonInheritance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 SummonInheritance { public static class ModConfig { public static ConfigEntry<bool> ModEnabled = null; public static ConfigEntry<bool> LiveSync = null; public static ConfigEntry<bool> InheritEquipment = null; public static ConfigEntry<float> ItemStackMultiplier = null; public static ConfigEntry<int> ItemCountCap = null; public static ConfigEntry<bool> InheritModdedOrUnknownTiers = null; public static readonly Dictionary<ItemTier, ConfigEntry<bool>> TierConfigs = new Dictionary<ItemTier, ConfigEntry<bool>>(); public static readonly Dictionary<string, ConfigEntry<bool>> TierDefNameConfigs = new Dictionary<string, ConfigEntry<bool>>(StringComparer.OrdinalIgnoreCase); public static ConfigEntry<bool> InheritDronesAndTurrets = null; public static ConfigEntry<bool> InheritBeetleGuards = null; public static ConfigEntry<bool> InheritAurelionite = null; public static ConfigEntry<bool> InheritSolusProbes = null; public static ConfigEntry<bool> InheritSquidTurrets = null; public static ConfigEntry<bool> InheritGhosts = null; public static ConfigEntry<bool> InheritBackupDrones = null; public static ConfigEntry<bool> InheritDevoted = null; public static ConfigEntry<bool> InheritOtherMinions = null; public static ConfigEntry<bool> InheritDios = null; public static ConfigEntry<string> BlacklistedItems = null; private static readonly HashSet<string> parsedBlacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static ConfigFile? configFile; private static bool riskOfOptionsInstalled; public static void Init(ConfigFile config) { configFile = config; riskOfOptionsInstalled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); ModEnabled = config.Bind<bool>("1. General", "ModEnabled", true, "Enable or disable the SummonInheritance mod."); LiveSync = config.Bind<bool>("1. General", "LiveSync", true, "Dynamically update living summons' inventories whenever you pick up new items during a stage."); InheritEquipment = config.Bind<bool>("1. General", "InheritEquipment", true, "Whether summons also inherit the player's active equipment."); ItemStackMultiplier = config.Bind<float>("1. General", "ItemStackMultiplier", 1f, "Fraction of player's item count given to summons (1.0 = 100%, 0.5 = 50%)."); ItemCountCap = config.Bind<int>("1. General", "ItemCountCap", 0, "Maximum stacks of any single item granted to a summon (0 = uncapped)."); InheritModdedOrUnknownTiers = config.Bind<bool>("2. Item Tiers", "InheritModdedOrUnknownTiers", true, "Automatically inherit items belonging to custom modded or uncataloged tiers (e.g. Starstorm 2 Relics, DLC tiers)."); BindBaseTier(config, (ItemTier)0, "InheritTier_Tier1", "Common (White)"); BindBaseTier(config, (ItemTier)1, "InheritTier_Tier2", "Uncommon (Green)"); BindBaseTier(config, (ItemTier)2, "InheritTier_Tier3", "Legendary (Red)"); BindBaseTier(config, (ItemTier)4, "InheritTier_Boss", "Boss (Yellow)"); BindBaseTier(config, (ItemTier)3, "InheritTier_Lunar", "Lunar (Blue)"); BindBaseTier(config, (ItemTier)6, "InheritTier_VoidTier1", "Void Common"); BindBaseTier(config, (ItemTier)7, "InheritTier_VoidTier2", "Void Uncommon"); BindBaseTier(config, (ItemTier)8, "InheritTier_VoidTier3", "Void Legendary"); BindBaseTier(config, (ItemTier)9, "InheritTier_VoidBoss", "Void Boss"); InheritDronesAndTurrets = config.Bind<bool>("3. Summon Types", "InheritDronesAndTurrets", true, "Inherit items on purchaseable drones and gunner turrets."); InheritBeetleGuards = config.Bind<bool>("3. Summon Types", "InheritBeetleGuards", true, "Inherit items on Queen's Gland Beetle Guards."); InheritAurelionite = config.Bind<bool>("3. Summon Types", "InheritAurelionite", true, "Inherit items on Halcyon Seed Golden Titan (Aurelionite)."); InheritSolusProbes = config.Bind<bool>("3. Summon Types", "InheritSolusProbes", true, "Inherit items on Empathy Cores Solus Probes."); InheritSquidTurrets = config.Bind<bool>("3. Summon Types", "InheritSquidTurrets", true, "Inherit items on Squid Polyp turrets."); InheritGhosts = config.Bind<bool>("3. Summon Types", "InheritGhosts", true, "Inherit items on Happiest Mask ghosts."); InheritBackupDrones = config.Bind<bool>("3. Summon Types", "InheritBackupDrones", true, "Inherit items on The Back-up equipment strike drones."); InheritDevoted = config.Bind<bool>("3. Summon Types", "InheritDevoted", true, "Inherit items on Devoted Lemurians and Seekers of the Storm allies."); InheritOtherMinions = config.Bind<bool>("3. Summon Types", "InheritOtherMinions", true, "Inherit items on any other minion/creature belonging to your team (including modded summons)."); InheritDios = config.Bind<bool>("4. Safety & Blacklist", "InheritDios", false, "Allow summons to inherit ExtraLife (Dio's Best Friend). Disabled by default to prevent drone revival bugs."); BlacklistedItems = config.Bind<string>("4. Safety & Blacklist", "BlacklistedItems", "LunarPrimaryReplacement, LunarSecondaryReplacement, LunarUtilityReplacement, LunarSpecialReplacement, TitanGoldDuringTP, RoboBallBuddy, BeetleGland, MinionLeash, Ghost", "Comma-separated item codenames to blacklist from being given to summons."); UpdateBlacklistCache(); BlacklistedItems.SettingChanged += delegate { UpdateBlacklistCache(); }; if (riskOfOptionsInstalled) { TryRegisterBaseRiskOfOptions(); } ((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)OnItemTierCatalogAvailable); } private static void BindBaseTier(ConfigFile config, ItemTier tier, string key, string name) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<bool> value = config.Bind<bool>("2. Item Tiers", key, true, "Inherit " + name + " items."); TierConfigs[tier] = value; TierDefNameConfigs[key] = value; } private static void OnItemTierCatalogAvailable() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown if (configFile == null) { return; } try { Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemTierDef current = enumerator.Current; if ((Object)(object)current == (Object)null) { continue; } string name = ((Object)current).name; if (string.IsNullOrEmpty(name)) { continue; } string text = name.Replace("Def", "").Trim(); string text2 = "InheritTier_" + text; ConfigEntry<bool> value; if (!TierDefNameConfigs.ContainsKey(name) && !TierDefNameConfigs.ContainsKey(text2)) { ConfigEntry<bool> val = configFile.Bind<bool>("2. Item Tiers", text2, true, "Dynamically discovered tier: Inherit " + text + " items."); TierConfigs[current.tier] = val; TierDefNameConfigs[name] = val; TierDefNameConfigs[text2] = val; if (riskOfOptionsInstalled) { TryRegisterOption((BaseOption)new CheckBoxOption(val)); } Debug.Log((object)$"[SummonInheritance] Dynamically registered tier: {text} ({current.tier})"); } else if (TierConfigs.TryGetValue(current.tier, out value)) { TierDefNameConfigs[name] = value; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception arg) { Debug.LogWarning((object)$"[SummonInheritance] Error scanning ItemTierCatalog: {arg}"); } } public static bool IsTierAllowed(ItemDef itemDef) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0061: 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) if ((Object)(object)itemDef == (Object)null) { return false; } if ((int)itemDef.tier == 5) { return false; } try { ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier); if ((Object)(object)itemTierDef != (Object)null && !string.IsNullOrEmpty(((Object)itemTierDef).name) && TierDefNameConfigs.TryGetValue(((Object)itemTierDef).name, out ConfigEntry<bool> value)) { return value.Value; } } catch { } if (TierConfigs.TryGetValue(itemDef.tier, out ConfigEntry<bool> value2)) { return value2.Value; } return InheritModdedOrUnknownTiers.Value; } private static void UpdateBlacklistCache() { parsedBlacklist.Clear(); if (!string.IsNullOrWhiteSpace(BlacklistedItems.Value)) { string[] array = BlacklistedItems.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { parsedBlacklist.Add(text.Trim()); } } } public static bool IsItemBlacklisted(string itemName) { return parsedBlacklist.Contains(itemName); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void TryRegisterBaseRiskOfOptions() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown try { ModSettingsManager.SetModDescription("Allows all summoned minions, drones, turrets, and allied creatures in your team to inherit your items and equipment.", "com.Antigravity.SummonInheritance", "SummonInheritance"); try { using Stream stream = typeof(ModConfig).Assembly.GetManifestResourceStream("SummonInheritance.icon.png"); if (stream != null) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array)) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)), "com.Antigravity.SummonInheritance", "SummonInheritance"); } } } catch (Exception arg) { Debug.LogWarning((object)$"[SummonInheritance] Failed to load embedded icon: {arg}"); } ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModEnabled)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LiveSync)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritEquipment)); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(ItemStackMultiplier, new StepSliderConfig { min = 0.1f, max = 2f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(ItemCountCap, new IntSliderConfig { min = 0, max = 50 })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritModdedOrUnknownTiers)); foreach (KeyValuePair<ItemTier, ConfigEntry<bool>> tierConfig in TierConfigs) { ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(tierConfig.Value)); } ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritDronesAndTurrets)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritBeetleGuards)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritAurelionite)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritSolusProbes)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritSquidTurrets)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritGhosts)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritBackupDrones)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritDevoted)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritOtherMinions)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InheritDios)); } catch (Exception arg2) { Debug.LogWarning((object)$"[SummonInheritance] Failed to register base RiskOfOptions: {arg2}"); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void TryRegisterOption(BaseOption option) { try { ModSettingsManager.AddOption(option); } catch (Exception arg) { Debug.LogWarning((object)$"[SummonInheritance] Failed to register dynamic option: {arg}"); } } } [BepInPlugin("com.Antigravity.SummonInheritance", "SummonInheritance", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SummonInheritancePlugin : BaseUnityPlugin { public const string PluginGUID = "com.Antigravity.SummonInheritance"; public const string PluginName = "SummonInheritance"; public const string PluginVersion = "1.0.0"; private static readonly List<MinionInheritanceSync> ActiveMinions = new List<MinionInheritanceSync>(); public static SummonInheritancePlugin Instance { get; private set; } = null; private void Awake() { Instance = this; ModConfig.Init(((BaseUnityPlugin)this).Config); MinionOwnership.onMinionOwnerChangedGlobal += OnMinionOwnerChanged; CharacterMaster.onStartGlobal += OnMasterStart; Inventory.onInventoryChangedGlobal += OnInventoryChanged; Stage.onStageStartGlobal += OnStageStart; ((BaseUnityPlugin)this).Logger.LogInfo((object)"SummonInheritance v1.0.0 initialized successfully with dynamic tier support!"); } private void OnDestroy() { MinionOwnership.onMinionOwnerChangedGlobal -= OnMinionOwnerChanged; CharacterMaster.onStartGlobal -= OnMasterStart; Inventory.onInventoryChangedGlobal -= OnInventoryChanged; Stage.onStageStartGlobal -= OnStageStart; } private void OnMasterStart(CharacterMaster master) { if (NetworkServer.active && ModConfig.ModEnabled.Value && !((Object)(object)master == (Object)null)) { ((MonoBehaviour)this).StartCoroutine(CheckAndAttachSync(master)); } } private void OnMinionOwnerChanged(MinionOwnership minionOwnership) { if (NetworkServer.active && ModConfig.ModEnabled.Value && !((Object)(object)minionOwnership == (Object)null)) { CharacterMaster component = ((Component)minionOwnership).GetComponent<CharacterMaster>(); if ((Object)(object)component != (Object)null) { ((MonoBehaviour)this).StartCoroutine(CheckAndAttachSync(component)); } } } private IEnumerator CheckAndAttachSync(CharacterMaster master) { yield return null; if (!((Object)(object)master == (Object)null) && !((Object)(object)master.inventory == (Object)null) && !((Object)(object)((Component)master).GetComponent<MinionInheritanceSync>() != (Object)null) && ShouldInherit(master, out CharacterMaster ownerMaster) && (Object)(object)ownerMaster != (Object)null) { ((Component)master).gameObject.AddComponent<MinionInheritanceSync>().Initialize(master, ownerMaster); } } private static void OnStageStart(Stage stage) { if (!NetworkServer.active || !ModConfig.ModEnabled.Value) { return; } ActiveMinions.RemoveAll((MinionInheritanceSync m) => (Object)(object)m == (Object)null); foreach (MinionInheritanceSync activeMinion in ActiveMinions) { activeMinion.Sync(); } } private static void OnInventoryChanged(Inventory inventory) { if (!NetworkServer.active || !ModConfig.ModEnabled.Value || !ModConfig.LiveSync.Value || (Object)(object)inventory == (Object)null) { return; } ActiveMinions.RemoveAll((MinionInheritanceSync m) => (Object)(object)m == (Object)null); foreach (MinionInheritanceSync activeMinion in ActiveMinions) { if ((Object)(object)activeMinion != (Object)null && (Object)(object)activeMinion.OwnerMaster != (Object)null && (Object)(object)activeMinion.OwnerMaster.inventory == (Object)(object)inventory) { activeMinion.Sync(); } } } public static void RegisterMinion(MinionInheritanceSync sync) { if (!ActiveMinions.Contains(sync)) { ActiveMinions.Add(sync); } } public static void UnregisterMinion(MinionInheritanceSync sync) { ActiveMinions.Remove(sync); } public static bool ShouldInherit(CharacterMaster minionMaster, out CharacterMaster? ownerMaster) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) ownerMaster = null; if (!ModConfig.ModEnabled.Value || (Object)(object)minionMaster == (Object)null || (Object)(object)minionMaster.inventory == (Object)null) { return false; } MinionOwnership minionOwnership = minionMaster.minionOwnership; if ((Object)(object)minionOwnership == (Object)null || (Object)(object)minionOwnership.ownerMaster == (Object)null) { return false; } ownerMaster = minionOwnership.ownerMaster; if ((Object)(object)ownerMaster == (Object)(object)minionMaster) { return false; } if ((Object)(object)ownerMaster.playerCharacterMasterController == (Object)null) { return false; } string text = (((Object)(object)minionMaster.bodyPrefab != (Object)null) ? ((Object)minionMaster.bodyPrefab).name : ""); CharacterBody body = minionMaster.GetBody(); if (string.IsNullOrEmpty(text) && (Object)(object)body != (Object)null) { text = ((Object)body).name; } string text2 = ((Object)minionMaster).name ?? ""; if (text.Contains("EngiTurret") || text.Contains("EngiWalkerTurret") || text2.Contains("EngiTurret") || text2.Contains("EngiWalkerTurret")) { return false; } if (text.Contains("DroneBackup") || text2.Contains("DroneBackup")) { return ModConfig.InheritBackupDrones.Value; } if (((Object)(object)body != (Object)null && (((Enum)body.bodyFlags).HasFlag((Enum)(object)(BodyFlags)4194304) || ((Enum)body.bodyFlags).HasFlag((Enum)(object)(BodyFlags)33554432))) || text.Contains("Drone") || text.Contains("Turret") || text2.Contains("Drone") || text2.Contains("Turret")) { return ModConfig.InheritDronesAndTurrets.Value; } if (text.Contains("BeetleGuard") || text2.Contains("BeetleGuard")) { return ModConfig.InheritBeetleGuards.Value; } if (text.Contains("TitanGold") || text2.Contains("TitanGold")) { return ModConfig.InheritAurelionite.Value; } if (text.Contains("RoboBall") || text.Contains("Solus") || text2.Contains("RoboBall") || text2.Contains("Solus")) { return ModConfig.InheritSolusProbes.Value; } if (text.Contains("SquidTurret") || text2.Contains("SquidTurret")) { return ModConfig.InheritSquidTurrets.Value; } if (minionMaster.inventory.GetItemCountPermanent(Items.Ghost) > 0 || text.Contains("Ghost") || text2.Contains("Ghost")) { return ModConfig.InheritGhosts.Value; } if (((Object)(object)body != (Object)null && ((Enum)body.bodyFlags).HasFlag((Enum)(object)(BodyFlags)8192)) || text.Contains("Devotion") || text2.Contains("Devotion") || text.Contains("LemurianBruiser")) { return ModConfig.InheritDevoted.Value; } return ModConfig.InheritOtherMinions.Value; } } public class MinionInheritanceSync : MonoBehaviour { public CharacterMaster MinionMaster { get; private set; } public CharacterMaster OwnerMaster { get; private set; } public void Initialize(CharacterMaster minion, CharacterMaster owner) { MinionMaster = minion; OwnerMaster = owner; SummonInheritancePlugin.RegisterMinion(this); Sync(); } private void OnDestroy() { SummonInheritancePlugin.UnregisterMinion(this); } public unsafe void Sync() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Invalid comparison between Unknown and I4 //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !ModConfig.ModEnabled.Value || (Object)(object)MinionMaster == (Object)null || (Object)(object)MinionMaster.inventory == (Object)null || (Object)(object)OwnerMaster == (Object)null || (Object)(object)OwnerMaster.inventory == (Object)null) { return; } Inventory inventory = OwnerMaster.inventory; Inventory inventory2 = MinionMaster.inventory; float num = Mathf.Clamp(ModConfig.ItemStackMultiplier.Value, 0.05f, 5f); int value = ModConfig.ItemCountCap.Value; GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; int itemCountPermanent = inventory.GetItemCountPermanent(current); ItemDef itemDef = ItemCatalog.GetItemDef(current); if ((Object)(object)itemDef == (Object)null || !ModConfig.IsTierAllowed(itemDef) || IsBlacklisted(itemDef)) { continue; } int num2 = 0; if (itemCountPermanent > 0) { num2 = Mathf.Max(1, Mathf.FloorToInt((float)itemCountPermanent * num)); if (value > 0) { num2 = Mathf.Min(num2, value); } } int itemCountPermanent2 = inventory2.GetItemCountPermanent(current); if (itemCountPermanent2 < num2) { inventory2.GiveItemPermanent(current, num2 - itemCountPermanent2); } else if (itemCountPermanent2 > num2) { inventory2.RemoveItemPermanent(current, itemCountPermanent2 - num2); } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } if (ModConfig.InheritEquipment.Value) { EquipmentIndex currentEquipmentIndex = inventory.currentEquipmentIndex; if ((int)currentEquipmentIndex != -1 && (((!((Object)(object)MinionMaster.bodyPrefab != (Object)null) || !((Object)MinionMaster.bodyPrefab).name.Contains("EquipmentDrone")) && !((Object)MinionMaster).name.Contains("EquipmentDrone")) || (int)inventory2.currentEquipmentIndex == -1) && inventory2.currentEquipmentIndex != currentEquipmentIndex) { inventory2.SetEquipmentIndex(currentEquipmentIndex); } } } private static bool IsBlacklisted(ItemDef itemDef) { if (itemDef.ContainsTag((ItemTag)13)) { return true; } if ((Object)(object)itemDef == (Object)(object)Items.LunarPrimaryReplacement || (Object)(object)itemDef == (Object)(object)Items.LunarSecondaryReplacement || (Object)(object)itemDef == (Object)(object)Items.LunarUtilityReplacement || (Object)(object)itemDef == (Object)(object)Items.LunarSpecialReplacement) { return true; } if (((Object)(object)itemDef == (Object)(object)Items.ExtraLife || (Object)(object)itemDef == (Object)(object)Items.ExtraLifeVoid) && !ModConfig.InheritDios.Value) { return true; } if ((Object)(object)itemDef == (Object)(object)Items.Ghost) { return true; } if (ModConfig.IsItemBlacklisted(((Object)itemDef).name)) { return true; } return false; } } }