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 Gorp v1.0.0
plugins/GorpMod.dll
Decompiled a day 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.AI.Walker; using EntityStates.DefectiveUnit; using EntityStates.Gup; using EntityStates.Poltergeist; using GorpMod.Characters.Enemies.Gorp; using GorpMod.Characters.Enemies.Gorp.Comopnents; using GorpMod.Characters.Enemies.Gorp.States; using GorpMod.Enemies.Gorp.Content; using GorpMod.Modules; using GorpMod.Modules.Characters; using GorpMod.Modules.Components; using HG.BlendableTypes; using HG.Reflection; using JetBrains.Annotations; using KinematicCharacterController; using On.RoR2; using R2API; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Achievements; using RoR2.AsyncManagement; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using RoR2BepInExPack.GameAssetPathsBetter; using ShaderSwapper; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [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: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyInformationalVersion("1.0.0+b539640433c8c3bb1a0281349d110c7fa5d0d969")] [assembly: AssemblyProduct("GorpMod")] [assembly: AssemblyTitle("GorpMod")] [assembly: AssemblyCompany("GorpMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Matchmaker { public static class Util { public static bool IsDebug => CharacterConfig.Debug.Value; public static Vector3 ToVector3(this Vector2 vector) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector.x, vector.y, 0f); } public static Vector3 ToVector3(this Vector2Int vector) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new Vector3((float)((Vector2Int)(ref vector)).x, (float)((Vector2Int)(ref vector)).y, 0f); } public static Vector2 ToVector2(this Vector3 vector) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(vector.x, vector.y); } public static Vector2 ToVector2(this Vector2Int vector) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return new Vector2((float)((Vector2Int)(ref vector)).x, (float)((Vector2Int)(ref vector)).y); } public static Vector2Int RoundToInt(this Vector2 vector) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector2Int(Mathf.RoundToInt(vector.x), Mathf.RoundToInt(vector.y)); } public static Vector2Int FloorToInt(this Vector2 vector) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector2Int(Mathf.FloorToInt(vector.x), Mathf.FloorToInt(vector.y)); } public static bool FAILSAFE(ref int count) { count++; if (count > 100000) { Debug.LogError((object)"FAILSAFE"); return true; } return false; } public static float ExpDecayLerp(float a, float b, float decay, float deltaTime) { return b + (a - b) * Mathf.Exp((0f - decay) * deltaTime); } public static Vector3 ExpDecayLerp(Vector3 a, Vector3 b, float decay, float deltaTime) { //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_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_001c: 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) return b + (a - b) * Mathf.Exp((0f - decay) * deltaTime); } public static Color ExpDecayLerp(Color a, Color b, float decay, float deltaTime) { //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_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_001c: 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) return b + (a - b) * Mathf.Exp((0f - decay) * deltaTime); } public static void NormalizeSpriteScale(SpriteRenderer spriteRenderer, float scale) { //IL_0007: 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_001d: 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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)spriteRenderer).transform; Vector3 val = Vector3.one * scale * spriteRenderer.sprite.pixelsPerUnit; Rect rect = spriteRenderer.sprite.rect; transform.localScale = val / ((Rect)(ref rect)).width; } public static int WeightedRandom(List<float> values, bool normalize = true) { if (normalize) { values.Normalize(); } float num = 0f; float value = Random.value; for (int i = 0; i < values.Count; i++) { num += values[i]; if (value <= num) { return i; } } return 0; } public static void Normalize(this List<float> weights) { float num = 0f; for (int i = 0; i < weights.Count; i++) { num += weights[i]; } if (num > 0f) { for (int j = 0; j < weights.Count; j++) { weights[j] /= num; } } } } } namespace GorpMod { [BepInPlugin("com.TheTimesweeper.Gorp", "Gorp", "0.1.0")] public class GorpPlugin : BaseUnityPlugin { public const string MODUID = "com.TheTimesweeper.Gorp"; public const string MODNAME = "Gorp"; public const string MODVERSION = "0.1.0"; public const string DEVELOPER_PREFIX = "HABIBI"; public static GorpPlugin instance; private void Awake() { instance = this; Log.Init(((BaseUnityPlugin)this).Logger); Materials.Init(); Language.Init(); new GorpCharacter().Initialize(); new ContentPacks().Initialize(); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCGorp(ConCommandArgs args) { //IL_0013: 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_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_0035: 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_0076: 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_0056: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) CharacterBody senderBody = ((ConCommandArgs)(ref args)).GetSenderBody(); InputBankTest inputBank = senderBody.inputBank; Ray val = default(Ray); ((Ray)(ref val))..ctor(inputBank.aimOrigin, inputBank.aimDirection); Vector3 val2 = senderBody.transform.position; RaycastHit val3 = default(RaycastHit); if (Util.CharacterRaycast(((Component)senderBody).gameObject, val, ref val3, float.PositiveInfinity, ((LayerIndex)(ref LayerIndex.world)).mask, (QueryTriggerInteraction)1)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.3f; } GameObject val4 = Object.Instantiate<GameObject>(GorpCharacter.BossEncounter, val2, Quaternion.identity); if (NetworkServer.active) { NetworkServer.Spawn(val4); } } } internal static class Log { private static ManualLogSource _logSource; public static DateTime _startTime = default(DateTime); private static string timesLog = ""; private static string funnyLog = ""; 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); } internal static bool CheckNullAndWarn(string name, object objecte) { Warning($"{name} is {objecte != null}"); return objecte != null; } internal static void WarningDebug(string format, params object[] data) { DebugWarning(format, data); } internal static void DebugWarning(string format, params object[] data) { bool flag = false; } internal static void CurrentTime(string funny) { bool flag = false; } internal static void AllTimes() { if (!string.IsNullOrEmpty(timesLog)) { Warning(timesLog); Warning(funnyLog); } } } } namespace GorpMod.Modules { internal static class Asset { internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>(); internal static Dictionary<string, Action<AssetBundle>> loadingBundles = new Dictionary<string, Action<AssetBundle>>(); internal static AssetBundle LoadAssetBundle(string bundleName) { AssetBundle result = null; try { result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)GorpPlugin.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}"); } return result; } internal static void LoadAssetBundleAsync(string bundleName, Action<AssetBundle> onComplete) { if (bundleName == "myassetbundle") { Log.Error("AssetBundle name hasn't been changed. not loading any assets to avoid conflicts. Everything will now break.\nMake sure to rename your assetbundle filename and rename the AssetBundleName field in your character setup code."); } if (loadedBundles.ContainsKey(bundleName)) { onComplete(loadedBundles[bundleName]); return; } if (loadingBundles.ContainsKey(bundleName)) { Dictionary<string, Action<AssetBundle>> dictionary = loadingBundles; string key = bundleName; dictionary[key] = (Action<AssetBundle>)Delegate.Combine(dictionary[key], onComplete); return; } loadingBundles[bundleName] = onComplete; string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)GorpPlugin.instance).Info.Location), "AssetBundles", bundleName); Action<AssetBundle> onComplete2 = delegate(AssetBundle bundle) { loadedBundles[bundleName] = bundle; if (loadingBundles.ContainsKey(bundleName)) { loadingBundles[bundleName]?.Invoke(bundle); loadingBundles.Remove(bundleName); } }; ContentPacks.asyncLoadCoroutines.Add(LoadAssetBundleFromPathAsync(path, onComplete2)); } internal static IEnumerator LoadAssetBundleFromPathAsync(string path, Action<AssetBundle> onComplete) { AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path); while (!((AsyncOperation)request).isDone) { yield return null; } onComplete?.Invoke(request.assetBundle); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void RunShaderSwaper(AssetBundleCreateRequest request) { ContentPacks.asyncLoadCoroutines.Add(ShaderSwapper.UpgradeStubbedShadersAsync(request.assetBundle)); } internal static void LoadAssetAsync<T>(this AssetBundle assetBundle, string name, Action<T> onComplete) where T : Object { ContentPacks.asyncLoadCoroutines.Add(assetBundle.LoadAssetCoroutine(name, onComplete)); } internal static void LoadAssetAsync<T>(string Path, Action<T> onComplete) where T : Object { ContentPacks.asyncLoadCoroutines.Add(LoadAssetCoroutine(Path, onComplete)); } internal static AsyncAsset<T> AddAsyncAsset<T>(this AssetBundle assetBundle, string name, Action<T> onComplete = null) where T : Object { return new AsyncAsset<T>(assetBundle, name, onComplete).AddCoroutine(); } internal static AsyncAsset<T> AddAsyncAsset<T>(string path, Action<T> onComplete = null) where T : Object { return new AsyncAsset<T>(path, onComplete).AddCoroutine(); } internal static IEnumerator LoadAssetCoroutine<T>(this AssetBundle assetBundle, string name, Action<T> onComplete) where T : Object { AssetBundleRequest request = assetBundle.LoadAssetAsync<T>(name); while (!((AsyncOperation)request).isDone) { yield return null; } onComplete?.Invoke((T)(object)/*isinst with value type is only supported in some contexts*/); } internal static IEnumerator LoadAssetCoroutine<T>(object key, Action<T> OnComplete) where T : Object { AsyncOperationHandle<T> loadAsset = Addressables.LoadAssetAsync<T>(key); while (!loadAsset.IsDone) { yield return null; } OnComplete?.Invoke(loadAsset.Result); } internal static void LoadAssetsAsync<T1>(AsyncAsset<T1> load1, Action<T1> onComplete) where T1 : Object { ContentPacks.asyncLoadCoroutines.Add(LoadAssetsAsyncCoroutine(load1, onComplete)); } internal static IEnumerator LoadAssetsAsyncCoroutine<T1>(AsyncAsset<T1> load1, Action<T1> onComplete) where T1 : Object { while (!load1.coroutine.MoveNext()) { yield return null; } onComplete(load1.result); } internal static void LoadAssetsAsync<T1, T2>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, Action<T1, T2> onComplete) where T1 : Object where T2 : Object { ContentPacks.asyncLoadCoroutines.Add(LoadAssetsAsyncCoroutine(load1, load2, onComplete)); } internal static IEnumerator LoadAssetsAsyncCoroutine<T1, T2>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, Action<T1, T2> onComplete) where T1 : Object where T2 : Object { while (!load1.coroutine.MoveNext()) { yield return null; } while (!load2.coroutine.MoveNext()) { yield return null; } onComplete(load1.result, load2.result); } internal static void LoadAssetsAsync<T1, T2, T3>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, AsyncAsset<T3> load3, Action<T1, T2, T3> onComplete) where T1 : Object where T2 : Object where T3 : Object { ContentPacks.asyncLoadCoroutines.Add(LoadAssetsAsyncCoroutine(load1, load2, load3, onComplete)); } internal static IEnumerator LoadAssetsAsyncCoroutine<T1, T2, T3>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, AsyncAsset<T3> load3, Action<T1, T2, T3> onComplete) where T1 : Object where T2 : Object where T3 : Object { while (!load1.coroutine.MoveNext()) { yield return null; } while (!load2.coroutine.MoveNext()) { yield return null; } while (!load3.coroutine.MoveNext()) { yield return null; } onComplete(load1.result, load2.result, load3.result); } internal static void LoadAssetsAsync<T1, T2, T3, T4>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, AsyncAsset<T3> load3, AsyncAsset<T4> load4, Action<T1, T2, T3, T4> onComplete) where T1 : Object where T2 : Object where T3 : Object where T4 : Object { ContentPacks.asyncLoadCoroutines.Add(LoadAssetsAsyncCoroutine(load1, load2, load3, load4, onComplete)); } internal static IEnumerator LoadAssetsAsyncCoroutine<T1, T2, T3, T4>(AsyncAsset<T1> load1, AsyncAsset<T2> load2, AsyncAsset<T3> load3, AsyncAsset<T4> load4, Action<T1, T2, T3, T4> onComplete) where T1 : Object where T2 : Object where T3 : Object where T4 : Object { while (!load1.coroutine.MoveNext()) { yield return null; } while (!load2.coroutine.MoveNext()) { yield return null; } while (!load3.coroutine.MoveNext()) { yield return null; } while (!load4.coroutine.MoveNext()) { yield return null; } onComplete(load1.result, load2.result, load3.result, load4.result); } internal static IEnumerator LoadFromAddressableOrBundle<T>(AssetBundle assetBundle, string bundlePath, string addressablePath, Action<T> OnComplete) where T : Object { if (!string.IsNullOrEmpty(bundlePath)) { return assetBundle.LoadAssetCoroutine(bundlePath, OnComplete); } if (!string.IsNullOrEmpty(addressablePath)) { return LoadAssetCoroutine(addressablePath, OnComplete); } return null; } internal static IEnumerator PreLoadAssetsAsync<T>(AssetBundle assetBundle, params string[] paths) where T : Object { List<IEnumerator> coroutines = PreLoadAssetsAsyncCoroutines<T>(assetBundle, paths); for (int i = 0; i < coroutines.Count; i++) { while (coroutines[i].MoveNext()) { yield return null; } } } internal static List<IEnumerator> PreLoadAssetsAsyncCoroutines<T>(AssetBundle assetBundle, params string[] paths) where T : Object { List<IEnumerator> list = new List<IEnumerator>(); for (int i = 0; i < paths.Length; i++) { list.Add(assetBundle.LoadAssetCoroutine<T>(paths[i], null)); } return list; } internal static IEnumerator LoadBuffIconAsync(BuffDef buffDef, AssetBundle assetBundle, string bundleLoadPath) { return assetBundle.LoadAssetCoroutine<Sprite>(bundleLoadPath, (Action<Sprite>)delegate(Sprite result) { buffDef.iconSprite = result; }); } internal static IEnumerator LoadBuffIconAsync(BuffDef buffDef, string addressablePath) { return Asset.LoadAssetCoroutine<Sprite>((object)addressablePath, (Action<Sprite>)delegate(Sprite result) { buffDef.iconSprite = result; }); } public static void RecolorEffects(Color color, GameObject MercSwordSlash) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0031: 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_0055: Unknown result type (might be due to invalid IL or missing references) ParticleSystemRenderer[] componentsInChildren = MercSwordSlash.GetComponentsInChildren<ParticleSystemRenderer>(); ParticleSystemRenderer[] array = componentsInChildren; foreach (ParticleSystemRenderer val in array) { ((Renderer)val).sharedMaterial = new Material(((Renderer)val).sharedMaterial); ((Renderer)val).sharedMaterial.SetColor("_MainColor", color); ((Renderer)val).sharedMaterial.SetColor("_Color", color); ((Renderer)val).sharedMaterial.SetColor("_TintColor", color); } } internal static GameObject DebugClone(this GameObject gameObject, bool network = false) { bool flag = false; return gameObject; } internal static GameObject CloneTracer(string originalTracerName, string newTracerName) { GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = PrefabAPI.InstantiateClone(val, newTracerName, true); if (!Object.op_Implicit((Object)(object)val2.GetComponent<EffectComponent>())) { val2.AddComponent<EffectComponent>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<VFXAttributes>())) { val2.AddComponent<VFXAttributes>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<NetworkIdentity>())) { val2.AddComponent<NetworkIdentity>(); } val2.GetComponent<Tracer>().speed = 250f; val2.GetComponent<Tracer>().length = 50f; Content.CreateAndAddEffectDef(val2); return val2; } internal static void ConvertAllRenderersToHopooShader(GameObject objectToConvert) { if (Object.op_Implicit((Object)(object)objectToConvert)) { MeshRenderer[] componentsInChildren = objectToConvert.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { ((Renderer)val).sharedMaterial?.ConvertDefaultShaderToHopoo(); } SkinnedMeshRenderer[] componentsInChildren2 = objectToConvert.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { ((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) { GameObject val = assetBundle.LoadAsset<GameObject>(resourceName); if (!Object.op_Implicit((Object)(object)val)) { Log.ErrorAssetBundle(resourceName, ((Object)assetBundle).name); return null; } CreateEffectFromObject(val, soundName, parentToTransform); return val; } internal static void CreateEffectFromObject(GameObject newEffect, string soundName, bool parentToTransform) { //IL_0032: 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) newEffect.AddComponent<DestroyOnTimer>().duration = 6f; newEffect.AddComponent<NetworkIdentity>(); if (!Object.op_Implicit((Object)(object)newEffect.GetComponent<VFXAttributes>())) { newEffect.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; } EffectComponent component = newEffect.GetComponent<EffectComponent>(); if (!Object.op_Implicit((Object)(object)component)) { component = newEffect.AddComponent<EffectComponent>(); component.applyScale = true; component.effectIndex = (EffectIndex)(-1); component.parentToReferencedTransform = parentToTransform; component.positionAtReferencedTransform = true; component.soundName = soundName; } Content.CreateAndAddEffectDef(newEffect); } 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 class AsyncAsset<T> where T : Object { public T result; public bool isDone; public IEnumerator coroutine; public Action<T> onComplete; public static implicit operator T(AsyncAsset<T> asset) { return asset.result; } public AsyncAsset(string path_, Action<T> onComplete_ = null) { onComplete = onComplete_; coroutine = Asset.LoadAssetCoroutine<T>(path_, OnCoroutineComplete); } public AsyncAsset(AssetBundle bundle_, string name_, Action<T> onComplete_ = null) { onComplete = onComplete_; coroutine = bundle_.LoadAssetCoroutine<T>(name_, OnCoroutineComplete); } public AsyncAsset<T> AddCoroutine() { ContentPacks.asyncLoadCoroutines.Add(coroutine); return this; } public void OnCoroutineComplete(T loadResult) { result = loadResult; isDone = true; onComplete?.Invoke(result); } } internal static class CameraParams { internal static CharacterCameraParamsData CreateCameraParams(float pivotVerticalOffset, Vector3 idealPosition, float pitch = 70f, float wallCushion = 0.1f, float fov = 0f) { //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_0011: 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_0027: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0082: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) CharacterCameraParamsData result = new CharacterCameraParamsData { maxPitch = BlendableFloat.op_Implicit(pitch), minPitch = BlendableFloat.op_Implicit(0f - pitch), pivotVerticalOffset = BlendableFloat.op_Implicit(pivotVerticalOffset), idealLocalCameraPos = BlendableVector3.op_Implicit(idealPosition), wallCushion = BlendableFloat.op_Implicit(wallCushion) }; if (fov != 0f) { result.fov = new BlendableFloat { value = fov, alpha = 1f }; } return result; } internal static CameraParamsOverrideHandle OverrideCameraParams(CameraTargetParams camParams, CharacterCameraParamsData paramsData, float transitionDuration = 0.5f) { //IL_0003: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) CameraParamsOverrideRequest val = new CameraParamsOverrideRequest { cameraParamsData = paramsData, priority = 1f }; return camParams.AddParamsOverride(val, transitionDuration); } } public class ConfigEntry { } public class ConfigEntry<T> : ConfigEntry { public ConfigEntry<T> ActualConfigEntry; public T DefaultValue; public T Value { get { if (ActualConfigEntry != null) { return ActualConfigEntry.Value; } return DefaultValue; } } public static implicit operator T(ConfigEntry<T> config) { return config.Value; } public ConfigEntry(T defaultValue) { ActualConfigEntry = null; DefaultValue = defaultValue; } public ConfigEntry(ConfigEntry<T> actualConfigEntry, T defaultValue) { ActualConfigEntry = actualConfigEntry; DefaultValue = defaultValue; } } public static class Config { public static ConfigFile MyConfig = ((BaseUnityPlugin)GorpPlugin.instance).Config; private static List<string> disabledSections = new List<string>(); private static bool enableAllSections = false; private static bool loadedIcon; public static void DisableSection(string section) { disabledSections.Add(section); } private static bool SectionDisabled(string section) { return disabledSections.Contains(section); } public static void ConfigureBody(CharacterBody bodyComponent, string section, string bodyInfoTitle = "") { if (string.IsNullOrEmpty(bodyInfoTitle)) { bodyInfoTitle = ((Object)bodyComponent).name; } bodyComponent.baseMaxHealth = BindAndOptions(section, bodyInfoTitle + " Base Max Health", bodyComponent.baseMaxHealth, 0f, 10000f, "levelMaxHealth will be adjusted accordingly (baseMaxHealth * 0.3)", restartRequired: true).Value; bodyComponent.levelMaxHealth = Mathf.Round(bodyComponent.baseMaxHealth * 0.3f); bodyComponent.baseRegen = BindAndOptions(section, bodyInfoTitle + " Base Regen", bodyComponent.baseRegen, "levelRegen will be adjusted accordingly (baseRegen * 0.2)", restartRequired: true).Value; bodyComponent.levelRegen = bodyComponent.baseRegen * 0.2f; bodyComponent.baseArmor = BindAndOptions(section, bodyInfoTitle + " Armor", bodyComponent.baseArmor, "", restartRequired: true).Value; bodyComponent.baseDamage = BindAndOptions(section, bodyInfoTitle + " Base Damage", bodyComponent.baseDamage, "pretty much all survivors are 12. If you want to change damage, change damage of the moves instead.\nlevelDamage will be adjusted accordingly (baseDamage * 0.2)", restartRequired: true).Value; bodyComponent.levelDamage = bodyComponent.baseDamage * 0.2f; bodyComponent.baseMoveSpeed = BindAndOptions(section, bodyInfoTitle + " Base Move Speed", bodyComponent.baseMoveSpeed, "", restartRequired: true).Value; bodyComponent.baseJumpCount = BindAndOptions(section, bodyInfoTitle + " Jump Count", bodyComponent.baseJumpCount, "", restartRequired: true).Value; } public static void ConfigureSkillDef(SkillDef skillDef, string section, string skillTitle, bool cooldown = true, bool maxStock = true, bool rechargeStock = false) { if (cooldown) { skillDef.baseRechargeInterval = BindAndOptions(section, skillTitle + " cooldown", skillDef.baseRechargeInterval, 0f, 20f, "", restartRequired: true).Value; } if (maxStock) { skillDef.baseMaxStock = BindAndOptions(section, skillTitle + " stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value; } if (rechargeStock) { skillDef.rechargeStock = BindAndOptions(section, skillTitle + " recharge stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value; } } 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> BindAndOptionsSlider<T>(string section, string name, T defaultValue, float min = 0f, float max = 20f, string description = "", bool restartRequired = false) { return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired); } 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; } description += $"\nDefault: {defaultValue}"; if (restartRequired) { description += "\n(restart required)"; } if (!enableAllSections && SectionDisabled(section)) { return new ConfigEntry<T>(null, defaultValue); } ConfigEntry<T> val = MyConfig.Bind<T>(section, name, defaultValue, description); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { TryRegisterOption<T>(val, min, max, restartRequired); } return new ConfigEntry<T>(val, defaultValue); } public static ConfigEntry BindAndOptions(string section, string name, ValueType defaultValue, float min, float max, string description = "", bool restartRequired = false) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (defaultValue is float) { return BindAndOptions(section, name, (float)(object)defaultValue, min, max, description, restartRequired); } if (defaultValue is int) { return BindAndOptions(section, name, (int)(object)defaultValue, min, max, description, restartRequired); } if (defaultValue is bool) { return BindAndOptions(section, name, (bool)(object)defaultValue, min, max, description, restartRequired); } if (defaultValue is KeyboardShortcut) { return BindAndOptions<KeyboardShortcut>(section, name, (KeyboardShortcut)(object)defaultValue, min, max, description, restartRequired); } if (defaultValue == null) { Log.Error($"defaultvalue was null somehow for {section}:{name} {defaultValue}"); } Log.Error($"Configuring a field with unsupported type {defaultValue.GetType()} for {section}:{name}"); return null; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired) { //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_0021: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_007b: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown if (entry is ConfigEntry<float>) { ModSettingsManager.AddOption((BaseOption)new SliderOption(entry as ConfigEntry<float>, new SliderConfig { min = min, max = max, formatString = "{0:0.00}", restartRequired = restartRequired })); } if (entry is ConfigEntry<int>) { ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry as ConfigEntry<int>, new IntSliderConfig { min = (int)min, max = (int)max, restartRequired = restartRequired })); } if (entry is ConfigEntry<bool>) { ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry as ConfigEntry<bool>, restartRequired)); } if (entry is ConfigEntry<KeyboardShortcut>) { ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, restartRequired)); } if (!loadedIcon) { loadedIcon = true; try { ModSettingsManager.SetModIcon(ImgHandler.LoadSpriteFromModFolder("icon.png")); } catch (Exception ex) { Log.Error("error adding ROO mod icon\n" + ex); } } } public static void InitConfigAttributes(Type typeWithStaticConfigFieldsMakeSureTheyreStatic) { FieldInfo[] fields = typeWithStaticConfigFieldsMakeSureTheyreStatic.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { ConfigureAttribute customAttribute = fieldInfo.GetCustomAttribute<ConfigureAttribute>(); if (customAttribute != null) { customAttribute.InitFromField(fieldInfo); try { fieldInfo.SetValue(null, BindAndOptions(customAttribute.section, customAttribute.name, customAttribute.defaultValue, customAttribute.min, customAttribute.max, customAttribute.description, customAttribute.restartRequired)); } catch { throw new Exception("Error adding config " + customAttribute.section + ": " + customAttribute.name + "."); } } } } 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); } } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] public class ConfigureAttribute : Attribute { public string name; public string description; public float min = 0f; public float max = 20f; public bool restartRequired = false; public string section { get; private set; } public ValueType defaultValue { get; private set; } public ConfigureAttribute(string section, float defaultValue) { this.section = section; this.defaultValue = defaultValue; } public ConfigureAttribute(string section, int defaultValue) { this.section = section; this.defaultValue = defaultValue; } public ConfigureAttribute(string section, bool defaultValue) { this.section = section; this.defaultValue = defaultValue; } public ConfigureAttribute(string section, KeyboardShortcut defaultValue) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) this.section = section; this.defaultValue = (ValueType)(object)defaultValue; } public void InitFromField(FieldInfo fieldInfo) { if (string.IsNullOrEmpty(name)) { name = fieldInfo.Name; } if (string.IsNullOrEmpty(description)) { description = name; } } } internal class Content { internal static void AddEntityStateConfiguration(EntityStateConfiguration entityStateConfiguration) { ContentPacks.entityStateConfigurations.Add(entityStateConfiguration); } 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 NetworkAndAddProjectilePrefab(GameObject prefab) { PrefabAPI.RegisterNetworkPrefab(prefab); AddProjectilePrefab(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 AddNetworkedObject(GameObject gameObject) { ContentPacks.networkedObjects.Add(gameObject); } 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, bool isHidden) { //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; val.isHidden = isHidden; AddBuffDef(val); return val; } internal static void AddItemDef(ItemDef itemDef) { ContentPacks.itemDefs.Add(itemDef); } internal static ItemDef CreateAndAddItemDef(string itemName, Sprite iconSprite, ItemTier itemTier, bool hidden = false, bool canRemove = false) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return CreateAndAddItemDef("HABIBI" + itemName + "Item", itemName, iconSprite, itemTier, hidden, canRemove); } internal static ItemDef CreateAndAddItemDef(string itemname, string token, Sprite iconSprite, ItemTier itemTier, bool hidden = false, bool canRemove = false) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) ItemDef val = ScriptableObject.CreateInstance<ItemDef>(); ((Object)val).name = itemname; val.nameToken = "HABIBIITEM_" + token.ToUpperInvariant() + "_NAME"; val.descriptionToken = "HABIBIITEM_" + token.ToUpperInvariant() + "_DESCRIPTION"; val.pickupToken = "HABIBIITEM_" + token.ToUpperInvariant() + "_PICKUP"; val.loreToken = "HABIBIITEM_" + token.ToUpperInvariant() + "_LORE"; val.canRemove = canRemove; val.pickupIconSprite = iconSprite; val.hidden = hidden; val.tier = itemTier; val.deprecatedTier = itemTier; AddItemDef(val); return val; } internal static void AddEffectDef(EffectDef effectDef) { ContentPacks.effectDefs.Add(effectDef); } internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab, bool donotPool = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (donotPool) { VFXAttributes orAddComponent = effectPrefab.GetOrAddComponent<VFXAttributes>(); orAddComponent.DoNotPool = true; } 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<EntityStateConfiguration> entityStateConfigurations = new List<EntityStateConfiguration>(); public static List<BuffDef> buffDefs = new List<BuffDef>(); public static List<EffectDef> effectDefs = new List<EffectDef>(); public static List<ItemDef> itemDefs = new List<ItemDef>(); public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>(); public static List<GameObject> networkedObjects = new List<GameObject>(); public static List<IEnumerator> asyncLoadCoroutines = new List<IEnumerator>(); public string identifier => "com.TheTimesweeper.Gorp"; 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; Log.CurrentTime("LoadStaticContentAsync start"); for (int i = 0; i < asyncLoadCoroutines.Count; i++) { while (asyncLoadCoroutines[i].MoveNext()) { yield return null; } } Log.CurrentTime("LoadStaticContentAsync done"); contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray()); contentPack.masterPrefabs.Add(masterPrefabs.ToArray()); contentPack.projectilePrefabs.Add(projectilePrefabs.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.entityStateConfigurations.Add(entityStateConfigurations.ToArray()); contentPack.buffDefs.Add(buffDefs.ToArray()); contentPack.effectDefs.Add(effectDefs.ToArray()); contentPack.itemDefs.Add(itemDefs.ToArray()); contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray()); contentPack.networkedObjectPrefabs.Add(networkedObjects.ToArray()); args.ReportProgress(1f); } 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; } } public static class ImgHandler { public static Sprite LoadSprite(string path, string name) { Texture2D texture2D = LoadTex2D(path, pointFilter: true); return CreateSprite(texture2D, name); } public static Texture2D LoadTex2D(string fullFilePath, bool pointFilter = false) { Texture2D val = LoadPNG(fullFilePath, pointFilter); if (pointFilter) { ((Texture)val).filterMode = (FilterMode)0; val.Apply(); } return val; } private static Sprite CreateSprite(Texture2D texture2D, string name) { //IL_0038: 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) ((Object)texture2D).name = name; ((Texture)texture2D).filterMode = (FilterMode)0; texture2D.Apply(); Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, (float)((Texture)texture2D).width, (float)((Texture)texture2D).height); Sprite val2 = Sprite.Create(texture2D, val, new Vector2(0.5f, 0.5f), 16f); ((Object)val2).name = name; return val2; } public static Texture2D LoadPNG(params string[] pathDirectories) { string text = pathDirectories[0]; for (int i = 1; i < pathDirectories.Length; i++) { text = Path.Combine(text, pathDirectories[i]); } return LoadPNG(text); } public static Texture2D LoadPNG(string filePath, bool pointFilter = false) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2); byte[] array = File.ReadAllBytes(filePath); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)(!pointFilter); val.Apply(); return val; } internal static Sprite LoadSpriteFromModFolder(string fileName) { Texture2D texture2D = LoadTex2DFromPModFolder(fileName); return CreateSprite(texture2D, fileName); } internal static Texture2D LoadTex2DFromPModFolder(string fileName, bool pointFilter = false) { string fullFilePath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)GorpPlugin.instance).Info.Location), fileName); return LoadTex2D(fullFilePath, pointFilter); } } 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.KeyAssetDisplayRules.ContainsKey(item2)) { text3 += SpitOutNewRule(item2, text2, ItemDisplays.KeyAssetDisplayRules[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.KeyAssetDisplayRules.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.GetKeyAsset(\"" + 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[]> KeyAssetDisplayRules = new Dictionary<Object, ItemDisplayRule[]>(); public static Dictionary<string, Object> KeyAssets = new Dictionary<string, Object>(); public static bool initialized = false; public static bool initializing = false; public static event Action OnDisplaysPopulated; public static void SetItemDisplaysWhenReady(Action onComplete) { if (initialized) { onComplete?.Invoke(); return; } OnDisplaysPopulated += onComplete; if (!initializing) { initializing = true; ContentPacks.asyncLoadCoroutines.Add(PopulateDisplays()); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(DisposeWhenDone)); } } internal static void DisposeWhenDone() { initialized = false; initializing = false; itemDisplayPrefabs = null; KeyAssetDisplayRules = null; KeyAssets = null; } internal static Object GetKeyAsset(string key) { if (KeyAssets.ContainsKey(key)) { return KeyAssets[key]; } Log.Warning("shit not found for " + key); return null; } internal static IEnumerator PopulateDisplays() { IEnumerator loadIDRS = Asset.LoadAssetCoroutine<GameObject>((object)"RoR2/Base/Loader/LoaderBody.prefab", (Action<GameObject>)delegate(GameObject result) { PopulateFromBody(result); }); while (loadIDRS.MoveNext()) { yield return null; } PopulateCustomLightningArm(); initialized = true; ItemDisplays.OnDisplaysPopulated?.Invoke(); } private static void PopulateFromBody(GameObject bodyPrefab) { ItemDisplayRuleSet itemDisplayRuleSet = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).GetComponent<CharacterModel>().itemDisplayRuleSet; KeyAssetRuleGroup[] keyAssetRuleGroups = itemDisplayRuleSet.keyAssetRuleGroups; for (int i = 0; i < keyAssetRuleGroups.Length; i++) { ItemDisplayRule[] rules = keyAssetRuleGroups[i].displayRuleGroup.rules; KeyAssetDisplayRules[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 CreateGenericDisplayRule(Object itemDef, string prefabName, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_000c: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) return CreateDisplayRuleGroupWithRules(itemDef, CreateDisplayRule(prefabName, childName, position, rotation, scale)); } public static KeyAssetRuleGroup CreateGenericDisplayRule(Object itemDef, GameObject prefab, string childName, Vector3 position, Vector3 rotation, Vector3 scale) { //IL_000c: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) return CreateDisplayRuleGroupWithRules(itemDef, CreateDisplayRule(prefab, childName, position, rotation, scale)); } 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 = KeyAssets[itemName]; if (val == (Object)null) { Log.Error("Could not load keyasset for " + itemName); } return val; } } internal static class LanguageAPI { public static void Add(string token, string text) { Language.Add(token, text); } } internal static class Language { public static string TokensOutput = ""; public static bool printingEnabled = false; public static void Init() { Language.collectLanguageRootFolders += Language_collectLanguageRootFolders; } private static void Language_collectLanguageRootFolders(List<string> obj) { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)GorpPlugin.instance).Info.Location), "Language"); if (Directory.Exists(text)) { obj.Add(text); } } public static void Add(string token, string text) { LanguageAPI.Add(token, text, "en"); 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)GorpPlugin.instance).Info.Location).FullName, "Language", "english", fileName); File.WriteAllText(path, text); } TokensOutput = ""; } } } internal static class Materials { private static List<Material> cachedMaterials = new List<Material>(); internal static Shader _hotpoo; internal static Shader hotpoo { get { //IL_0021: 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 ((Object)(object)_hotpoo == (Object)null) { Log.Warning("Hotpoo was null. doing the big scary waitforcompletion"); _hotpoo = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion(); } return _hotpoo; } set { _hotpoo = value; } } public static void Init() { ContentPacks.asyncLoadCoroutines.Add(Asset.LoadAssetCoroutine<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader", (Action<Shader>)delegate(Shader result) { hotpoo = result; })); } [Obsolete("CreateHopooMaterialFromBundle is a bit more descriptive")] 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 loaded. 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) { material.SetFloat("_EmPower", emission); return material; } 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 IEnumerator CreateDisplayPrefabAsync(AssetBundle assetBundle, string displayPrefabName, GameObject characterModelObject, Action<GameObject> OnComplete) { return assetBundle.LoadAssetCoroutine<GameObject>(displayPrefabName, (Action<GameObject>)delegate(GameObject display) { if ((Object)(object)display == (Object)null) { Log.Error("could not load display prefab " + displayPrefabName + ". Make sure this prefab exists in assetbundle " + ((Object)assetBundle).name); OnComplete(null); } else { CharacterModel val = display.GetComponent<CharacterModel>(); if (!Object.op_Implicit((Object)(object)val)) { val = display.AddComponent<CharacterModel>(); } val.baseRendererInfos = characterModelObject.GetComponent<CharacterModel>().baseRendererInfos; Asset.ConvertAllRenderersToHopooShader(display); OnComplete(display); } }); } public static GameObject CreateDisplayPrefab(AssetBundle assetBundle, string displayPrefabName, GameObject bodyPrefab) { 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 = bodyPrefab.GetComponentInChildren<CharacterModel>().baseRendererInfos; Asset.ConvertAllRenderersToHopooShader(val); return val; } internal static IEnumerator LoadCharacterModelAsync(AssetBundle assetBundle, string modelName, Action<GameObject> onComplete) { return assetBundle.LoadAssetCoroutine<GameObject>(modelName, onComplete); } internal static IEnumerator CloneCharacterBodyAsync(GameObject modelObject, BodyInfo bodyInfo, Action<GameObject> onComplete) { return Asset.LoadAssetCoroutine<GameObject>((object)bodyInfo.bodyToClonePath, (Action<GameObject>)delegate(GameObject loadedBody) { if (!Object.op_Implicit((Object)(object)loadedBody)) { Log.Error(bodyInfo.bodyToClonePath + " Body to clone is not a valid body, character creation failed"); } else { GameObject val = PrefabAPI.InstantiateClone(loadedBody, bodyInfo.bodyName); for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } CreateBodyPrefab(val, modelObject, bodyInfo); onComplete?.Invoke(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 PrefabAPI.InstantiateClone(val, modelName, false); } 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); Skills.ClearGenericSkills(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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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.bodyFlags = bodyInfo.bodyFlags; component.sprintingSpeedMultiplier = 1.45f; 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_, BodyInfo bodyInfo_, 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>(); if (!flag) { SetupCustomRendererInfos(val, customInfos_); } else { SetupPreAttachedRendererInfos(val); } SetupHurtboxGroup(bodyPrefab_, ((Component)val).gameObject); if (bodyInfo_.hasAimAnimator) { SetupAimAnimator(bodyPrefab_, ((Component)val).gameObject); } if (bodyInfo_.hasFoostepController) { SetupFootstepController(((Component)val).gameObject); } if (bodyInfo_.hasRagdoll) { SetupRagdoll(((Component)val).gameObject); } if (bodyInfo_.hasSkinController) { SetupSkinController(((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}"); } else { 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bodyPrefab.GetComponent<HurtBoxGroup>() != (Object)null) { Log.Debug("HurtBoxGroup already exists on model prefab. aborting code setup"); return; } ChildLocator component = model.GetComponent<ChildLocator>(); if (!Object.op_Implicit((Object)(object)component.FindChild("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.FindChildGameObject("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.FindChildGameObject("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; } 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 footstepHandler = model.AddComponent<FootstepHandler>(); footstepHandler.baseFootstepString = "Play_player_footstep"; footstepHandler.sprintFootstepOverrideString = ""; footstepHandler.enableFootstepDust = true; ContentPacks.asyncLoadCoroutines.Add(Asset.LoadAssetCoroutine<GameObject>((object)"RoR2/Base/Common/VFX/GenericFootstepDust.prefab", (Action<GameObject>)delegate(GameObject result) { footstepHandler.footstepDustPrefab = result; })); } private static void SetupRagdoll(GameObject model) { RagdollController ragdollController = model.GetComponent<RagdollController>(); if (!Object.op_Implicit((Object)(object)ragdollController)) { return; } if ((Object)(object)ragdollMaterial == (Object)null) { ContentPacks.asyncLoadCoroutines.Add(Asset.LoadAssetCoroutine<PhysicMaterial>((object)"RoR2/Base/Common/physmatRagdoll.physicMaterial", (Action<PhysicMaterial>)delegate(PhysicMaterial result) { ragdollMaterial = result; SetupRagdollBones(ragdollController); })); } else { SetupRagdollBones(ragdollController); } } private static void SetupRagdollBones(RagdollController ragdollController) { Transform[] bones = ragdollController.bones; foreach (Transform val in bones) { if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.layer = LayerIndex.ragdoll.intVal; Collider component = ((Component)val).GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component)) { component.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>(); } private static void SetupSkinController(GameObject gameObject) { gameObject.GetOrAddComponent<ModelSkinController>(); } 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 void CloneDopplegangerMasterAsync(GameObject bodyPrefab, string masterName, string masterToCopyPath = "RoR2/Base/Merc/MercMonsterMaster.prefab", Action<GameObject> onComplete = null) { ContentPacks.asyncLoadCoroutines.Add(CloneDopplegangerMasterAsyncCoroutine(bodyPrefab, masterName, masterToCopyPath, onComplete)); } public static IEnumerator CloneDopplegangerMasterAsyncCoroutine(GameObject bodyPrefab, string masterName, string masterToCopyPath = "RoR2/Base/Merc/MercMonsterMaster.prefab", Action<GameObject> onComplete = null) { return Asset.LoadAssetCoroutine<GameObject>((object)masterToCopyPath, (Action<GameObject>)delegate(GameObject result) { GameObject val = PrefabAPI.InstantiateClone(result, masterName, true); val.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab; Content.AddMasterPrefab(val); onComplete?.Invoke(val); }); } public static GameObject CreateBlankMasterPrefab(GameObject bodyPrefab, string masterName) { GameObject master = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"); return CloneMaster(bodyPrefab, masterName, master); } public static IEnumerator CreateBlankMasterPrefabAsyncCoroutine(GameObject bodyPrefab, string masterName, Action<GameObject> onComplete) { return Asset.LoadAssetCoroutine<GameObject>((object)"RoR2/Base/Commando/CommandoMonsterMaster.prefab", (Action<GameObject>)delegate(GameObject result) { onComplete(CloneMaster(bodyPrefab, masterName, result)); }); } public static void CreateBlankMasterPrefabAsync(GameObject bodyPrefab, string masterName, Action<GameObject> onComplete) { ContentPacks.asyncLoadCoroutines.Add(Asset.LoadAssetCoroutine<GameObject>((object)"RoR2/Base/Commando/CommandoMonsterMaster.prefab", (Action<GameObject>)delegate(GameObject result) { onComplete(CloneMaster(bodyPrefab, masterName, result)); })); } private static GameObject CloneMaster(GameObject bodyPrefab, string masterName, GameObject master) { GameObject val = PrefabAPI.InstantiateClone(master, 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>(); } } 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 i