Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Mediator v1.0.0
plugins/MediatorMod.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AncientScepter; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.AI.Walker; using EntityStates.Commando.CommandoWeapon; using HG; using HG.BlendableTypes; using MediatorMod.Components; using MediatorMod.Modules; using MediatorMod.Modules.Achievements; using MediatorMod.Modules.BaseStates; using MediatorMod.Modules.Characters; using MediatorMod.Survivors.Mediator; using MediatorMod.Survivors.Mediator.Components; using MediatorMod.Survivors.Mediator.SkillStates; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using RoR2.Achievements; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.ContentManagement; using RoR2.Projectile; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MediatorMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MediatorMod")] [assembly: AssemblyTitle("MediatorMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace MediatorMod { internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void ErrorAssetBundle(string assetName, string bundleName) { Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.CeoOfSwag.Mediator", "Mediator", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MediatorPlugin : BaseUnityPlugin { public const string MODUID = "com.CeoOfSwag.Mediator"; public const string MODNAME = "Mediator"; public const string MODVERSION = "1.0.0"; public const string DEVELOPER_PREFIX = "CEO"; public static MediatorPlugin instance; private void Awake() { instance = this; Log.Init(((BaseUnityPlugin)this).Logger); Language.Init(); new MediatorSurvivor().Initialize(); new ContentPacks().Initialize(); } } } namespace MediatorMod.Modules { internal static class Asset { internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>(); internal static AssetBundle LoadAssetBundle(string bundleName) { if (bundleName == "myassetbundle") { Log.Error("AssetBundle name hasn't been changed. not loading any assets to avoid conflicts.\nMake sure to rename your assetbundle filename and rename the AssetBundleName field in your character setup code "); return null; } if (loadedBundles.ContainsKey(bundleName)) { return loadedBundles[bundleName]; } AssetBundle val = null; try { val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)MediatorPlugin.instance).Info.Location), "AssetBundles", bundleName)); } catch (Exception arg) { Log.Error($"Error loading asset bundle, {bundleName}. Your asset bundle must be in a folder next to your mod dll called 'AssetBundles'. Follow the guide to build and install your mod correctly!\n{arg}"); } loadedBundles[bundleName] = val; return val; } internal static GameObject CloneTracer(string originalTracerName, string newTracerName) { if ((Object)(object)LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName) == (Object)null) { return null; } GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName), newTracerName, true); if (!Object.op_Implicit((Object)(object)val.GetComponent<EffectComponent>())) { val.AddComponent<EffectComponent>(); } if (!Object.op_Implicit((Object)(object)val.GetComponent<VFXAttributes>())) { val.AddComponent<VFXAttributes>(); } if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>())) { val.AddComponent<NetworkIdentity>(); } val.GetComponent<Tracer>().speed = 250f; val.GetComponent<Tracer>().length = 50f; Content.CreateAndAddEffectDef(val); return val; } internal static void ConvertAllRenderersToHopooShader(GameObject objectToConvert) { if (!Object.op_Implicit((Object)(object)objectToConvert)) { return; } MeshRenderer[] componentsInChildren = objectToConvert.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Renderer)val).sharedMaterial)) { ((Renderer)val).sharedMaterial.ConvertDefaultShaderToHopoo(); } } SkinnedMeshRenderer[] componentsInChildren2 = objectToConvert.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial)) { ((Renderer)val2).sharedMaterial.ConvertDefaultShaderToHopoo(); } } } internal static GameObject LoadCrosshair(string crosshairName) { GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/" + crosshairName + "Crosshair"); if ((Object)(object)val == (Object)null) { Log.Error("could not load crosshair with the name " + crosshairName + ". defaulting to Standard"); return LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/StandardCrosshair"); } return val; } internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, bool parentToTransform) { return assetBundle.LoadEffect(resourceName, "", parentToTransform); } internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, string soundName = "", bool parentToTransform = false) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) GameObject val = assetBundle.LoadAsset<GameObject>(resourceName); if (!Object.op_Implicit((Object)(object)val)) { Log.ErrorAssetBundle(resourceName, ((Object)assetBundle).name); return null; } val.AddComponent<DestroyOnTimer>().duration = 12f; val.AddComponent<NetworkIdentity>(); val.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; EffectComponent val2 = val.AddComponent<EffectComponent>(); val2.applyScale = false; val2.effectIndex = (EffectIndex)(-1); val2.parentToReferencedTransform = parentToTransform; val2.positionAtReferencedTransform = true; val2.soundName = soundName; Content.CreateAndAddEffectDef(val); return val; } internal static GameObject CreateProjectileGhostPrefab(this AssetBundle assetBundle, string ghostName) { GameObject val = assetBundle.LoadAsset<GameObject>(ghostName); if ((Object)(object)val == (Object)null) { Log.Error("Failed to load ghost prefab " + ghostName); } if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>())) { val.AddComponent<NetworkIdentity>(); } if (!Object.op_Implicit((Object)(object)val.GetComponent<ProjectileGhostController>())) { val.AddComponent<ProjectileGhostController>(); } ConvertAllRenderersToHopooShader(val); return val; } internal static GameObject CloneProjectilePrefab(string prefabName, string newPrefabName) { return PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/" + prefabName), newPrefabName); } internal static GameObject LoadAndAddProjectilePrefab(this AssetBundle assetBundle, string newPrefabName) { GameObject val = assetBundle.LoadAsset<GameObject>(newPrefabName); if ((Object)(object)val == (Object)null) { Log.ErrorAssetBundle(newPrefabName, ((Object)assetBundle).name); return null; } Content.AddProjectilePrefab(val); return val; } } public static class Config { public static ConfigFile MyConfig = ((BaseUnityPlugin)MediatorPlugin.instance).Config; public static ConfigEntry<bool> CharacterEnableConfig(string section, string characterName, string description = "", bool enabledByDefault = true) { if (string.IsNullOrEmpty(description)) { description = "Set to false to disable this character and as much of its code and content as possible"; } return BindAndOptions(section, "Enable " + characterName, enabledByDefault, description, restartRequired: true); } public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "", bool restartRequired = false) { return BindAndOptions(section, name, defaultValue, 0f, 20f, description, restartRequired); } public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, float min, float max, string description = "", bool restartRequired = false) { if (string.IsNullOrEmpty(description)) { description = name; } if (restartRequired) { description += " (restart required)"; } ConfigEntry<T> result = MyConfig.Bind<T>(section, name, defaultValue, description); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { } return result; } public static ConfigEntry<float> BindAndOptionsSlider(string section, string name, float defaultValue, string description, float min = 0f, float max = 20f, bool restartRequired = false) { return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired) { } public static bool GetKeyPressed(KeyboardShortcut entry) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) foreach (KeyCode modifier in ((KeyboardShortcut)(ref entry)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return Input.GetKeyDown(((KeyboardShortcut)(ref entry)).MainKey); } } internal class Content { internal static void AddCharacterBodyPrefab(GameObject bprefab) { ContentPacks.bodyPrefabs.Add(bprefab); } internal static void AddMasterPrefab(GameObject prefab) { ContentPacks.masterPrefabs.Add(prefab); } internal static void AddProjectilePrefab(GameObject prefab) { ContentPacks.projectilePrefabs.Add(prefab); } internal static void AddSurvivorDef(SurvivorDef survivorDef) { ContentPacks.survivorDefs.Add(survivorDef); } internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, null, 100f); } internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, float sortPosition) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, null, sortPosition); } internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, UnlockableDef unlockableDef) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, unlockableDef, 100f); } internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, UnlockableDef unlockableDef, float sortPosition) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) SurvivorDef val = ScriptableObject.CreateInstance<SurvivorDef>(); val.bodyPrefab = bodyPrefab; val.displayPrefab = displayPrefab; val.primaryColor = charColor; val.cachedName = ((Object)bodyPrefab).name.Replace("Body", ""); val.displayNameToken = tokenPrefix + "NAME"; val.descriptionToken = tokenPrefix + "DESCRIPTION"; val.outroFlavorToken = tokenPrefix + "OUTRO_FLAVOR"; val.mainEndingEscapeFailureFlavorToken = tokenPrefix + "OUTRO_FAILURE"; val.desiredSortPosition = sortPosition; val.unlockableDef = unlockableDef; AddSurvivorDef(val); } internal static void AddUnlockableDef(UnlockableDef unlockableDef) { ContentPacks.unlockableDefs.Add(unlockableDef); } internal static UnlockableDef CreateAndAddUnlockbleDef(string identifier, string nameToken, Sprite achievementIcon) { UnlockableDef val = ScriptableObject.CreateInstance<UnlockableDef>(); val.cachedName = identifier; val.nameToken = nameToken; val.achievementIcon = achievementIcon; AddUnlockableDef(val); return val; } internal static void AddSkillDef(SkillDef skillDef) { ContentPacks.skillDefs.Add(skillDef); } internal static void AddSkillFamily(SkillFamily skillFamily) { ContentPacks.skillFamilies.Add(skillFamily); } internal static void AddEntityState(Type entityState) { ContentPacks.entityStates.Add(entityState); } internal static void AddBuffDef(BuffDef buffDef) { ContentPacks.buffDefs.Add(buffDef); } internal static BuffDef CreateAndAddBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) BuffDef val = ScriptableObject.CreateInstance<BuffDef>(); ((Object)val).name = buffName; val.buffColor = buffColor; val.canStack = canStack; val.isDebuff = isDebuff; val.eliteDef = null; val.iconSprite = buffIcon; AddBuffDef(val); return val; } internal static void AddEffectDef(EffectDef effectDef) { ContentPacks.effectDefs.Add(effectDef); } internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown EffectDef val = new EffectDef(effectPrefab); AddEffectDef(val); return val; } internal static void AddNetworkSoundEventDef(NetworkSoundEventDef networkSoundEventDef) { ContentPacks.networkSoundEventDefs.Add(networkSoundEventDef); } internal static NetworkSoundEventDef CreateAndAddNetworkSoundEventDef(string eventName) { NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>(); val.akId = AkSoundEngine.GetIDFromString(eventName); val.eventName = eventName; AddNetworkSoundEventDef(val); return val; } } internal class ContentPacks : IContentPackProvider { internal ContentPack contentPack = new ContentPack(); public static List<GameObject> bodyPrefabs = new List<GameObject>(); public static List<GameObject> masterPrefabs = new List<GameObject>(); public static List<GameObject> projectilePrefabs = new List<GameObject>(); public static List<SurvivorDef> survivorDefs = new List<SurvivorDef>(); public static List<UnlockableDef> unlockableDefs = new List<UnlockableDef>(); public static List<SkillFamily> skillFamilies = new List<SkillFamily>(); public static List<SkillDef> skillDefs = new List<SkillDef>(); public static List<Type> entityStates = new List<Type>(); public static List<BuffDef> buffDefs = new List<BuffDef>(); public static List<EffectDef> effectDefs = new List<EffectDef>(); public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>(); public string identifier => "com.CeoOfSwag.Mediator"; public void Initialize() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.identifier = identifier; contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray()); contentPack.masterPrefabs.Add(masterPrefabs.ToArray()); contentPack.survivorDefs.Add(survivorDefs.ToArray()); contentPack.unlockableDefs.Add(unlockableDefs.ToArray()); contentPack.skillDefs.Add(skillDefs.ToArray()); contentPack.skillFamilies.Add(skillFamilies.ToArray()); contentPack.entityStateTypes.Add(entityStates.ToArray()); contentPack.buffDefs.Add(buffDefs.ToArray()); contentPack.effectDefs.Add(effectDefs.ToArray()); contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } internal static class ItemDisplayCheck { public static List<Object> allDisplayedItems; public static void PrintUnused(ItemDisplayRuleSet itemDisplayRuleSet, string bodyName = "") { PrintUnused((IEnumerable<KeyAssetRuleGroup>)itemDisplayRuleSet.keyAssetRuleGroups.ToList(), bodyName); } public static void PrintUnused(IEnumerable<KeyAssetRuleGroup> ruleSet = null, string bodyName = "") { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) string text = "generating item displays for " + bodyName; if (allDisplayedItems == null) { LazyGatherAllItems(); } List<Object> list = new List<Object>(allDisplayedItems); string text2 = ""; if (ruleSet != null) { foreach (KeyAssetRuleGroup item in ruleSet) { if (item.displayRuleGroup.rules.Length != 0) { list.Remove(item.keyAsset); if (string.IsNullOrEmpty(text2)) { text2 = item.displayRuleGroup.rules[0].childName; } } } } if (string.IsNullOrEmpty(text2)) { text2 = "Chest"; } foreach (Object item2 in list) { string text3 = ""; if (ItemDisplays.KeyAssetDisplayPrefabs.ContainsKey(item2)) { text3 += SpitOutNewRule(item2, text2, ItemDisplays.KeyAssetDisplayPrefabs[item2]); } else { Log.Error($"COULD NOT FIND DISPLAY PREFABS FOR KEYASSET {item2}"); } text += text3; } Log.Message(text); } private static void LazyGatherAllItems() { allDisplayedItems = new List<Object>(ItemDisplays.KeyAssetDisplayPrefabs.Keys); allDisplayedItems.Sort(delegate(Object item1, Object item2) { if (item1 is ItemDef && item2 is ItemDef) { return item1.name.CompareTo(item2.name); } if (item1 is EquipmentDef && item2 is EquipmentDef) { return item1.name.CompareTo(item2.name); } if (item1 is ItemDef && item2 is EquipmentDef) { return -1; } return (item1 is EquipmentDef && item2 is ItemDef) ? 1 : 0; }); } private static string SpitOutNewRule(Object asset, string firstCompatibleChild, ItemDisplayRule[] displayRules) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (displayRules.Length == 0) { return $"\n[NO DISPLAY RULES FOUND FOR THE KEYASSET {asset}"; } string text = "\n itemDisplayRules.Add(ItemDisplays.CreateDisplayRuleGroupWithRules(ItemDisplays.KeyAssets[\"" + asset.name + "\"]"; for (int i = 0; i < displayRules.Length; i++) { text = (((int)displayRules[i].limbMask != 0) ? (text + ",\n" + $" ItemDisplays.CreateLimbMaskDisplayRule(LimbFlags.{displayRules[i].limbMask})") : (text + ",\n ItemDisplays.CreateDisplayRule(ItemDisplays.LoadDisplay(\"" + ((Object)displayRules[i].followerPrefab).name + "\"),\n \"" + firstCompatibleChild + "\",\n new Vector3(2, 2, 2),\n new Vector3(0, 0, 0),\n new Vector3(1, 1, 1)\n )")); } return text + "\n ));"; } } internal static class ItemDisplays { private static Dictionary<string, GameObject> itemDisplayPrefabs = new Dictionary<string, GameObject>(); public static Dictionary<Object, ItemDisplayRule[]> KeyAssetDisplayPrefabs = new Dictionary<Object, ItemDisplayRule[]>(); public static Dictionary<string, Object> KeyAssets = new Dictionary<string, Object>(); public static int queuedDisplays; public static bool initialized = false; public static void LazyInit() { if (!initialized) { initialized = true; PopulateDisplays(); } } internal static void DisposeWhenDone() { queuedDisplays--; if (queuedDisplays <= 0 && initialized) { initialized = false; itemDisplayPrefabs = null; KeyAssetDisplayPrefabs = null; KeyAssets = null; } } internal static void PopulateDisplays() { PopulateFromBody("LoaderBody"); } private static void PopulateFromBody(string bodyName) { ItemDisplayRuleSet itemDisplayRuleSet = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/" + bodyName).GetComponent<ModelLocator>().modelTransform).GetComponent<CharacterModel>().itemDisplayRuleSet; KeyAssetRuleGroup[] keyAssetRuleGroups = itemDisplayRuleSet.keyAssetRuleGroups; for (int i = 0; i < keyAssetRuleGroups.Length; i++) { ItemDisplayRule[] rules = keyAssetRuleGroups[i].displayRuleGroup.rules; KeyAssetDisplayPrefabs[keyAssetRuleGroups[i].keyAsset] = rules; KeyAssets[keyAssetRuleGroups[i].keyAsset.name] = keyAssetRuleGroups[i].keyAsset; for (int j = 0; j < rules.Length; j++) { GameObject followerPrefab = rules[j].followerPrefab; if (Object.op_Implicit((Object)(object)followerPrefab)) { string key = ((Object)followerPrefab).name?.ToLowerInvariant(); if (!itemDisplayPrefabs.ContainsKey(key)) { itemDisplayPrefabs[key] = followerPrefab; } } } } } private static void PopulateCustomLightningArm() { GameObject val = PrefabAPI.InstantiateClone(itemDisplayPrefabs["displaylightningarmright"], "DisplayLightningCustom", false); LimbMatcher component = val.GetComponent<LimbMatcher>(); component.limbPairs[0].targetChildLimb = "LightningArm1"; component.limbPairs[1].targetChildLimb = "LightningArm2"; component.limbPairs[2].targetChildLimb = "LightningArmEnd"; itemDisplayPrefabs["displaylightningarmcustom"] = val; } public static GameObject LoadDisplay(string name) { if (itemDisplayPrefabs.ContainsKey(name.ToLowerInvariant()) && Object.op_Implicit((Object)(object)itemDisplayPrefabs[name.ToLowerInvariant()])) { return itemDisplayPrefabs[name.ToLowerInvariant()]; } Log.Error("item display " + name + " returned null"); return null; } public static KeyAssetRuleGroup CreateDisplayRuleGroupWithRules(string itemName, params ItemDisplayRule[] rules) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return CreateDisplayRuleGroupWithRules(GetKeyAssetFromString(itemName), rules); } public static KeyAssetRuleGroup CreateDisplayRuleGroupWithRules(Object keyAsset_, params ItemDisplayRule[] rules) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (keyAsset_ == (Object)null) { Log.Error("could not find keyasset"); } return new KeyAssetRuleGroup { keyAsset = keyAsset_, displayRuleGroup = new DisplayRuleGroup { rules = rules } }; } public static ItemDisplayRule CreateDisplayRule(string prefabName, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return CreateDisplayRule(LoadDisplay(prefabName), childName, position, rotation, scale); } public static ItemDisplayRule CreateDisplayRule(GameObject itemPrefab, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0003: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) return new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, childName = childName, followerPrefab = itemPrefab, limbMask = (LimbFlags)0, localPos = position, localAngles = rotation, localScale = scale }; } public static ItemDisplayRule CreateLimbMaskDisplayRule(LimbFlags limb) { //IL_0003: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) return new ItemDisplayRule { ruleType = (ItemDisplayRuleType)1, limbMask = limb, childName = "", followerPrefab = null }; } private static Object GetKeyAssetFromString(string itemName) { Object val = (Object)(object)LegacyResourcesAPI.Load<ItemDef>("ItemDefs/" + itemName); if (val == (Object)null) { val = (Object)(object)LegacyResourcesAPI.Load<EquipmentDef>("EquipmentDefs/" + itemName); } if (val == (Object)null) { Log.Error("Could not load keyasset for " + itemName); } return val; } } internal static class Language { public static string TokensOutput = ""; public static bool usingLanguageFolder = false; public static bool printingEnabled = false; public static void Init() { if (usingLanguageFolder) { Language.collectLanguageRootFolders += Language_collectLanguageRootFolders; } } private static void Language_collectLanguageRootFolders(List<string> obj) { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)MediatorPlugin.instance).Info.Location), "Language"); if (Directory.Exists(text)) { obj.Add(text); } } public static void Add(string token, string text) { if (!usingLanguageFolder) { LanguageAPI.Add(token, text); } if (printingEnabled) { TokensOutput = TokensOutput + "\n \"" + token + "\" : \"" + text.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n") + "\","; } } public static void PrintOutput(string fileName = "") { if (printingEnabled) { string text = "{\n strings:\n {" + TokensOutput + "\n }\n}"; Log.Message(fileName + ": \n" + text); if (!string.IsNullOrEmpty(fileName)) { string path = Path.Combine(Directory.GetParent(((BaseUnityPlugin)MediatorPlugin.instance).Info.Location).FullName, "Language", "en", fileName); File.WriteAllText(path, text); } TokensOutput = ""; } } } internal static class Materials { private static List<Material> cachedMaterials = new List<Material>(); internal static Shader hotpoo = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/HGStandard"); public static Material LoadMaterial(this AssetBundle assetBundle, string materialName) { return assetBundle.CreateHopooMaterialFromBundle(materialName); } public static Material CreateHopooMaterialFromBundle(this AssetBundle assetBundle, string materialName) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown Material val = cachedMaterials.Find(delegate(Material mat) { materialName.Replace(" (Instance)", ""); return ((Object)mat).name.Contains(materialName); }); if (Object.op_Implicit((Object)(object)val)) { Log.Debug(((Object)val).name + " has already been loaded. returning cached"); return val; } val = assetBundle.LoadAsset<Material>(materialName); if (!Object.op_Implicit((Object)(object)val)) { Log.ErrorAssetBundle(materialName, ((Object)assetBundle).name); return new Material(hotpoo); } return val.ConvertDefaultShaderToHopoo(); } public static Material SetHopooMaterial(this Material tempMat) { return tempMat.ConvertDefaultShaderToHopoo(); } public static Material ConvertDefaultShaderToHopoo(this Material tempMat) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (cachedMaterials.Contains(tempMat)) { Log.Debug(((Object)tempMat).name + " has already been converted. returning cached"); return tempMat; } string text = ((Object)tempMat.shader).name.ToLowerInvariant(); if (!text.StartsWith("standard") && !text.StartsWith("autodesk")) { Log.Debug(((Object)tempMat).name + " is not unity standard shader. aborting material conversion"); return tempMat; } float? num = null; Color? val = null; if (tempMat.IsKeywordEnabled("_NORMALMAP")) { num = tempMat.GetFloat("_BumpScale"); } if (tempMat.IsKeywordEnabled("_EMISSION")) { val = tempMat.GetColor("_EmissionColor"); } tempMat.shader = hotpoo; tempMat.SetTexture("_EmTex", tempMat.GetTexture("_EmissionMap")); tempMat.EnableKeyword("DITHER"); if (num.HasValue) { tempMat.SetFloat("_NormalStrength", num.Value); tempMat.SetTexture("_NormalTex", tempMat.GetTexture("_BumpMap")); } if (val.HasValue) { tempMat.SetColor("_EmColor", val.Value); tempMat.SetFloat("_EmPower", 1f); } if (tempMat.IsKeywordEnabled("NOCULL")) { tempMat.SetInt("_Cull", 0); } if (tempMat.IsKeywordEnabled("LIMBREMOVAL")) { tempMat.SetInt("_LimbRemovalOn", 1); } cachedMaterials.Add(tempMat); return tempMat; } public static Material MakeUnique(this Material material) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (cachedMaterials.Contains(material)) { return new Material(material); } return material; } public static Material SetColor(this Material material, Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) material.SetColor("_Color", color); return material; } public static Material SetNormal(this Material material, float normalStrength = 1f) { material.SetFloat("_NormalStrength", normalStrength); return material; } public static Material SetEmission(this Material material) { return material.SetEmission(1f); } public static Material SetEmission(this Material material, float emission) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return material.SetEmission(emission, Color.white); } public static Material SetEmission(this Material material, float emission, Color emissionColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) material.SetFloat("_EmPower", emission); material.SetColor("_EmColor", emissionColor); return material; } public static Material SetCull(this Material material, bool cull = false) { material.SetInt("_Cull", cull ? 1 : 0); return material; } public static Material SetSpecular(this Material material, float strength) { material.SetFloat("_SpecularStrength", strength); return material; } public static Material SetSpecular(this Material material, float strength, float exponent) { material.SetFloat("_SpecularStrength", strength); material.SetFloat("SpecularExponent", exponent); return material; } } internal static class Prefabs { private static PhysicMaterial ragdollMaterial; public static GameObject CreateDisplayPrefab(AssetBundle assetBundle, string displayPrefabName, GameObject prefab) { GameObject val = assetBundle.LoadAsset<GameObject>(displayPrefabName); if ((Object)(object)val == (Object)null) { Log.Error("could not load display prefab " + displayPrefabName + ". Make sure this prefab exists in assetbundle " + ((Object)assetBundle).name); return null; } CharacterModel val2 = val.GetComponent<CharacterModel>(); if (!Object.op_Implicit((Object)(object)val2)) { val2 = val.AddComponent<CharacterModel>(); } val2.baseRendererInfos = prefab.GetComponentInChildren<CharacterModel>().baseRendererInfos; Asset.ConvertAllRenderersToHopooShader(val); return val; } public static GameObject LoadCharacterModel(AssetBundle assetBundle, string modelName) { GameObject val = assetBundle.LoadAsset<GameObject>(modelName); if ((Object)(object)val == (Object)null) { Log.Error("could not load model prefab " + modelName + ". Make sure this prefab exists in assetbundle " + ((Object)assetBundle).name); return null; } return val; } public static GameObject LoadCharacterBody(AssetBundle assetBundle, string bodyName) { GameObject val = assetBundle.LoadAsset<GameObject>(bodyName); if ((Object)(object)val == (Object)null) { Log.Error("could not load body prefab " + bodyName + ". Make sure this prefab exists in assetbundle " + ((Object)assetBundle).name); return null; } return val; } public static GameObject CloneCharacterBody(BodyInfo bodyInfo) { GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/" + bodyInfo.bodyNameToClone + "Body"); if (!Object.op_Implicit((Object)(object)val)) { Log.Error(bodyInfo.bodyNameToClone + " Body to clone is not a valid body, character creation failed"); return null; } GameObject val2 = PrefabAPI.InstantiateClone(val, bodyInfo.bodyName); for (int num = val2.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val2.transform.GetChild(num)).gameObject); } return val2; } public static GameObject CreateBodyPrefab(AssetBundle assetBundle, string modelPrefabName, BodyInfo bodyInfo) { return CreateBodyPrefab(LoadCharacterModel(assetBundle, modelPrefabName), bodyInfo); } public static GameObject CreateBodyPrefab(GameObject model, BodyInfo bodyInfo) { return CreateBodyPrefab(CloneCharacterBody(bodyInfo), model, bodyInfo); } public static GameObject CreateBodyPrefab(GameObject newBodyPrefab, AssetBundle assetBundle, string modelName, BodyInfo bodyInfo) { return CreateBodyPrefab(newBodyPrefab, LoadCharacterModel(assetBundle, modelName), bodyInfo); } public static GameObject CreateBodyPrefab(AssetBundle assetBundle, string bodyPrefabName, string modelPrefabName, BodyInfo bodyInfo) { return CreateBodyPrefab(LoadCharacterBody(assetBundle, bodyPrefabName), LoadCharacterModel(assetBundle, modelPrefabName), bodyInfo); } public static GameObject CreateBodyPrefab(GameObject newBodyPrefab, GameObject model, BodyInfo bodyInfo) { if ((Object)(object)model == (Object)null || (Object)(object)newBodyPrefab == (Object)null) { Log.Error($"Character creation failed. Model: {model}, Body: {newBodyPrefab}"); return null; } SetupCharacterBody(newBodyPrefab, bodyInfo); Transform modelBaseTransform = AddCharacterModelToSurvivorBody(newBodyPrefab, model.transform, bodyInfo); SetupModelLocator(newBodyPrefab, modelBaseTransform, model.transform); SetupCharacterDirection(newBodyPrefab, modelBaseTransform, model.transform); SetupCameraTargetParams(newBodyPrefab, bodyInfo); SetupCapsuleCollider(newBodyPrefab); Content.AddCharacterBodyPrefab(newBodyPrefab); return newBodyPrefab; } private static void SetupCharacterBody(GameObject newBodyPrefab, BodyInfo bodyInfo) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = newBodyPrefab.GetComponent<CharacterBody>(); component.baseNameToken = bodyInfo.bodyNameToken; component.subtitleNameToken = bodyInfo.subtitleNameToken; component.portraitIcon = bodyInfo.characterPortrait; component.bodyColor = bodyInfo.bodyColor; component._defaultCrosshairPrefab = bodyInfo.crosshair; component.hideCrosshair = false; component.preferredPodPrefab = bodyInfo.podPrefab; component.baseMaxHealth = bodyInfo.maxHealth; component.baseRegen = bodyInfo.healthRegen; component.baseArmor = bodyInfo.armor; component.baseMaxShield = bodyInfo.shield; component.baseDamage = bodyInfo.damage; component.baseAttackSpeed = bodyInfo.attackSpeed; component.baseCrit = bodyInfo.crit; component.baseMoveSpeed = bodyInfo.moveSpeed; component.baseJumpPower = bodyInfo.jumpPower; component.autoCalculateLevelStats = bodyInfo.autoCalculateLevelStats; if (bodyInfo.autoCalculateLevelStats) { component.levelMaxHealth = Mathf.Round(component.baseMaxHealth * 0.3f); component.levelMaxShield = Mathf.Round(component.baseMaxShield * 0.3f); component.levelRegen = component.baseRegen * 0.2f; component.levelMoveSpeed = 0f; component.levelJumpPower = 0f; component.levelDamage = component.baseDamage * 0.2f; component.levelAttackSpeed = 0f; component.levelCrit = 0f; component.levelArmor = 0f; } else { component.levelMaxHealth = bodyInfo.healthGrowth; component.levelMaxShield = bodyInfo.shieldGrowth; component.levelRegen = bodyInfo.regenGrowth; component.levelMoveSpeed = bodyInfo.moveSpeedGrowth; component.levelJumpPower = bodyInfo.jumpPowerGrowth; component.levelDamage = bodyInfo.damageGrowth; component.levelAttackSpeed = bodyInfo.attackSpeedGrowth; component.levelCrit = bodyInfo.critGrowth; component.levelArmor = bodyInfo.armorGrowth; } component.baseAcceleration = bodyInfo.acceleration; component.baseJumpCount = bodyInfo.jumpCount; component.sprintingSpeedMultiplier = 1.45f; component.bodyFlags = (BodyFlags)16; component.rootMotionInMainState = false; component.hullClassification = (HullClassification)0; component.isChampion = false; } private static Transform AddCharacterModelToSurvivorBody(GameObject bodyPrefab, Transform modelTransform, BodyInfo bodyInfo) { //IL_0063: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00b8: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) Transform val = bodyPrefab.transform.Find("ModelBase"); if ((Object)(object)val == (Object)null) { val = new GameObject("ModelBase").transform; val.parent = bodyPrefab.transform; val.localPosition = bodyInfo.modelBasePosition; val.localRotation = Quaternion.identity; } modelTransform.parent = ((Component)val).transform; modelTransform.localPosition = Vector3.zero; modelTransform.localRotation = Quaternion.identity; Transform val2 = bodyPrefab.transform.Find("CameraPivot"); if ((Object)(object)val2 == (Object)null) { val2 = new GameObject("CameraPivot").transform; val2.parent = bodyPrefab.transform; val2.localPosition = bodyInfo.cameraPivotPosition; val2.localRotation = Quaternion.identity; } Transform val3 = bodyPrefab.transform.Find("AimOrigin"); if ((Object)(object)val3 == (Object)null) { val3 = new GameObject("AimOrigin").transform; val3.parent = bodyPrefab.transform; val3.localPosition = bodyInfo.aimOriginPosition; val3.localRotation = Quaternion.identity; } bodyPrefab.GetComponent<CharacterBody>().aimOriginTransform = val3; return ((Component)val).transform; } private static void SetupCharacterDirection(GameObject prefab, Transform modelBaseTransform, Transform modelTransform) { if (Object.op_Implicit((Object)(object)prefab.GetComponent<CharacterDirection>())) { CharacterDirection component = prefab.GetComponent<CharacterDirection>(); component.targetTransform = modelBaseTransform; component.overrideAnimatorForwardTransform = null; component.rootMotionAccumulator = null; component.modelAnimator = ((Component)modelTransform).GetComponent<Animator>(); component.driveFromRootRotation = false; component.turnSpeed = 720f; } } private static void SetupCameraTargetParams(GameObject prefab, BodyInfo bodyInfo) { CameraTargetParams component = prefab.GetComponent<CameraTargetParams>(); component.cameraParams = bodyInfo.cameraParams; component.cameraPivotTransform = prefab.transform.Find("CameraPivot"); } private static void SetupModelLocator(GameObject prefab, Transform modelBaseTransform, Transform modelTransform) { ModelLocator component = prefab.GetComponent<ModelLocator>(); component.modelTransform = modelTransform; component.modelBaseTransform = modelBaseTransform; } private static void SetupCapsuleCollider(GameObject prefab) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) CapsuleCollider component = prefab.GetComponent<CapsuleCollider>(); component.center = new Vector3(0f, 0f, 0f); component.radius = 0.5f; component.height = 1.82f; component.direction = 1; } public static CharacterModel SetupCharacterModel(GameObject bodyPrefab, CustomRendererInfo[] customInfos = null) { CharacterModel val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.GetComponent<CharacterModel>(); bool flag = (Object)(object)val != (Object)null; if (!flag) { val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.AddComponent<CharacterModel>(); } val.body = bodyPrefab.GetComponent<CharacterBody>(); val.autoPopulateLightInfos = true; val.invisibilityCount = 0; val.temporaryOverlays = new List<TemporaryOverlayInstance>(); if (!flag) { SetupCustomRendererInfos(val, customInfos); } else { SetupPreAttachedRendererInfos(val); } SetupHurtboxGroup(bodyPrefab, ((Component)val).gameObject); SetupAimAnimator(bodyPrefab, ((Component)val).gameObject); SetupFootstepController(((Component)val).gameObject); SetupRagdoll(((Component)val).gameObject); return val; } public static void SetupPreAttachedRendererInfos(CharacterModel characterModel) { for (int i = 0; i < characterModel.baseRendererInfos.Length; i++) { if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null) { characterModel.baseRendererInfos[i].defaultMaterial = characterModel.baseRendererInfos[i].renderer.sharedMaterial; } if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null) { Log.Error($"no material for rendererinfo of this renderer: {characterModel.baseRendererInfos[i].renderer}"); } characterModel.baseRendererInfos[i].defaultMaterial.ConvertDefaultShaderToHopoo(); } } public static void SetupCustomRendererInfos(CharacterModel characterModel, CustomRendererInfo[] customInfos) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) ChildLocator component = ((Component)characterModel).GetComponent<ChildLocator>(); if (!Object.op_Implicit((Object)(object)component)) { Log.Error("Failed CharacterModel setup: ChildLocator component does not exist on the model"); return; } List<RendererInfo> list = new List<RendererInfo>(); for (int i = 0; i < customInfos.Length; i++) { if (!Object.op_Implicit((Object)(object)component.FindChild(customInfos[i].childName))) { Log.Error("Trying to add a RendererInfo for a renderer that does not exist: " + customInfos[i].childName); continue; } Renderer component2 = ((Component)component.FindChild(customInfos[i].childName)).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component2)) { Material val = customInfos[i].material; if ((Object)(object)val == (Object)null) { val = ((!customInfos[i].dontHotpoo) ? component2.sharedMaterial.ConvertDefaultShaderToHopoo() : component2.sharedMaterial); } list.Add(new RendererInfo { renderer = component2, defaultMaterial = val, ignoreOverlays = customInfos[i].ignoreOverlays, defaultShadowCastingMode = (ShadowCastingMode)1 }); } } characterModel.baseRendererInfos = list.ToArray(); } private static void SetupHurtboxGroup(GameObject bodyPrefab, GameObject model) { SetupMainHurtboxesFromChildLocator(bodyPrefab, model); SetHurtboxesHealthComponents(bodyPrefab); } private static void SetupMainHurtboxesFromChildLocator(GameObject bodyPrefab, GameObject model) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bodyPrefab.GetComponent<HurtBoxGroup>() != (Object)null) { Log.Debug("Hitboxgroup already exists on model prefab. aborting code setup"); return; } ChildLocator component = model.GetComponent<ChildLocator>(); if (string.IsNullOrEmpty(component.FindChildNameInsensitive("MainHurtbox"))) { Log.Error("Could not set up main hurtbox: make sure you have a transform pair in your prefab's ChildLocator called 'MainHurtbox'"); return; } HurtBoxGroup val = model.AddComponent<HurtBoxGroup>(); HurtBox val2 = null; GameObject val3 = component.FindChildGameObjectInsensitive("HeadHurtbox"); if (Object.op_Implicit((Object)(object)val3)) { Log.Debug("HeadHurtboxFound. Setting up"); val2 = val3.AddComponent<HurtBox>(); ((Component)val2).gameObject.layer = LayerIndex.entityPrecise.intVal; val2.healthComponent = bodyPrefab.GetComponent<HealthComponent>(); val2.isBullseye = false; val2.isSniperTarget = true; val2.damageModifier = (DamageModifier)0; val2.hurtBoxGroup = val; val2.indexInGroup = 1; } HurtBox val4 = component.FindChildGameObjectInsensitive("MainHurtbox").AddComponent<HurtBox>(); ((Component)val4).gameObject.layer = LayerIndex.entityPrecise.intVal; val4.healthComponent = bodyPrefab.GetComponent<HealthComponent>(); val4.isBullseye = true; val4.isSniperTarget = (Object)(object)val2 == (Object)null; val4.damageModifier = (DamageModifier)0; val4.hurtBoxGroup = val; val4.indexInGroup = 0; if (Object.op_Implicit((Object)(object)val2)) { val.hurtBoxes = (HurtBox[])(object)new HurtBox[2] { val4, val2 }; } else { val.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val4 }; } val.mainHurtBox = val4; val.bullseyeCount = 1; } private static string FindChildNameInsensitive(this ChildLocator childLocator, string child) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return childLocator.transformPairs.Where((NameTransformPair pair) => pair.name.ToLowerInvariant() == child.ToLowerInvariant()).FirstOrDefault().name; } private static Transform FindChildInsensitive(this ChildLocator childLocator, string child) { return childLocator.FindChild(childLocator.FindChildNameInsensitive(child)); } private static GameObject FindChildGameObjectInsensitive(this ChildLocator childLocator, string child) { return childLocator.FindChildGameObject(childLocator.FindChildNameInsensitive(child)); } public static void SetHurtboxesHealthComponents(GameObject bodyPrefab) { HealthComponent component = bodyPrefab.GetComponent<HealthComponent>(); HurtBoxGroup[] componentsInChildren = bodyPrefab.GetComponentsInChildren<HurtBoxGroup>(); foreach (HurtBoxGroup val in componentsInChildren) { val.mainHurtBox.healthComponent = component; for (int j = 0; j < val.hurtBoxes.Length; j++) { val.hurtBoxes[j].healthComponent = component; } } } private static void SetupFootstepController(GameObject model) { FootstepHandler val = model.AddComponent<FootstepHandler>(); val.baseFootstepString = "Play_player_footstep"; val.sprintFootstepOverrideString = ""; val.enableFootstepDust = true; val.footstepDustPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/GenericFootstepDust"); } private static void SetupRagdoll(GameObject model) { RagdollController component = model.GetComponent<RagdollController>(); if (!Object.op_Implicit((Object)(object)component)) { return; } if ((Object)(object)ragdollMaterial == (Object)null) { ragdollMaterial = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<RagdollController>().bones[1]).GetComponent<Collider>().material; } Transform[] bones = component.bones; foreach (Transform val in bones) { if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.layer = LayerIndex.ragdoll.intVal; Collider component2 = ((Component)val).GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component2)) { component2.sharedMaterial = ragdollMaterial; } else { Log.Error($"Ragdoll bone {((Component)val).gameObject} doesn't have a collider. Ragdoll will break."); } } } } private static void SetupAimAnimator(GameObject prefab, GameObject model) { AimAnimator val = model.AddComponent<AimAnimator>(); val.directionComponent = prefab.GetComponent<CharacterDirection>(); val.pitchRangeMax = 60f; val.pitchRangeMin = -60f; val.yawRangeMin = -80f; val.yawRangeMax = 80f; val.pitchGiveupRange = 30f; val.yawGiveupRange = 10f; val.giveupDuration = 3f; val.inputBank = prefab.GetComponent<InputBankTest>(); } public static void CreateGenericDoppelganger(GameObject bodyPrefab, string masterName, string masterToCopy) { CloneDopplegangerMaster(bodyPrefab, masterName, masterToCopy); } public static GameObject CloneDopplegangerMaster(GameObject bodyPrefab, string masterName, string masterToCopy) { GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/" + masterToCopy + "MonsterMaster"), masterName, true); val.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab; Content.AddMasterPrefab(val); return val; } public static GameObject CreateBlankMasterPrefab(GameObject bodyPrefab, string masterName) { GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), masterName, true); ContentPacks.masterPrefabs.Add(val); CharacterMaster component = val.GetComponent<CharacterMaster>(); component.bodyPrefab = bodyPrefab; AISkillDriver[] components = val.GetComponents<AISkillDriver>(); for (int i = 0; i < components.Length; i++) { Object.Destroy((Object)(object)components[i]); } return val; } public static GameObject LoadMaster(this AssetBundle assetBundle, GameObject bodyPrefab, string assetName) { //IL_0047: 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) GameObject val = assetBundle.LoadAsset<GameObject>(assetName); BaseAI val2 = val.GetComponent<BaseAI>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<BaseAI>(); val2.aimVectorDampTime = 0.1f; val2.aimVectorMaxSpeed = 360f; } val2.scanState = new SerializableEntityStateType(typeof(Wander)); EntityStateMachine component = val.GetComponent<EntityStateMachine>(); if ((Object)(object)component == (Object)null) { AddEntityStateMachine(val, "AI", typeof(Wander), typeof(Wander)); } val2.stateMachine = component; CharacterMaster val3 = val.GetComponent<CharacterMaster>(); if ((Object)(object)val3 == (Object)null) { val3 = val.AddComponent<CharacterMaster>(); } val3.bodyPrefab = bodyPrefab; val3.teamIndex = (TeamIndex)2; Content.AddMasterPrefab(val); return val; } public static void ClearEntityStateMachines(GameObject bodyPrefab) { EntityStateMachine[] components = bodyPrefab.GetComponents<EntityStateMachine>(); for (int num = components.Length - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)components[num]); } NetworkStateMachine component = bodyPrefab.GetComponent<NetworkStateMachine>(); component.stateMachines = Array.Empty<EntityStateMachine>(); CharacterDeathBehavior component2 = bodyPrefab.GetComponent<CharacterDeathBehavior>(); if (Object.op_Implicit((Object)(object)component2)) { component2.idleStateMachine = Array.Empty<EntityStateMachine>(); } SetStateOnHurt component3 = bodyPrefab.GetComponent<SetStateOnHurt>(); if (Object.op_Implicit((Object)(object)component3)) { component3.idleStateMachine = Array.Empty<EntityStateMachine>(); } CharacterBody component4 = bodyPrefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component4)) { component4.vehicleIdleStateMachine = Array.Empty<EntityStateMachine>(); } } public static EntityStateMachine AddEntityStateMachine(GameObject prefab, string machineName, Type mainStateType = null, Type initalStateType = null, bool addToHurt = true, bool addToDeath = true) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) EntityStateMachine val = EntityStateMachine.FindByCustomName(prefab, machineName); if ((Object)(object)val == (Object)null) { val = prefab.AddComponent<EntityStateMachine>(); } else { Log.Message("An Entity State Machine already exists with the name " + machineName + ". replacing."); } val.customName = machineName; if (mainStateType == null) { mainStateType = typeof(Idle); } val.mainStateType = new SerializableEntityStateType(mainStateType); if (initalStateType == null) { initalStateType = typeof(Idle); } val.initialStateType = new SerializableEntityStateType(initalStateType); NetworkStateMachine component = prefab.GetComponent<NetworkStateMachine>(); if (Object.op_Implicit((Object)(object)component)) { component.stateMachines = component.stateMachines.Append(val).ToArray(); } CharacterDeathBehavior component2 = prefab.GetComponent<CharacterDeathBehavior>(); if (Object.op_Implicit((Object)(object)component2) && addToDeath) { component2.idleStateMachine = component2.idleStateMachine.Append(val).ToArray(); } SetStateOnHurt component3 = prefab.GetComponent<SetStateOnHurt>(); if (Object.op_Implicit((Object)(object)component3) && addToHurt) { component3.idleStateMachine = component3.idleStateMachine.Append(val).ToArray(); } CharacterBody component4 = prefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component4)) { component4.vehicleIdleStateMachine = component4.vehicleIdleStateMachine.Append(val).ToArray(); } return val; } public static EntityStateMachine AddMainEntityStateMachine(GameObject bodyPrefab, string machineName = "Body", Type mainStateType = null, Type initalStateType = null) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) EntityStateMachine val = EntityStateMachine.FindByCustomName(bodyPrefab, machineName); if ((Object)(object)val == (Object)null) { val = bodyPrefab.AddComponent<EntityStateMachine>(); } else { Log.Message("An Entity State Machine already exists with the name " + machineName + ". replacing."); } val.customName = machineName; if (mainStateType == null) { mainStateType = typeof(GenericCharacterMain); } val.mainStateType = new SerializableEntityStateType(mainStateType); if (initalStateType == null) { initalStateType = typeof(SpawnTeleporterState); } val.initialStateType = new SerializableEntityStateType(initalStateType); NetworkStateMachine component = bodyPrefab.GetComponent<NetworkStateMachine>(); if (Object.op_Implicit((Object)(object)component)) { component.stateMachines = component.stateMachines.Append(val).ToArray(); } CharacterDeathBehavior component2 = bodyPrefab.GetComponent<CharacterDeathBehavior>(); if (Object.op_Implicit((Object)(object)component2)) { component2.deathStateMachine = val; } SetStateOnHurt component3 = bodyPrefab.GetComponent<SetStateOnHurt>(); if (Object.op_Implicit((Object)(object)component3)) { component3.targetStateMachine = val; } return val; } public static void SetupHitBoxGroup(GameObject modelPrefab, string hitBoxGroupName, params string[] hitboxChildNames) { ChildLocator component = modelPrefab.GetComponent<ChildLocator>(); Transform[] array = (Transform[])(object)new Transform[hitboxChildNames.Length]; for (int i = 0; i < hitboxChildNames.Length; i++) { array[i] = component.FindChild(hitboxChildNames[i]); if ((Object)(object)array[i] == (Object)null) { Log.Error("missing hitbox for " + hitboxChildNames[i]); } } SetupHitBoxGroup(modelPrefab, hitBoxGroupName, array); } public static void SetupHitBoxGroup(GameObject prefab, string hitBoxGroupName, params Transform[] hitBoxTransforms) { List<HitBox> list = new List<HitBox>(); foreach (Transform val in hitBoxTransforms) { if ((Object)(object)val == (Object)null) { Log.Error("Error setting up hitboxGroup for " + hitBoxGroupName + ": hitbox transform was null"); continue; } HitBox item = ((Component)val).gameObject.AddComponent<HitBox>(); ((Component)val).gameObject.layer = LayerIndex.projectile.intVal; list.Add(item); } if (list.Count == 0) { Log.Error("No hitboxes were set up. aborting setting up hitboxGroup for " + hitBoxGroupName); return; } HitBoxGroup val2 = prefab.AddComponent<HitBoxGroup>(); val2.hitBoxes = list.ToArray(); val2.groupName = hitBoxGroupName; } } public class CustomRendererInfo { public string childName; public Material material = null; public bool dontHotpoo = false; public bool ignoreOverlays = false; } internal static class Skills { public static void CreateSkillFamilies(GameObject targetPrefab) { SkillSlot[] array = new SkillSlot[4]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); CreateSkillFamilies(targetPrefab, (SkillSlot[])(object)array); } public static void CreateSkillFamilies(GameObject targetPrefab, params SkillSlot[] slots) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown SkillLocator component = targetPrefab.GetComponent<SkillLocator>(); foreach (SkillSlot val in slots) { SkillSlot val2 = val; switch (val2 - -1) { case 1: component.primary = CreateGenericSkillWithSkillFamily(targetPrefab, "Primary"); break; case 2: component.secondary = CreateGenericSkillWithSkillFamily(targetPrefab, "Secondary"); break; case 3: component.utility = CreateGenericSkillWithSkillFamily(targetPrefab, "Utility"); break; case 4: component.special = CreateGenericSkillWithSkillFamily(targetPrefab, "Special"); break; } } } public static void ClearGenericSkills(GameObject targetPrefab) { GenericSkill[] componentsInChildren = targetPrefab.GetComponentsInChildren<GenericSkill>(); foreach (GenericSkill val in componentsInChildren) { Object.DestroyImmediate((Object)(object)val); } } public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, SkillSlot skillSlot, bool hidden = false) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected I4, but got Unknown SkillLocator component = targetPrefab.GetComponent<SkillLocator>(); switch (skillSlot - -1) { case 1: return component.primary = CreateGenericSkillWithSkillFamily(targetPrefab, "Primary", hidden); case 2: return component.secondary = CreateGenericSkillWithSkillFamily(targetPrefab, "Secondary", hidden); case 3: return component.utility = CreateGenericSkillWithSkillFamily(targetPrefab, "Utility", hidden); case 4: return component.special = CreateGenericSkillWithSkillFamily(targetPrefab, "Special", hidden); case 0: Log.Error("Failed to create GenericSkill with skillslot None. If making a GenericSkill outside of the main 4, specify a familyName, and optionally a genericSkillName"); return null; default: return null; } } public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, string familyName, bool hidden = false) { return CreateGenericSkillWithSkillFamily(targetPrefab, familyName, familyName, hidden); } public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, string genericSkillName, string familyName, bool hidden = false) { GenericSkill val = targetPrefab.AddComponent<GenericSkill>(); val.skillName = genericSkillName; val.hideInCharacterSelect = hidden; SkillFamily val2 = ScriptableObject.CreateInstance<SkillFamily>(); ((Object)val2).name = ((Object)targetPrefab).name + familyName + "Family"; val2.variants = (Variant[])(object)new Variant[0]; val._skillFamily = val2; Content.AddSkillFamily(val2); return val; } public static void AddSkillToFamily(SkillFamily skillFamily, SkillDef skillDef, UnlockableDef unlockableDef = null) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0054: 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) Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1); Variant[] variants = skillFamily.variants; int num = skillFamily.variants.Length - 1; Variant val = new Variant { skillDef = skillDef, unlockableDef = unlockableDef }; ((Variant)(ref val)).viewableNode = new Node(skillDef.skillNameToken, false, (Node)null); variants[num] = val; } public static void AddSkillsToFamily(SkillFamily skillFamily, params SkillDef[] skillDefs) { foreach (SkillDef skillDef in skillDefs) { AddSkillToFamily(skillFamily, skillDef); } } public static void AddPrimarySkills(GameObject targetPrefab, params SkillDef[] skillDefs) { AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().primary.skillFamily, skillDefs); } public static void AddSecondarySkills(GameObject targetPrefab, params SkillDef[] skillDefs) { AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().secondary.skillFamily, skillDefs); } public static void AddUtilitySkills(GameObject targetPrefab, params SkillDef[] skillDefs) { AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().utility.skillFamily, skillDefs); } public static void AddSpecialSkills(GameObject targetPrefab, params SkillDef[] skillDefs) { AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().special.skillFamily, skillDefs); } public static void AddUnlockablesToFamily(SkillFamily skillFamily, params UnlockableDef[] unlockableDefs) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < unlockableDefs.Length; i++) { Variant val = skillFamily.variants[i]; val.unlockableDef = unlockableDefs[i]; skillFamily.variants[i] = val; } } public static SkillDef CreateSkillDef(SkillDefInfo skillDefInfo) { return Skills.CreateSkillDef<SkillDef>(skillDefInfo); } public static T CreateSkillDef<T>(SkillDefInfo skillDefInfo) where T : SkillDef { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) T val = ScriptableObject.CreateInstance<T>(); ((SkillDef)val).skillName = skillDefInfo.skillName; ((Object)(object)val).name = skillDefInfo.skillName; ((SkillDef)val).skillNameToken = skillDefInfo.skillNameToken; ((SkillDef)val).skillDescriptionToken = skillDefInfo.skillDescriptionToken; ((SkillDef)val).icon = skillDefInfo.skillIcon; ((SkillDef)val).activationState = skillDefInfo.activationState; ((SkillDef)val).activationStateMachineName = skillDefInfo.activationStateMachineName; ((SkillDef)val).interruptPriority = skillDefInfo.interruptPriority; ((SkillDef)val).baseMaxStock = skillDefInfo.baseMaxStock; ((SkillDef)val).baseRechargeInterval = skillDefInfo.baseRechargeInterval; ((SkillDef)val).rechargeStock = skillDefInfo.rechargeStock; ((SkillDef)val).requiredStock = skillDefInfo.requiredStock; ((SkillDef)val).stockToConsume = skillDefInfo.stockToConsume; ((SkillDef)val).dontAllowPastMaxStocks = skillDefInfo.dontAllowPastMaxStocks; ((SkillDef)val).beginSkillCooldownOnSkillEnd = skillDefInfo.beginSkillCooldownOnSkillEnd; ((SkillDef)val).canceledFromSprinting = skillDefInfo.canceledFromSprinting; ((SkillDef)val).forceSprintDuringState = skillDefInfo.forceSprintDuringState; ((SkillDef)val).fullRestockOnAssign = skillDefInfo.fullRestockOnAssign; ((SkillDef)val).resetCooldownTimerOnUse = skillDefInfo.resetCooldownTimerOnUse; ((SkillDef)val).isCombatSkill = skillDefInfo.isCombatSkill; ((SkillDef)val).mustKeyPress = skillDefInfo.mustKeyPress; ((SkillDef)val).cancelSprintingOnActivation = skillDefInfo.cancelSprintingOnActivation; ((SkillDef)val).keywordTokens = skillDefInfo.keywordTokens; Content.AddSkillDef((SkillDef)(object)val); return val; } } internal class SkillDefInfo { public string skillName; public string skillNameToken; public string skillDescriptionToken; public string[] keywordTokens = Array.Empty<string>(); public Sprite skillIcon; public SerializableEntityStateType activationState; public string activationStateMachineName; public InterruptPriority interruptPriority; public float baseRechargeInterval; public int baseMaxStock = 1; public int rechargeStock = 1; public int requiredStock = 1; public int stockToConsume = 1; public bool resetCooldownTimerOnUse = false; public bool fullRestockOnAssign = true; public bool dontAllowPastMaxStocks = false; public bool beginSkillCooldownOnSkillEnd = false; public bool mustKeyPress = false; public bool isCombatSkill = true; public bool canceledFromSprinting = false; public bool cancelSprintingOnActivation = true; public bool forceSprintDuringState = false; public SkillDefInfo() { } public SkillDefInfo(string skillName, string skillNameToken, string skillDescriptionToken, Sprite skillIcon, SerializableEntityStateType activationState, string activationStateMachineName = "Body", bool agile = false) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) this.skillName = skillName; this.skillNameToken = skillNameToken; this.skillDescriptionToken = skillDescriptionToken; this.skillIcon = skillIcon; this.activationState = activationState; this.activationStateMachineName = activationStateMachineName; cancelSprintingOnActivation = !agile; if (agile) { keywordTokens = new string[1] { "KEYWORD_AGILE" }; } interruptPriority = (InterruptPriority)0; isCombatSkill = true; baseRechargeInterval = 0f; requiredStock = 0; stockToConsume = 0; } } internal static class Skins { internal struct SkinDefInfo { internal SkinDef[] BaseSkins; internal Sprite Icon; internal string NameToken; internal UnlockableDef UnlockableDef; internal GameObject RootObject; internal RendererInfo[] RendererInfos; internal MeshReplacement[] MeshReplacements; internal GameObjectActivation[] GameObjectActivations; internal ProjectileGhostReplacement[] ProjectileGhostReplacements; internal MinionSkinReplacement[] MinionSkinReplacements; internal string Name; } internal static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, RendererInfo[] defaultRendererInfos, GameObject root, UnlockableDef unlockableDef = null) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown SkinDefInfo skinDefInfo = new SkinDefInfo { BaseSkins = Array.Empty<SkinDef>(), GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0], Icon = skinIcon, MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[0], MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[0], Name = skinName, NameToken = skinName, ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[0], RendererInfos = (RendererInfo[])(object)new RendererInfo[defaultRendererInfos.Length], RootObject = root, UnlockableDef = unlockableDef }; SkinDef.Awake += new hook_Awake(DoNothing); SkinDef val = ScriptableObject.CreateInstance<SkinDef>(); val.baseSkins = skinDefInfo.BaseSkins; val.icon = skinDefInfo.Icon; val.unlockableDef = skinDefInfo.UnlockableDef; val.rootObject = skinDefInfo.RootObject; defaultRendererInfos.CopyTo(skinDefInfo.RendererInfos, 0); val.rendererInfos = skinDefInfo.RendererInfos; val.gameObjectActivations = skinDefInfo.GameObjectActivations; val.meshReplacements = skinDefInfo.MeshReplacements; val.projectileGhostReplacements = skinDefInfo.ProjectileGhostReplacements; val.minionSkinReplacements = skinDefInfo.MinionSkinReplacements; val.nameToken = skinDefInfo.NameToken; ((Object)val).name = skinDefInfo.Name; SkinDef.Awake -= new hook_Awake(DoNothing); return val; } private static void DoNothing(orig_Awake orig, SkinDef self) { } private static RendererInfo[] getRendererMaterials(RendererInfo[] defaultRenderers, params Material[] materials) { RendererInfo[] array = (RendererInfo[])(object)new RendererInfo[defaultRenderers.Length]; defaultRenderers.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { try { array[i].defaultMaterial = materials[i]; } catch { Log.Error("error adding skin rendererinfo material. make sure you're not passing in too many"); } } return array; } internal static MeshReplacement[] getMeshReplacements(AssetBundle assetBundle, RendererInfo[] defaultRendererInfos, params string[] meshes) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) List<MeshReplacement> list = new List<MeshReplacement>(); for (int i = 0; i < defaultRendererInfos.Length; i++) { if (!string.IsNullOrEmpty(meshes[i])) { list.Add(new MeshReplacement { renderer = defaultRendererInfos[i].renderer, mesh = assetBundle.LoadAsset<Mesh>(meshes[i]) }); } } return list.ToArray(); } } internal static class Tokens { public const string agilePrefix = "<style=cIsUtility>Agile.</style>"; public static string DamageText(string text) { return "<style=cIsDamage>" + text + "</style>"; } public static string DamageValueText(float value) { return $"<style=cIsDamage>{value * 100f}% damage</style>"; } public static string UtilityText(string text) { return "<style=cIsUtility>" + text + "</style>"; } public static string RedText(string text) { return HealthText(text); } public static string HealthText(string text) { return "<style=cIsHealth>" + text + "</style>"; } public static string KeywordText(string keyword, string sub) { return "<style=cKeywordName>" + keyword + "</style><style=cSub>" + sub + "</style>"; } public static string ScepterDescription(string desc) { return "\n<color=#d299ff>SCEPTER: " + desc + "</color>"; } public static string GetAchievementNameToken(string identifier) { return "ACHIEVEMENT_" + identifier.ToUpperInvariant() + "_NAME"; } public static string GetAchievementDescriptionToken(string identifier) { return "ACHIEVEMENT_" + identifier.ToUpperInvariant() + "_DESCRIPTION"; } } } namespace MediatorMod.Modules.Characters { public abstract class CharacterBase<T> where T : CharacterBase<T>, new() { public abstract string assetBundleName { get; } public abstract string bodyName { get; } public abstract string modelPrefabName { get; } public abstract BodyInfo bodyInfo { get; } public virtual CustomRendererInfo[] customRendererInfos { get; } public virtual ItemDisplaysBase itemDisplays { get; } public static T instance { get; private set; } public abstract AssetBundle assetBundle { get; protected set; } public abstract GameObject bodyPrefab { get; protected set; } public abstract CharacterBody prefabCharacterBody { get; protected set; } public abstract GameObject characterModelObject { get; protected set; } public abstract CharacterModel prefabCharacterModel { get; protected set; } public virtual void Initialize() { instance = this as T; assetBundle = Asset.LoadAssetBundle(assetBundleName); InitializeCharacter(); } public virtual void InitializeCharacter() { InitializeCharacterBodyPrefab(); InitializeItemDisplays(); } protected virtual void InitializeCharacterBodyPrefab() { characterModelObject = Prefabs.LoadCharacterModel(assetBundle, modelPrefabName); bodyPrefab = Prefabs.CreateBodyPrefab(characterModelObject, bodyInfo); prefabCharacterBody = bodyPrefab.GetComponent<CharacterBody>(); prefabCharacterModel = Prefabs.SetupCharacterModel(bodyPrefab, customRendererInfos); } public virtual void InitializeItemDisplays() { ItemDisplayRuleSet val = ScriptableObject.CreateInstance<ItemDisplayRuleSet>(); ((Object)val).name = "idrs" + bodyName; prefabCharacterModel.itemDisplayRuleSet = val; if (itemDisplays != null) { ItemDisplays.queuedDisplays++; ContentManager.onContentPacksAssigned += SetItemDisplays; } } public void SetItemDisplays(ReadOnlyArray<ReadOnlyContentPack> obj) { itemDisplays.SetItemDisplays(prefabCharacterModel.itemDisplayRuleSet); } public abstract void InitializeEntityStateMachines(); public abstract void InitializeSkills(); public abstract void InitializeSkins(); public abstract void InitializeCharacterMaster(); } public class BodyInfo { public string bodyName = ""; public string bodyNameToken = ""; public string subtitleNameToken = ""; public string bodyNameToClone = "Commando"; public Color bodyColor = Color.white; public Texture characterPortrait = null; public float sortPosition = 100f; public GameObject crosshair = null; public GameObject podPrefab = null; public float maxHealth = 100f; public float healthRegen = 1f; public float armor = 0f; public float shield = 0f; public int jumpCount = 1; public float damage = 12f; public float attackSpeed = 1f; public float crit = 1f; public float moveSpeed = 7f; public float acceleration = 80f; public float jumpPower = 15f; public bool autoCalculateLevelStats = true; public float healthGrowth = 30.000002f; public float regenGrowth = 0.2f; public float armorGrowth = 0f; public float shieldGrowth = 0f; public float damageGrowth = 2.4f; public float attackSpeedGrowth = 0f; public float critGrowth = 0f; public float moveSpeedGrowth = 0f; public float jumpPowerGrowth = 0f; public Vector3 aimOriginPosition = new Vector3(0f, 1.6f, 0f); public Vector3 modelBasePosition = new Vector3(0f, -0.92f, 0f); public Vector3 cameraPivotPosition = new Vector3(0f, 0.8f, 0f); public float cameraParamsVerticalOffset = 1.37f; public float cameraParamsDepth = -10f; private CharacterCameraParams _cameraParams; public CharacterCameraParams cameraParams { get { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_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) if ((Object)(object)_cameraParams == (Object)null) { _cameraParams = ScriptableObject.CreateInstance<CharacterCameraParams>(); _cameraParams.data.minPitch = BlendableFloat.op_Implicit(-70f); _cameraParams.data.maxPitch = BlendableFloat.op_Implicit(70f); _cameraParams.data.wallCushion = BlendableFloat.op_Implicit(0.1f); _cameraParams.data.pivotVerticalOffset = BlendableFloat.op_Implicit(cameraParamsVerticalOffset); _cameraParams.data.idealLocalCameraPos = BlendableVector3.op_Implicit(new Vector3(0f, 0f, cameraParamsDepth)); } return _cameraParams; } set { _cameraParams = value; } } } public abstract class ItemDisplaysBase { public void SetItemDisplays(ItemDisplayRuleSet itemDisplayRuleSet) { List<KeyAssetRuleGroup> list = new List<KeyAssetRuleGroup>(); ItemDisplays.LazyInit(); SetItemDisplayRules(list); itemDisplayRuleSet.keyAssetRuleGroups = list.ToArray(); ItemDisplays.DisposeWhenDone(); } protected abstract void SetItemDisplayRules(List<KeyAssetRuleGroup> itemDisplayRules); } public abstract class SurvivorBase<T> : CharacterBase<T> where T : SurvivorBase<T>, new() { public abstract string masterName { get; } public abstract string displayPrefabName { get; } public abstract string survivorTokenPrefix { get; } public abstract UnlockableDef characterUnlockableDef { get; } public abstract GameObject displayPrefab { get; protected set; } public override void InitializeCharacter() { base.InitializeCharacter(); InitializeDisplayPrefab(); InitializeSurvivor(); } protected virtual void InitializeDisplayPrefab() { displayPrefab = Prefabs.CreateDisplayPrefab(assetBundle, displayPrefabName, bodyPrefab); } protected virtual void InitializeSurvivor() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Content.CreateSurvivor(bodyPrefab, displayPrefab, bodyInfo.bodyColor, survivorTokenPrefix, characterUnlockableDef, bodyInfo.sortPosition); } protected virtual void AddCssPreviewSkill(int indexFromEditor, SkillFamily skillFamily, SkillDef skillDef) { CharacterSelectSurvivorPreviewDisplayController component = displayPrefab.GetComponent<CharacterSelectSurvivorPreviewDisplayController>(); if (!Object.op_Implicit((Object)(object)component)) { Log.Error("trying to add skillChangeResponse to null CharacterSelectSurvivorPreviewDisplayController.\nMake sure you created one on your Display prefab in editor"); return; } component.skillChangeResponses[indexFromEditor].triggerSkillFamily = skillFamily; component.skillChangeResponses[indexFromEditor].triggerSkill = skillDef; } protected virtual void AddCssPreviewSkin(int indexFromEditor, SkinDef skinDef) { CharacterSelectSurvivorPreviewDisplayController component = displayPrefab.GetComponent<CharacterSelectSurvivorPreviewDisplayController>(); if (!Object.op_Implicit((Object)(object)component)) { Log.Error("trying to add skinChangeResponse to null CharacterSelectSurvivorPreviewDisplayController.\nMake sure you created one on your Display prefab in editor"); } else { component.skinChangeResponses[indexFromEditor].triggerSkin = skinDef; } } protected virtual void FinalizeCSSPreviewDisplayController() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)displayPrefab)) { return; } CharacterSelectSurvivorPreviewDisplayController component = displayPrefab.GetComponent<CharacterSelectSurvivorPreviewDisplayController>(); if (!Object.op_Implicit((Object)(object)component)) { return; } component.bodyPrefab = bodyPrefab; List<SkillChangeResponse> list = new List<SkillChangeResponse>(); for (int i = 0; i < component.skillChangeResponses.Length; i++) { if ((Object)(object)component.skillChangeResponses[i].triggerSkillFamily != (Object)null) { list.Add(component.skillChangeResponses[i]); } } component.skillChangeResponses = list.ToArray(); } } } namespace MediatorMod.Modules.BaseStates { public abstract class BaseMeleeAttack : BaseSkillState, IStepSetter { public int swingIndex; protected string hitboxGroupName = "SwordGroup"; protected DamageTypeCombo damageType = DamageTypeCombo.op_Implicit((DamageType)0); protected float damageCoefficient = 3.5f; protected float procCoefficient = 1f; protected float pushForce = 300f; protected Vector3 bonusForce = Vector3.zero; protected float baseDuration = 1f; protected float attackStartPercentTime = 0.2f; protected float attackEndPercentTime = 0.4f; protected float earlyExitPercentTime = 0.4f; protected float hitStopDuration = 0.012f; protected float attackRecoil = 0.75f; protected float hitHopVelocity = 4f; protected string swingSoundString = ""; protected string hitSoundString = ""; protected string muzzleString = "SwingCenter"; protected string playbackRateParam = "Slash.playbackRate"; protected GameObject swingEffectPrefab; protected GameObject hitEffectPrefab; protected NetworkSoundEventIndex impactSound = (NetworkSoundEventIndex)(-1); protected OverlapAttack attack; public float duration; public float hitsNum; public bool hasFired; private float hitPauseTimer; protected bool inHitPause; private bool hasHopped; protected float stopwatch; protected Animator animator; private HitStopCachedState hitStopCachedState; private Vector3 storedVelocity; public override void OnEnter() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //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) ((BaseState)this).OnEnter(); duration = baseDuration / ((BaseState)this).attackSpeedStat; animator = ((EntityState)this).GetModelAnimator(); ((BaseState)this).StartAimMode(0.5f + duration, false); PlayAttackAnimation(); attack = new OverlapAttack(); attack.damageType = damageType; attack.attacker = ((EntityState)this).gameObject; attack.inflictor = ((EntityState)this).gameObject; attack.teamIndex = ((BaseState)this).GetTeam(); attack.damage = damageCoefficient * ((BaseState)this).damageStat; attack.procCoefficient = procCoefficient; attack.hitEffectPrefab = hitEffectPrefab; attack.forceVector = bonusForce; attack.pushAwayForce = pushForce; attack.hitBoxGroup = ((BaseState)this).FindHitBoxGroup(hitboxGroupName); attack.isCrit = ((BaseState)this).RollCrit(); attack.impactSound = impactSound; ModifyOverlapAttack(attack); } protected virtual void ModifyOverlapAttack(OverlapAttack attack) { } protected virtual void PlayAttackAnimation() { ((EntityState)this).PlayCrossfade("Gesture, Override", "Slash" + (1 + swingIndex), playbackRateParam, duration, 0.05f); } public override void OnExit() { if (inHitPause) { RemoveHitstop(); } ((EntityState)this).OnExit(); } protected virtual void PlaySwingEffect() { EffectManager.SimpleMuzzleFlash(swingEffectPrefab, ((EntityState)this).gameObject, muzzleString, false); } protected virtual void OnHitEnemyAuthority() { Util.PlaySound(hitSoundString, ((EntityState)this).gameObject); if (!hasHopped) { if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && !((EntityState)this).characterMotor.isGrounded && hitHopVelocity > 0f) { ((BaseState)this).SmallHop(((EntityState)this).characterMotor, hitHopVelocity); } hasHopped = true; } ApplyHitstop(); } protected void ApplyHitstop() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!inHitPause && hitStopDuration > 0f) { storedVelocity = ((EntityState)this).characterMotor.velocity; hitStopCachedState = ((BaseState)this).CreateHitStopCachedState(((EntityState)this).characterMotor, animator, playbackRateParam); hitPauseTimer = hitStopDuration / ((BaseState)this).attackSpeedStat; inHitPause = true; } if (!(hitStopDuration <= 0f)) { } } private void FireAttack() { if (((EntityState)this).isAuthority && attack.Fire((List<HurtBox>)null)) { OnHitEnemyAuthority(); } } private void EnterAttack() { hasFired = true; Util.PlayAttackSpeedSound(swingSoundString, ((EntityState)this).gameObject, ((BaseState)this).attackSpeedStat); PlaySwingEffect(); if (((EntityState)this).isAuthority) { ((BaseState)this).AddRecoil(-1f * attackRecoil, -2f * attackRecoil, -0.5f * attackRecoil, 0.5f * attackRecoil); } } public override void FixedUpdate() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) ((EntityState)this).FixedUpdate(); hitPauseTimer -= Time.deltaTime; if (hitPauseTimer <= 0f && inHitPause) { RemoveHitstop(); if (hitsNum > 0f) { attack.ResetIgnoredHealthComponents(); hitsNum -= 1f; } } if (!inHitPause) { stopwatch += Time.deltaTime; } else { if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor)) { ((EntityState)this).characterMotor.velocity = Vector3.zero; } if (Object.op_Implicit((Object)(object)animator)) { animator.SetFloat(playbackRateParam, 0f); } } bool flag = stopwatch >= duration * attackStartPercentTime; bool flag2 = stopwatch >= duration * attackEndPercentTime; if ((flag && !flag2) || (flag && flag2 && !hasFired)) { if (!hasFired) { EnterAttack(); } FireAttack(); } if (stopwatch >= duration && ((EntityState)this).isAuthority) { ((EntityState)this).outer.SetNextStateToMain(); } } private void RemoveHitstop() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) ((BaseState)this).ConsumeHitStopCachedState(hitStopCachedState, ((EntityState)this).characterMotor, animator); inHitPause = false; ((EntityState)this).characterMotor.velocity = storedVelocity; } public override InterruptPriority GetMinimumInterruptPriority() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (stopwatch >= duration * earlyExitPercentTime) { return (InterruptPriority)0; } return (InterruptPriority)1; } public override void OnSerialize(NetworkWriter writer) { ((BaseSkillState)this).OnSerialize(writer); writer.Write(swingIndex); } public override void OnDeserialize(NetworkReader reader) { ((BaseSkillState)this).OnDeserialize(reader); swingIndex = reader.ReadInt32(); } public void SetStep(int i) { swingIndex = i; } public void ResetAttacks() { attack.ResetIgnoredHealthComponents(); } } public abstract class BaseTimedSkillState : BaseSkillState { protected float duration; protected float castStartTime; protected float castEndTime; protected bool hasFired; protected bool isFiring; protected bool hasExited; public abstract float TimedBaseDuration { get; } public abstract float TimedBaseCastStartPercentTime { get; } public virtual float TimedBaseCastEndPercentTime => 1f; public override void OnEnter() { InitDurationValues(); ((BaseState)this).OnEnter(); } protected virtual void InitDurationValues() { duration = TimedBaseDuration / ((BaseState)this).attackSpeedStat; castStartTime = TimedBaseCastStartPercentTime * duration; castEndTime = TimedBaseCastEndPercentTime * duration; } protected virtual void OnCastEnter() { } protected virtual void OnCastFixedUpdate() { } protected virtual void OnCastUpdate() { } protected virtual void OnCastExit() { } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); bool flag = ((EntityState)this).fixedAge >= castStartTime; bool flag2 = ((EntityState)this).fixedAge >= castEndTime; isFiring = false; if ((flag && !flag2) || (flag && flag2 && !hasFired)) { isFiring = true; OnCastFixedUpdate(); if (!hasFired) { OnCastEnter(); hasFired = true; } } if (flag2 && !hasExited) { hasExited = true; OnCastExit(); } if (((EntityState)this).fixedAge > duration) { ((EntityState)this).outer.SetNextStateToMain(); } } public override void Update() { ((EntityState)this).Update(); if (isFiring) { OnCastUpdate(); } } } public class ExampleTimedSkillState : BaseTimedSkillState { public override float TimedBaseDuration => 1.5f; public override float TimedBaseCastStartPercentTime => 0.2f; public override float TimedBaseCastEndPercentTime => 0.9f; protected override void OnCastEnter() { } protected override void OnCastFixedUpdate() { } protected override void OnCastExit() { } } public class ExampleDelayedSkillState : BaseTimedSkillState { public override float TimedBaseDuration => 1.5f; public override float TimedBaseCastStartPercentTime => 0.2f; protected override void OnCastEnter() { } } } namespace MediatorMod.Modules.Achievements { public abstract class BaseMasteryAchievement : BaseAchievement { public abstract string RequiredCharacterBody { get; } public abstract float RequiredDifficultyCoefficient { get; } public override BodyIndex LookUpRequiredBodyIndex() { //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_000f: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex(RequiredCharacterBody); } public override void OnBodyRequirementMet() { ((BaseAchievement)this).OnBodyRequirementMet(); Run.onClientGameOverGlobal += OnClientGameOverGlobal; } public override void OnBodyRequirementBroken() { Run.onClientGameOverGlobal -= OnClientGameOverGlobal; ((BaseAchievement)this).OnBodyRequirementBroken(); } private void OnClientGameOverGlobal(Run run, RunReport runReport) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)runReport.gameEnding) || !runReport.gameEnding.isWin) { return; } DifficultyIndex val = runReport.ruleBook.FindDifficulty(); DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(val); if (difficultyDef != null) { bool flag = difficultyDef.countsAsHardMode && difficultyDef.scalingValue >= RequiredDifficultyCoefficient; bool flag2 = difficultyDef.nameToken == "INFERNO_NAME"; bool flag3 = (int)val >= 3 && (int)val <= 10; if (flag || flag2 || flag3) { ((BaseAchievement)this).Grant(); } } } } } namespace MediatorMod.Components { public class MenuSoundComponent : MonoBehaviour { private void OnEnable() { ((MonoBehaviour)this).StartCoroutine(MenuSound()); } private IEnumerator MenuSound() { yield return (object)new WaitForSeconds(0.3f); Util.PlaySound("Play_bandit2_m1_reload_bullet", ((Component)this).gameObject); yield return null; } } } namespace MediatorMod.Survivors.Mediator { public static class MediatorAI { public static void Init(GameObject bodyPrefab, string masterName) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due
plugins/AncientScepter.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AncientScepter.ScepterSkillsMonster; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.Bandit2.Weapon; using EntityStates.Captain.Weapon; using EntityStates.Chef; using EntityStates.Commando.CommandoWeapon; using EntityStates.Drifter; using EntityStates.Huntress; using EntityStates.Huntress.Weapon; using EntityStates.Loader; using EntityStates.Mage; using EntityStates.Mage.Weapon; using EntityStates.Merc; using EntityStates.Merc.Weapon; using EntityStates.Railgunner.Backpack; using EntityStates.Railgunner.Weapon; using EntityStates.Seeker; using EntityStates.TitanMonster; using EntityStates.Toolbot; using EntityStates.Treebot.TreebotFlower; using EntityStates.VoidSurvivor.CorruptMode; using EntityStates.VoidSurvivor.Weapon; using EntityStates.Vulture.Weapon; using HG.Reflection; using IL.EntityStates.Captain.Weapon; using IL.EntityStates.Loader; using IL.EntityStates.Mage.Weapon; using Mono.Cecil.Cil; using MonoMod.Cil; using On; using On.EntityStates; using On.EntityStates.Bandit2.Weapon; using On.EntityStates.Captain.Weapon; using On.EntityStates.Chef; using On.EntityStates.Commando.CommandoWeapon; using On.EntityStates.Drifter; using On.EntityStates.Huntress; using On.EntityStates.Huntress.Weapon; using On.EntityStates.Loader; using On.EntityStates.Mage; using On.EntityStates.Merc; using On.EntityStates.Railgunner.Backpack; using On.EntityStates.Railgunner.Weapon; using On.EntityStates.Seeker; using On.EntityStates.TitanMonster; using On.EntityStates.Toolbot; using On.EntityStates.Treebot.TreebotFlower; using On.EntityStates.VoidSurvivor.CorruptMode; using On.EntityStates.Vulture.Weapon; using On.RoR2; using On.RoR2.Orbs; using On.RoR2.Projectile; using On.RoR2.UI.MainMenu; using R2API; using RoR2; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI.MainMenu; using TILER2; using ThinkInvisible.ClassicItems; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AncientScepter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Mod for Risk of Rain 2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+bef29d9a1939700a4ad2711380ea47d2e7294c95")] [assembly: AssemblyProduct("AncientScepter")] [assembly: AssemblyTitle("AncientScepter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace AncientScepter { public abstract class ScepterSkill { public abstract SkillDef myDef { get; protected set; } public abstract string oldDescToken { get; protected set; } public abstract string newDescToken { get; protected set; } public abstract string overrideStr { get; } public abstract string targetBody { get; } public abstract SkillSlot targetSlot { get; } public abstract int targetVariantIndex { get; } internal abstract void SetupAttributes(); internal virtual void LoadBehavior() { } internal virtual void UnloadBehavior() { } } public class AncientScepterItem : ItemBase<AncientScepterItem> { public enum StridesInteractionMode { HeresyTakesPrecedence, ScepterTakesPrecedence, ScepterRerolls } public enum RerollMode { Disabled, Random, Scrap } public enum UnusedMode { Keep, Reroll, Metamorphosis } private class ScepterReplacer { public string bodyName; public SkillSlot slotIndex; public int variantIndex; public SkillDef replDef; public SkillDef trgtDef; public int registryEpoch; } public static RerollMode rerollMode; public static UnusedMode unusedMode; public static bool enableMonsterSkills; public static StridesInteractionMode stridesInteractionMode; public static bool altModel; public static bool removeClassicItemsScepterFromPool; public static bool enableSOTVTransforms; public static bool artiFlamePerformanceMode; public static bool captainNukeFriendlyFire; public static bool engiTurretAdjustCooldown; public static bool engiWalkerAdjustCooldown; public static bool turretBlacklist; private GameObject itemModel; private GameObject itemDisplay; public static GameObject ItemBodyModelPrefab; public static GameObject ancientWispPrefab; public static Material purpleFireMaterial; internal List<ScepterSkill> skills = new List<ScepterSkill>(); private bool handlingOverride = false; private readonly List<ScepterReplacer> scepterReplacers = new List<ScepterReplacer>(); private readonly Dictionary<SkillSlot, SkillDef> heresyDefs = new Dictionary<SkillSlot, SkillDef>(); private bool handlingInventory = false; public override string ItemName => "Ancient Scepter"; public override string ItemLangTokenName => "ANCIENT_SCEPTER"; public override string ItemPickupDesc => "Upgrades one of your skills."; public override string ItemFullDescription => "Upgrade one of your <style=cIsUtility>skills</style>. " + ((rerollMode != 0) ? "<style=cStack>(Unique per survivor)</style>." : "Reduce skill cooldown by <style=cIsUtility>0%</style> <style=cStack>(+30% per stack. Unique per survivor)</style>.") + "\n<style=cStack>" + ((rerollMode != 0) ? "Extra/Unusable" : "Unusable") + " pickups will reroll into " + ((rerollMode == RerollMode.Scrap) ? "Item Scrap, Red" : "other Legendary items.") + "</style>"; public override string ItemLore => "Perfected energies. <He> holds it before us. The crystal of foreign elements is not attached physically, yet it does not falter from the staff's structure.\n\nOverwhelming strength. We watch as <His> might splits the ground asunder with a single strike.\n\nWondrous possibilities. <His> knowledge unlocks further pathways of development. We are enlightened by <Him>.\n\nExcellent results. From <His> hands, [Nanga] takes hold. It is as <He> said: The weak are culled.\n\nRisking everything. The crystal destabilizies. [Nanga] is gone, and <He> is forced to wield it once again.\n\nPower comes at a cost. <He> is willing to pay."; public override ItemTier Tier => (ItemTier)2; public override ItemTag[] ItemTags => EvaluateItemTags(); private string AssetName => altModel ? "AghanimScepter" : "AncientScepter"; public override GameObject ItemModel { get { if ((Object)(object)itemModel == (Object)null) { itemModel = Assets.mainAssetBundle.LoadAsset<GameObject>("mdl" + AssetName + "Pickup"); } return itemModel; } } public override GameObject ItemDisplay { get { if ((Object)(object)itemDisplay == (Object)null) { itemDisplay = Assets.mainAssetBundle.LoadAsset<GameObject>("mdl" + AssetName + "Display"); } return itemDisplay; } } public override Sprite ItemIcon => Assets.mainAssetBundle.LoadAsset<Sprite>("tex" + AssetName + "Icon"); public override bool TILER2_MimicBlacklisted => true; public override bool AIBlacklisted => true; public override void Init(ConfigFile config) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown ancientWispPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/characterbodies/AncientWispBody"); RegisterSkills(); CreateConfig(config); CreateLang(); CreateItem(); Hooks(); Install(); CreateCraftableDef(); MainMenuController.Start += new hook_Start(MainMenuController_Start); } private void MainMenuController_Start(orig_Start orig, MainMenuController self) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown orig.Invoke(self); MainMenuController.Start -= new hook_Start(MainMenuController_Start); } private ItemTag[] EvaluateItemTags() { List<ItemTag> list = new List<ItemTag> { (ItemTag)3, (ItemTag)4, (ItemTag)31 }; if (turretBlacklist) { list.Add((ItemTag)13); } return list.ToArray(); } public override void CreateConfig(ConfigFile config) { string text = "Item: " + ItemName; engiTurretAdjustCooldown = config.Bind<bool>("Engineer", "TR12-C Gauss Compact Faster Recharge", false, "If true, TR12-C Gauss Compact will recharge faster to match the additional stock.").Value; engiWalkerAdjustCooldown = config.Bind<bool>("Engineer", "TR58-C Carbonizer Mini Faster Recharge", false, "If true, TR58-C Carbonizer Mini will recharge faster to match the additional stock.").Value; turretBlacklist = config.Bind<bool>("Engineer", "Blacklist Turrets", false, "If true, turrets will be blacklisted from getting the Ancient Scepter.\nIf false, they will get the scepter and will get rerolled depending on the reroll mode.").Value; artiFlamePerformanceMode = config.Bind<bool>("Artificer", "ArtiFlamePerformance", false, "If true, Dragon's Breath will use significantly lighter particle effects and no dynamic lighting.").Value; captainNukeFriendlyFire = config.Bind<bool>("Captain", "Captain Nuke Friendly Fire", false, "If true, then Captain's Scepter Nuke will also inflict blight on allies.").Value; rerollMode = config.Bind<RerollMode>(text, "Reroll on pickup mode", RerollMode.Disabled, "If \"Disabled\", additional stacks will not be rerolled. Gaining extra stacks reduces skill cooldown.\nIf \"Random\", any stacks picked up past the first will reroll to other red items.\nIf \"Scrap\", any stacks picked up past the first will reroll into red scrap.").Value; unusedMode = config.Bind<UnusedMode>(text, "Unused mode", UnusedMode.Metamorphosis, "If \"Keep\", Characters which cannot benefit from the item will still keep it.\nIf \"Reroll\", Characters without any scepter upgrades will reroll according to above pickup mode.\nIf \"Metamorphosis\", Characters without scepter upgrades will only reroll if Artifact of Metamorphosis is not active.").Value; stridesInteractionMode = config.Bind<StridesInteractionMode>(text, "Strides pickup mode", StridesInteractionMode.ScepterRerolls, "Changes what happens when a character whose skill is affected by Ancient Scepter has both Ancient Scepter and the corresponding heretic skill replacements (Visions/Hooks/Strides/Essence) at the same time.").Value; enableMonsterSkills = config.Bind<bool>(text, "Enable skills for monsters", true, "If true, certain monsters get the effects of the Ancient Scepter.").Value; altModel = config.Bind<bool>(text, "Alt Model", false, "Changes the model as a reference to a certain other scepter that upgrades abilities.").Value; removeClassicItemsScepterFromPool = config.Bind<bool>(text, "CLASSICITEMS: Remove Classic Items Ancient Scepter From Droplist If Installed", true, "If true, then the Ancient Scepter from Classic Items will be removed from the drop pool to prevent complications.").Value; ScepterSkill scepterSkill = skills.First((ScepterSkill x) => x is EngiTurret2); scepterSkill.myDef.baseRechargeInterval = EngiTurret2.oldDef.baseRechargeInterval * (engiTurretAdjustCooldown ? (2f / 3f) : 1f); SkillUtil.GlobalUpdateSkillDef(scepterSkill.myDef); ScepterSkill scepterSkill2 = skills.First((ScepterSkill x) => x is EngiWalker2); scepterSkill2.myDef.baseRechargeInterval = EngiWalker2.oldDef.baseRechargeInterval / (engiWalkerAdjustCooldown ? 2f : 1f); SkillUtil.GlobalUpdateSkillDef(scepterSkill2.myDef); if (Chainloader.PluginInfos.ContainsKey("com.ThinkInvisible.ClassicItems") && removeClassicItemsScepterFromPool) { Run.onRunStartGlobal += RemoveClassicItemsScepter; } enableSOTVTransforms = config.Bind<bool>(text, "Transformation Notification", true, "If true, then when scepters are re-rolled, then it will be accompanied by a transformation notification like other items.").Value; } protected override void CreateCraftableDef() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0050: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown CraftableDef val = ScriptableObject.CreateInstance<CraftableDef>(); val.pickup = (Object)(object)base.ItemDef; Recipe[] array = new Recipe[1]; Recipe val2 = new Recipe(); val2.amountToDrop = 1; val2.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2] { new RecipeIngredient { pickup = (Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)"b4d935cc376fab14a9e1b3e0aa772536").WaitForCompletion() }, new RecipeIngredient { pickup = (Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)"c2701e84e1d92a246a9adaffd41b56a5").WaitForCompletion() } }; array[0] = val2; val.recipes = (Recipe[])(object)array; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void RemoveClassicItemsScepter(Run run) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ((Item)Item<Scepter>.instance).itemDef; if (itemDef != null && (int)itemDef.itemIndex > -1) { Run.instance.DisableItemDrop(((Item)Item<Scepter>.instance).itemDef.itemIndex); } } public override ItemDisplayRuleDict CreateDisplayRules() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: 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_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07cf: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) //IL_07ea: Unknown result type (might be due to invalid IL or missing references) //IL_07ef: Unknown result type (might be due to invalid IL or missing references) //IL_07f0: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Unknown result type (might be due to invalid IL or missing references) //IL_083a: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Unknown result type (might be due to invalid IL or missing references) //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08e0: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0921: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0955: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_0990: Unknown result type (might be due to invalid IL or missing references) //IL_0991: Unknown result type (might be due to invalid IL or missing references) //IL_09ac: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09e0: Unknown result type (might be due to invalid IL or missing references) //IL_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_09fb: Unknown result type (might be due to invalid IL or missing references) //IL_0a11: Unknown result type (might be due to invalid IL or missing references) //IL_0a16: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a1c: Unknown result type (might be due to invalid IL or missing references) SetupMaterials(ItemModel); ItemDisplay val = ItemModel.AddComponent<ItemDisplay>(); val.rendererInfos = Assets.SetupRendererInfos(ItemModel); ItemBase.displayPrefab = ItemDisplay; SetupMaterials(ItemBase.displayPrefab); val = ItemBase.displayPrefab.AddComponent<ItemDisplay>(); val.rendererInfos = Assets.SetupRendererInfos(ItemBase.displayPrefab); ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Pelvis", localPos = new Vector3(0.1473f, -0.073f, -0.0935f), localAngles = new Vector3(333.2843f, 198.8161f, 165.1177f), localScale = new Vector3(0.2235f, 0.2235f, 0.2235f) } }); val2.Add("mdlHuntress", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Pelvis", localPos = new Vector3(0f, 0.0638f, 0.0973f), localAngles = new Vector3(76.6907f, 0f, 0f), localScale = new Vector3(0.2812f, 0.2812f, 0.2812f) } }); val2.Add("mdlMage", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "HandR", localPos = new Vector3(-0.0021f, 0.1183f, 0.063f), localAngles = new Vector3(0f, 34.1f, 90f), localScale = new Vector3(0.4416f, 0.4416f, 0.4416f) } }); val2.Add("mdlEngi", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "CannonHeadR", localPos = new Vector3(0.0186f, 0.3435f, 0.2246f), localAngles = new Vector3(0f, 0f, 0f), localScale = new Vector3(0.5614f, 0.5614f, 0.5614f) } }); val2.Add("mdlMerc", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Pelvis", localPos = new Vector3(0.1712f, 0f, 0f), localAngles = new Vector3(69.8111f, 180f, 180f), localScale = new Vector3(0.2679f, 0.2679f, 0.2679f) } }); val2.Add("mdlLoader", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "MechLowerArmR", localPos = new Vector3(0.0813f, 0.4165f, -0.0212f), localAngles = new Vector3(0f, 180f, 180f), localScale = new Vector3(0.4063f, 0.4063f, 0.4063f) } }); val2.Add("mdlCaptain", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Chest", localPos = new Vector3(-0.0046f, 0.0099f, -0.286f), localAngles = new Vector3(10.4706f, 1.6895f, 24.8468f), localScale = new Vector3(0.4928f, 0.4928f, 0.4928f) } }); val2.Add("mdlToolbot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Chest", localPos = new Vector3(1.1191f, 0.358f, -1.6717f), localAngles = new Vector3(0f, 0f, 270f), localScale = new Vector3(2.4696f, 2.4696f, 2.4696f) } }); val2.Add("mdlTreebot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "CalfFrontL", localPos = new Vector3(0f, 0.8376f, -0.1766f), localAngles = new Vector3(0f, 0f, 0f), localScale = new Vector3(0.8037f, 0.8037f, 0.8037f) } }); val2.Add("mdlCroco", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "MouthMuzzle", localPos = new Vector3(0f, 2.1215f, 2.9939f), localAngles = new Vector3(0f, 0f, 270f), localScale = new Vector3(5.2969f, 5.2969f, 5.2969f) } }); val2.Add("mdlBandit", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemBase.displayPrefab, childName = "Pelvis", localPos = new Vector3(-0.1152f, -0.1278f, 0.2056f), localAngles = new Vector3(20f, 285f, 10f), localScale = new Vector3(0.2235f, 0.2235f, 0.2235f) } }); val2.Add("mdlEnforcer", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { ItemHelpers.CreateDisplayRule(ItemBase.displayPrefab, "Pelvis", new Vector3(-0.08448f, 0.00357f, -0.35566f), new Vector3(43.57039f, 347.6845f, 69.64303f), new Vector3(0.31291f, 0.31291f, 0.31291f)) }); val2.Add("mdlNemforcer", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { ItemHelpers.CreateDisplayRule(ItemBase.displayPrefab, "Minigun", new Vector3(0.00287f, -0.00305f, -0.03029f), new Vector3(358.9499f, 89.5545f, 180.8908f), new Vector3(0.00837f, 0.00837f, 0.00837f)) }); val2.Add("mdlVoidSurvivor", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { childName = "Hand", followerPrefab = ItemBase.displayPrefab, localPos = new Vector3(-0.02335f, 0.11837f, 0.11306f), localAngles = new Vector3(55.42191f, 299.1461f, 266.1845f), localScale = new Vector3(0.56092f, 0.56276f, 0.56092f) } }); val2.Add("mdlRailGunner", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { childName = "ThighR", followerPrefab = ItemBase.displayPrefab, localPos = new Vector3(-0.11836f, 0.17205f, 0.0282f), localAngles = new Vector3(353.4687f, 184.4017f, 177.4758f), localScale = new Vector3(0.2235f, 0.2235f, 0.2235f) } }); val2.Add("mdlNemmando", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { childName = "Sword", followerPrefab = ItemBase.displayPrefab, localPos = new Vector3(-5.576489E-05f, 0.001674413f, -2.617424E-05f), localAngles = new Vector3(1.114511f, 204.2958f, 177.8329f), localScale = new Vector3(0.0026f, 0.0026f, 0.0026f) } }); val2.Add("mdlHeretic", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { childName = "ThighL", followerPrefab = ItemBase.displayPrefab, localPos = new Vector3(0.49264f, -0.16267f, -0.14486f), localAngles = new Vector3(9.97009f, 351.3801f, 100.2498f), localScale = new Vector3(0.5f, 0.5f, 0.5f) } }); val2.Add("mdlBrother", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { childName = "HandL", followerPrefab = ItemBase.displayPrefab, localPos = new Vector3(-0.05066f, 0.13436f, 0.0282f), localAngles = new Vector3(79.95749f, 180f, 230.595f), localScale = new Vector3(0.4f, 0.4f, 0.4f) } }); return val2; } protected override void SetupMaterials(GameObject modelPrefab) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) purpleFireMaterial = ((Renderer)((Component)ancientWispPrefab.transform.Find("Model Base?/mdlAncientWisp/AncientWispArmature/chest/Fire, Main")).GetComponent<ParticleSystemRenderer>()).material; modelPrefab.GetComponentInChildren<Renderer>().material = Assets.CreateMaterial("mat" + AssetName, 1f, Color.white, 1f); ParticleSystemRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<ParticleSystemRenderer>(); foreach (ParticleSystemRenderer val in componentsInChildren) { ((Renderer)val).material = purpleFireMaterial; } } public AncientScepterItem() { skills.Add(new ArtificerFlamethrower2()); skills.Add(new ArtificerFlyUp2()); skills.Add(new Bandit2ResetRevolver2()); skills.Add(new Bandit2SkullRevolver2()); skills.Add(new CaptainAirstrike2()); skills.Add(new CaptainAirstrikeAlt2()); skills.Add(new CommandoBarrage2()); skills.Add(new CommandoGrenade2()); skills.Add(new CrocoDisease2()); skills.Add(new EngiTurret2()); skills.Add(new EngiWalker2()); skills.Add(new HuntressBallista2()); skills.Add(new HuntressRain2()); skills.Add(new LoaderChargeFist2()); skills.Add(new LoaderChargeZapFist2()); skills.Add(new MercEvis2()); skills.Add(new MercEvisProjectile2()); skills.Add(new ToolbotDash2()); skills.Add(new TreebotFlower2_2()); skills.Add(new TreebotFireFruitSeed2()); skills.Add(new RailgunnerSuper2()); skills.Add(new RailgunnerCryo2()); skills.Add(new VoidFiendCrush()); skills.Add(new SeekerMeditate2()); skills.Add(new SeekerPalmBlast2()); skills.Add(new ChefGlaze2()); skills.Add(new ChefYesChef2()); skills.Add(new DrifterSalvage2()); skills.Add(new DrifterTinker2()); if (enableMonsterSkills) { skills.Add(new AurelioniteEyeLaser2()); skills.Add(new VultureWindblade2()); } } public void RegisterSkills() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) foreach (ScepterSkill skill in skills) { skill.SetupAttributes(); RegisterScepterSkill(skill.myDef, skill.targetBody, skill.targetSlot, skill.targetVariantIndex); } RegisterScepterSkill(VoidFiendCrush.myCtxDef, "VoidSurvivorBody", VoidFiendCrush.dirtySkillDef); HereticNevermore2 hereticNevermore = new HereticNevermore2(); hereticNevermore.SetupAttributes(); RegisterScepterSkill(hereticNevermore.myDef, hereticNevermore.targetBody, Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Heretic/HereticDefaultAbility.asset").WaitForCompletion()); skills.Add(hereticNevermore); } public void Install() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown CharacterBody.onBodyInventoryChangedGlobal += On_CBInventoryChangedGlobal; CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(On_CMGetDeployableSameSlotLimit); GenericSkill.UnsetSkillOverride += new hook_UnsetSkillOverride(On_GSUnsetSkillOverride); Run.onRunStartGlobal += On_RunStartGlobal; RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients); foreach (ScepterSkill skill in skills) { skill.LoadBehavior(); } foreach (CharacterMaster item in MiscUtil.AliveList()) { if (item.hasBody) { CharacterBody body = item.GetBody(); HandleScepterSkill(body); } } } private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected I4, but got Unknown SkillSlot result = (SkillSlot)(-1); if ((Object)(object)sender.inventory != (Object)null && sender.inventory.GetItemCountEffective(base.ItemDef) > 0 && (Object)(object)sender.skillLocator != (Object)null && TryGetScepterSlot(sender, out result)) { SkillSlot val = result; SkillSlot val2 = val; switch (val2 - -1) { case 1: args.primarySkill.cooldownReductionMultAdd += ((float)sender.inventory.GetItemCountEffective(base.ItemDef) - 1f) * 0.3f; break; case 2: args.secondarySkill.cooldownReductionMultAdd += ((float)sender.inventory.GetItemCountEffective(base.ItemDef) - 1f) * 0.3f; break; case 3: args.utilitySkill.cooldownReductionMultAdd += ((float)sender.inventory.GetItemCountEffective(base.ItemDef) - 1f) * 0.3f; break; case 4: args.specialSkill.cooldownReductionMultAdd += ((float)sender.inventory.GetItemCountEffective(base.ItemDef) - 1f) * 0.3f; break; } } if (sender.HasBuff(AncientScepterMain.chefSuperWeakDebuff)) { args.armorAdd -= 30f * (float)sender.GetBuffCount(AncientScepterMain.chefSuperWeakDebuff); args.damageTotalMult *= 0.6f; args.moveSpeedTotalMult *= 0.6f; } } private bool TryGetScepterSlot(CharacterBody body, out SkillSlot result) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected I4, but got Unknown result = (SkillSlot)(-1); if ((Object)(object)body.skillLocator == (Object)null || (Object)(object)body.master == (Object)null || body.master.loadout == null) { return false; } string bodyName = BodyCatalog.GetBodyName(body.bodyIndex); List<ScepterReplacer> list = scepterReplacers.Where((ScepterReplacer x) => x.bodyName == bodyName).ToList(); if (list.Count == 0) { return false; } foreach (ScepterReplacer replacement in list) { if (Object.op_Implicit((Object)(object)replacement.trgtDef)) { GenericSkill val = ((IEnumerable<GenericSkill>)body.skillLocator.allSkills).FirstOrDefault((Func<GenericSkill, bool>)((GenericSkill s) => Object.op_Implicit((Object)(object)s) && ((Object)(object)s.skillDef == (Object)(object)replacement.trgtDef || (Object)(object)s.baseSkill == (Object)(object)replacement.trgtDef))); if (Object.op_Implicit((Object)(object)val)) { SkillSlot val2 = (((int)replacement.slotIndex != -1) ? replacement.slotIndex : body.skillLocator.FindSkillSlot(val)); result = (SkillSlot)(int)val2; return true; } } } return false; } public void InstallLanguage() { foreach (ScepterSkill skill in skills) { if (skill.oldDescToken != null) { languageOverlays.Add(LanguageAPI.AddOverlay(skill.newDescToken, Language.GetString(skill.oldDescToken) + skill.overrideStr)); } } } private void On_GSUnsetSkillOverride(orig_UnsetSkillOverride orig, GenericSkill self, object source, SkillDef skillDef, SkillOverridePriority priority) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, source, skillDef, priority); if (!handlingOverride && Object.op_Implicit((Object)(object)self.characterBody)) { handlingOverride = true; CleanScepter(self.characterBody, self); HandleScepterSkill(self.characterBody); handlingOverride = false; } } private int On_CMGetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 int num = orig.Invoke(self, slot); if ((int)slot != 1) { return num; } CharacterBody body = self.GetBody(); GenericSkill val = ((body == null) ? null : body.skillLocator?.special); if (!Object.op_Implicit((Object)(object)val)) { return num; } if ((Object)(object)val.skillDef == (Object)(object)skills.First((ScepterSkill x) => x is EngiTurret2).myDef) { return num + 1; } if ((Object)(object)val.skillDef == (Object)(object)skills.First((ScepterSkill x) => x is EngiWalker2).myDef) { return num + 2; } return num; } public bool RegisterScepterSkill(SkillDef replacingDef, string targetBodyName, SkillSlot targetSlot, int targetVariant) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0141: Unknown result type (might be due to invalid IL or missing references) if (targetVariant < 0) { AncientScepterMain._logger.LogError((object)"Can't register a scepter skill to negative variant index"); return false; } ScepterReplacer scepterReplacer = scepterReplacers.FirstOrDefault((ScepterReplacer x) => x.bodyName == targetBodyName && x.slotIndex == targetSlot && x.variantIndex == targetVariant); if (scepterReplacer != null) { AncientScepterMain._logger.LogMessage((object)("Replacing scepter skill for \"" + targetBodyName + "\" (" + scepterReplacer.replDef.skillName + ") with (" + replacingDef.skillName + ")")); scepterReplacers.Remove(scepterReplacer); scepterReplacer = null; } scepterReplacer = scepterReplacers.FirstOrDefault((ScepterReplacer x) => x.bodyName == targetBodyName && (Object)(object)x.trgtDef != (Object)null); AncientScepterMain._logger.LogMessage((object)("Adding scepter skill for \"" + targetBodyName + "\" (" + replacingDef.skillName + ")")); scepterReplacers.Add(new ScepterReplacer { bodyName = targetBodyName, slotIndex = targetSlot, variantIndex = targetVariant, replDef = replacingDef, registryEpoch = ((scepterReplacer != null) ? (scepterReplacer.registryEpoch + 1) : 0) }); return true; } public bool RegisterScepterSkill(SkillDef replacingDef, string targetBodyName, SkillDef targetDef) { //IL_010d: Unknown result type (might be due to invalid IL or missing references) ScepterReplacer scepterReplacer = scepterReplacers.FirstOrDefault((ScepterReplacer x) => x.bodyName == targetBodyName && (Object)(object)x.trgtDef == (Object)(object)targetDef); if (scepterReplacer != null) { AncientScepterMain._logger.LogMessage((object)("Replacing scepter skill for \"" + targetBodyName + "\" (" + scepterReplacer.replDef.skillName + ") with (" + replacingDef.skillName + ")")); scepterReplacers.Remove(scepterReplacer); scepterReplacer = null; } scepterReplacer = scepterReplacers.FirstOrDefault((ScepterReplacer x) => x.bodyName == targetBodyName && (Object)(object)x.trgtDef == (Object)null); AncientScepterMain._logger.LogMessage((object)("Adding scepter skill for \"" + targetBodyName + "\" (" + replacingDef.skillName + ")")); scepterReplacers.Add(new ScepterReplacer { bodyName = targetBodyName, slotIndex = (SkillSlot)(-1), variantIndex = -1, replDef = replacingDef, trgtDef = targetDef, registryEpoch = ((scepterReplacer != null) ? (scepterReplacer.registryEpoch + 1) : 0) }); return true; } private void On_RunStartGlobal(Run run) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) heresyDefs.Add((SkillSlot)0, CommonAssets.lunarPrimaryReplacementSkillDef); heresyDefs.Add((SkillSlot)1, CommonAssets.lunarSecondaryReplacementSkillDef); heresyDefs.Add((SkillSlot)2, CommonAssets.lunarUtilityReplacementSkillDef); heresyDefs.Add((SkillSlot)3, CommonAssets.lunarSpecialReplacementSkillDef); foreach (ScepterReplacer repdef in scepterReplacers.Where((ScepterReplacer x) => (Object)(object)x.trgtDef == (Object)null).Reverse()) { GameObject val = BodyCatalog.FindBodyPrefab(repdef.bodyName); SkillLocator val2 = ((val != null) ? val.GetComponent<SkillLocator>() : null); if (!Object.op_Implicit((Object)(object)val2) || (int)repdef.slotIndex == -1 || repdef.variantIndex < 0) { continue; } Variant[] variants = val2.GetSkill(repdef.slotIndex).skillFamily.variants; if (variants.Length <= repdef.variantIndex) { AncientScepterMain._logger.LogError((object)$"Invalid Scepter Replacement for body:{repdef.bodyName},slot:{repdef.slotIndex},with skill:{repdef.replDef.skillNameToken}"); repdef.trgtDef = null; continue; } ScepterReplacer scepterReplacer = scepterReplacers.FirstOrDefault((ScepterReplacer x) => (Object)(object)x.trgtDef == (Object)(object)variants[repdef.variantIndex].skillDef && x.registryEpoch >= repdef.registryEpoch); if (scepterReplacer != null) { AncientScepterMain._logger.LogMessage((object)("Replacing scepter skill for \"" + repdef.bodyName + "\" (" + repdef.replDef.skillName + ") with (" + scepterReplacer.replDef.skillName + ")")); repdef.trgtDef = null; } else { repdef.trgtDef = variants[repdef.variantIndex].skillDef; } } Run.onRunStartGlobal -= On_RunStartGlobal; } private void On_CBInventoryChangedGlobal(CharacterBody body) { if (handlingInventory) { return; } handlingInventory = true; if (!HandleScepterSkill(body) && RerollUnused()) { if (GetCountPermanent(body) > 0) { Reroll(body, GetCountPermanent(body)); } else if (GetCountTemporary(body) > 0) { Reroll(body, GetCountTemporary(body), isTemp: true); } } else if (GetCountPermanent(body) > 1 && rerollMode != 0) { Reroll(body, GetCountPermanent(body) - 1); } else if (GetCountEffective(body) > 1 && GetCountTemporary(body) > 0 && rerollMode != 0) { Reroll(body, GetCountTemporary(body) - 1, isTemp: true); } handlingInventory = false; } private bool RerollUnused() { return unusedMode switch { UnusedMode.Keep => false, UnusedMode.Metamorphosis => !RunArtifactManager.instance.IsArtifactEnabled(Artifacts.randomSurvivorOnRespawnArtifactDef), _ => true, }; } private void Reroll(CharacterBody self, int count) { Reroll(self, count, isTemp: false); } private void Reroll(CharacterBody self, int count, bool isTemp) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_008f: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if (count <= 0) { return; } switch (rerollMode) { case RerollMode.Disabled: break; case RerollMode.Random: { List<PickupIndex> list = Run.instance.availableTier3DropList.Except((IEnumerable<PickupIndex>)(object)new PickupIndex[1] { PickupCatalog.FindPickupIndex(base.ItemDef.itemIndex) }).ToList(); List<ItemIndex> list2 = new List<ItemIndex>(); for (int j = 0; j < count; j++) { ItemIndex itemIndex = PickupCatalog.GetPickupDef(list[Random.Range(0, list.Count)]).itemIndex; if (isTemp) { self.inventory.RemoveItemTemp(base.ItemDef.itemIndex, 1f); self.inventory.GiveItemTemp(itemIndex, 1f); } else { self.inventory.RemoveItemPermanent(base.ItemDef, 1); self.inventory.GiveItemPermanent(itemIndex, 1); } list2.Add(itemIndex); } if (!enableSOTVTransforms) { break; } { foreach (ItemIndex item in list2.Distinct()) { CharacterMasterNotificationQueue.SendTransformNotification(self.master, base.ItemDef.itemIndex, item, (TransformationType)0); } break; } } case RerollMode.Scrap: { for (int i = 0; i < count; i++) { if (isTemp) { self.inventory.RemoveItemTemp(base.ItemDef.itemIndex, 1f); self.inventory.GiveItemTemp(Items.ScrapRed.itemIndex, 1f); } else { self.inventory.RemoveItemPermanent(base.ItemDef, 1); self.inventory.GiveItemPermanent(Items.ScrapRed, 1); } } if (enableSOTVTransforms) { CharacterMasterNotificationQueue.SendTransformNotification(self.master, base.ItemDef.itemIndex, Items.ScrapRed.itemIndex, (TransformationType)0); } break; } } } private void CleanScepter(CharacterBody self, GenericSkill slot = null, bool force = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) string bodyName = BodyCatalog.GetBodyName(self.bodyIndex); List<ScepterReplacer> source = scepterReplacers.FindAll((ScepterReplacer x) => x.bodyName == bodyName); if (Object.op_Implicit((Object)(object)slot)) { if (source.Any((ScepterReplacer r) => (Object)(object)r.replDef == (Object)(object)slot.skillDef && (force || ((Object)(object)slot.baseSkill != (Object)(object)r.trgtDef && !slot.skillOverrides.Any((SkillOverride s) => (Object)(object)r.trgtDef == (Object)(object)s.skillDef))))) { slot.UnsetSkillOverride((object)self, slot.skillDef, (SkillOverridePriority)2); } return; } GenericSkill[] allSkills = self.skillLocator.allSkills; foreach (GenericSkill val in allSkills) { if (source.Any((ScepterReplacer r) => (Object)(object)r.replDef == (Object)(object)slot.skillDef && (force || ((Object)(object)slot.baseSkill != (Object)(object)r.trgtDef && !slot.skillOverrides.Any((SkillOverride s) => (Object)(object)r.trgtDef == (Object)(object)s.skillDef))))) { val.UnsetSkillOverride((object)self, val.skillDef, (SkillOverridePriority)2); } } } private bool HandleScepterSkill(CharacterBody self, bool forceOff = false) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_01ef: Invalid comparison between Unknown and I4 //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_046f: 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_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) ScepterReplacer replVar; if (Object.op_Implicit((Object)(object)self.skillLocator) && self.master?.loadout != null) { string bodyName = BodyCatalog.GetBodyName(self.bodyIndex); List<ScepterReplacer> list = scepterReplacers.FindAll((ScepterReplacer x) => x.bodyName == bodyName); if (list.Count > 0) { if (list.Select((ScepterReplacer x) => x.replDef).Intersect(self.skillLocator.allSkills.Select((GenericSkill x) => x.skillDef)).Any() && GetCountEffective(self) > 0) { return true; } GenericSkill val = null; SkillSlot val2 = (SkillSlot)(-1); replVar = null; bool flag = false; foreach (ScepterReplacer replacement in list) { foreach (GenericSkill item in self.skillLocator.allSkills.Reverse().ToList().FindAll((GenericSkill s) => (Object)(object)s.skillDef == (Object)(object)replacement.trgtDef || (Object)(object)s.baseSkill == (Object)(object)replacement.trgtDef)) { val = item; val2 = (((int)replacement.slotIndex == -1) ? self.skillLocator.FindSkillSlot(val) : replacement.slotIndex); if ((stridesInteractionMode != StridesInteractionMode.ScepterTakesPrecedence || bodyName == "HereticBody") && hasHeresyForSlot(val2) && (Object)(object)replacement.trgtDef != (Object)(object)heresyDefs[val2]) { flag = true; continue; } replVar = replacement; break; } if (replVar != null && Object.op_Implicit((Object)(object)val) && (Object)(object)replVar.trgtDef == (Object)(object)val.skillDef) { break; } } if (replVar == null) { return flag && stridesInteractionMode != StridesInteractionMode.ScepterRerolls; } bool flag2 = handlingOverride; handlingOverride = true; if (!forceOff && GetCountEffective(self) > 0) { if (stridesInteractionMode == StridesInteractionMode.ScepterTakesPrecedence && hasHeresyForSlot(val2)) { self.skillLocator.GetSkill(val2).UnsetSkillOverride((object)self, heresyDefs[val2], (SkillOverridePriority)3); } val.SetSkillOverride((object)self, replVar.replDef, (SkillOverridePriority)2); val.onSkillChanged += UnsetOverrideLater; } else { val.UnsetSkillOverride((object)self, replVar.replDef, (SkillOverridePriority)2); if (stridesInteractionMode == StridesInteractionMode.ScepterTakesPrecedence && hasHeresyForSlot(val2)) { self.skillLocator.GetSkill(val2).SetSkillOverride((object)self, heresyDefs[val2], (SkillOverridePriority)3); } } handlingOverride = flag2; return true; } } return false; void UnsetOverrideLater(GenericSkill skill) { skill.onSkillChanged -= UnsetOverrideLater; skill.UnsetSkillOverride((object)self, replVar.replDef, (SkillOverridePriority)2); } bool hasHeresyForSlot(SkillSlot skillSlot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown return (int)skillSlot switch { 0 => self.inventory.GetItemCountEffective(Items.LunarPrimaryReplacement) > 0, 1 => self.inventory.GetItemCountEffective(Items.LunarSecondaryReplacement) > 0, 2 => self.inventory.GetItemCountEffective(Items.LunarUtilityReplacement) > 0, 3 => self.inventory.GetItemCountEffective(Items.LunarSpecialReplacement) > 0, _ => false, }; } } } [BepInPlugin("com.DestroyedClone.AncientScepter", "StandaloneAncientScepter", "1.1.37")] [BepInDependency("com.bepis.r2api", "5.2.0")] [BepInDependency("com.bepis.r2api.items", "1.0.1")] [BepInDependency("com.bepis.r2api.prefab", "1.0.1")] [BepInDependency("com.bepis.r2api.language", "1.0.0")] [BepInDependency("com.bepis.r2api.damagetype", "1.0.0")] [BepInDependency("com.bepis.r2api.orb", "1.0.0")] [BepInDependency("com.bepis.r2api.content_management", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class AncientScepterMain : BaseUnityPlugin { public const string ModVer = "1.1.37"; public const string ModName = "StandaloneAncientScepter"; public const string ModGuid = "com.DestroyedClone.AncientScepter"; internal static ManualLogSource _logger = null; public List<ItemBase> Items = new List<ItemBase>(); public static Dictionary<ItemBase, bool> ItemStatusDictionary = new Dictionary<ItemBase, bool>(); protected readonly List<LanguageOverlay> languageOverlays = new List<LanguageOverlay>(); public static BuffDef perishSongDebuff; public static BuffDef chefSuperWeakDebuff; public void Awake() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown _logger = ((BaseUnityPlugin)this).Logger; ModCompat.Init(); CustomDamageTypes.SetupDamageTypes(); SetupBuffs(); Assets.PopulateAssets(); Assets.SpriteAssets.InitializeAssets(); IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes() where !type.IsAbstract && type.IsSubclassOf(typeof(ItemBase)) select type; foreach (Type item in enumerable) { ItemBase itemBase = (ItemBase)Activator.CreateInstance(item); if (ValidateItem(itemBase, Items)) { itemBase.Init(((BaseUnityPlugin)this).Config); } } Run.onRunStartGlobal += Run_onRunStartGlobal; MainMenuController.Start += new hook_Start(MainMenuController_Start); Language.onCurrentLanguageChanged += Language_onCurrentLanguageChanged; } public static void SetupBuffs() { //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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) perishSongDebuff = ScriptableObject.CreateInstance<BuffDef>(); ((Object)perishSongDebuff).name = "Perish Song"; perishSongDebuff.iconSprite = Resources.Load<Sprite>("textures/difficultyicons/texDifficultyHardIcon"); perishSongDebuff.buffColor = Color.red; perishSongDebuff.canStack = true; perishSongDebuff.isHidden = false; perishSongDebuff.isDebuff = false; perishSongDebuff.isCooldown = false; if (!ContentAddition.AddBuffDef(perishSongDebuff)) { _logger.LogWarning((object)"Buff 'perishSongDebuff' failed to be added."); } chefSuperWeakDebuff = ScriptableObject.CreateInstance<BuffDef>(); ((Object)chefSuperWeakDebuff).name = "ChefSuperWeakness"; chefSuperWeakDebuff.iconSprite = Addressables.LoadAssetAsync<Sprite>((object)"095037011ecb52c47bf861cc9ebd53a0").WaitForCompletion(); chefSuperWeakDebuff.buffColor = Color.magenta; chefSuperWeakDebuff.canStack = true; chefSuperWeakDebuff.isHidden = false; chefSuperWeakDebuff.isDebuff = true; chefSuperWeakDebuff.isCooldown = false; if (!ContentAddition.AddBuffDef(chefSuperWeakDebuff)) { _logger.LogWarning((object)"Buff 'chefSuperWeakDebuff' failed to be added."); } } private void Language_onCurrentLanguageChanged() { InstallLanguage(); } private void MainMenuController_Start(orig_Start orig, MainMenuController self) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown orig.Invoke(self); InstallLanguage(); MainMenuController.Start -= new hook_Start(MainMenuController_Start); } private void Run_onRunStartGlobal(Run run) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (NetworkServer.active) { Xoroshiro128Plus val = new Xoroshiro128Plus(run.seed); ItemBase<AncientScepterItem>.instance.rng = new Xoroshiro128Plus(val.nextUlong); } } public void InstallLanguage() { foreach (ScepterSkill skill in ItemBase<AncientScepterItem>.instance.skills) { if (skill.oldDescToken != null) { LanguageOverlay item = LanguageAPI.AddOverlay(skill.newDescToken, Language.GetString(skill.oldDescToken) + skill.overrideStr, Language.currentLanguageName ?? "en"); languageOverlays.Add(item); } } } public bool ValidateItem(ItemBase item, List<ItemBase> itemList) { bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("Item: " + item.ItemName, "Blacklist Item from AI Use?", true, "Should the AI not be able to obtain this item? By default, most monsters lack skill upgrades and will reroll.").Value; ItemStatusDictionary.Add(item, ((Behaviour)this).enabled); itemList.Add(item); if (value) { item.AIBlacklisted = true; } return ((Behaviour)this).enabled; } public static void AddBuffAndDot(BuffDef buff, float duration, int stackCount, CharacterBody body) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0060: 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) DotIndex val = (DotIndex)Array.FindIndex(DotController.dotDefs, (DotDef dotDef) => (Object)(object)dotDef.associatedBuff == (Object)(object)buff); for (int i = 0; i < stackCount; i++) { if ((int)val != -1) { DotController.InflictDot(((Component)body).gameObject, ((Component)body).gameObject, val, duration, 0.25f, (uint?)uint.MaxValue); } else { body.AddTimedBuffAuthority(buff.buffIndex, duration); } } } } public static class Assets { public static class SpriteAssets { public static Sprite ArtificerFlameThrower2; public static Sprite ArtificerFlyUp2; public static Sprite Bandit2ResetRevolver2; public static Sprite Bandit2SkullRevolver2; public static Sprite CaptainAirstrike2; public static Sprite CaptainAirstrikeAlt2; public static Sprite CommandoBarrage2; public static Sprite CommandoGrenade2; public static Sprite CrocoDisease2; public static Sprite EngiTurret2; public static Sprite EngiWalker2; public static Sprite HereticNevermore2; public static Sprite HuntressBallista2; public static Sprite HuntressRain2; public static Sprite LoaderChargeFist2; public static Sprite LoaderChargeZapFist2; public static Sprite MercEvis2; public static Sprite MercEvis2Projectile; public static Sprite ToolbotDash2; public static Sprite TreebotFireFruitSeed2; public static Sprite TreebotFlower2_2; public static Sprite RailgunnerSupercharge2; public static Sprite RailgunnerFireSupercharge2; public static Sprite RailgunnerCryocharge2; public static Sprite RailgunnerFireCryocharge2; public static Sprite VoidFiendSuppress2; public static Sprite VoidFiendCorruptedSuppress2; public static Sprite SeekerMeditate2; public static Sprite SeekerPalmBlast2; public static Sprite ChefGlaze2; public static Sprite ChefYesChef2; public static Sprite DrifterSalvage2; public static Sprite DrifterTinker2; public static void InitializeAssets() { ArtificerFlameThrower2 = mainAssetBundle.LoadAsset<Sprite>("texArtiR1"); ArtificerFlyUp2 = mainAssetBundle.LoadAsset<Sprite>("texArtiR2"); Bandit2ResetRevolver2 = mainAssetBundle.LoadAsset<Sprite>("texBanditR1"); Bandit2SkullRevolver2 = mainAssetBundle.LoadAsset<Sprite>("texBanditR2"); CaptainAirstrike2 = mainAssetBundle.LoadAsset<Sprite>("texCapU1"); CaptainAirstrikeAlt2 = mainAssetBundle.LoadAsset<Sprite>("texCapU2"); CommandoBarrage2 = mainAssetBundle.LoadAsset<Sprite>("texCommandoR1"); CommandoGrenade2 = mainAssetBundle.LoadAsset<Sprite>("texCommandoR2"); CrocoDisease2 = mainAssetBundle.LoadAsset<Sprite>("texAcridR1"); EngiTurret2 = mainAssetBundle.LoadAsset<Sprite>("texEngiR1"); EngiWalker2 = mainAssetBundle.LoadAsset<Sprite>("texEngiR2"); HereticNevermore2 = mainAssetBundle.LoadAsset<Sprite>("texHereticR2"); HuntressBallista2 = mainAssetBundle.LoadAsset<Sprite>("texHuntressR2"); HuntressRain2 = mainAssetBundle.LoadAsset<Sprite>("texHuntressR1"); LoaderChargeFist2 = mainAssetBundle.LoadAsset<Sprite>("texLoaderU1"); LoaderChargeZapFist2 = mainAssetBundle.LoadAsset<Sprite>("texLoaderU2"); MercEvis2 = mainAssetBundle.LoadAsset<Sprite>("texMercR1"); MercEvis2Projectile = mainAssetBundle.LoadAsset<Sprite>("texMercR2"); ToolbotDash2 = mainAssetBundle.LoadAsset<Sprite>("texMultU1"); TreebotFireFruitSeed2 = mainAssetBundle.LoadAsset<Sprite>("texRexR2"); TreebotFlower2_2 = mainAssetBundle.LoadAsset<Sprite>("texRexR1"); RailgunnerSupercharge2 = mainAssetBundle.LoadAsset<Sprite>("texRailgunnerR1"); RailgunnerFireSupercharge2 = mainAssetBundle.LoadAsset<Sprite>("texRailgunnerP1"); RailgunnerCryocharge2 = mainAssetBundle.LoadAsset<Sprite>("texRailgunnerR2"); RailgunnerFireCryocharge2 = mainAssetBundle.LoadAsset<Sprite>("texRailgunnerP2"); VoidFiendSuppress2 = mainAssetBundle.LoadAsset<Sprite>("texVoidFiendR1"); VoidFiendCorruptedSuppress2 = mainAssetBundle.LoadAsset<Sprite>("texVoidFiendR1C"); SeekerMeditate2 = mainAssetBundle.LoadAsset<Sprite>("texSeekerR1"); SeekerPalmBlast2 = mainAssetBundle.LoadAsset<Sprite>("texSeekerR2"); ChefGlaze2 = mainAssetBundle.LoadAsset<Sprite>("texChefR1"); ChefYesChef2 = mainAssetBundle.LoadAsset<Sprite>("texChefR2"); DrifterSalvage2 = mainAssetBundle.LoadAsset<Sprite>("texDrifterR1"); DrifterTinker2 = mainAssetBundle.LoadAsset<Sprite>("texDrifterR2"); } } internal static AssetBundle mainAssetBundle; public static Shader hotpoo = Resources.Load<Shader>("Shaders/Deferred/HGStandard"); public static Material commandoMat; public static void PopulateAssets() { if ((Object)(object)mainAssetBundle == (Object)null) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AncientScepter.ancientscepter")) { mainAssetBundle = AssetBundle.LoadFromStream(stream); } } } public static Material CreateMaterial(string materialName, float emission, Color emissionColor, float normalStrength) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)commandoMat)) { commandoMat = Resources.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<CharacterModel>().baseRendererInfos[0].defaultMaterial; } Material val = Object.Instantiate<Material>(commandoMat); Material val2 = mainAssetBundle.LoadAsset<Material>(materialName); if (!Object.op_Implicit((Object)(object)val2)) { return commandoMat; } ((Object)val).name = materialName; val.SetColor("_Color", val2.GetColor("_Color")); val.SetTexture("_MainTex", val2.GetTexture("_MainTex")); val.SetColor("_EmColor", emissionColor); val.SetFloat("_EmPower", emission); val.SetTexture("_EmTex", val2.GetTexture("_EmissionMap")); val.SetFloat("_NormalStrength", normalStrength); return val; } public static Material CreateMaterial(string materialName) { return CreateMaterial(materialName, 0f); } public static Material CreateMaterial(string materialName, float emission) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return CreateMaterial(materialName, emission, Color.black); } public static Material CreateMaterial(string materialName, float emission, Color emissionColor) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return CreateMaterial(materialName, emission, emissionColor, 0f); } public static RendererInfo[] SetupRendererInfos(GameObject obj) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(); RendererInfo[] array = (RendererInfo[])(object)new RendererInfo[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = new RendererInfo { defaultMaterial = componentsInChildren[i].material, renderer = componentsInChildren[i], defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false }; } return array; } } public class BanditRicochetOrb : Orb { public delegate void HitCallback(BanditRicochetOrb orb); public int bouncesRemaining; public bool resetBouncedObjects; public float damageValue; public GameObject attacker; public CharacterBody attackerBody; public GameObject inflictor; public List<HealthComponent> bouncedObjects; public TeamIndex teamIndex; public bool isCrit; public ProcChainMask procChainMask; public float procCoefficient = 1f; public DamageColorIndex damageColorIndex; public float range = 30f; public DamageType damageType; private BullseyeSearch search; public GameObject hitEffectPrefab; public GameObject tracerEffectPrefab; public string hitSoundString; public HitCallback hitCallback; public override void OnArrival() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00ba: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) ((Orb)this).OnArrival(); if (Object.op_Implicit((Object)(object)base.target)) { range *= Bandit2SkullRevolver2.reductionPerBounceMultiplier; damageValue *= Bandit2SkullRevolver2.reductionPerBounceMultiplier; if (Object.op_Implicit((Object)(object)tracerEffectPrefab)) { EffectData val = new EffectData { origin = ((Component)base.target).transform.position, start = base.origin }; EffectManager.SpawnEffect(tracerEffectPrefab, val, true); } if (damageValue > 0f) { HealthComponent healthComponent = base.target.healthComponent; if (Object.op_Implicit((Object)(object)healthComponent)) { DamageInfo val2 = new DamageInfo { damage = damageValue, attacker = attacker, inflictor = inflictor, force = Vector3.zero, crit = isCrit, procChainMask = procChainMask, procCoefficient = procCoefficient, position = ((Component)base.target).transform.position, damageColorIndex = damageColorIndex, damageType = DamageTypeCombo.op_Implicit(damageType) }; DamageAPI.AddModdedDamageType(val2, CustomDamageTypes.ScepterBandit2SkullDT); healthComponent.TakeDamage(val2); GlobalEventManager.instance.OnHitEnemy(val2, ((Component)healthComponent).gameObject); GlobalEventManager.instance.OnHitAll(val2, ((Component)healthComponent).gameObject); } } hitCallback?.Invoke(this); if (bouncesRemaining > 0) { if (!Bandit2SkullRevolver2.GetRicochetChance(attackerBody)) { bouncesRemaining = 1; } if (resetBouncedObjects) { bouncedObjects.Clear(); bouncedObjects.Add(base.target.healthComponent); } HurtBox val3 = PickNextTarget(((Component)base.target).transform.position); if (Object.op_Implicit((Object)(object)val3)) { BanditRicochetOrb obj = new BanditRicochetOrb { search = search, origin = ((Component)base.target).transform.position, target = val3, attacker = attacker, attackerBody = attackerBody, inflictor = inflictor, teamIndex = teamIndex, damageValue = damageValue, isCrit = attackerBody.RollCrit(), bouncesRemaining = bouncesRemaining - 1, bouncedObjects = bouncedObjects, resetBouncedObjects = resetBouncedObjects, procChainMask = procChainMask, procCoefficient = procCoefficient, damageColorIndex = damageColorIndex }; ((Orb)obj).duration = ((Orb)this).duration; obj.range = range; obj.damageType = damageType; obj.tracerEffectPrefab = tracerEffectPrefab; obj.hitEffectPrefab = hitEffectPrefab; obj.hitSoundString = hitSoundString; obj.hitCallback = hitCallback; BanditRicochetOrb banditRicochetOrb = obj; OrbManager.instance.AddOrb((Orb)(object)banditRicochetOrb); return; } } } bouncedObjects.Clear(); } public HurtBox PickNextTarget(Vector3 position) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0053: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (search == null) { search = new BullseyeSearch(); } search.searchOrigin = position; search.searchDirection = Vector3.zero; search.teamMaskFilter = TeamMask.allButNeutral; ((TeamMask)(ref search.teamMaskFilter)).RemoveTeam(teamIndex); search.filterByLoS = true; search.sortMode = (SortMode)1; search.maxDistanceFilter = range; search.RefreshCandidates(); HurtBox val = (from v in search.GetResults() where !bouncedObjects.Contains(v.healthComponent) select v).FirstOrDefault(); if (Object.op_Implicit((Object)(object)val)) { bouncedObjects.Add(val.healthComponent); } return val; } } public static class CustomDamageTypes { internal static ModdedDamageType ScepterFruitDT; internal static ModdedDamageType ScepterCaptainNukeDT; internal static ModdedDamageType ScepterBandit2SkullDT; internal static ModdedDamageType ScepterDestroy10ArmorDT; internal static ModdedDamageType ScepterSlow80For30DT; internal static ModdedDamageType ScepterCHEFSuperWeak; internal static void SetupDamageTypes() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ScepterFruitDT = DamageAPI.ReserveDamageType(); ScepterCaptainNukeDT = DamageAPI.ReserveDamageType(); ScepterBandit2SkullDT = DamageAPI.ReserveDamageType(); ScepterDestroy10ArmorDT = DamageAPI.ReserveDamageType(); ScepterSlow80For30DT = DamageAPI.ReserveDamageType(); ScepterCHEFSuperWeak = DamageAPI.ReserveDamageType(); } } public abstract class ItemBase<T> : ItemBase where T : ItemBase<T> { public static T instance { get; private set; } public ItemBase() { if (instance != null) { throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBoilerplate/Item was instantiated twice"); } instance = this as T; } } public abstract class ItemBase { public static GameObject displayPrefab; protected readonly List<LanguageOverlay> languageOverlays = new List<LanguageOverlay>(); protected readonly Dictionary<string, string> genericLanguageTokens = new Dictionary<string, string>(); protected readonly Dictionary<string, Dictionary<string, string>> specificLanguageTokens = new Dictionary<string, Dictionary<string, string>>(); public abstract string ItemName { get; } public abstract string ItemLangTokenName { get; } public abstract string ItemPickupDesc { get; } public abstract string ItemFullDescription { get; } public abstract string ItemLore { get; } public abstract ItemTier Tier { get; } public virtual ItemTag[] ItemTags { get; set; } = (ItemTag[])(object)new ItemTag[0]; public abstract GameObject ItemModel { get; } public abstract Sprite ItemIcon { get; } public abstract GameObject ItemDisplay { get; } public ItemDef ItemDef { get; set; } public virtual bool CanRemove { get; } = true; public virtual bool AIBlacklisted { get; set; } = false; public virtual bool TILER2_MimicBlacklisted { get; set; } = false; public static ItemDef myDef { get; set; } public Xoroshiro128Plus rng { get; internal set; } public bool languageInstalled { get; private set; } = false; public abstract void Init(ConfigFile config); public virtual void CreateConfig(ConfigFile config) { } protected void CreateLang() { LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_NAME", ItemName); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_PICKUP", ItemPickupDesc); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_DESCRIPTION", ItemFullDescription); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_LORE", ItemLore); } public virtual ItemDisplayRuleDict CreateDisplayRules() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ItemDisplayRuleDict((ItemDisplayRule[])(object)new ItemDisplayRule[0]); } protected void CreateItem() { //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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown if (AIBlacklisted) { ItemTags = new List<ItemTag>(ItemTags) { (ItemTag)4 }.ToArray(); } ItemDef = ScriptableObject.CreateInstance<ItemDef>(); myDef = ItemDef; ((Object)ItemDef).name = "ITEM_" + ItemLangTokenName; ItemDef.nameToken = "ITEM_" + ItemLangTokenName + "_NAME"; ItemDef.pickupToken = "ITEM_" + ItemLangTokenName + "_PICKUP"; ItemDef.descriptionToken = "ITEM_" + ItemLangTokenName + "_DESCRIPTION"; ItemDef.loreToken = "ITEM_" + ItemLangTokenName + "_LORE"; ItemDef.pickupModelPrefab = ItemModel; ItemDef.pickupIconSprite = ItemIcon; ItemDef.hidden = false; ItemDef.tags = ItemTags; ItemDef.canRemove = CanRemove; ItemDef.deprecatedTier = Tier; if (ItemTags.Length != 0) { ItemDef.tags = ItemTags; } if (TILER2_MimicBlacklisted && Chainloader.PluginInfos.ContainsKey("com.ThinkInvisible.TILER2")) { TILER2_BlacklistItem(ItemDef); } ItemAPI.Add(new CustomItem(ItemDef, CreateDisplayRules())); } protected virtual void CreateCraftableDef() { } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TILER2_BlacklistItem(ItemDef itemDef) { FakeInventory.blacklist.Add(itemDef); } public virtual void Hooks() { } protected virtual void SetupMaterials(GameObject modelPrefab) { Renderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].material.shader = Assets.hotpoo; } } public int GetCountPermanent(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountPermanent(ItemDef); } public int GetCountPermanent(CharacterMaster master) { if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory)) { return 0; } return master.inventory.GetItemCountPermanent(ItemDef); } public int GetCountSpecificPermanent(CharacterBody body, ItemDef itemDef) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountPermanent(itemDef); } public int GetCountTemporary(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountTemp(ItemDef); } public int GetCountTemporary(CharacterMaster master) { if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory)) { return 0; } return master.inventory.GetItemCountTemp(ItemDef); } public int GetCountSpecificTemporary(CharacterBody body, ItemDef itemDef) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountTemp(itemDef); } public int GetCountEffective(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountEffective(ItemDef); } public int GetCountEffective(CharacterMaster master) { if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory)) { return 0; } return master.inventory.GetItemCountEffective(ItemDef); } public int GetCountSpecificEffective(CharacterBody body, ItemDef itemDef) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountEffective(itemDef); } } internal class ItemHelpers { public static RendererInfo[] ItemDisplaySetup(GameObject obj) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<MeshRenderer>(); RendererInfo[] array = (RendererInfo[])(object)new RendererInfo[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = new RendererInfo { defaultMaterial = ((Renderer)componentsInChildren[i]).material, renderer = (Renderer)(object)componentsInChildren[i], defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false }; } return array; } public static KeyAssetRuleGroup CreateGenericDisplayRuleGroup(Object keyAsset_, GameObject itemPrefab, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0025: Unknown result type (might be due to invalid IL or missing references) ItemDisplayRule val = CreateDisplayRule(itemPrefab, childName, position, rotation, scale); return CreateDisplayRuleGroupWithRules(keyAsset_, val); } public static ItemDisplayRule CreateDisplayRule(GameObject itemPrefab, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0003: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) ItemDisplayRule result = default(ItemDisplayRule); result.ruleType = (ItemDisplayRuleType)0; result.childName = childName; result.followerPrefab = itemPrefab; result.limbMask = (LimbFlags)0; result.localPos = position; result.localAngles = rotation; result.localScale = scale; return result; } public static KeyAssetRuleGroup CreateDisplayRuleGroupWithRules(Object keyAsset_, params ItemDisplayRule[] rules) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) KeyAssetRuleGroup result = default(KeyAssetRuleGroup); result.keyAsset = keyAsset_; result.displayRuleGroup = new DisplayRuleGroup { rules = rules }; return result; } public static string OrderManifestLoreFormatter(string deviceName, string estimatedDelivery, string sentTo, string trackingNumber, string devicePickupDesc, string shippingMethod, string orderDetails) { string[] value = new string[19] { "<align=left>Estimated Delivery:<indent=70%>Sent To:</indent></align>", "<align=left>" + estimatedDelivery + "<indent=70%>" + sentTo + "</indent></align>", "", "<indent=1%><style=cIsDamage><size=125%><u> Shipping Details:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0</u></size></style></indent>", "", "<indent=2%>-Order: <style=cIsUtility>" + deviceName + "</style></indent>", "<indent=4%><style=cStack>Tracking Number: " + trackingNumber + "</style></indent>", "", "<indent=2%>-Order Description: " + devicePickupDesc + "</indent>", "", "<indent=2%>-Shipping Method: <style=cIsHealth>" + shippingMethod + "</style></indent>", "", "", "", "<indent=2%>-Order Details: " + orderDetails + "</indent>", "", "", "", "<style=cStack>Delivery being brought to you by the brand new </style><style=cIsUtility>Orbital Drop-Crate System (TM)</style>. <style=cStack><u>No refunds.</u></style>" }; return string.Join("\n", value); } } public static class MiscUtil { public class FilingDictionary<T> : IEnumerable<T>, IEnumerable { private readonly Dictionary<Type, T> _dict = new Dictionary<Type, T>(); public int Count => _dict.Count; public void Add(T inst) { _dict.Add(inst.GetType(), inst); } public void Add<subT>(subT inst) where subT : T { _dict.Add(typeof(subT), (T)(object)inst); } public void Set<subT>(subT inst) where subT : T { _dict[typeof(subT)] = (T)(object)inst; } public subT Get<subT>() where subT : T { return (subT)(object)_dict[typeof(subT)]; } public void Remove(T inst) { _dict.Remove(inst.GetType()); } public void RemoveWhere(Func<T, bool> predicate) { foreach (T item in _dict.Values.Where(predicate).ToList()) { _dict.Remove(item.GetType()); } } public IEnumerator<T> GetEnumerator() { return _dict.Values.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public ReadOnlyFilingDictionary<T> AsReadOnly() { return new ReadOnlyFilingDictionary<T>(this); } } public class ReadOnlyFilingDictionary<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable { private readonly FilingDictionary<T> baseCollection; public int Count => baseCollection.Count; public ReadOnlyFilingDictionary(FilingDictionary<T> baseCollection) { this.baseCollection = baseCollection; } public IEnumerator<T> GetEnumerator() { return baseCollection.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return baseCollection.GetEnumerator(); } } public static List<CharacterMaster> AliveList(bool playersOnly = false) { if (playersOnly) { return (from x in PlayerCharacterMasterController.instances where x.isConnected && Object.op_Implicit((Object)(object)x.master) && x.master.hasBody && x.master.GetBody().healthComponent.alive select x.master).ToList(); } return CharacterMaster.readOnlyInstancesList.Where((CharacterMaster x) => x.hasBody && x.GetBody().healthComponent.alive).ToList(); } public static void SpawnItemFromBody(CharacterBody src, int tier, Xoroshiro128Plus rng) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = tier switch { 1 => Run.instance.availableTier2DropList, 2 => Run.instance.availableTier3DropList, 3 => Run.instance.availableLunarItemDropList, 4 => Run.instance.availableEquipmentDropList, 5 => Run.instance.availableLunarEquipmentDropList, 0 => Run.instance.availableTier1DropList, _ => throw new ArgumentOutOfRangeException("tier", tier, "spawnItemFromBody: Item tier must be between 0 and 5 inclusive"), }; PickupDropletController.CreatePickupDroplet(list[rng.RangeInt(0, list.Count)], src.transform.position, new Vector3(Random.Range(-5f, 5f), 20f, Random.Range(-5f, 5f))); } } public class ModCompat { internal static bool compatBetterUI; public static void Init() { if (Chainloader.PluginInfos.ContainsKey("com.xoxfaby.BetterUI")) { BetterUICompatInit(); } } public static void BetterUICompatInit() { compatBetterUI = true; } } public class HereticPerishSong : BaseSkillState { [SerializeField] public string soundName = "Play_heretic_squawk"; public SphereSearch sphereSearch = new SphereSearch(); public float duration = 3f; public int index = 0; public int count = 0; private HurtBox[] hurtBoxes; public override void