using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Remnants.Behaviours; using Remnants.Data; using Remnants.Patches; using Remnants.utilities; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Remnants")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("Remnants")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6c141570-800d-4365-af83-2d520645ce78")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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; } } } namespace Remnants { [BepInDependency("evaisa.lethallib", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("KawaiiBone.Remnants", "Remnants", "1.4.4")] public class Remnants : BaseUnityPlugin { private const string modGUID = "KawaiiBone.Remnants"; private const string modName = "Remnants"; private const string modVersion = "1.4.4"; public static Remnants Instance; private readonly Harmony _harmony = new Harmony("KawaiiBone.Remnants"); internal ManualLogSource Mls; public RegisterBodiesSpawnBehaviour RegisterBodiesSpawn = new RegisterBodiesSpawnBehaviour(); public Config RemnantsConfig = new Config(); public RegisterBodySuitsBehaviour RegisterBodySuits = new RegisterBodySuitsBehaviour(); public LoadAssetsBodies LoadBodyAssets = new LoadAssetsBodies(); public SpawnBodiesBehaviour SpawningBodyBeh = new SpawnBodiesBehaviour(); public RemnantItemsBehaviour RemnantItemsBeh = new RemnantItemsBehaviour(); public RandomizeBatteriesBehaviour ItemsBatteriesBeh = new RandomizeBatteriesBehaviour(); public SpawnRemnantItemsBehaviour SpawnRemnantItemsBeh = new SpawnRemnantItemsBehaviour(); private RegisterItemsBehaviour _registerItemsBehaviour = new RegisterItemsBehaviour(); private string[] _riskLevelArray = new string[9] { "Safe", "D", "C", "B", "A", "S", "S+", "S++", "S+++" }; public string[] RiskLevelArray => _riskLevelArray; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Mls = Logger.CreateLogSource("KawaiiBone.Remnants"); Mls.LogInfo((object)"modGUID has started"); RemnantsConfig.Initialize(); _harmony.PatchAll(typeof(RemnantItemsPatch)); _harmony.PatchAll(typeof(SpawnRemnantItemsPatch)); _harmony.PatchAll(typeof(SpawnableScrapPatch)); _harmony.PatchAll(typeof(BodySuitBehaviour)); _harmony.PatchAll(typeof(RegisterSuitsPatch)); _harmony.PatchAll(typeof(AddRemnantItemsToItemList)); _harmony.PatchAll(typeof(EndRoundStatsPatch)); _harmony.PatchAll(typeof(BeltBagTranspiler)); _harmony.PatchAll(typeof(UtilitySlotTranspiler)); _harmony.PatchAll(typeof(PartyWipeRemnantItemsTranspiler)); _harmony.PatchAll(typeof(Remnants)); _registerItemsBehaviour.Initialize(); RegisterBodiesSpawn.Initialize(); LoadBodyAssets.Initialize(); RegisterBodySuits.Initialize(); SpawningBodyBeh.Initialize(); ItemsBatteriesBeh.Initialize(); SpawnRemnantItemsBeh.Initialize(); Mls.LogInfo((object)"modGUID has loaded"); } } } namespace Remnants.utilities { internal class CoroutineHelper : MonoBehaviour { [CompilerGenerated] private sealed class d__6 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Action action; public float delay; public CoroutineHelper <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; action(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static CoroutineHelper Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } public void ExecuteAfterDelay(Action action, float delay) { ((MonoBehaviour)this).StartCoroutine(DelayedExecution(action, delay)); } [IteratorStateMachine(typeof(d__6))] private IEnumerator DelayedExecution(Action action, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { <>4__this = this, action = action, delay = delay }; } } public class RemnantData { public string RemnantItemName { get; set; } public int RarityInfo { get; set; } } public class SuitData { public string SuitName { get; set; } public bool UseSuit { get; set; } } } namespace Remnants.Patches { internal class AddRemnantItemsToItemList { private static bool _hasAddedNetworkRemnantItems; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void AddNetworkRemnantToStartOfRoundList(StartOfRound __instance) { if (!_hasAddedNetworkRemnantItems) { _hasAddedNetworkRemnantItems = true; ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Patch, adding network remnant items to startOfRound item list."); List networkRemnantItems = Remnants.Instance.RemnantItemsBeh.NetworkRemnantItems; for (int i = 0; i < networkRemnantItems.Count; i++) { __instance.allItemsList.itemsList.Add(networkRemnantItems[i].item); } } } } internal class BeltBagTranspiler { private static FieldInfo _itemIsScrapField = AccessTools.Field(typeof(GrabbableObject), "itemProperties"); private static List _remnantItemNameList = null; [HarmonyPatch(typeof(BeltBagItem), "ItemInteractLeftRight")] [HarmonyTranspiler] private static IEnumerable SaveItemsInShipTranspiler(IEnumerable instructions, ILGenerator il) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown ManualLogSource mls = Remnants.Instance.Mls; if (!Remnants.Instance.RemnantsConfig.UseBeltBagTranspiler.Value) { mls.LogWarning((object)"Beltbag feature disabled, beltbag can now not pickup remnant items."); return instructions; } List list = new List(instructions); int num = -1; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (num == -1 && CodeInstructionExtensions.LoadsField(list[i], _itemIsScrapField, false)) { num = i; } else if (num > -1 && list[i].opcode == OpCodes.Brtrue) { num2 = i; break; } } if (num == -1 || num2 == -1) { mls.LogError((object)"Could not find place in if statement to edit, unable to use BeltBagItem with remnant items."); return list.AsEnumerable(); } int num3 = num2 - num; for (int j = 0; j < num3; j++) { list[j + num].opcode = OpCodes.Nop; } list[num2].opcode = OpCodes.Brfalse_S; list.Insert(num, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BeltBagTranspiler), "CheckIsStoreOrRemnantItem", new Type[1] { typeof(GrabbableObject) }, (Type[])null))); mls.LogInfo((object)"Transpiler succes with function: ItemInteractLeftRight for BeltBagItem."); return list.AsEnumerable(); } public bool CheckIsStoreOrRemnantItem(GrabbableObject grabbableObject) { if ((Object)(object)grabbableObject == (Object)null || (Object)(object)grabbableObject.itemProperties == (Object)null || !((Behaviour)grabbableObject).isActiveAndEnabled) { return false; } if (!grabbableObject.itemProperties.isScrap) { return true; } if (_remnantItemNameList == null) { _remnantItemNameList = (from c in Remnants.Instance.RemnantsConfig.GetRemnantItemList(reloadConfig: false) select c.RemnantItemName).ToList(); } if (_remnantItemNameList.FindIndex((string configEntry) => configEntry == grabbableObject.itemProperties.itemName || configEntry == ((Object)grabbableObject.itemProperties).name) != -1) { return true; } return false; } } internal class UtilitySlotTranspiler { private static FieldInfo _itemIsScrapField = AccessTools.Field(typeof(GrabbableObject), "itemProperties"); private static List _remnantUtilityNameList = null; [HarmonyPatch(typeof(PlayerControllerB), "FirstEmptyItemSlot")] [HarmonyTranspiler] private static IEnumerable FirstEmptyItemSlotTranspiler(IEnumerable instructions, ILGenerator il) { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown ManualLogSource mls = Remnants.Instance.Mls; if (!Remnants.Instance.RemnantsConfig.UseBeltBagTranspiler.Value) { mls.LogWarning((object)"Remnant flashlight slot feature disabled, flashlight slot can now not pickup remnant flashlight items."); return instructions; } List list = new List(instructions); int num = -1; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (num == -1 && CodeInstructionExtensions.LoadsField(list[i], _itemIsScrapField, false)) { num = i; } else if (num > -1 && list[i].opcode == OpCodes.Brtrue) { num2 = i; break; } } if (num == -1 || num2 == -1) { mls.LogError((object)"Could not find place in if statement to edit, unable to use remnant flashlight slot feature."); return list.AsEnumerable(); } int num3 = num2 - num; for (int j = 0; j < num3; j++) { list[j + num].opcode = OpCodes.Nop; } list.Insert(num, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UtilitySlotTranspiler), "IsRemnantFlashlightOrScrap", new Type[1] { typeof(GrabbableObject) }, (Type[])null))); mls.LogInfo((object)"Transpiler succes with function: FirstEmptyItemSlot for remnant flashlight item slot."); return list.AsEnumerable(); } public static bool IsRemnantFlashlightOrScrap(GrabbableObject attemptingGrab) { if (_remnantUtilityNameList == null) { List first = (from c in Remnants.Instance.RemnantsConfig.GetRemnantItemList(reloadConfig: false) select c.RemnantItemName.ToLower()).ToList(); List second = Remnants.Instance.RemnantsConfig.GetBannedFromUtilitySlotItemNames().ConvertAll((string c) => c.ToLower()); _remnantUtilityNameList = first.Except(second).ToList(); } return _remnantUtilityNameList.FindIndex((string ul) => ul == attemptingGrab.itemProperties.itemName.ToLower() || ul == ((Object)attemptingGrab.itemProperties).name.ToLower()) == -1 && attemptingGrab.itemProperties.isScrap; } } internal class PartyWipeRemnantItemsTranspiler { private static FieldInfo _itemIsScrapField = AccessTools.Field(typeof(GrabbableObject), "itemProperties"); [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyTranspiler] private static IEnumerable RemnantItemsOnPartyWipeTranspiler(IEnumerable instructions, ILGenerator il) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown ManualLogSource mls = Remnants.Instance.Mls; if (Remnants.Instance.RemnantsConfig.ShouldDespawnRemnantItemsOnPartyWipe.Value) { mls.LogWarning((object)"Despawm remnant items on party wipe feature disabled, remnant items will now despawn on party wipe like scrap on the ship."); return instructions; } List list = new List(instructions); int num = -1; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (num == -1 && CodeInstructionExtensions.LoadsField(list[i], _itemIsScrapField, false)) { num = i; } else if (num > -1 && list[i].opcode == OpCodes.Brfalse) { num2 = i; break; } } if (num == -1 || num2 == -1) { mls.LogError((object)"Could not find place in if statement to edit, unable to keep remnant items on ship on party wipe."); return list.AsEnumerable(); } int num3 = num2 - num; for (int j = 0; j < num3; j++) { list[j + num].opcode = OpCodes.Nop; } list[num2].opcode = OpCodes.Brfalse_S; list.Insert(num, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BeltBagTranspiler), "CheckIsStoreOrRemnantItem", new Type[1] { typeof(GrabbableObject) }, (Type[])null))); mls.LogInfo((object)"Transpiler succes with function: DespawnPropsAtEndOfRound for not despawning remnant items on party wipe."); return list.AsEnumerable(); } } internal class RegisterSuitsPatch { private static bool _hasRegistered; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void RegisterBodySuitsPatch(StartOfRound __instance) { if (!_hasRegistered) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Patching register body suits."); Remnants.Instance.RegisterBodySuits.RegisterSuitsDataToConfig(__instance.unlockablesList.unlockables); _hasRegistered = true; } } } internal class RemnantItemsPatch { [HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")] [HarmonyPostfix] private static void PatchRemnantItems(object[] __args) { ManualLogSource mls = Remnants.Instance.Mls; NetworkObjectReference[] array = (NetworkObjectReference[])__args[0]; mls.LogInfo((object)"Patching remnant items."); if (array == null) { mls.LogWarning((object)"spawnedScrap IS NULL"); return; } RemnantItemsBehaviour remnantItemsBeh = Remnants.Instance.RemnantItemsBeh; RandomizeBatteriesBehaviour itemsBatteriesBeh = Remnants.Instance.ItemsBatteriesBeh; SpawnBodiesBehaviour spawningBodyBeh = Remnants.Instance.SpawningBodyBeh; List list = new List(); List remnantItemList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(); List overriddenScrapItems = Remnants.Instance.RemnantsConfig.GetOverriddenScrapItems(); NetworkObject val = default(NetworkObject); for (int i = 0; i < array.Length; i++) { if (!((NetworkObjectReference)(ref array[i])).TryGet(ref val, (NetworkManager)null)) { continue; } GrabbableObject grabbableObject = ((Component)val).GetComponent(); if (!((Object)(object)grabbableObject == (Object)null)) { if (overriddenScrapItems.FindIndex((string scrapName) => scrapName == grabbableObject.itemProperties.itemName || scrapName == ((Object)grabbableObject.itemProperties).name) != -1) { list.Add(((Component)grabbableObject).gameObject); } else if (remnantItemList.FindIndex((RemnantData itemData) => itemData.RemnantItemName == grabbableObject.itemProperties.itemName || itemData.RemnantItemName == ((Object)grabbableObject.itemProperties).name) != -1) { list.Add(((Component)grabbableObject).gameObject); } } } itemsBatteriesBeh.RandomizeItemsBattery(list); spawningBodyBeh.SpawnBodiesOnItems(list); } } internal class SpawnableScrapPatch { private static int _currentLevelMinScrap = 0; private static int _currentLevelMaxScrap = 0; private static List _removedSpawnableItems = new List(); [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPrefix] public static void SpawnScrapInLevelPatch(RoundManager __instance) { //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Patching remnant items spawns."); List spawnableScrap = __instance.currentLevel.spawnableScrap; List scrapItemDataList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(); _removedSpawnableItems = spawnableScrap.Where((SpawnableItemWithRarity spawnableItem) => scrapItemDataList.FindIndex((RemnantData itemData) => itemData.RarityInfo == 0 && itemData.RemnantItemName == spawnableItem.spawnableItem.itemName) != -1).ToList(); spawnableScrap.RemoveAll((SpawnableItemWithRarity spawnableItem) => _removedSpawnableItems.Contains(spawnableItem)); __instance.currentLevel.spawnableScrap = spawnableScrap; if (Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value <= 0 || !Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value) { return; } _currentLevelMinScrap = __instance.currentLevel.minScrap; _currentLevelMaxScrap = __instance.currentLevel.maxScrap; float num = 1f; float num2 = 100f / (float)Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value; if (!Remnants.Instance.RemnantsConfig.UseSpecificLevelRarities.Value) { num = (float)Remnants.Instance.RemnantsConfig.MaxRemnantRarity.Value / num2; } else if (Remnants.Instance.RemnantsConfig.CustomLevelRarities.ContainsKey(__instance.currentLevel.PlanetName)) { num = (float)Remnants.Instance.RemnantsConfig.CustomLevelRarities[__instance.currentLevel.PlanetName].Item2 / num2; } else { foreach (KeyValuePair> levelRarity in Remnants.Instance.RemnantsConfig.LevelRarities) { string value = __instance.currentLevel.PlanetName.Split(new char[1] { ' ' }).Last(); LevelTypes key = levelRarity.Key; if (((object)(LevelTypes)(ref key)).ToString().Contains(value)) { num = (float)levelRarity.Value.Item2 / num2; break; } } } num = Mathf.Clamp(num, 1f, (float)Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value); SelectableLevel currentLevel = __instance.currentLevel; currentLevel.minScrap += (int)num; SelectableLevel currentLevel2 = __instance.currentLevel; currentLevel2.maxScrap += (int)num; } [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPostfix] public static void SpawnScrapInLevelEndPatch(RoundManager __instance) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Patching end of Spawn Scrap."); __instance.currentLevel.spawnableScrap.AddRange(_removedSpawnableItems); _removedSpawnableItems.Clear(); if (Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value > 0 && Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value) { __instance.currentLevel.minScrap = _currentLevelMinScrap; __instance.currentLevel.maxScrap = _currentLevelMaxScrap; } } } internal class SpawnRemnantItemsPatch { [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPostfix] private static void PatchSpawnRemnantItems(RoundManager __instance) { if (!Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Patching spawn remnant items."); Remnants.Instance.SpawnRemnantItemsBeh.SpawnRemnantItems(__instance); Remnants.Instance.SpawningBodyBeh.SpawnBodiesOnPositions(Remnants.Instance.SpawnRemnantItemsBeh.BodySpawnPositions, alwaysSpawn: true); } } } internal class EndRoundStatsPatch { private static int SyncScrapValueCounter; private static int _totalScrapValueInLevel; [HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")] [HarmonyPostfix] private static void PatchSyncScrapValuesClientRpcScrapValue(object[] __args, RoundManager __instance) { ManualLogSource mls = Remnants.Instance.Mls; if (!Remnants.Instance.RemnantsConfig.UseEndRoundPatchFix.Value) { return; } NetworkObjectReference[] array = (NetworkObjectReference[])__args[0]; if (array == null) { mls.LogWarning((object)"spawnedScrap IS NULL"); return; } if (SyncScrapValueCounter % 2 == 0) { _totalScrapValueInLevel += (int)__instance.totalScrapValueInLevel; } SyncScrapValueCounter++; } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPrefix] private static void PatchShipHasLeft(object[] __args, RoundManager __instance) { ManualLogSource mls = Remnants.Instance.Mls; if (Remnants.Instance.RemnantsConfig.UseEndRoundPatchFix.Value) { mls.LogInfo((object)"Patching ShipHasLeft."); RoundManager.Instance.totalScrapValueInLevel = _totalScrapValueInLevel; _totalScrapValueInLevel = 0; } } } } namespace Remnants.Data { public class Config { private struct ConfigData { public string Name; public string Discription; public string StringValue; public ConfigData(string name, string discription, string stringValue) { Name = name; Discription = discription; StringValue = stringValue; } } private struct ConfigDataValue where T : struct { public string Name; public string Discription; public T Value; } public ConfigEntry MinRemnantRarity; public ConfigEntry MaxRemnantRarity; public ConfigEntry MinRemnantBatteryCharge; public ConfigEntry MaxRemnantBatteryCharge; public List> ConfigScrapDataList; public List> ConfigSuitsDataList; public ConfigEntry UseSpecificLevelRarities; public ConfigEntry MaxRemnantItemCost; public ConfigEntry SpawnRarityOfBody; public ConfigEntry BodySpawnModifierRiskLevel; public ConfigEntry RemnantScrapMinCostPercentage; public ConfigEntry RemnantScrapMaxCostPercentage; public ConfigEntry ShouldDespawnRemnantItemsOnPartyWipe; public ConfigEntry ShouldBodiesBeScrap; public ConfigEntry MinBodyScrapValue; public ConfigEntry MaxBodyScrapValue; public Dictionary> LevelRarities = new Dictionary>(); public Dictionary> CustomLevelRarities = new Dictionary>(); public ConfigEntry IncreasedScrapSpawnPool; public ConfigEntry UseLegacySpawning; public ConfigEntry MinRemnantItemsSpawning; public ConfigEntry MaxRemnantItemsSpawning; public ConfigEntry RemnantItemsSpawningModifier; public ConfigEntry MaxDuplicatesRemnantItems; public ConfigEntry MinItemsFoundOnBodies; public ConfigEntry MaxItemsFoundOnBodies; public ConfigEntry UseBeltBagTranspiler; public ConfigEntry UseEndRoundPatchFix; private bool _hasInitialized = false; private List> _minRemnantLevelRarities = new List>(); private List> _maxRemnantLevelRarities = new List>(); private List> _minRemnantCustomLevelRarities = new List>(); private List> _maxRemnantCustomLevelRarities = new List>(); private List> _configRemnantDataPairList = new List>(); private List> _configCustomLevelsRarities = new List>(); private List> _configSuitsDataList = new List>(); private ConfigEntry _bannedNamesFromRegistering; private ConfigEntry _overriddenScrapItems; private ConfigEntry _bannedItemsFromSaving; private ConfigEntry _bannedItemsFromUtilitySlot; private ConfigFile _configFile; private string _bannedPlanetName = "71 Gordion"; private const string _LethalConfigName = "ainavt.lc.lethalconfig"; private string _configFileName = "\\Remnants.cfg"; private string _generalSection = "General"; private string _generalBodySection = "GeneralBody"; private string _levelsSection = "Levels"; private string _customLevelsSection = "ModdedLevels"; private string _otherSection = "Other"; private string _remnantsSection = "Remnants"; private string _spawningSection = "Spawning"; private string _spawningLegacySection = "SpawningLegacy"; private string _suitsSection = "Suits"; private string _saveLoadSection = "Save/load"; private const int _maxPercentage = 100; private const int _minPercentage = 1; private const int _maxRemnantItemsSpawned = 50; private const float _minItemCost = 5f; private const float _maxItemCost = 1000f; private const float _maxItemStoreCost = 10000f; private const float _maxModifierWithMoonThreath = 10f; private const int _maxDuplicatesOfARemnantItem = 15; private const int _maximumItemsFoundOnBody = 10; private const int _maximumScrapSpawnPoolIncrease = 30; private const int _defaultMinRarity = 1; private const int _defaultMaxRarity = 100; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; LoadConfig(); } } private void LoadConfig() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0695: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) LoadConfigData(); _configFile = new ConfigFile(Paths.ConfigPath + _configFileName, true); MinRemnantRarity = _configFile.Bind(_generalSection, "Min remnant item rarity", 1, "Minimum chance of a remnant item spawning."); MinRemnantRarity.Value = Mathf.Clamp(MinRemnantRarity.Value, 1, 100); MaxRemnantRarity = _configFile.Bind(_generalSection, "Max remnant item rarity", 100, "Maximum chance of a remnant item spawning."); MaxRemnantRarity.Value = Mathf.Clamp(MaxRemnantRarity.Value, MinRemnantRarity.Value, 100); MinRemnantBatteryCharge = _configFile.Bind(_generalSection, "Min remnant battery charge", 20, "Minimum remnant item battery charge on first finding it."); MinRemnantBatteryCharge.Value = Mathf.Clamp(MinRemnantBatteryCharge.Value, 1, 100); MaxRemnantBatteryCharge = _configFile.Bind(_generalSection, "Max remnant battery charge", 90, "Maximum remnant item battery charge on first finding it."); MaxRemnantBatteryCharge.Value = Mathf.Clamp(MaxRemnantBatteryCharge.Value, MinRemnantBatteryCharge.Value, 100); RemnantScrapMinCostPercentage = _configFile.Bind(_generalSection, "Remnant item min scrap cost percentage", 5, "The min percentage of how much worth of scrap a remnant item is compared to its normal credit cost. \nFrom 0 percentage scrap cost to 1000 percentage."); RemnantScrapMinCostPercentage.Value = Mathf.Clamp(RemnantScrapMinCostPercentage.Value, 0, 1000); RemnantScrapMaxCostPercentage = _configFile.Bind(_generalSection, "Remnant item max scrap cost percentage", 20, "The max percentage of how much worth of scrap a remnant item is compared to its normal credit cost. \nFrom 0 percentage scrap cost to 1000 percentage."); RemnantScrapMaxCostPercentage.Value = Mathf.Clamp(RemnantScrapMaxCostPercentage.Value, RemnantScrapMinCostPercentage.Value, 1000); ShouldBodiesBeScrap = _configFile.Bind(_generalBodySection, "Should bodies be scrap", true, "When the bodies are a scrap they can be grabbed, have a scrap value and can be sold. \nIf not then it becomes a prop and cannot be interacted with."); SpawnRarityOfBody = _configFile.Bind(_generalBodySection, "Body spawn rarity", 2, "This number is the chance that a body spawns next to an remnant item."); SpawnRarityOfBody.Value = Mathf.Clamp(SpawnRarityOfBody.Value, 0, 100); BodySpawnModifierRiskLevel = _configFile.Bind(_generalBodySection, "Body spawn modifier per moon risk level", 1.2f, "By increasing this modifier you will increase the spawnchance of the body per risk level moon."); BodySpawnModifierRiskLevel.Value = Mathf.Clamp(BodySpawnModifierRiskLevel.Value, 0f, 10f); MinBodyScrapValue = _configFile.Bind(_generalBodySection, "Min scrap value of the bodies", 8, "The minimum scrap value of the bodies that this mod spawns. \nThis only works if the bodies are set to scrap."); MinBodyScrapValue.Value = Mathf.Clamp(MinBodyScrapValue.Value, 0, 1000); MaxBodyScrapValue = _configFile.Bind(_generalBodySection, "Max scrap value of the bodies", 25, "The maximum scrap value of the bodies that this mod spawns. \nThis only works if the bodies are set to scrap."); MaxBodyScrapValue.Value = Mathf.Clamp(MaxBodyScrapValue.Value, MinBodyScrapValue.Value, 1000); MaxRemnantItemCost = _configFile.Bind(_otherSection, "Max value to calculate rarity", 400f, "This value helps calculating the spawn rarity, the rarity is calculated by the credit cost of the shop item. \nThis caps the maximum cost of an item and setting it as min spawn rarity if it is the same or higher than this value. \nThe more an item cost, the less spawn chance/spawn rarity it has."); MaxRemnantItemCost.Value = Mathf.Clamp(MaxRemnantItemCost.Value, 5f, 10000f); _bannedNamesFromRegistering = _configFile.Bind(_otherSection, "Item list banned from registering as scrap", "Clipboard,StickyNote,Binoculars,MapDevice,Key,Error", "List of items that are barred from registering as scrap/remnant item. \nThese default items are there to avoid adding scrap that are left out of the vanilla version, don't work, or cause crashes. \nTo add more names to the list, be sure to add a comma between names."); _overriddenScrapItems = _configFile.Bind(_otherSection, "Scrap item list to be used as remnant items", "Example scrap,Scrap-example", "In here you can add scrap items to be treated as remnant items, to spawn bodies on and to randomize batteries. \nTo add more names to the list, be sure to add a comma between names."); UseBeltBagTranspiler = _configFile.Bind(_otherSection, "Beltbag can store remnant items", true, "Make the beltbag item able to store remnant items. You can disable this feature to make other mods for the beltbag item more compatible."); UseEndRoundPatchFix = _configFile.Bind(_otherSection, "Use end of round score fix", true, "Due the spawning of remnnant items and bodies separately the end round score is not accurate, this feature fixes this issue."); _bannedItemsFromUtilitySlot = _configFile.Bind(_otherSection, "Remnant item list banned from the utility slot", "Shovel,example", "List of Remnant items that are barred from the utility slot. \nThese default items are vanilla shop items that are banned from the utility slot."); MinRemnantItemsSpawning = _configFile.Bind(_spawningSection, "Minimum remnant items spawned on a moon", 3, "The minimum remnant items that can spawn on a moon. \nThis value gets increased by the threat level a moon has, along the down below modifier."); MinRemnantItemsSpawning.Value = Mathf.Clamp(MinRemnantItemsSpawning.Value, 0, 50); MaxRemnantItemsSpawning = _configFile.Bind(_spawningSection, "Maximum remnant items spawned on a moon", 8, "The maximum remnant items that can spawn on a moon. \nThis value gets increased by the threat level a moon has, along the down below modifier."); MaxRemnantItemsSpawning.Value = Mathf.Clamp(MaxRemnantItemsSpawning.Value, MinRemnantItemsSpawning.Value, 50); RemnantItemsSpawningModifier = _configFile.Bind(_spawningSection, "Remnant items spawn modifier", 1f, "A modifier that increases the spawn pool of remnant items in relative to the moon threat level. \nPutting the value under zero, will disable this feature and will always use the normal spawn amount."); RemnantItemsSpawningModifier.Value = Mathf.Clamp(RemnantItemsSpawningModifier.Value, -1f, 10f); MaxDuplicatesRemnantItems = _configFile.Bind(_spawningSection, "Maximum duplicates can spawn", 4, "The maximum duplicates of a remnant item that can spawn on a moon. \nDo note that the spawning of remnant items will stop when it has used up all maximum duplicates."); MaxDuplicatesRemnantItems.Value = Mathf.Clamp(MaxDuplicatesRemnantItems.Value, 1, 15); MinItemsFoundOnBodies = _configFile.Bind(_spawningSection, "Minimum remnant items found on a body", 1, "The Minimum remnant items found on a body."); MinItemsFoundOnBodies.Value = Mathf.Clamp(MinItemsFoundOnBodies.Value, 1, 10); MaxItemsFoundOnBodies = _configFile.Bind(_spawningSection, "Maximum remnant items found on a body", 4, "The maximum remnant items found on a body."); MaxItemsFoundOnBodies.Value = Mathf.Clamp(MaxItemsFoundOnBodies.Value, MinItemsFoundOnBodies.Value, 10); UseLegacySpawning = _configFile.Bind(_spawningLegacySection, "Use legacy spawning", false, "Chooses if you want to use the older version of spawning remnant items. \nThe older version spawns along the normal scrap, which can be in lockers. \nWhile this is active this means that the new version will be disabled."); IncreasedScrapSpawnPool = _configFile.Bind(_spawningLegacySection, "Max increase scrap spawn pool", 15, "Increases the total scrap spawn pool to accommodate the remnant items spawning along the scrap items. \nThis is intended to make sure you get enough scrap value per moon."); IncreasedScrapSpawnPool.Value = Mathf.Clamp(IncreasedScrapSpawnPool.Value, 0, 30); _minRemnantLevelRarities = new List>(); _maxRemnantLevelRarities = new List>(); LevelRarities = new Dictionary>(); UseSpecificLevelRarities = _configFile.Bind(_levelsSection, "Use level specific rarities", false, (ConfigDescription)null); string[] names = Enum.GetNames(typeof(LevelTypes)); foreach (string text in names) { LevelTypes val = (LevelTypes)(-1); if (text == ((object)(LevelTypes)(ref val)).ToString()) { continue; } val = (LevelTypes)1; if (text == ((object)(LevelTypes)(ref val)).ToString()) { continue; } val = (LevelTypes)15356; if (!(text == ((object)(LevelTypes)(ref val)).ToString())) { val = (LevelTypes)1024; if (!(text == ((object)(LevelTypes)(ref val)).ToString())) { _minRemnantLevelRarities.Add(_configFile.Bind(_levelsSection, text + " min remnant rarity", 1, "Minimum chance of a remnant item spawning on moon: " + text + ".")); _minRemnantLevelRarities.Last().Value = Mathf.Clamp(_minRemnantLevelRarities.Last().Value, 1, 100); _maxRemnantLevelRarities.Add(_configFile.Bind(_levelsSection, text + " max remnant rarity", 100, "Maximum chance of a remnant item spawning on moon: " + text + ".")); _maxRemnantLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantLevelRarities.Last().Value, _minRemnantLevelRarities.Last().Value, 100); LevelRarities.Add((LevelTypes)Enum.Parse(typeof(LevelTypes), text), new Tuple(_minRemnantLevelRarities.Last().Value, _maxRemnantLevelRarities.Last().Value)); } } } ShouldDespawnRemnantItemsOnPartyWipe = _configFile.Bind(_saveLoadSection, "Despawn remnant items on party wipe", true, "On party wipe all items are despawned from the ship, this ensures that remnant items also are despawned. \nIf you use a mod that prevents items from being despawned, here you can edit it too for remnant items. \nThis will not use the transpiler for cleaning up items, and may cause issues."); _bannedItemsFromSaving = _configFile.Bind(_saveLoadSection, "Item list banned from saving", "Clipboard,StickyNote,Binoculars,MapDevice,Error", "List of items that are barred saving on the ship. \nThese default items are there to avoid issues with saving items on the ship. \nTo add more names to the list, be sure to add a comma between names."); ConfigScrapDataList = _configRemnantDataPairList.ConvertAll((ConfigDataValue itemData) => _configFile.Bind(_remnantsSection, itemData.Name, -1, "Set here the spawn rarity.\n -1 is the default using its store credits cost to calculate the rarity.\n 0 Is preventing from spawning it, and 1 to 100 is its costum rarity to spawn.")); for (int j = 0; j < ConfigScrapDataList.Count; j++) { ConfigScrapDataList[j].Value = Mathf.Clamp(ConfigScrapDataList[j].Value, -1, 100); } ConfigSuitsDataList = _configSuitsDataList.ConvertAll((ConfigDataValue itemData) => _configFile.Bind(_suitsSection, itemData.Name, true, itemData.Discription)); _minRemnantCustomLevelRarities = new List>(); _maxRemnantCustomLevelRarities = new List>(); for (int k = 0; k < _configCustomLevelsRarities.Count; k += 2) { _minRemnantCustomLevelRarities.Add(_configFile.Bind(_customLevelsSection, _configCustomLevelsRarities[k].Name, 1, _configCustomLevelsRarities[k].Discription)); _minRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_minRemnantCustomLevelRarities.Last().Value, 1, 100); _maxRemnantCustomLevelRarities.Add(_configFile.Bind(_customLevelsSection, _configCustomLevelsRarities[k + 1].Name, 100, _configCustomLevelsRarities[k + 1].Discription)); _maxRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantCustomLevelRarities.Last().Value, _minRemnantCustomLevelRarities.Last().Value, 100); CustomLevelRarities.Add(RemoveEndSentence(_configCustomLevelsRarities[k].Name, " min remnant rarity"), new Tuple(_minRemnantCustomLevelRarities.Last().Value, _maxRemnantCustomLevelRarities.Last().Value)); } ManualLogSource mls = Remnants.Instance.Mls; if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { mls.LogInfo((object)"LethalConfig found, creating lethal config items"); CreateLethalConfigItems(); } else { mls.LogInfo((object)"LethalConfig not found"); } _configFile.Save(); } private void LoadConfigData() { List configSectionData = GetConfigSectionData(_remnantsSection); if (configSectionData != null || configSectionData.Count > 0) { string value = "false"; string value2 = "true"; string stringValue = "-1"; for (int i = 0; i < configSectionData.Count; i++) { if (configSectionData[i].StringValue.Contains(value2) || configSectionData[i].StringValue.Contains(value)) { ConfigData value3 = configSectionData[i]; value3.StringValue = stringValue; configSectionData[i] = value3; } } _configRemnantDataPairList = configSectionData.ConvertAll(delegate(ConfigData configData) { ConfigDataValue result3 = default(ConfigDataValue); result3.Name = configData.Name; result3.Discription = configData.Discription; result3.Value = Convert.ToInt32(configData.StringValue); return result3; }); } List configSectionData2 = GetConfigSectionData(_customLevelsSection); if (configSectionData2 != null || configSectionData2.Count > 0) { _configCustomLevelsRarities = configSectionData2.ConvertAll(delegate(ConfigData configDataInt) { ConfigDataValue result2 = default(ConfigDataValue); result2.Name = configDataInt.Name; result2.Discription = configDataInt.Discription; result2.Value = Convert.ToInt32(configDataInt.StringValue); return result2; }); } List configSectionData3 = GetConfigSectionData(_suitsSection); if (configSectionData3 != null || configSectionData3.Count > 0) { _configSuitsDataList = configSectionData3.ConvertAll(delegate(ConfigData configDataSuit) { ConfigDataValue result = default(ConfigDataValue); result.Name = configDataSuit.Name; result.Discription = configDataSuit.Discription; result.Value = Convert.ToBoolean(configDataSuit.StringValue); return result; }); } } private void CreateLethalConfigItems() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0055: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_007e: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b1: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00dd: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0115: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Expected O, but got Unknown //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Expected O, but got Unknown //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Expected O, but got Unknown //IL_03ff: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Expected O, but got Unknown //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Expected O, but got Unknown //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Expected O, but got Unknown //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Expected O, but got Unknown //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Expected O, but got Unknown //IL_04a3: Expected O, but got Unknown //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Expected O, but got Unknown //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Expected O, but got Unknown //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Expected O, but got Unknown //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Expected O, but got Unknown //IL_050c: Expected O, but got Unknown //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Expected O, but got Unknown //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Expected O, but got Unknown //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Expected O, but got Unknown //IL_0547: Expected O, but got Unknown //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Expected O, but got Unknown //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Expected O, but got Unknown //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Expected O, but got Unknown //IL_05a6: Expected O, but got Unknown //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Expected O, but got Unknown //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Expected O, but got Unknown //IL_05e1: Expected O, but got Unknown //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Expected O, but got Unknown ConfigEntry minRemnantRarity = MinRemnantRarity; IntSliderOptions val = new IntSliderOptions(); ((BaseRangeOptions)val).Min = 1; ((BaseRangeOptions)val).Max = 100; IntSliderConfigItem val2 = new IntSliderConfigItem(minRemnantRarity, val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); ConfigEntry maxRemnantRarity = MaxRemnantRarity; IntSliderOptions val3 = new IntSliderOptions(); ((BaseRangeOptions)val3).Min = MinRemnantRarity.Value; ((BaseRangeOptions)val3).Max = 100; IntSliderConfigItem val4 = new IntSliderConfigItem(maxRemnantRarity, val3); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); ConfigEntry minRemnantBatteryCharge = MinRemnantBatteryCharge; IntSliderOptions val5 = new IntSliderOptions(); ((BaseRangeOptions)val5).Min = 1; ((BaseRangeOptions)val5).Max = 100; IntSliderConfigItem val6 = new IntSliderConfigItem(minRemnantBatteryCharge, val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); ConfigEntry maxRemnantBatteryCharge = MaxRemnantBatteryCharge; IntSliderOptions val7 = new IntSliderOptions(); ((BaseRangeOptions)val7).Min = MinRemnantBatteryCharge.Value; ((BaseRangeOptions)val7).Max = 100; IntSliderConfigItem val8 = new IntSliderConfigItem(maxRemnantBatteryCharge, val7); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8); ConfigEntry remnantScrapMinCostPercentage = RemnantScrapMinCostPercentage; IntSliderOptions val9 = new IntSliderOptions(); ((BaseRangeOptions)val9).Min = 0; ((BaseRangeOptions)val9).Max = 1000; IntSliderConfigItem val10 = new IntSliderConfigItem(remnantScrapMinCostPercentage, val9); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10); ConfigEntry remnantScrapMaxCostPercentage = RemnantScrapMaxCostPercentage; IntSliderOptions val11 = new IntSliderOptions(); ((BaseRangeOptions)val11).Min = RemnantScrapMinCostPercentage.Value; ((BaseRangeOptions)val11).Max = 1000; IntSliderConfigItem val12 = new IntSliderConfigItem(remnantScrapMaxCostPercentage, val11); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12); BoolCheckBoxConfigItem val13 = new BoolCheckBoxConfigItem(ShouldBodiesBeScrap, false); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val13); ConfigEntry spawnRarityOfBody = SpawnRarityOfBody; IntSliderOptions val14 = new IntSliderOptions(); ((BaseRangeOptions)val14).Min = 0; ((BaseRangeOptions)val14).Max = 100; ((BaseOptions)val14).RequiresRestart = false; IntSliderConfigItem val15 = new IntSliderConfigItem(spawnRarityOfBody, val14); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val15); ConfigEntry bodySpawnModifierRiskLevel = BodySpawnModifierRiskLevel; FloatSliderOptions val16 = new FloatSliderOptions(); ((BaseRangeOptions)val16).Min = 0f; ((BaseRangeOptions)val16).Max = 10f; ((BaseOptions)val16).RequiresRestart = false; FloatSliderConfigItem val17 = new FloatSliderConfigItem(bodySpawnModifierRiskLevel, val16); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val17); ConfigEntry minBodyScrapValue = MinBodyScrapValue; IntSliderOptions val18 = new IntSliderOptions(); ((BaseRangeOptions)val18).Min = 0; ((BaseRangeOptions)val18).Max = 1000; ((BaseOptions)val18).RequiresRestart = false; IntSliderConfigItem val19 = new IntSliderConfigItem(minBodyScrapValue, val18); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val19); ConfigEntry maxBodyScrapValue = MaxBodyScrapValue; IntSliderOptions val20 = new IntSliderOptions(); ((BaseRangeOptions)val20).Min = MinBodyScrapValue.Value; ((BaseRangeOptions)val20).Max = 1000; ((BaseOptions)val20).RequiresRestart = false; IntSliderConfigItem val21 = new IntSliderConfigItem(maxBodyScrapValue, val20); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21); ConfigEntry minRemnantItemsSpawning = MinRemnantItemsSpawning; IntSliderOptions val22 = new IntSliderOptions(); ((BaseRangeOptions)val22).Min = 0; ((BaseRangeOptions)val22).Max = 50; ((BaseOptions)val22).RequiresRestart = false; IntSliderConfigItem val23 = new IntSliderConfigItem(minRemnantItemsSpawning, val22); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val23); ConfigEntry maxRemnantItemsSpawning = MaxRemnantItemsSpawning; IntSliderOptions val24 = new IntSliderOptions(); ((BaseRangeOptions)val24).Min = MinRemnantItemsSpawning.Value; ((BaseRangeOptions)val24).Max = 50; ((BaseOptions)val24).RequiresRestart = false; IntSliderConfigItem val25 = new IntSliderConfigItem(maxRemnantItemsSpawning, val24); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val25); ConfigEntry remnantItemsSpawningModifier = RemnantItemsSpawningModifier; FloatSliderOptions val26 = new FloatSliderOptions(); ((BaseRangeOptions)val26).Min = -1f; ((BaseRangeOptions)val26).Max = 10f; ((BaseOptions)val26).RequiresRestart = false; FloatSliderConfigItem val27 = new FloatSliderConfigItem(remnantItemsSpawningModifier, val26); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val27); ConfigEntry maxDuplicatesRemnantItems = MaxDuplicatesRemnantItems; IntSliderOptions val28 = new IntSliderOptions(); ((BaseRangeOptions)val28).Min = 1; ((BaseRangeOptions)val28).Max = 15; ((BaseOptions)val28).RequiresRestart = false; IntSliderConfigItem val29 = new IntSliderConfigItem(maxDuplicatesRemnantItems, val28); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val29); ConfigEntry minItemsFoundOnBodies = MinItemsFoundOnBodies; IntSliderOptions val30 = new IntSliderOptions(); ((BaseRangeOptions)val30).Min = 1; ((BaseRangeOptions)val30).Max = 10; ((BaseOptions)val30).RequiresRestart = false; IntSliderConfigItem val31 = new IntSliderConfigItem(minItemsFoundOnBodies, val30); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val31); ConfigEntry maxItemsFoundOnBodies = MaxItemsFoundOnBodies; IntSliderOptions val32 = new IntSliderOptions(); ((BaseRangeOptions)val32).Min = MinItemsFoundOnBodies.Value; ((BaseRangeOptions)val32).Max = 10; ((BaseOptions)val32).RequiresRestart = false; IntSliderConfigItem val33 = new IntSliderConfigItem(maxItemsFoundOnBodies, val32); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val33); BoolCheckBoxConfigItem val34 = new BoolCheckBoxConfigItem(UseLegacySpawning); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val34); ConfigEntry increasedScrapSpawnPool = IncreasedScrapSpawnPool; IntSliderOptions val35 = new IntSliderOptions(); ((BaseRangeOptions)val35).Min = 0; ((BaseRangeOptions)val35).Max = 30; ((BaseOptions)val35).RequiresRestart = false; IntSliderConfigItem val36 = new IntSliderConfigItem(increasedScrapSpawnPool, val35); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val36); BoolCheckBoxConfigItem val37 = new BoolCheckBoxConfigItem(ShouldDespawnRemnantItemsOnPartyWipe); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val37); TextInputFieldConfigItem val38 = new TextInputFieldConfigItem(_bannedItemsFromSaving); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val38); ConfigEntry maxRemnantItemCost = MaxRemnantItemCost; FloatSliderOptions val39 = new FloatSliderOptions(); ((BaseRangeOptions)val39).Min = 5f; ((BaseRangeOptions)val39).Max = 10000f; FloatSliderConfigItem val40 = new FloatSliderConfigItem(maxRemnantItemCost, val39); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val40); TextInputFieldConfigItem val41 = new TextInputFieldConfigItem(_bannedNamesFromRegistering); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val41); TextInputFieldConfigItem val42 = new TextInputFieldConfigItem(_overriddenScrapItems, false); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val42); BoolCheckBoxConfigItem val43 = new BoolCheckBoxConfigItem(UseBeltBagTranspiler, true); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val43); BoolCheckBoxConfigItem val44 = new BoolCheckBoxConfigItem(UseEndRoundPatchFix, true); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val44); TextInputFieldConfigItem val45 = new TextInputFieldConfigItem(_bannedItemsFromUtilitySlot); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val45); for (int i = 0; i < ConfigScrapDataList.Count; i++) { ConfigEntry obj = ConfigScrapDataList[i]; IntSliderOptions val46 = new IntSliderOptions(); ((BaseRangeOptions)val46).Min = -1; ((BaseRangeOptions)val46).Max = 100; IntSliderConfigItem val47 = new IntSliderConfigItem(obj, val46); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val47); } BoolCheckBoxConfigItem val48 = new BoolCheckBoxConfigItem(UseSpecificLevelRarities); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val48); for (int j = 0; j < _minRemnantLevelRarities.Count; j++) { ConfigEntry obj2 = _minRemnantLevelRarities[j]; IntSliderOptions val49 = new IntSliderOptions(); ((BaseRangeOptions)val49).Min = 1; ((BaseRangeOptions)val49).Max = 100; IntSliderConfigItem val50 = new IntSliderConfigItem(obj2, val49); ConfigEntry obj3 = _maxRemnantLevelRarities[j]; IntSliderOptions val51 = new IntSliderOptions(); ((BaseRangeOptions)val51).Min = _minRemnantLevelRarities[j].Value; ((BaseRangeOptions)val51).Max = 100; IntSliderConfigItem val52 = new IntSliderConfigItem(obj3, val51); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val50); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val52); } for (int k = 0; k < _minRemnantCustomLevelRarities.Count; k++) { ConfigEntry obj4 = _minRemnantCustomLevelRarities[k]; IntSliderOptions val53 = new IntSliderOptions(); ((BaseRangeOptions)val53).Min = 1; ((BaseRangeOptions)val53).Max = 100; IntSliderConfigItem val54 = new IntSliderConfigItem(obj4, val53); ConfigEntry obj5 = _maxRemnantCustomLevelRarities[k]; IntSliderOptions val55 = new IntSliderOptions(); ((BaseRangeOptions)val55).Min = _minRemnantCustomLevelRarities[k].Value; ((BaseRangeOptions)val55).Max = 100; IntSliderConfigItem val56 = new IntSliderConfigItem(obj5, val55); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val54); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val56); } } public List GetBannedFromRegisteringItemNames() { if (Utility.IsNullOrWhiteSpace(_bannedNamesFromRegistering.Value)) { return new List(); } return _bannedNamesFromRegistering.Value.Split(new char[1] { ',' }).ToList(); } public List GetBannedFromUtilitySlotItemNames() { if (Utility.IsNullOrWhiteSpace(_bannedItemsFromUtilitySlot.Value)) { return new List(); } return _bannedItemsFromUtilitySlot.Value.Split(new char[1] { ',' }).ToList(); } public List GetBannedFromSavingItemNames() { if (Utility.IsNullOrWhiteSpace(_bannedItemsFromSaving.Value)) { return new List(); } return _bannedItemsFromSaving.Value.Split(new char[1] { ',' }).ToList(); } public List GetOverriddenScrapItems() { if (Utility.IsNullOrWhiteSpace(_overriddenScrapItems.Value)) { return new List(); } return _overriddenScrapItems.Value.Split(new char[1] { ',' }).ToList(); } public List GetRemnantItemList(bool reloadConfig = true) { if (reloadConfig) { _configFile.Reload(); } if (ConfigScrapDataList == null || ConfigScrapDataList.Count == 0) { return new List(); } return ConfigScrapDataList.ConvertAll((ConfigEntry configEntry) => new RemnantData { RemnantItemName = ((ConfigEntryBase)configEntry).Definition.Key, RarityInfo = configEntry.Value }); } public void SetRemnantItemList(List remnantDataList) { ConfigScrapDataList = remnantDataList.ConvertAll((RemnantData remnantData) => _configFile.Bind(_remnantsSection, remnantData.RemnantItemName, remnantData.RarityInfo, "Set here the spawn rarity.\n -1 is the default using its store credits cost to calculate the rarity.\n 0 Is preventing from spawning it, and 1 to 100 is its costum rarity to spawn.")); _configFile.Save(); } public List GetSuitsList() { if (ConfigSuitsDataList == null || ConfigSuitsDataList.Count == 0) { return new List(); } return ConfigSuitsDataList.ConvertAll((ConfigEntry configEntry) => new SuitData { SuitName = ((ConfigEntryBase)configEntry).Definition.Key, UseSuit = configEntry.Value }); } public void SetSuitsList(List suitDataList) { ConfigSuitsDataList = suitDataList.ConvertAll((SuitData suitData) => _configFile.Bind(_suitsSection, suitData.SuitName, suitData.UseSuit, "By changing the value, you can choose whether this suit is used on a body or not.")); _configFile.Save(); } public void SetCustomLevelsRarities(List customMoonNames, int minPercentage = 1, int maxPercentage = 100) { foreach (string customMoonName in customMoonNames) { if (!CustomLevelRarities.ContainsKey(customMoonName) && !(customMoonName == _bannedPlanetName)) { _minRemnantCustomLevelRarities.Add(_configFile.Bind(_customLevelsSection, customMoonName + " min remnant rarity", 1, "Minimum chance of a remnant item spawning on moon: " + customMoonName + ".")); _minRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_minRemnantCustomLevelRarities.Last().Value, minPercentage, maxPercentage); _maxRemnantCustomLevelRarities.Add(_configFile.Bind(_customLevelsSection, customMoonName + " max remnant rarity", 100, "Maximum chance of a remnant item spawning on moon: " + customMoonName + ".")); _maxRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantCustomLevelRarities.Last().Value, _minRemnantCustomLevelRarities.Last().Value, maxPercentage); CustomLevelRarities.Add(customMoonName, new Tuple(_minRemnantCustomLevelRarities.Last().Value, _maxRemnantCustomLevelRarities.Last().Value)); } } _configFile.Save(); } public Dictionary> GetCustomLevelRarities() { _configFile.Reload(); if (CustomLevelRarities == null || CustomLevelRarities.Count == 0) { return new Dictionary>(); } for (int i = 0; i < _minRemnantCustomLevelRarities.Count; i++) { CustomLevelRarities[((ConfigEntryBase)_minRemnantCustomLevelRarities[i]).Definition.Key] = new Tuple(_minRemnantCustomLevelRarities[i].Value, _maxRemnantCustomLevelRarities[i].Value); } return CustomLevelRarities; } private string RemoveEndSentence(string fullSentence, string toRemoveAtEnd) { if (fullSentence.EndsWith(toRemoveAtEnd)) { for (int i = 0; i < fullSentence.Length; i++) { if (fullSentence[i] == toRemoveAtEnd[0] && i + toRemoveAtEnd.Length == fullSentence.Length) { return fullSentence.Substring(0, i); } } } return fullSentence; } private List GetConfigSectionData(string section) { List list = new List(); if (!File.Exists(Paths.ConfigPath + _configFileName)) { return list; } StreamReader streamReader = new StreamReader(Paths.ConfigPath + _configFileName); string text = streamReader.ReadLine(); bool flag = false; while (text != null && (!flag || !text.StartsWith("["))) { if (flag) { AddDataToList(streamReader, text, list); } else if (text == "[" + section + "]") { flag = true; text = streamReader.ReadLine(); AddDataToList(streamReader, text, list); } text = streamReader.ReadLine(); } streamReader.Close(); return list; } private void AddDataToList(StreamReader sr, string line, List list) { string text = "## "; string value = "#"; string text2 = " = "; ConfigData item = default(ConfigData); if (line.StartsWith(text)) { item.Discription = line.Remove(0, text.Length); while (line != null && line.StartsWith(value)) { line = sr.ReadLine(); } ManualLogSource mls = Remnants.Instance.Mls; int num = line.LastIndexOf(text2); item.Name = line.Remove(num); item.StringValue = line.Remove(0, num + text2.Length - 1); list.Add(item); } } public bool CheckIsStoreOrRemnantItem(GrabbableObject grabbableObject) { ManualLogSource mls = Remnants.Instance.Mls; if ((Object)(object)grabbableObject == (Object)null || (Object)(object)grabbableObject.itemProperties == (Object)null) { mls.LogError((object)"GrabbableObject is null!"); return false; } if (!grabbableObject.itemProperties.isScrap) { mls.LogError((object)"GrabbableObject is not scrap!"); return true; } mls.LogInfo((object)("ConfigScrapDataList lengt: " + ConfigScrapDataList.Count)); foreach (ConfigEntry configScrapData in ConfigScrapDataList) { mls.LogInfo((object)((ConfigEntryBase)configScrapData).Definition.Key); } mls.LogWarning((object)(grabbableObject.itemProperties.itemName + " " + ((Object)grabbableObject.itemProperties).name)); if (ConfigScrapDataList.FindIndex((ConfigEntry configEntry) => ((ConfigEntryBase)configEntry).Definition.Key == grabbableObject.itemProperties.itemName || ((ConfigEntryBase)configEntry).Definition.Key == ((Object)grabbableObject.itemProperties).name) != -1) { mls.LogError((object)"GrabbableObject is a remnant item!"); return true; } mls.LogError((object)"GrabbableObject is a normal scrap item!"); return false; } } public class LoadAssetsBodies { private bool _hasInitialized = false; private bool _isLoadingBundle = false; private string _assetBundleName = "remnants"; private string _prefabTypeName = ".prefab"; private string _assetTypeName = ".asset"; private string _iconSpriteName = "ScrapItemIcon2"; private string _dropSoundName = "BodyCollision2"; private string _grabSoundName = "StartJump"; private AssetBundle _assetBundleBodies = null; private string[] _bodiesFileNamesArray = new string[4] { "DefaultBodyProp", "HeadBurstBodyProp", "CoilHeadBodyProp", "WebbedBodyProp" }; private string[] _bodiesItemsFileNamesArray = new string[4] { "DefaultBodyItem", "HeadBurstBodyItem", "CoilBodyItem", "WebbedBodyItem" }; public KeyValuePair[] EnemiesAndBodiesNames = new KeyValuePair[4] { new KeyValuePair("Any", "DefaultBody"), new KeyValuePair("Spring", "CoilHeadBody"), new KeyValuePair("Bunker Spider", "WebbedBody"), new KeyValuePair("Girl", "HeadBurstBody") }; public string[] BannedPrefabTexturesChange = new string[2] { "WebbedBody", "WebbedBodyProp" }; public string BannedPrefabTextureChange = "WebbedBody"; public bool HasLoadedAnyAssets = false; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; SceneManager.sceneLoaded += LoadAssetBundle; } } private void LoadAssetBundle(Scene scene, LoadSceneMode mode) { ManualLogSource mls = Remnants.Instance.Mls; Sprite val = Resources.FindObjectsOfTypeAll().Concat(Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList() .Find((Sprite sprite) => ((Object)sprite).name == _iconSpriteName); if (_isLoadingBundle || (Object)(object)val == (Object)null) { return; } _isLoadingBundle = true; string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, _assetBundleName); if (!File.Exists(text)) { mls.LogError((object)("Assetbundle " + _assetBundleName + " not found.")); return; } _assetBundleBodies = AssetBundle.LoadFromFile(text); if ((Object)(object)_assetBundleBodies == (Object)null) { mls.LogError((object)("Failed to load: " + _assetBundleName)); return; } List list = Resources.FindObjectsOfTypeAll().Concat(Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList(); AudioClip dropSFX = list.Find((AudioClip audioClip) => ((Object)audioClip).name == _dropSoundName); AudioClip grabSFX = list.Find((AudioClip audioClip1) => ((Object)audioClip1).name == _grabSoundName); string[] bodiesItemsFileNamesArray = _bodiesItemsFileNamesArray; foreach (string assetName in bodiesItemsFileNamesArray) { LoadAndRegisterBodyItemAsset(assetName, _assetTypeName, val, dropSFX, grabSFX); } string[] bodiesFileNamesArray = _bodiesFileNamesArray; foreach (string assetName2 in bodiesFileNamesArray) { LoadAndRegisterBodyPropAsset(assetName2, _prefabTypeName); } SceneManager.sceneLoaded -= LoadAssetBundle; } private void LoadAndRegisterBodyPropAsset(string assetName, string assetType) { ManualLogSource mls = Remnants.Instance.Mls; GameObject val = _assetBundleBodies.LoadAsset(assetName + assetType); if ((Object)(object)val == (Object)null) { mls.LogError((object)("Failed to load: " + assetName)); return; } mls.LogInfo((object)("Loaded asset: " + ((Object)val).name)); val.AddComponent(); NetworkPrefabs.RegisterNetworkPrefab(val); HasLoadedAnyAssets = true; } private void LoadAndRegisterBodyItemAsset(string assetName, string assetType, Sprite icon, AudioClip dropSFX, AudioClip grabSFX) { ManualLogSource mls = Remnants.Instance.Mls; Item val = _assetBundleBodies.LoadAsset(assetName + assetType); if ((Object)(object)val == (Object)null) { mls.LogError((object)("Failed to load: " + assetName)); return; } mls.LogInfo((object)("Loaded asset: " + ((Object)val).name)); val.itemIcon = icon; val.dropSFX = dropSFX; val.grabSFX = grabSFX; val.spawnPrefab.AddComponent(); val.spawnPrefab.AddComponent(); BodyGrabbableObject bodyGrabbableObject = val.spawnPrefab.AddComponent(); ((GrabbableObject)bodyGrabbableObject).itemProperties = val; ((GrabbableObject)bodyGrabbableObject).grabbable = true; ((GrabbableObject)bodyGrabbableObject).grabbableToEnemies = true; ((GrabbableObject)bodyGrabbableObject).isInFactory = true; Items.RegisterItem(val); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); HasLoadedAnyAssets = true; } } } namespace Remnants.Behaviours { public class BodyGrabbableObject : GrabbableObject { private int _saveSuitIndex = 0; private BodySuitBehaviour _bodySuitBehaviour = null; private void Awake() { ManualLogSource mls = Remnants.Instance.Mls; _bodySuitBehaviour = ((Component)this).GetComponent(); if ((Object)(object)_bodySuitBehaviour == (Object)null) { mls.LogError((object)"Did not found BodySuitBehaviour."); } } public override void Start() { //IL_0019: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) base.propColliders = ((Component)this).gameObject.GetComponentsInChildren(); base.originalScale = ((Component)this).transform.localScale; if (base.itemProperties.isScrap && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null) { base.radarIcon = Object.Instantiate(StartOfRound.Instance.itemRadarIconPrefab, RoundManager.Instance.mapPropsContainer.transform).transform; } if (!base.itemProperties.isScrap) { HoarderBugAI.grabbableObjectsInMap.Add(((Component)this).gameObject); } base.originalScale = ((Component)this).transform.localScale; if (base.itemProperties.itemSpawnsOnGround) { base.startFallingPosition = ((Component)this).transform.position; if ((Object)(object)((Component)this).transform.parent != (Object)null) { base.startFallingPosition = ((Component)this).transform.parent.InverseTransformPoint(base.startFallingPosition); } ((GrabbableObject)this).FallToGround(false, false, default(Vector3)); } else { base.fallTime = 1f; base.hasHitGround = true; base.reachedFloorTarget = true; base.targetFloorPosition = ((Component)this).transform.localPosition; } MeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).renderingLayerMask = 1u; } SkinnedMeshRenderer[] componentsInChildren2 = ((Component)this).gameObject.GetComponentsInChildren(); for (int j = 0; j < componentsInChildren2.Length; j++) { ((Renderer)componentsInChildren2[j]).renderingLayerMask = 1u; } ((GrabbableObject)this).EnablePhysics(true); } public override void EquipItem() { ((GrabbableObject)this).EquipItem(); } public override void Update() { ((GrabbableObject)this).Update(); } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override string __getTypeName() { return "BodyGrabbableObject"; } public override int GetItemDataToSave() { if (!base.itemProperties.saveItemVariable) { Debug.LogError((object)("GetItemDataToSave is being called on " + base.itemProperties.itemName + ", which does not have saveItemVariable set true.")); } if ((Object)(object)_bodySuitBehaviour != (Object)null) { _saveSuitIndex = _bodySuitBehaviour.saveSuitIndex; } return _saveSuitIndex; } public override void LoadItemSaveData(int saveData) { if (!base.itemProperties.saveItemVariable) { Debug.LogError((object)("LoadItemSaveData is being called on " + base.itemProperties.itemName + ", which does not have saveItemVariable set true.")); } _saveSuitIndex = saveData; if ((Object)(object)_bodySuitBehaviour != (Object)null) { _bodySuitBehaviour.UpdateSuit(_saveSuitIndex); } } public void SyncIndexSuit(int indexSuit) { if ((Object)(object)_bodySuitBehaviour != (Object)null) { _bodySuitBehaviour.SyncIndexSuitClientRpc(indexSuit); } } } internal class BodyMovementBehaviour : MonoBehaviour { private bool _hasInitialized = false; private GrabbableObject _grabbableObject = null; private Rigidbody[] _rigidbodies = null; private string _skipRigidBodyName = "ScanNode"; private bool _isInStasis = false; private float _onGroundTimer = 0f; private float _onHeldTimer = 0f; private const float _onGroundMoveDuration = 2f; private const float _heldMoveDuration = 0f; private void Awake() { ManualLogSource mls = Remnants.Instance.Mls; _grabbableObject = ((Component)this).GetComponent(); if ((Object)(object)_grabbableObject == (Object)null) { mls.LogWarning((object)"Did not found GrabbableObject."); return; } _rigidbodies = ((Component)_grabbableObject).GetComponentsInChildren(); if (_rigidbodies == null) { mls.LogWarning((object)"Rigidbodies is null."); return; } _rigidbodies = _rigidbodies.Where((Rigidbody rigidbody) => ((Object)((Component)rigidbody).gameObject).name != _skipRigidBodyName).ToArray(); _hasInitialized = true; } private void Update() { if (_hasInitialized) { UpdateMovementAtStart(); } } private void UpdateMovementAtStart() { if (!_isInStasis) { _onGroundTimer += Time.deltaTime; if (_onGroundTimer > 2f) { SetStasis(shouldBeStatis: true); _isInStasis = true; } } } private void UpdateConstantMovement() { if (_grabbableObject.isHeld) { _onHeldTimer += Time.deltaTime; _onGroundTimer = 0f; if (_isInStasis && _onHeldTimer < 0f) { SetStasis(shouldBeStatis: false); _isInStasis = false; } if (!_isInStasis && _onHeldTimer > 0f) { SetStasis(shouldBeStatis: true); _isInStasis = true; } } else if (!_grabbableObject.isHeld) { _onGroundTimer += Time.deltaTime; _onHeldTimer = 0f; if (_isInStasis && _onGroundTimer < 2f) { _isInStasis = false; SetStasis(shouldBeStatis: false); } else if (!_isInStasis && _onGroundTimer > 2f) { SetStasis(shouldBeStatis: true); _isInStasis = true; } } } private void SetStasis(bool shouldBeStatis) { Rigidbody[] rigidbodies = _rigidbodies; foreach (Rigidbody val in rigidbodies) { val.isKinematic = shouldBeStatis; } } } internal class BodySuitBehaviour : NetworkBehaviour { private int _saveSuitIndex = 0; public int saveSuitIndex => _saveSuitIndex; public void UpdateSuit(int suitIndex) { _saveSuitIndex = suitIndex; if (((Object)((Component)this).gameObject).name.Contains(Remnants.Instance.LoadBodyAssets.BannedPrefabTextureChange) || Remnants.Instance.RegisterBodySuits.SuitsIndexList.Count == 0) { return; } SkinnedMeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren(); Material suitMaterial = StartOfRound.Instance.unlockablesList.unlockables[_saveSuitIndex].suitMaterial; if (!((Object)(object)suitMaterial == (Object)null)) { ((Renderer)componentInChildren).material = suitMaterial; for (int i = 0; i < ((Renderer)componentInChildren).materials.Length; i++) { ((Renderer)componentInChildren).materials[i] = suitMaterial; } } } protected override void __initializeRpcs() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3184508696u, new RpcReceiveHandler(__rpc_handler_3184508696), "SyncIndexSuitServerRpc"); ((NetworkBehaviour)this).__registerRpc(269264864u, new RpcReceiveHandler(__rpc_handler_269264864), "SyncIndexSuitClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } [ServerRpc] public void SyncIndexSuitServerRpc(int indexSuit) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3184508696u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, indexSuit); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3184508696u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { SyncIndexSuitClientRpc(indexSuit); } } [ClientRpc] public void SyncIndexSuitClientRpc(int indexSuit) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(269264864u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, indexSuit); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 269264864u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { UpdateSuit(indexSuit); } } } private static void __rpc_handler_3184508696(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0048: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { Traverse val = Traverse.Create((object)target).Field("__rpc_exec_stage"); int indexSuit = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref indexSuit); val.SetValue((object)(__RpcExecStage)1); ((BodySuitBehaviour)(object)target).SyncIndexSuitServerRpc(indexSuit); val.SetValue((object)(__RpcExecStage)0); } } private static void __rpc_handler_269264864(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int indexSuit = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref indexSuit); Traverse val = Traverse.Create((object)target).Field("__rpc_exec_stage"); val.SetValue((object)(__RpcExecStage)2); ((BodySuitBehaviour)(object)target).SyncIndexSuitClientRpc(indexSuit); val.SetValue((object)(__RpcExecStage)0); } } } internal class PositionOnNavMeshBehaviour { private float _maxReachDistance = 6f; private float _minReachDistance = 0.125f; private float _movedReachDistance = 5f; private float _moveDistance = 1f; private float _yOffset = 1f; private const int _areaMask = -1; private float _maxDistanceFromNavmesh = 0.5f; public PositionOnNavMeshBehaviour(float maxReachDistance, float minReachDistance, float movedReachDistance, float moveDistance, float yOffset) { _maxReachDistance = maxReachDistance; _minReachDistance = minReachDistance; _movedReachDistance = movedReachDistance; _moveDistance = moveDistance; _yOffset = yOffset; } public bool SetPositionOnNavMesh(Vector3 startPosition, out Vector3 newPosition) { //IL_000c: 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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) ManualLogSource mls = Remnants.Instance.Mls; NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(startPosition, ref val, _maxReachDistance, -1)) { mls.LogWarning((object)"Position is not in range of Navmesh."); newPosition = Vector3.zero; return false; } if (((NavMeshHit)(ref val)).distance <= _minReachDistance) { newPosition = startPosition; newPosition.y += _yOffset; return true; } Vector3 position = ((NavMeshHit)(ref val)).position; position.y = startPosition.y; Vector3 val2 = position - startPosition; float magnitude = ((Vector3)(ref val2)).magnitude; Vector3 val3 = val2 / magnitude; Vector3 val4 = ((NavMeshHit)(ref val)).position + val3 * _moveDistance; NavMeshHit val5 = default(NavMeshHit); if (NavMesh.SamplePosition(val4, ref val5, _movedReachDistance, -1)) { newPosition = ((NavMeshHit)(ref val5)).position; newPosition.y += _yOffset; return true; } mls.LogWarning((object)"Moved position not found on navmesh, using older position on navmesh."); newPosition = ((NavMeshHit)(ref val)).position; newPosition.y += _yOffset; return true; } public bool SetRandomOffsetOnNavmesh(Vector3 startPosition, out Vector3 newPosition) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) ManualLogSource mls = Remnants.Instance.Mls; NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(startPosition, ref val, _maxDistanceFromNavmesh, -1)) { mls.LogWarning((object)"Position is not on Navmesh."); newPosition = Vector3.zero; return false; } float num = Mathf.Abs(_moveDistance); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Random.Range(0f - num, num), Random.Range(0f - num, num), Random.Range(0f - num, num)); NavMeshHit val3 = default(NavMeshHit); if (!NavMesh.SamplePosition(startPosition + val2, ref val3, num, -1)) { mls.LogWarning((object)"Random position is not on Navmesh, using starting position."); newPosition = startPosition; return true; } newPosition = ((NavMeshHit)(ref val3)).position; return true; } } public class RandomizeBatteriesBehaviour { private bool _hasInitialized = false; private Random _random = new Random(); public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; } } public void RandomizeItemsBattery(List itemsObjects = null) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Randomizing items batteries."); if (itemsObjects == null) { mls.LogWarning((object)"List to randomize batteries is null!"); return; } foreach (GameObject itemsObject in itemsObjects) { if (!((Object)(object)itemsObject == (Object)null)) { GrabbableObject component = itemsObject.GetComponent(); if (component.itemProperties.requiresBattery && component.insertedBattery != null && component.isInFactory && !component.isInShipRoom) { int num = _random.Next(Remnants.Instance.RemnantsConfig.MinRemnantBatteryCharge.Value, Remnants.Instance.RemnantsConfig.MaxRemnantBatteryCharge.Value); component.SyncBatteryServerRpc(num); mls.LogInfo((object)("Has updated " + component.itemProperties.itemName + " charge to " + component.insertedBattery.charge)); } } } } public void RandomizeItemBattery(GameObject itemObject = null) { ManualLogSource mls = Remnants.Instance.Mls; if (!((Object)(object)itemObject == (Object)null)) { GrabbableObject component = itemObject.GetComponent(); if (!((Object)(object)component == (Object)null) && component.itemProperties.requiresBattery && component.insertedBattery != null && component.isInFactory && !component.isInShipRoom) { int num = _random.Next(Remnants.Instance.RemnantsConfig.MinRemnantBatteryCharge.Value, Remnants.Instance.RemnantsConfig.MaxRemnantBatteryCharge.Value); component.SyncBatteryServerRpc(num); mls.LogInfo((object)("Has updated " + component.itemProperties.itemName + " charge to " + component.insertedBattery.charge)); } } } } public class RemnantItemsBehaviour { private bool _hasInitialized = false; private List _networkRemnantItems = new List(); public List NetworkRemnantItems => _networkRemnantItems; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; } } public void AddNetworkRemnantItem(ScrapItem scrapItem) { if (scrapItem != null && !_networkRemnantItems.Contains(scrapItem)) { _networkRemnantItems.Add(scrapItem); } } } public class SpawnBodiesBehaviour { private bool _hasInitialized = false; private float _courotineDelayTAmount = 11f; private string _propName = "Prop"; private List _propBodyObjects = new List(); private List _scrapBodyObjects = new List(); private Random _random = new Random(); private PositionOnNavMeshBehaviour _positionOnNavMeshBehaviour = new PositionOnNavMeshBehaviour(6f, 0.125f, 5f, 1f, 1f); private int _maxPercentage = 100; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; SceneManager.sceneLoaded += CollectBodiesFromNetworkObjects; } } public void SpawnBodiesOnItems(List itemsObjects, bool alwaysSpawn = false) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Spawning bodies."); if (itemsObjects == null || itemsObjects.Count == 0) { mls.LogWarning((object)"List to spawn bodies on, is null or is empty!"); return; } List positionList = itemsObjects.ConvertAll((GameObject gameObj) => gameObj.transform.position); SpawnBodiesOnPositions(positionList, alwaysSpawn); } public void SpawnBodiesOnPositions(List positionList, bool alwaysSpawn = false) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) ManualLogSource mls = Remnants.Instance.Mls; RoundManager roundManager = RoundManager.Instance; if ((Object)(object)roundManager == (Object)null) { mls.LogWarning((object)"Roundmanager not found!"); } else { if (!Remnants.Instance.LoadBodyAssets.HasLoadedAnyAssets || Remnants.Instance.RemnantsConfig.SpawnRarityOfBody.Value == 0 || positionList.Count == 0) { return; } List> list = CreatePrefabAndRarityList(); if (list == null || list.Count == 0) { mls.LogWarning((object)"No indoor enemies found on this moon, skipping body spawning"); return; } List NetworkObjectReferenceList = new List(); List scrapValueList = new List(); List suitsIndexList = Remnants.Instance.RegisterBodySuits.SuitsIndexList; int maxValue = CalculateTotalRarityValue(list); float num = CalculateSpawnChance(StartOfRound.Instance.currentLevel.riskLevel); bool value = Remnants.Instance.RemnantsConfig.ShouldBodiesBeScrap.Value; bool flag = false; foreach (Vector3 position in positionList) { if (!alwaysSpawn) { if (!flag) { flag = (float)_random.Next(_maxPercentage) <= num; } if (!flag) { continue; } } if (!_positionOnNavMeshBehaviour.SetPositionOnNavMesh(position, out var newPosition)) { mls.LogWarning((object)"Did not found place to spawn body, skipping it."); continue; } NetworkObject val = null; int randomBodyIndex = GetRandomBodyIndex(list, _random.Next(maxValue)); if (!value) { val = SpawnPropBody(list[randomBodyIndex].Key, newPosition); } else { val = SpawnScrapBody(list[randomBodyIndex].Key, newPosition, roundManager.spawnedScrapContainer); NetworkObjectReferenceList.Add(NetworkObjectReference.op_Implicit(val)); int item = (int)((float)_random.Next(Remnants.Instance.RemnantsConfig.MinBodyScrapValue.Value, Remnants.Instance.RemnantsConfig.MaxBodyScrapValue.Value) * roundManager.scrapAmountMultiplier); scrapValueList.Add(item); } if (suitsIndexList.Count != 0) { int indexSuit = suitsIndexList[_random.Next(suitsIndexList.Count)]; if (!value) { BodySuitBehaviour component = ((Component)val).GetComponent(); component.SyncIndexSuitClientRpc(indexSuit); } else { BodyGrabbableObject component2 = ((Component)val).GetComponent(); component2.SyncIndexSuit(indexSuit); } } flag = false; } if (NetworkObjectReferenceList.Count != 0) { CoroutineHelper coroutineHelper = CoroutineHelper.Instance; if ((Object)(object)coroutineHelper == (Object)null) { coroutineHelper = new GameObject().AddComponent(); } coroutineHelper.ExecuteAfterDelay(delegate { roundManager.SyncScrapValuesClientRpc(NetworkObjectReferenceList.ToArray(), scrapValueList.ToArray()); }, _courotineDelayTAmount); } } } private NetworkObject SpawnPropBody(GameObject prefab, Vector3 spawnPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(prefab, spawnPosition, Random.rotation, RoundManager.Instance.mapPropsContainer.transform); NetworkObject component = val.GetComponent(); component.Spawn(true); return component; } private NetworkObject SpawnScrapBody(GameObject prefab, Vector3 spawnPosition, Transform parent) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(prefab, spawnPosition, Random.rotation, parent); NetworkObject component = val.GetComponent(); component.Spawn(false); return component; } private List> CreatePrefabAndRarityList() { RegisterBodiesSpawnBehaviour registerBodiesSpawn = Remnants.Instance.RegisterBodiesSpawn; SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; string key = currentLevel.PlanetName; if (registerBodiesSpawn.HasIllegalCharacters(currentLevel.PlanetName)) { key = registerBodiesSpawn.PlanetsBodiesRarities.First().Key; } if (!registerBodiesSpawn.PlanetsBodiesRarities.ContainsKey(key)) { registerBodiesSpawn.RegisterBodiesToNewMoon(currentLevel); } Dictionary bodiesArray = registerBodiesSpawn.PlanetsBodiesRarities[key]; if (!Remnants.Instance.RemnantsConfig.ShouldBodiesBeScrap.Value) { List list = _propBodyObjects.Where((GameObject prefab) => bodiesArray.ContainsKey(((Object)prefab).name.Substring(0, ((Object)prefab).name.Length - _propName.Length))).ToList(); return list.ConvertAll((GameObject prefab) => new KeyValuePair(prefab, bodiesArray[((Object)prefab).name.Substring(0, ((Object)prefab).name.Length - _propName.Length)])); } List list2 = _scrapBodyObjects.Where((GameObject prefab) => bodiesArray.ContainsKey(((Object)prefab).name)).ToList(); return list2.ConvertAll((GameObject prefab) => new KeyValuePair(prefab, bodiesArray[((Object)prefab).name])); } private int CalculateTotalRarityValue(List> prefabAndRarityList) { int num = 0; foreach (KeyValuePair prefabAndRarity in prefabAndRarityList) { num += prefabAndRarity.Value; } return num; } private int GetRandomBodyIndex(List> prefabAndRarityList, int randomNumber) { int num = 0; for (int i = 0; i < prefabAndRarityList.Count; i++) { num += prefabAndRarityList[i].Value; if (num > randomNumber) { return i; } } return 0; } private float CalculateSpawnChance(string riskLevelName) { float value = Remnants.Instance.RemnantsConfig.BodySpawnModifierRiskLevel.Value; float num = Remnants.Instance.RemnantsConfig.SpawnRarityOfBody.Value; int num2 = Array.IndexOf(Remnants.Instance.RiskLevelArray, riskLevelName); if (!Mathf.Approximately(value, 0f) && num2 != -1) { num *= (float)num2 * value; } return num; } private void CollectBodiesFromNetworkObjects(Scene scene, LoadSceneMode mode) { ManualLogSource mls = Remnants.Instance.Mls; GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance == (Object)null || instance.isDisconnecting) { _propBodyObjects.Clear(); _scrapBodyObjects.Clear(); } else { if (!instance.isHostingGame || (_propBodyObjects.Count != 0 && _scrapBodyObjects.Count != 0)) { return; } List bodyObjNames = Remnants.Instance.LoadBodyAssets.EnemiesAndBodiesNames.Select((KeyValuePair EnemyAndBodyName) => EnemyAndBodyName.Value).ToList(); IReadOnlyList prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs; List list = prefabs.Where((NetworkPrefab netObj) => bodyObjNames.FindIndex((string name) => name + _propName == ((Object)netObj.Prefab).name) != -1).ToList(); _propBodyObjects = list.ConvertAll((NetworkPrefab netObj) => netObj.Prefab); List list2 = prefabs.Where((NetworkPrefab netObj) => bodyObjNames.Contains(((Object)netObj.Prefab).name)).ToList(); _scrapBodyObjects = list2.ConvertAll((NetworkPrefab netObj) => netObj.Prefab); } } } public class RegisterBodySuitsBehaviour { private bool _hasInitialized = false; private List _suitsIndexList = new List(); private List _suitsData = new List(); private char[] _illegalChars = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' }; public List SuitsIndexList => _suitsIndexList; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; _suitsData = Remnants.Instance.RemnantsConfig.GetSuitsList(); } } public void RegisterSuitsDataToConfig(List unlockableItemsList) { RegisterSuitsData(unlockableItemsList); Remnants.Instance.RemnantsConfig.SetSuitsList(_suitsData); } private void RegisterSuitsData(List unlockableItemsList) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)"Registering suits data."); List list = new List(); for (int i = 0; i < unlockableItemsList.Count; i++) { if (!((Object)(object)unlockableItemsList[i].suitMaterial != (Object)null) || _suitsIndexList.Contains(i)) { continue; } string suitName = unlockableItemsList[i].unlockableName; int num = _suitsData.FindIndex((SuitData suitData) => suitData.SuitName == suitName); if (!list.Contains(suitName) && !HasIllegalCharacters(suitName)) { if (num == -1) { _suitsIndexList.Add(i); _suitsData.Add(new SuitData { SuitName = suitName, UseSuit = true }); mls.LogInfo((object)("Register new suit data of: " + suitName)); list.Add(suitName); } else if (_suitsData[num].UseSuit) { _suitsIndexList.Add(i); mls.LogInfo((object)("Register suit data of: " + suitName)); list.Add(suitName); } } } mls.LogInfo((object)"Suits data registered."); } private bool HasIllegalCharacters(string name) { if (Utility.IsNullOrWhiteSpace(name)) { return true; } return name.IndexOfAny(_illegalChars) != -1; } } public class RegisterBodiesSpawnBehaviour { private bool _hasInitialized = false; private bool _isRegisteringToMoons = false; private bool _isRegisteringToCostumMoons = false; public Dictionary> PlanetsBodiesRarities = new Dictionary>(); private char[] _illegalChars = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' }; private List _customMoonsNames = new List(); public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; SceneManager.sceneLoaded += RegisterBodiesToMoons; SceneManager.sceneLoaded += RegisterBodiesToCostumMoons; } } private void RegisterBodiesToMoons(Scene scene, LoadSceneMode mode) { ManualLogSource mls = Remnants.Instance.Mls; StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && !_isRegisteringToMoons && Remnants.Instance.LoadBodyAssets.HasLoadedAnyAssets) { mls.LogInfo((object)"Registering bodies to moons"); _isRegisteringToMoons = true; RegisterMoonsData(instance.levels); SceneManager.sceneLoaded -= RegisterBodiesToMoons; _isRegisteringToMoons = false; } } private void RegisterBodiesToCostumMoons(Scene scene, LoadSceneMode mode) { ManualLogSource mls = Remnants.Instance.Mls; if ((Object)(object)StartOfRound.Instance != (Object)null) { SceneManager.sceneLoaded -= RegisterBodiesToCostumMoons; Remnants.Instance.RemnantsConfig.SetCustomLevelsRarities(_customMoonsNames); } else { if (_isRegisteringToCostumMoons) { return; } List list = Resources.FindObjectsOfTypeAll().Concat(Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList(); if (list == null || list.Count == 0) { return; } _isRegisteringToCostumMoons = true; mls.LogInfo((object)"Registering custom moons data."); foreach (SelectableLevel item in list) { if (!HasIllegalCharacters(item.PlanetName) && !PlanetsBodiesRarities.ContainsKey(item.PlanetName)) { RegisterBodiesToNewMoon(item); _customMoonsNames.Add(item.PlanetName); } } mls.LogInfo((object)"Custom moons data registered."); _isRegisteringToCostumMoons = false; } } private void RegisterMoonsData(SelectableLevel[] levels) { List list = new List(); foreach (SelectableLevel val in levels) { if (!HasIllegalCharacters(val.PlanetName) && !PlanetsBodiesRarities.ContainsKey(val.PlanetName)) { RegisterBodiesToNewMoon(val); if (!Enum.TryParse(((Object)val).name, out LevelTypes _)) { list.Add(val.PlanetName); } } } Remnants.Instance.RemnantsConfig.SetCustomLevelsRarities(list); } public void RegisterBodiesToNewMoon(SelectableLevel newLevel) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)("New moon found attempting to register bodies to moon: " + newLevel.PlanetName)); PlanetsBodiesRarities.Add(newLevel.PlanetName, new Dictionary()); KeyValuePair[] enemiesAndBodiesNames = Remnants.Instance.LoadBodyAssets.EnemiesAndBodiesNames; foreach (SpawnableEnemyWithRarity enemyWithRarity in newLevel.Enemies) { if (enemyWithRarity.enemyType.isOutsideEnemy) { continue; } int num = Mathf.Clamp(Array.FindIndex(enemiesAndBodiesNames, (KeyValuePair enemyBodyName) => enemyBodyName.Key == enemyWithRarity.enemyType.enemyName), 0, enemiesAndBodiesNames.Length - 1); if (PlanetsBodiesRarities[newLevel.PlanetName].TryGetValue(enemiesAndBodiesNames[num].Value, out var value)) { if (value < enemyWithRarity.rarity) { PlanetsBodiesRarities[newLevel.PlanetName][enemiesAndBodiesNames[num].Value] = enemyWithRarity.rarity; } } else { PlanetsBodiesRarities[newLevel.PlanetName][enemiesAndBodiesNames[num].Value] = enemyWithRarity.rarity; } } mls.LogInfo((object)("Registered bodies to moon: " + newLevel.PlanetName)); } public bool HasIllegalCharacters(string name) { if (Utility.IsNullOrWhiteSpace(name)) { return true; } return name.IndexOfAny(_illegalChars) != -1; } } internal class RegisterItemsBehaviour { private bool _hasInitialized = false; private bool _isAddingItems = false; private List _bannedItemsNamesList = new List(); private const int _minSellValue = 1; private const int _maxSellValue = 2; private const float _minCreditCost = 1f; private const float _toFullCostMod = 2.5f; private const float _maxPercentage = 100f; private RemnantDataListBehaviour _remnantDataListBehaviour = new RemnantDataListBehaviour(); private List _remnantItemList = new List(); private RemnantItemsBehaviour _remnantItemsBehaviour = null; private float _creditsWorthMinPercentage = 0f; private float _creditsWorthMaxPercentage = 100f; private Func _checkIsScrapFunc = null; private Action _createRemnantItemAction = null; public void Initialize() { if (_hasInitialized) { return; } _hasInitialized = true; _bannedItemsNamesList = Remnants.Instance.RemnantsConfig.GetBannedFromRegisteringItemNames(); _remnantItemList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(reloadConfig: false); bool value = Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value; bool value2 = Remnants.Instance.RemnantsConfig.UseSpecificLevelRarities.Value; _remnantItemsBehaviour = Remnants.Instance.RemnantItemsBeh; _creditsWorthMinPercentage = (float)Remnants.Instance.RemnantsConfig.RemnantScrapMinCostPercentage.Value / 100f; _creditsWorthMaxPercentage = (float)Remnants.Instance.RemnantsConfig.RemnantScrapMaxCostPercentage.Value / 100f; if (value) { _checkIsScrapFunc = IsAlreadyScrap; if (value2) { _createRemnantItemAction = CreateMoonSpecificLegacyRemnantItem; } else { _createRemnantItemAction = CreateMoonGeneralLegacyRemnantItem; } } else { _checkIsScrapFunc = IsAlreadyScrapOrRegistered; if (value2) { _createRemnantItemAction = CreateMoonSpecificRemnantItem; } else { _createRemnantItemAction = CreateMoonGeneralRemnantItem; } } SceneManager.sceneLoaded += StoreItemsRegisterAsScrap; } private void StoreItemsRegisterAsScrap(Scene scene, LoadSceneMode mode) { ManualLogSource mls = Remnants.Instance.Mls; if ((Object)(object)StartOfRound.Instance != (Object)null) { SceneManager.sceneLoaded -= StoreItemsRegisterAsScrap; _remnantDataListBehaviour.UpdateScrapDataList(); _remnantItemList.Clear(); } else if (!_isAddingItems) { List list = Resources.FindObjectsOfTypeAll().Concat(Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList(); if (list.Count != 0 && list != null) { mls.LogInfo((object)"Loading in items."); _isAddingItems = true; AddStoreItemsToScrap(list); _isAddingItems = false; mls.LogInfo((object)"Items loaded in."); } } } private void AddStoreItemsToScrap(List allItems) { ManualLogSource mls = Remnants.Instance.Mls; try { foreach (Item item in allItems) { if ((Object)(object)item == (Object)null || HasBannedName(item) || _checkIsScrapFunc(item) || IsPrefabIncorrect(item.spawnPrefab)) { continue; } int itemCreditsWorth = GetItemCreditsWorth(item); if ((float)itemCreditsWorth >= 1f) { int num = _remnantItemList.FindIndex((RemnantData remnantData) => remnantData.RemnantItemName == item.itemName); int itemRarityInfo = -1; if (num != -1) { itemRarityInfo = _remnantItemList[num].RarityInfo; } RegisterItemAsScrap(item, itemCreditsWorth, itemRarityInfo); } } } catch (Exception ex) { mls.LogError((object)ex.ToString()); } } private bool HasBannedName(Item item) { return _bannedItemsNamesList.FindIndex((string x) => x == ((Object)item).name || x == item.itemName) != -1; } private bool IsAlreadyScrap(Item item) { return item.isScrap || Items.scrapItems.FindIndex((ScrapItem scrapItem) => scrapItem.item.itemName == item.itemName || scrapItem.origItem.itemName == item.itemName) != -1; } private bool IsAlreadyScrapOrRegistered(Item item) { return item.isScrap || _remnantItemsBehaviour.NetworkRemnantItems.FindIndex((ScrapItem remnantItem) => remnantItem.item.itemName == item.itemName || remnantItem.origItem.itemName == item.itemName) != -1; } private bool IsPrefabIncorrect(GameObject gameObject) { return (Object)(object)gameObject == (Object)null || (Object)(object)gameObject.GetComponent() == (Object)null; } private int GetItemCreditsWorth(Item item) { int num = Items.shopItems.FindIndex((ShopItem shopItem) => shopItem.origItem.itemName == item.itemName); if (num != -1) { return Items.shopItems[num].price; } return item.creditsWorth; } private void RegisterItemAsScrap(Item item, int creditsWorth, int itemRarityInfo) { ManualLogSource mls = Remnants.Instance.Mls; mls.LogInfo((object)("Registering " + item.itemName + " as scrap.")); bool arg = itemRarityInfo == -1 || itemRarityInfo == 0; _createRemnantItemAction(item, arg, itemRarityInfo, creditsWorth); mls.LogInfo((object)("Added " + item.itemName + " as a scrap item.")); _remnantDataListBehaviour.AddItemToDataList(item.itemName); } private int CalculateRarityByCredits(int itemCreditWorth, int minStoreScrapRarity, int maxStoreScrapRarity) { float value = Remnants.Instance.RemnantsConfig.MaxRemnantItemCost.Value; float num = Mathf.Clamp((float)itemCreditWorth, 1f, value); float num2 = Mathf.Abs(num / value * (float)maxStoreScrapRarity - (float)maxStoreScrapRarity); return Mathf.Clamp((int)num2, minStoreScrapRarity, maxStoreScrapRarity); } private int CalculateRarityOfItem(int itemRarity, int minRarity, int maxRarity) { int num = maxRarity - minRarity; return (int)((float)num / 100f * (float)itemRarity) + minRarity; } private void CreateMoonGeneralLegacyRemnantItem(Item item, bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { int num = CalculateGeneralRarity(useRarityByCredits, itemRarityInfo, creditsWorth); Items.RegisterScrap(item, num, (LevelTypes)(-1)); UpdateScrapItemData(item, creditsWorth); } private void CreateMoonGeneralRemnantItem(Item item, bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown int num = CalculateGeneralRarity(useRarityByCredits, itemRarityInfo, creditsWorth); ScrapItem scrapItem = new ScrapItem(item, num, (LevelTypes)(-1), (string[])null); scrapItem = CreateScrapitemData(scrapItem, creditsWorth); _remnantItemsBehaviour.AddNetworkRemnantItem(scrapItem); } private void CreateMoonSpecificRemnantItem(Item item, bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown KeyValuePair, Dictionary> keyValuePair = CreateMoonSpecificRarities(item, useRarityByCredits, itemRarityInfo, creditsWorth); ScrapItem scrapItem = new ScrapItem(item, keyValuePair.Key, keyValuePair.Value); scrapItem = CreateScrapitemData(scrapItem, creditsWorth); _remnantItemsBehaviour.AddNetworkRemnantItem(scrapItem); } private void CreateMoonSpecificLegacyRemnantItem(Item item, bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { KeyValuePair, Dictionary> keyValuePair = CreateMoonSpecificRarities(item, useRarityByCredits, itemRarityInfo, creditsWorth); Items.RegisterScrap(item, keyValuePair.Key, keyValuePair.Value); UpdateScrapItemData(item, creditsWorth); } private void UpdateScrapItemData(Item item, int creditsWorth) { int index = Items.scrapItems.FindIndex((ScrapItem scrapItem) => scrapItem.item.itemName == item.itemName || scrapItem.origItem.itemName == item.itemName); Items.scrapItems[index].item.minValue = Mathf.Clamp((int)((float)creditsWorth * 2.5f * _creditsWorthMinPercentage), 1, int.MaxValue); Items.scrapItems[index].item.maxValue = Mathf.Clamp((int)((float)creditsWorth * 2.5f * _creditsWorthMaxPercentage), 2, int.MaxValue); Items.scrapItems[index].item.itemSpawnsOnGround = true; Utilities.FixMixerGroups(Items.scrapItems[index].item.spawnPrefab); GrabbableObject componentInChildren = Items.scrapItems[index].item.spawnPrefab.GetComponentInChildren(); ((Object)Items.scrapItems[index].item.spawnPrefab).hideFlags = (HideFlags)0; if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.isInFactory = true; ((Object)componentInChildren).hideFlags = (HideFlags)0; } } private ScrapItem CreateScrapitemData(ScrapItem scrapItem, int creditsWorth) { string name = Assembly.GetCallingAssembly().GetName().Name; scrapItem.modName = name; scrapItem.item.minValue = Mathf.Clamp((int)((float)creditsWorth * _creditsWorthMinPercentage), 0, int.MaxValue); scrapItem.item.maxValue = Mathf.Clamp((int)((float)creditsWorth * _creditsWorthMaxPercentage), 0, int.MaxValue); scrapItem.item.itemSpawnsOnGround = true; Utilities.FixMixerGroups(scrapItem.item.spawnPrefab); GrabbableObject componentInChildren = scrapItem.item.spawnPrefab.GetComponentInChildren(); ((Object)scrapItem.item.spawnPrefab).hideFlags = (HideFlags)0; if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.isInFactory = true; ((Object)componentInChildren).hideFlags = (HideFlags)0; } return scrapItem; } private int CalculateGeneralRarity(bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { int num = 0; if (useRarityByCredits) { return CalculateRarityByCredits(creditsWorth, Remnants.Instance.RemnantsConfig.MinRemnantRarity.Value, Remnants.Instance.RemnantsConfig.MaxRemnantRarity.Value); } return CalculateRarityOfItem(itemRarityInfo, Remnants.Instance.RemnantsConfig.MinRemnantRarity.Value, Remnants.Instance.RemnantsConfig.MaxRemnantRarity.Value); } private KeyValuePair, Dictionary> CreateMoonSpecificRarities(Item item, bool useRarityByCredits, int itemRarityInfo, int creditsWorth) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); Dictionary dictionary2 = new Dictionary(); if (useRarityByCredits) { foreach (KeyValuePair> levelRarity in Remnants.Instance.RemnantsConfig.LevelRarities) { dictionary.Add(levelRarity.Key, CalculateRarityByCredits(creditsWorth, levelRarity.Value.Item1, levelRarity.Value.Item2)); } foreach (KeyValuePair> customLevelRarity in Remnants.Instance.RemnantsConfig.CustomLevelRarities) { dictionary2.Add(customLevelRarity.Key, CalculateRarityByCredits(creditsWorth, customLevelRarity.Value.Item1, customLevelRarity.Value.Item2)); } } else { foreach (KeyValuePair> levelRarity2 in Remnants.Instance.RemnantsConfig.LevelRarities) { dictionary.Add(levelRarity2.Key, CalculateRarityOfItem(itemRarityInfo, levelRarity2.Value.Item1, levelRarity2.Value.Item2)); } foreach (KeyValuePair> customLevelRarity2 in Remnants.Instance.RemnantsConfig.CustomLevelRarities) { dictionary2.Add(customLevelRarity2.Key, CalculateRarityOfItem(itemRarityInfo, customLevelRarity2.Value.Item1, customLevelRarity2.Value.Item2)); } } return new KeyValuePair, Dictionary>(dictionary, dictionary2); } } internal class RemnantDataListBehaviour { private List _RemnantItemsListData = new List(); private int _defaultRarityInfoValue = -1; public void AddItemToDataList(string itemName) { if (_RemnantItemsListData.FindIndex((RemnantData scrapData) => scrapData.RemnantItemName == itemName) == -1) { RemnantData remnantData = new RemnantData(); remnantData.RemnantItemName = itemName; remnantData.RarityInfo = _defaultRarityInfoValue; _RemnantItemsListData.Add(remnantData); } } public void UpdateScrapDataList() { List remnantItemList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(); if (remnantItemList.Count != 0) { UpdateDataList(remnantItemList); } WriteScrapDataList(); } private void WriteScrapDataList() { Remnants.Instance.RemnantsConfig.SetRemnantItemList(_RemnantItemsListData); } private void UpdateDataList(List remnantDataList) { ManualLogSource mls = Remnants.Instance.Mls; List fileScrapDataList = remnantDataList; List list = new List(); int i; for (i = 0; i < _RemnantItemsListData.Count; i++) { int num = fileScrapDataList.FindIndex((RemnantData scrapData) => scrapData.RemnantItemName == _RemnantItemsListData[i].RemnantItemName); if (num != -1) { _RemnantItemsListData[i].RarityInfo = fileScrapDataList[num].RarityInfo; } } int j; for (j = 0; j < fileScrapDataList.Count; j++) { int num2 = _RemnantItemsListData.FindIndex((RemnantData scrapData) => scrapData.RemnantItemName == fileScrapDataList[j].RemnantItemName); if (num2 == -1) { list.Add(fileScrapDataList[j]); } } foreach (RemnantData item in list) { _RemnantItemsListData.Add(item); } } } public class SpawnRemnantItemsBehaviour { private bool _hasInitialized = false; private string[] _riskLevelArray = null; private Random _random = new Random(); private float _spawnBalanceModifier = 0.55f; private float _courotineDelayTAmount = 11f; private RandomizeBatteriesBehaviour _randomizeBatteriesBeh = null; private int _maxPercentage = 100; private PositionOnNavMeshBehaviour _positionOnNavMeshBeh = new PositionOnNavMeshBehaviour(0f, 0.125f, 0f, 1.3f, 0f); private List _bodySpawnPositions = new List(); public List BodySpawnPositions => _bodySpawnPositions; public void Initialize() { if (!_hasInitialized) { _hasInitialized = true; _riskLevelArray = Remnants.Instance.RiskLevelArray; _randomizeBatteriesBeh = Remnants.Instance.ItemsBatteriesBeh; } } public void SpawnRemnantItems(RoundManager roundManager) { //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) ManualLogSource mls = Remnants.Instance.Mls; if ((Object)(object)roundManager == (Object)null) { return; } List availableNetworkRemnantItems = GetAvailableNetworkRemnantItems(); int value = Remnants.Instance.RemnantsConfig.MinItemsFoundOnBodies.Value; int maxValue = Mathf.Clamp(Remnants.Instance.RemnantsConfig.MaxItemsFoundOnBodies.Value, value, int.MaxValue); int num = CalculateAmountItemsToSpawn(roundManager); List> remnantItemsBaseContainer = CreateRemnantItemsBaseContainer(roundManager, availableNetworkRemnantItems); List> list = CreateRemnantItemsContainer(remnantItemsBaseContainer); int num2 = CreateTotalRarity(list); List NetworkObjectReferenceList = new List(); List scrapValueList = new List(); _bodySpawnPositions.Clear(); float num3 = CalculateBodySpawnChance(StartOfRound.Instance.currentLevel.riskLevel); bool flag = true; int num4 = 0; int num5 = 0; for (int i = 0; i < num; i++) { if (num2 <= 0 || list.Count == 0) { break; } KeyValuePair remnantItemToSpawnData = GetRandomSpawnData(list, num2); if (Utility.IsNullOrWhiteSpace(remnantItemToSpawnData.Key)) { mls.LogError((object)"Remnant item spawn data not found"); break; } num2 -= remnantItemToSpawnData.Value; list.Remove(remnantItemToSpawnData); ScrapItem val = availableNetworkRemnantItems.Find((ScrapItem networkRemnantItem) => networkRemnantItem.item.itemName == remnantItemToSpawnData.Key); Vector3 newPosition = Vector3.zero; if (num4 <= 0 || _bodySpawnPositions.Count == 0) { int num6 = roundManager.AnomalyRandom.Next(0, roundManager.insideAINodes.Length); Vector3 randomNavMeshPositionInBoxPredictable = roundManager.GetRandomNavMeshPositionInBoxPredictable(roundManager.insideAINodes[num6].transform.position, 8f, roundManager.navHit, roundManager.AnomalyRandom, -1, 1f); newPosition = randomNavMeshPositionInBoxPredictable; flag = true; } else { if (num4 <= 0 || !_positionOnNavMeshBeh.SetRandomOffsetOnNavmesh(_bodySpawnPositions.Last(), out newPosition)) { mls.LogWarning((object)"Something went wrong with spawning remnant items spawning positions."); continue; } num4--; flag = false; } if (flag && (float)_random.Next(_maxPercentage) <= num3) { num4 = _random.Next(value, maxValue) - 1; _bodySpawnPositions.Add(newPosition); } GameObject val2 = Object.Instantiate(val.item.spawnPrefab, newPosition, Quaternion.identity, roundManager.spawnedScrapContainer); NetworkObject component = val2.GetComponent(); component.Spawn(false); int num7 = (int)((float)_random.Next(val.item.minValue, val.item.maxValue) * roundManager.scrapAmountMultiplier); _randomizeBatteriesBeh.RandomizeItemBattery(val2); NetworkObjectReferenceList.Add(NetworkObjectReference.op_Implicit(component)); scrapValueList.Add(num7); num5 += num7; } RoundManager obj = roundManager; obj.totalScrapValueInLevel += (float)num5; if (NetworkObjectReferenceList.Count != 0) { CoroutineHelper coroutineHelper = CoroutineHelper.Instance; if ((Object)(object)coroutineHelper == (Object)null) { coroutineHelper = new GameObject().AddComponent(); } coroutineHelper.ExecuteAfterDelay(delegate { roundManager.SyncScrapValuesClientRpc(NetworkObjectReferenceList.ToArray(), scrapValueList.ToArray()); }, _courotineDelayTAmount); } } private List GetAvailableNetworkRemnantItems() { List networkRemnantItems = Remnants.Instance.RemnantItemsBeh.NetworkRemnantItems; List remnantItemDataList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(reloadConfig: false); networkRemnantItems.RemoveAll((ScrapItem spawnableItem) => remnantItemDataList.FindIndex((RemnantData itemData) => itemData.RarityInfo == 0 && (itemData.RemnantItemName == spawnableItem.origItem.itemName || itemData.RemnantItemName == spawnableItem.item.itemName)) != -1); return networkRemnantItems; } private int CalculateAmountItemsToSpawn(RoundManager roundManager) { int value = Remnants.Instance.RemnantsConfig.MinRemnantItemsSpawning.Value; int maxValue = Mathf.Clamp(Remnants.Instance.RemnantsConfig.MaxRemnantItemsSpawning.Value, value, int.MaxValue); float value2 = Remnants.Instance.RemnantsConfig.RemnantItemsSpawningModifier.Value; int num = 0; num = Mathf.Clamp(Array.IndexOf(_riskLevelArray, roundManager.currentLevel.riskLevel), 0, _riskLevelArray.Length); float num2 = 1f; if (value2 > 0f) { num2 = (float)num * _spawnBalanceModifier * value2; } float num3 = roundManager.scrapAmountMultiplier * num2; return (int)((float)_random.Next(value, maxValue) * num3); } private List> CreateRemnantItemsBaseContainer(RoundManager roundManager, List networkRemnantItems) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) ManualLogSource mls = Remnants.Instance.Mls; bool value = Remnants.Instance.RemnantsConfig.UseSpecificLevelRarities.Value; List> list = new List>(); if (value) { foreach (ScrapItem networkRemnantItem in networkRemnantItems) { LevelTypes result; if (networkRemnantItem.customLevelRarities.ContainsKey(roundManager.currentLevel.PlanetName)) { list.Add(new KeyValuePair(networkRemnantItem.item.itemName, networkRemnantItem.customLevelRarities[roundManager.currentLevel.PlanetName])); } else if (networkRemnantItem.customLevelRarities.ContainsKey(((Object)roundManager.currentLevel).name)) { list.Add(new KeyValuePair(networkRemnantItem.item.itemName, networkRemnantItem.customLevelRarities[((Object)roundManager.currentLevel).name])); } else if (Enum.TryParse(((Object)roundManager.currentLevel).name, out result)) { list.Add(new KeyValuePair(networkRemnantItem.item.itemName, networkRemnantItem.levelRarities[result])); } } } else { foreach (ScrapItem networkRemnantItem2 in networkRemnantItems) { list.Add(new KeyValuePair(networkRemnantItem2.item.itemName, networkRemnantItem2.levelRarities[(LevelTypes)(-1)])); } } return list; } private List> CreateRemnantItemsContainer(List> remnantItemsBaseContainer) { int value = Remnants.Instance.RemnantsConfig.MaxDuplicatesRemnantItems.Value; List> list = new List>(); for (int i = 0; i < value; i++) { list.AddRange(remnantItemsBaseContainer); } return list; } private int CreateTotalRarity(List> remnantItemsContainer) { int num = 0; foreach (KeyValuePair item in remnantItemsContainer) { num += item.Value; } return num; } private KeyValuePair GetRandomSpawnData(List> remnantItemsContainer, int totalRarity) { int num = _random.Next(0, totalRarity); int num2 = 0; KeyValuePair result = new KeyValuePair("", 0); foreach (KeyValuePair item in remnantItemsContainer) { if (num <= num2 + item.Value) { result = item; return result; } num2 += item.Value; } return result; } private float CalculateBodySpawnChance(string riskLevelName) { float value = Remnants.Instance.RemnantsConfig.BodySpawnModifierRiskLevel.Value; float num = Remnants.Instance.RemnantsConfig.SpawnRarityOfBody.Value; int num2 = Array.IndexOf(Remnants.Instance.RiskLevelArray, riskLevelName); if (!Mathf.Approximately(value, 0f) && num2 != -1) { num *= (float)num2 * value; } return num; } } }