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 CompanyIssuedProtogen v1.0.0
CompanyIssuedProtogen.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using CompanyIssuedProtogen.Protogen; using CompanyIssuedProtogen.Tools; using GameNetcodeStuff; using HarmonyLib; using Steamworks; using Steamworks.Data; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("CompanyIssuedProtogen")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A ScottyFoxArt Lethal Company Mod : Company Issued Protogen! ")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CompanyIssuedProtogen")] [assembly: AssemblyTitle("CompanyIssuedProtogen")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class WigglyBones : MonoBehaviour { public float damping = 12f; private List<Transform> bones = new List<Transform>(); private List<Quaternion> relativeRotations = new List<Quaternion>(); private List<Quaternion> oldRotations = new List<Quaternion>(); private void Start() { InitializeBones(); } private void InitializeBones() { TraverseHierarchy(((Component)this).transform); } private void TraverseHierarchy(Transform root) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown Stack<Transform> stack = new Stack<Transform>(); stack.Push(root); while (stack.Count > 0) { Transform val = stack.Pop(); if ((Object)(object)val != (Object)(object)((Component)this).transform) { bones.Add(val); relativeRotations.Add(Quaternion.Inverse(val.parent.rotation) * val.rotation); oldRotations.Add(val.rotation); } foreach (Transform item2 in val) { Transform item = item2; stack.Push(item); } } } private void Update() { ApplyJiggleEffect(); } private void ApplyJiggleEffect() { //IL_0015: 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_0026: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < bones.Count; i++) { Quaternion val = bones[i].parent.rotation * relativeRotations[i]; bones[i].rotation = Quaternion.Slerp(oldRotations[i], val, damping * Time.deltaTime); oldRotations[i] = bones[i].rotation; } } } namespace CompanyIssuedProtogen { internal class BoneMimicHandler : MonoBehaviour { private struct BonePair { public Transform original; public Transform target; public bool rotation; public bool position; public Vector3 offset; public Vector3 rotation_offset; public BonePair(Transform original, Transform target, bool rotation = false, bool position = false) { //IL_001e: 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_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) this.original = target; this.target = target; this.rotation = rotation; this.position = position; offset = Vector3.zero; rotation_offset = Vector3.zero; } } private List<BonePair> bonePairs = new List<BonePair>(); private Dictionary<string, Transform> original_reference; private Dictionary<string, Transform> target_reference; public void ClearReferences() { original_reference.Clear(); target_reference.Clear(); } public void BuildOriginalReference(Transform target) { original_reference = BuildReference(target); } public void BuildTargetReference(Transform target) { target_reference = BuildReference(target); } private Dictionary<string, Transform> BuildReference(Transform target) { Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); Transform[] componentsInChildren = ((Component)target).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!dictionary.ContainsKey(((Object)val).name)) { dictionary.Add(((Object)val).name, val); } } return dictionary; } public void ResetBonePairs() { bonePairs.Clear(); } public Transform GetOriginalBone(string name) { Transform value = null; if (original_reference != null) { original_reference.TryGetValue(name, out value); } return value; } public Transform GetTargetBone(string name) { Transform value = null; if (target_reference != null) { target_reference.TryGetValue(name, out value); } return value; } public void PairBones(string original, string target, bool rotation = true, bool position = true) { if (rotation || position) { PairBones(GetOriginalBone(original), GetTargetBone(target), rotation, position); } } public void PairBones(string original, string target, Vector3 offset, Vector3 rotation_offset, bool rotation = true, bool position = true) { //IL_0018: 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) if (rotation || position) { PairBones(GetOriginalBone(original), GetTargetBone(target), offset, rotation_offset, rotation, position); } } public void PairBones(Transform original, string target, bool rotation = true, bool position = true) { if (rotation || position) { PairBones(original, GetTargetBone(target), rotation, position); } } public void PairBones(Transform original, string target, Vector3 offset, Vector3 rotation_offset, bool rotation = true, bool position = true) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (rotation || position) { PairBones(original, GetTargetBone(target), offset, rotation_offset, rotation, position); } } public void PairBones(string original, Transform target, bool rotation = true, bool position = true) { if (rotation || position) { PairBones(GetOriginalBone(original), target, rotation, position); } } public void PairBones(string original, Transform target, Vector3 offset, Vector3 rotation_offset, bool rotation = true, bool position = true) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (rotation || position) { PairBones(GetOriginalBone(original), target, offset, rotation_offset, rotation, position); } } public void PairBones(Transform original, Transform target, bool rotation = true, bool position = true) { if (Object.op_Implicit((Object)(object)original) && Object.op_Implicit((Object)(object)target) && (rotation || position)) { bonePairs.Add(SetUpBonePair(original, target, rotation, position)); } } public void PairBones(Transform original, Transform target, Vector3 offset, Vector3 rotation_offset, bool rotation = true, bool position = true) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)original) && Object.op_Implicit((Object)(object)target) && (rotation || position)) { bonePairs.Add(SetUpBonePair(original, target, offset, rotation_offset, rotation, position)); } } private BonePair SetUpBonePair(Transform original, Transform target, bool rotation = true, bool position = true) { BonePair result = default(BonePair); result.original = original; result.target = target; result.rotation = rotation; result.position = position; return result; } private BonePair SetUpBonePair(Transform original, Transform target, Vector3 offset, Vector3 rotation_offset, bool rotation = true, bool position = true) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) BonePair result = default(BonePair); result.original = original; result.target = target; result.rotation = rotation; result.position = position; if (rotation) { result.rotation_offset = rotation_offset; } if (position) { result.offset = offset; } return result; } private void SyncBones() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) foreach (BonePair bonePair in bonePairs) { if (Object.op_Implicit((Object)(object)bonePair.original) && Object.op_Implicit((Object)(object)bonePair.target)) { if (bonePair.rotation) { bonePair.original.eulerAngles = bonePair.target.eulerAngles + bonePair.rotation_offset; } if (bonePair.position) { bonePair.original.position = bonePair.target.position + bonePair.offset; } } } } private void LateUpdate() { SyncBones(); } } internal class SimpleIKHandler : MonoBehaviour { private Transform lefthand; private Transform righthand; private Transform leftfoot; private Transform rightfoot; private Animator animator; private void Start() { animator = ((Component)this).GetComponent<Animator>(); } public void SetLeftHand(Transform target) { lefthand = target; } public void SetRightHand(Transform target) { righthand = target; } public void SetLeftFoot(Transform target) { leftfoot = target; } public void SetRightFoot(Transform target) { rightfoot = target; } private void OnAnimatorIK(int layerIndex) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)animator)) { if (Object.op_Implicit((Object)(object)leftfoot)) { animator.SetIKPositionWeight((AvatarIKGoal)0, 1f); animator.SetIKRotationWeight((AvatarIKGoal)0, 1f); animator.SetIKPosition((AvatarIKGoal)0, leftfoot.position); animator.SetIKRotation((AvatarIKGoal)0, leftfoot.rotation); } if (Object.op_Implicit((Object)(object)rightfoot)) { animator.SetIKPositionWeight((AvatarIKGoal)1, 1f); animator.SetIKRotationWeight((AvatarIKGoal)1, 1f); animator.SetIKPosition((AvatarIKGoal)1, rightfoot.position); animator.SetIKRotation((AvatarIKGoal)1, rightfoot.rotation); } if (Object.op_Implicit((Object)(object)lefthand)) { animator.SetIKPositionWeight((AvatarIKGoal)2, 1f); animator.SetIKRotationWeight((AvatarIKGoal)2, 1f); animator.SetIKPosition((AvatarIKGoal)2, lefthand.position); animator.SetIKRotation((AvatarIKGoal)2, lefthand.rotation); } if (Object.op_Implicit((Object)(object)righthand)) { animator.SetIKPositionWeight((AvatarIKGoal)3, 1f); animator.SetIKRotationWeight((AvatarIKGoal)3, 1f); animator.SetIKPosition((AvatarIKGoal)3, righthand.position); animator.SetIKRotation((AvatarIKGoal)3, righthand.rotation); } } } } [BepInPlugin("CompanyIssuedProtogen", "CompanyIssuedProtogen", "1.0.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Logger; private void Awake() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; try { Logger.LogInfo((object)"Plugin CompanyIssuedProtogen"); Logger.LogInfo((object)"Dressing Up Protogens"); if (ProtogenPrefabs.Init()) { Logger.LogInfo((object)"Teaching Protogens Emotions"); ProtogenExpressions.BuildExpressions(); Logger.LogInfo((object)"Spray Painting Protogens"); Logger.LogInfo((object)"Patching Protogens In."); new Harmony("SFXArt.CompanyIssuedProtoGen").PatchAll(Assembly.GetExecutingAssembly()); Logger.LogInfo((object)"Plugin CompanyIssuedProtogen is loaded!"); } else { Logger.LogError((object)"Could not load assets...!"); } } catch (Exception) { Logger.LogInfo((object)"Plugin CompanyIssuedProtogen failed to load..."); } } } public static class TextureTools { public static void DominantColors(Texture2D texture, out bool isDark, out Color mainColor, out Color secondaryColor) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) Color[] pixels = texture.GetPixels(); Dictionary<Color, int> dictionary = new Dictionary<Color, int>(); Color val = Color.white; int num = 0; Color val2 = Color.black; float num2 = 0f; Color val3 = Color.black; Color[] array = pixels; float num3 = default(float); float num4 = default(float); float num5 = default(float); foreach (Color val4 in array) { if (dictionary.ContainsKey(val4)) { dictionary[val4]++; } else { dictionary.Add(val4, 1); } if (dictionary[val4] > num) { num = dictionary[val4]; val = val4; } Color.RGBToHSV(val4, ref num3, ref num4, ref num5); if ((double)num5 > 0.5 || val2 == Color.black) { if (num4 == num2) { val2 = Color.Lerp(val2, val4, 0.5f); } else if (num4 > num2) { val2 = val4; num2 = num4; } } val3 += val4; } val3 /= (float)pixels.Length; float num6 = default(float); float num7 = default(float); Color.RGBToHSV(val, ref num3, ref num6, ref num7); isDark = (double)num7 < 0.5; float num8 = default(float); float num9 = default(float); float num10 = default(float); Color.RGBToHSV(val3, ref num8, ref num9, ref num10); float num11 = default(float); float num12 = default(float); Color.RGBToHSV(val2, ref num6, ref num11, ref num12); mainColor = val; secondaryColor = Color.HSVToRGB(num8, Mathf.Lerp(num9, num11, 0.5f), Mathf.Lerp(num10, num12, 0.5f)); if (mainColor == secondaryColor) { if (isDark) { secondaryColor = Color.white; } else { secondaryColor = Color.black; } } } public static Color[] FlatColor(int width, int height, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } return array; } } public static class PluginInfo { public const string PLUGIN_GUID = "CompanyIssuedProtogen"; public const string PLUGIN_NAME = "CompanyIssuedProtogen"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace CompanyIssuedProtogen.Tools { internal class AssetHelper { private AssetBundle assetbundle; private Dictionary<string, Object> assets = new Dictionary<string, Object>(); public void LoadAssetsStripped(string path, string prefix) { assetbundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), path)); string[] allAssetNames = assetbundle.GetAllAssetNames(); foreach (string text in allAssetNames) { if (text.StartsWith(prefix)) { string text2 = text.Remove(0, prefix.Length); if (!assets.ContainsKey(text2)) { assets.Add(text2, assetbundle.LoadAsset(text)); } else { Debug.LogWarning((object)("StrippedAsset : " + text2 + " : Already Exists.")); } } } assetbundle.Unload(false); } public T Get<T>(string name) where T : Object { if (!assets.TryGetValue(name, out var value)) { return default(T); } return (T)(object)value; } public bool Has<T>(string name, out T asset) where T : Object { asset = (assets.TryGetValue(name, out var value) ? ((T)(object)value) : default(T)); return (Object)(object)asset != (Object)null; } } public static class PixelKit { public static void HSV(ref Color original, float H, float S, float V) { //IL_0004: 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) original = Color.HSVToRGB(H, S, V); } public static void HV(ref Color original, float H, float V) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(H, num2, V); } public static void HS(ref Color original, float H, float S) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(H, S, num3); } public static void SV(ref Color original, float S, float V) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(num, S, V); } public static void Hue(ref Color original, float amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(amount, num2, num3); } public static void Saturate(ref Color original, float amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(num, amount, num3); } public static void Value(ref Color original, float amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(original, ref num, ref num2, ref num3); original = Color.HSVToRGB(num, num2, amount); } public static void Multiply(ref Color original, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //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_000d: Unknown result type (might be due to invalid IL or missing references) original *= color; } public static void Invert(ref Color original) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) original -= Color.white; } public static Color Lerp_Mask(Color original, Color reference, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return Color.Lerp(original, color, 1f - reference.r); } public static Color Lerp_Alpha(Color original, Color reference) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0008: Unknown result type (might be due to invalid IL or missing references) return Color.Lerp(original, reference, reference.a); } } } namespace CompanyIssuedProtogen.Protogen { internal static class ProtogenBones { public static BoneMimicHandler AttachBones(ProtogenHandler protogen) { Transform target = ((Component)((Component)protogen.player).GetComponentInChildren<LODGroup>()).transform.Find("metarig"); GameObject gameObject = ((Component)protogen).gameObject; gameObject.AddComponent<SimpleIKHandler>(); BoneMimicHandler boneMimicHandler = gameObject.AddComponent<BoneMimicHandler>(); AttachToTarget(boneMimicHandler, ((Component)protogen).transform, target); return boneMimicHandler; } public static BoneMimicHandler AttachTempBones(ProtogenHandler protogen, Transform target) { BoneMimicHandler boneMimicHandler = ((Component)protogen).gameObject.AddComponent<BoneMimicHandler>(); AttachToTarget(boneMimicHandler, ((Component)protogen).transform, target); return boneMimicHandler; } private static void AttachToTarget(BoneMimicHandler bones, Transform original, Transform target) { bones.ResetBonePairs(); bones.BuildOriginalReference(original); bones.BuildTargetReference(target); bones.PairBones(original, target); if (!Object.op_Implicit((Object)(object)bones.GetTargetBone("spine"))) { bones.PairBones("Spine", "spine.001"); } else { bones.PairBones("Spine", "spine"); } bones.PairBones("Chest", "spine.003", rotation: true, position: false); bones.PairBones("Neck", "spine.004", rotation: true, position: false); bones.PairBones("Head", "spine.004_end", rotation: true, position: false); bones.PairBones("shoulder.L", "shoulder.L", rotation: true, position: false); bones.PairBones("upper_arm.L", "arm.L_upper", rotation: true, position: false); bones.PairBones("forearm.L", "arm.L_lower", rotation: true, position: false); bones.PairBones("hand.L", "hand.L", rotation: true, position: false); bones.PairBones("Index01.L", "finger2.L", rotation: true, position: false); bones.PairBones("Middle01.L", "finger3.L", rotation: true, position: false); bones.PairBones("Middle01.L.001", "finger3.L.001", rotation: true, position: false); bones.PairBones("Thumb01.L", "finger1.L", rotation: true, position: false); bones.PairBones("shoulder.R", "shoulder.R", rotation: true, position: false); bones.PairBones("upper_arm.R", "arm.R_upper", rotation: true, position: false); bones.PairBones("forearm.R", "arm.R_lower", rotation: true, position: false); bones.PairBones("hand.R", "hand.R", rotation: true, position: false); bones.PairBones("Index01.R", "finger2.R", rotation: true, position: false); bones.PairBones("Middle01.R", "finger3.R", rotation: true, position: false); bones.PairBones("Middle01.R.001", "finger3.R.001", rotation: true, position: false); bones.PairBones("Thumb01.R", "finger1.R", rotation: true, position: false); bones.PairBones("thigh.L", "thigh.L"); bones.PairBones("shin.L", "shin.L", rotation: true, position: false); bones.PairBones("foot.L", "foot.L"); bones.PairBones("toe.L", "toe.L", rotation: true, position: false); bones.PairBones("thigh.R", "thigh.R"); bones.PairBones("shin.R", "shin.R", rotation: true, position: false); bones.PairBones("foot.R", "foot.R"); bones.PairBones("toe.R", "toe.R", rotation: true, position: false); } public static void AttachWigglyBones(Transform original) { if (!Object.op_Implicit((Object)(object)((Component)original).GetComponent<WigglyBones>())) { ((Component)original).gameObject.AddComponent<WigglyBones>(); } } public static void UpdateIKTargets(Transform original, BoneMimicHandler bones) { SimpleIKHandler component = ((Component)original).GetComponent<SimpleIKHandler>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)bones)) { component.SetLeftHand(bones.GetTargetBone("hand.L")); component.SetRightHand(bones.GetTargetBone("hand.R")); component.SetLeftFoot(bones.GetTargetBone("foot.L")); component.SetRightFoot(bones.GetTargetBone("foot.R")); } } } public enum FacialExpression { None, Default, Dance, Point, Paranoid, Crash } internal static class ProtogenExpressions { private static Material[] expressions; public static void BuildExpressions() { if (expressions == null) { expressions = (Material[])(object)new Material[6]; expressions[0] = CreateUnLitExpressionMaterial(ProtogenPrefabs.face_none); expressions[1] = CreateLitExpressionMaterial(ProtogenPrefabs.face_default); expressions[2] = CreateLitExpressionMaterial(ProtogenPrefabs.face_dance); expressions[3] = CreateLitExpressionMaterial(ProtogenPrefabs.face_point); expressions[4] = CreateLitExpressionMaterial(ProtogenPrefabs.face_paranoid); expressions[5] = CreateLitExpressionMaterial(ProtogenPrefabs.face_crash); } } private static Material CreateUnLitExpressionMaterial(Texture2D texture) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Material val = new Material(ProtogenPrefabs.face_unlit); val.SetTexture("_BaseColorMap", (Texture)(object)texture); return val; } private static Material CreateLitExpressionMaterial(Texture2D texture) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown Material val = new Material(ProtogenPrefabs.face_lit); val.SetTexture("_BaseColorMap", (Texture)(object)texture); val.SetTexture("_EmissiveColorMap", (Texture)(object)texture); return val; } public static Material GetFacialMaterial(FacialExpression expression) { return expressions[(int)expression]; } } internal class ProtogenHandler : MonoBehaviour { public bool isAttached; private bool isInitialized; public bool validDeadbody; public PlayerControllerB player; public Transform body; public Renderer bodyRenderer; public Transform ears; public Renderer earsRenderer; public Transform tail; public Renderer tailRenderer; public Transform tank; public Renderer tankRenderer; public BoneMimicHandler bones; public BoneMimicHandler temp_bones; private FacialExpression expression; private Material[] body_materials; public void UpdateCosmetics() { ProtogenTextureKit textureKit = ProtogenManager.GetTextureKit(ProtogenUtil.GetPlayerID(player)); ProtogenTextures.ApplyTextures(this, textureKit); ProtogenTextures.UpdateSuit(this); body_materials = bodyRenderer.materials; } public void UpdateExpression() { FacialExpression facialExpression = expression; facialExpression = ((!player.isPlayerDead) ? (player.performingEmote ? ((player.playerBodyAnimator.GetInteger("emoteNumber") <= 1) ? FacialExpression.Dance : FacialExpression.Point) : ((player.playersManager.fearLevel >= 0.9f && player.insanityLevel > player.maxInsanityLevel / 2f) ? FacialExpression.Crash : ((!(player.playersManager.fearLevel >= 0.9f) && !(player.insanityLevel > player.maxInsanityLevel / 2f)) ? ((!(player.playersManager.fearLevel >= 0.4f) && !(player.insanityLevel > 0f)) ? FacialExpression.Default : FacialExpression.Point) : FacialExpression.Paranoid))) : FacialExpression.None); if (facialExpression != expression) { expression = facialExpression; body_materials[3] = ProtogenExpressions.GetFacialMaterial(expression); bodyRenderer.materials = body_materials; } } public void Initialize() { if (!isInitialized) { body = ((Component)this).transform.Find("ProtoBody"); bodyRenderer = (Renderer)(object)((Component)body).GetComponent<SkinnedMeshRenderer>(); ((Component)this).gameObject.AddComponent<SimpleIKHandler>(); ears = Object.Instantiate<GameObject>(ProtogenPrefabs.prefab_ears).transform; earsRenderer = (Renderer)(object)((Component)ears).GetComponent<SkinnedMeshRenderer>(); tail = Object.Instantiate<GameObject>(ProtogenPrefabs.prefab_tail).transform; tailRenderer = (Renderer)(object)((Component)tail).GetComponent<SkinnedMeshRenderer>(); tank = Object.Instantiate<GameObject>(ProtogenPrefabs.prefab_tank).transform; tankRenderer = (Renderer)(object)((Component)tank).GetComponent<MeshRenderer>(); ((Component)ears).gameObject.AddComponent<WigglyBones>(); ((Component)tail).gameObject.AddComponent<WigglyBones>(); body_materials = bodyRenderer.materials; isInitialized = true; } } public void AttachToPlayer(PlayerControllerB player) { this.player = player; bones = ProtogenBones.AttachBones(this); ears.SetParent(bones.GetOriginalBone("Head"), false); tail.SetParent(bones.GetOriginalBone("Spine"), false); tank.SetParent(bones.GetOriginalBone("Chest"), false); ProtogenBones.UpdateIKTargets(((Component)this).transform, bones); isAttached = true; IsVisible(visible: true); ((Component)this).transform.SetParent(((Component)player).transform, false); } public void RemoveFromPlayer() { IsVisible(visible: false); RemoveFromDeadBody(); Object.DestroyImmediate((Object)(object)bones); bones = null; isAttached = false; validDeadbody = false; player = null; ((Component)this).transform.SetParent((Transform)null, false); } public void AttachToDeadBody() { if (HasDeadBody()) { temp_bones = ProtogenBones.AttachTempBones(this, ((Component)player.deadBody).transform); } } public void RemoveFromDeadBody() { Object.DestroyImmediate((Object)(object)temp_bones); temp_bones = null; validDeadbody = false; } public bool HasDeadBody() { if (player.isPlayerDead) { if (!((Object)(object)player.deadBody == (Object)null)) { return ((Component)player.deadBody).gameObject.activeSelf; } return false; } return false; } public void UpdateVisuals() { bool visible = ((isAttached && (HasDeadBody() || !player.isPlayerDead) && (HasDeadBody() || !ProtogenUtil.IsLocal(player))) ? true : false); if (player.isPlayerDead) { if (Object.op_Implicit((Object)(object)temp_bones) && !validDeadbody) { RemoveFromDeadBody(); } else if (!Object.op_Implicit((Object)(object)temp_bones) && validDeadbody) { AttachToDeadBody(); } } else if (Object.op_Implicit((Object)(object)temp_bones)) { RemoveFromDeadBody(); } IsVisible(visible); } public void IsVisible(bool visible) { bodyRenderer.enabled = visible; earsRenderer.enabled = visible; tailRenderer.enabled = visible; tankRenderer.enabled = visible; IsTracking(visible); FollowBody(visible); } public void IsTracking(bool tracking) { if (Object.op_Implicit((Object)(object)bones) && !Object.op_Implicit((Object)(object)temp_bones)) { ((Behaviour)bones).enabled = tracking; } else { ((Behaviour)bones).enabled = false; } if (Object.op_Implicit((Object)(object)temp_bones)) { ((Behaviour)temp_bones).enabled = tracking; } } public void FollowBody(bool follow) { //IL_0042: 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 (follow) { if (Object.op_Implicit((Object)(object)temp_bones)) { ((Component)this).transform.position = ((Component)player.deadBody).transform.position; } else { ((Component)this).transform.position = ((Component)player).transform.position; } } } private void Awake() { } private void Start() { } private void Update() { } private void LateUpdate() { UpdateVisuals(); UpdateExpression(); } private void OnEnable() { } private void OnDisable() { IsVisible(visible: false); } private void OnDestroy() { Plugin.Logger.LogError((object)"UH OH THAT WASN'T SUPPOSED TO HAPPEN...!"); Plugin.Logger.LogError((object)"A PROTOGEN WAS DESTROYED! PANIC...!"); Plugin.Logger.LogError((object)"REMOVING PROTOGEN TO PREVENT ERROR...!"); ProtogenManager.RemoveProtogen(player); } } internal static class ProtogenManager { private static Dictionary<PlayerControllerB, ProtogenHandler> PlayerProtogens = new Dictionary<PlayerControllerB, ProtogenHandler>(); private static Dictionary<ulong, ProtogenTextureKit> TextureKits = new Dictionary<ulong, ProtogenTextureKit>(); private static Stack<ProtogenHandler> ProtogenPool = new Stack<ProtogenHandler>(); public static bool HasProtogen(PlayerControllerB player, out ProtogenHandler protogen) { protogen = null; if (PlayerProtogens != null) { PlayerProtogens.TryGetValue(player, out protogen); } return (Object)(object)protogen != (Object)null; } public static ProtogenHandler GetProtogen(PlayerControllerB player) { ProtogenHandler value = null; if (!PlayerProtogens.TryGetValue(player, out value)) { value = CreateProtogen(); PlayerProtogens.Add(player, value); value.AttachToPlayer(player); value.UpdateCosmetics(); } return value; } public static void RemoveProtogen(PlayerControllerB player) { if (PlayerProtogens.TryGetValue(player, out var value)) { value.RemoveFromPlayer(); Object.Destroy((Object)(object)value); } PlayerProtogens.Remove(player); } public static ProtogenTextureKit GetTextureKit(ulong playerID) { if (!TextureKits.TryGetValue(playerID, out var value)) { value = ProtogenTextures.BuildTextures(playerID); TextureKits.Add(playerID, value); } return value; } private static ProtogenHandler CreateProtogen() { ProtogenHandler protogenHandler = Object.Instantiate<GameObject>(ProtogenPrefabs.prefab_body).AddComponent<ProtogenHandler>(); protogenHandler.Initialize(); return protogenHandler; } } internal static class ProtogenPrefabs { private const string ASSETBUNDLE = "companyprotogen"; private const string VERSIONFILE = "Assets/Protogen/version.txt"; private const string VERSION = "RELEASE_1"; private const string BODY_SUIT = "Assets/Protogen/FurPatterns/Body/Suit.png"; private const string BODY_PAWS_DETAIL = "Assets/Protogen/FurPatterns/Body/PawDetail.png"; private const string BODY_PAWS = "Assets/Protogen/FurPatterns/Body/Paws.png"; private const string BODY_REGAL = "Assets/Protogen/FurPatterns/Body/Regal.png"; private const string BODY_SHADE = "Assets/Protogen/FurPatterns/Body/Shade.png"; private const string BODY_SPOTTY = "Assets/Protogen/FurPatterns/Body/Spotty.png"; private const string BODY_STRIPED = "Assets/Protogen/FurPatterns/Body/Striped.png"; private const string EARS_INNER = "Assets/Protogen/FurPatterns/Ears/Inner.png"; private const string EARS_STRIPED = "Assets/Protogen/FurPatterns/Ears/Striped.png"; private const string EARS_TIPPED = "Assets/Protogen/FurPatterns/Ears/Tipped.png"; private const string TAIL_REGAL = "Assets/Protogen/FurPatterns/Tail/Regal.png"; private const string TAIL_SHAPES = "Assets/Protogen/FurPatterns/Tail/Shapes.png"; private const string TAIL_SPOTTY = "Assets/Protogen/FurPatterns/Tail/Spotty.png"; private const string TAIL_STRIPED = "Assets/Protogen/FurPatterns/Tail/Striped.png"; private const string PREFAB_PROTO = "Assets/Protogen/Prefabs/ProtoPrefab.prefab"; private const string PREFAB_EARS = "Assets/Protogen/Prefabs/ProtoEarsPrefab.prefab"; private const string PREFAB_TAIL = "Assets/Protogen/Prefabs/ProtoTailLongPrefab.prefab"; private const string PREFAB_TANK = "Assets/Protogen/Prefabs/ProtoTankPrefab.prefab"; private const string TEXTURES_ICON = "Assets/Protogen/Textures/defaulticon.png"; private const string TEXTURES_BODY = "Assets/Protogen/Textures/BodyTex.png"; private const string TEXTURES_EARS = "Assets/Protogen/Textures/EarsTex.png"; private const string TEXTURES_TAIL = "Assets/Protogen/Textures/TailTex.png"; private const string FACES_MAT_UNLIT = "Assets/Protogen/Faces/ProtoUnLitScreenMat.mat"; private const string FACES_MAT_LIT = "Assets/Protogen/Faces/ProtoScreenMat.mat"; private const string FACES_NONE = "Assets/Protogen/Faces/ScreenPlaceholder.png"; private const string FACES_DEFAULT = "Assets/Protogen/Faces/DefaultFace.png"; private const string FACES_DANCE = "Assets/Protogen/Faces/DanceFace.png"; private const string FACES_POINT = "Assets/Protogen/Faces/PointFace.png"; private const string FACES_PARANOID = "Assets/Protogen/Faces/ParanoidFace.png"; private const string FACES_CRASH = "Assets/Protogen/Faces/CrashFace.png"; public static AssetBundle assetbundle; public static GameObject prefab_body; public static GameObject prefab_ears; public static GameObject prefab_tail; public static GameObject prefab_tank; public static Texture2D fur_body_suit; public static Texture2D fur_body_paws_detail; public static Texture2D fur_body_paws; public static Texture2D fur_body_regal; public static Texture2D fur_body_shade; public static Texture2D fur_body_spotty; public static Texture2D fur_body_striped; public static Texture2D fur_ears_inner; public static Texture2D fur_ears_striped; public static Texture2D fur_ears_tipped; public static Texture2D fur_tail_regal; public static Texture2D fur_tail_shapes; public static Texture2D fur_tail_spotty; public static Texture2D fur_tail_striped; public static Texture2D icon_default; public static Texture2D body_default; public static Texture2D ears_default; public static Texture2D tail_default; public static Material face_unlit; public static Material face_lit; public static Texture2D face_none; public static Texture2D face_default; public static Texture2D face_dance; public static Texture2D face_point; public static Texture2D face_paranoid; public static Texture2D face_crash; public static bool Init() { assetbundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "companyprotogen")); if (assetbundle.LoadAsset<TextAsset>("Assets/Protogen/version.txt").text != "RELEASE_1") { Plugin.Logger.LogError((object)"Assetbundle is outdated/incompatible!"); return false; } prefab_body = assetbundle.LoadAsset<GameObject>("Assets/Protogen/Prefabs/ProtoPrefab.prefab"); prefab_ears = assetbundle.LoadAsset<GameObject>("Assets/Protogen/Prefabs/ProtoEarsPrefab.prefab"); prefab_tail = assetbundle.LoadAsset<GameObject>("Assets/Protogen/Prefabs/ProtoTailLongPrefab.prefab"); prefab_tank = assetbundle.LoadAsset<GameObject>("Assets/Protogen/Prefabs/ProtoTankPrefab.prefab"); fur_body_suit = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Suit.png"); fur_body_paws_detail = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/PawDetail.png"); fur_body_paws = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Paws.png"); fur_body_regal = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Regal.png"); fur_body_shade = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Shade.png"); fur_body_spotty = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Spotty.png"); fur_body_striped = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Body/Striped.png"); fur_ears_inner = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Ears/Inner.png"); fur_ears_striped = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Ears/Striped.png"); fur_ears_tipped = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Ears/Tipped.png"); fur_tail_regal = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Tail/Regal.png"); fur_tail_shapes = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Tail/Shapes.png"); fur_tail_spotty = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Tail/Spotty.png"); fur_tail_striped = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/FurPatterns/Tail/Striped.png"); icon_default = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Textures/defaulticon.png"); body_default = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Textures/BodyTex.png"); ears_default = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Textures/EarsTex.png"); tail_default = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Textures/TailTex.png"); face_unlit = assetbundle.LoadAsset<Material>("Assets/Protogen/Faces/ProtoUnLitScreenMat.mat"); face_lit = assetbundle.LoadAsset<Material>("Assets/Protogen/Faces/ProtoScreenMat.mat"); face_none = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/ScreenPlaceholder.png"); face_default = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/DefaultFace.png"); face_dance = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/DanceFace.png"); face_point = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/PointFace.png"); face_paranoid = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/ParanoidFace.png"); face_crash = assetbundle.LoadAsset<Texture2D>("Assets/Protogen/Faces/CrashFace.png"); return true; } } internal class ProtogenTextureKit { public bool isDark; public Color mainColor; public Color secondaryColor; public Texture2D icon; public Texture2D body; public Texture2D ears; public Texture2D tail; public MaterialPropertyBlock iconProp; public MaterialPropertyBlock bodyProp; public MaterialPropertyBlock earsProp; public MaterialPropertyBlock tailProp; } internal class ProtogenTextures { public static void ApplyTextures(ProtogenHandler protogen, ProtogenTextureKit texKit) { protogen.bodyRenderer.SetPropertyBlock(texKit.iconProp, 2); protogen.bodyRenderer.SetPropertyBlock(texKit.bodyProp, 0); protogen.earsRenderer.SetPropertyBlock(texKit.earsProp); protogen.tailRenderer.SetPropertyBlock(texKit.tailProp); } public static void UpdateSuit(ProtogenHandler protogen) { MaterialPropertyBlock val = CreateProperty(StartOfRound.Instance.unlockablesList.unlockables[protogen.player.currentSuitID].suitMaterial.mainTexture); protogen.bodyRenderer.SetPropertyBlock(val, 1); protogen.tankRenderer.SetPropertyBlock(val); } public static ProtogenTextureKit BuildTextures(ulong playerID) { ProtogenTextureKit kit = new ProtogenTextureKit(); kit.icon = ProtogenUtil.GetPlayerIcon(playerID); TextureTools.DominantColors(kit.icon, out kit.isDark, out kit.mainColor, out kit.secondaryColor); RandomizeTextures(playerID, ref kit); kit.iconProp = CreateEmissiveProperty((Texture)(object)kit.icon); kit.bodyProp = CreateProperty((Texture)(object)kit.body); kit.tailProp = CreateProperty((Texture)(object)kit.tail); kit.earsProp = CreateProperty((Texture)(object)kit.ears); return kit; } private static void RandomizeTextures(ulong seed, ref ProtogenTextureKit kit) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown Color[] array = RandomizeBody(seed, kit); Color[] array2 = RandomizeEars(seed, kit); Color[] array3 = RandomizeTail(seed, kit); kit.body = new Texture2D(1024, 1024, (TextureFormat)3, true); kit.ears = new Texture2D(512, 512, (TextureFormat)3, true); kit.tail = new Texture2D(512, 512, (TextureFormat)3, true); kit.body.SetPixels(0, 0, 1024, 1024, array); kit.ears.SetPixels(0, 0, 512, 512, array2); kit.tail.SetPixels(0, 0, 512, 512, array3); kit.body.Apply(); kit.ears.Apply(); kit.tail.Apply(); } public static Color[] RandomizeBody(ulong seed, ProtogenTextureKit kit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) int magic = 45634; Color mainColor = kit.mainColor; List<int> list = DeckShuffle(seed, 4); int num = (int)(GenerateRandomNumber(mainColor, magic, seed) % list.Count()); Color[] array = null; switch ((num < list.Count) ? list[num] : (-1)) { case 0: array = ProtogenPrefabs.fur_body_striped.GetPixels(); break; case 1: array = ProtogenPrefabs.fur_body_spotty.GetPixels(); break; case 2: array = ProtogenPrefabs.fur_body_shade.GetPixels(); break; case 3: array = ProtogenPrefabs.fur_body_regal.GetPixels(); break; } Color[] array2 = TextureTools.FlatColor(1024, 1024, kit.isDark ? kit.mainColor : kit.secondaryColor); Color[] pixels = ProtogenPrefabs.fur_body_suit.GetPixels(); Color[] pixels2 = ProtogenPrefabs.fur_body_paws.GetPixels(); Color[] pixels3 = ProtogenPrefabs.fur_body_paws_detail.GetPixels(); Color color = (kit.isDark ? kit.secondaryColor : kit.mainColor); Color val = (kit.isDark ? Color.white : Color.black); Color val2 = Color.Lerp(val, kit.mainColor, 0.5f); val2 = Color.Lerp(val2, kit.secondaryColor, 0.25f); for (int i = 0; i < array2.Length; i++) { if (array != null) { array2[i] = PixelKit.Lerp_Mask(array2[i], array[i], color); } array2[i] = PixelKit.Lerp_Mask(array2[i], pixels2[i], val2); array2[i] = PixelKit.Lerp_Mask(array2[i], pixels3[i], val); array2[i] = PixelKit.Lerp_Alpha(array2[i], pixels[i]); } return array2; } public static Color[] RandomizeEars(ulong seed, ProtogenTextureKit kit) { //IL_0007: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) int magic = 185139221; Color mainColor = kit.mainColor; List<int> list = DeckShuffle(seed, 2); int num = (int)(GenerateRandomNumber(mainColor, magic, seed) % list.Count()); Color[] array = null; switch ((num < list.Count) ? list[num] : (-1)) { case 0: array = ProtogenPrefabs.fur_ears_striped.GetPixels(); break; case 1: array = ProtogenPrefabs.fur_ears_tipped.GetPixels(); break; } Color[] array2 = TextureTools.FlatColor(512, 512, kit.isDark ? kit.mainColor : kit.secondaryColor); Color[] pixels = ProtogenPrefabs.fur_ears_inner.GetPixels(); Color color = (kit.isDark ? kit.secondaryColor : kit.mainColor); for (int i = 0; i < array2.Length; i++) { if (array != null) { array2[i] = PixelKit.Lerp_Mask(array2[i], array[i], color); } array2[i] = PixelKit.Lerp_Mask(array2[i], pixels[i], color); } return array2; } public static Color[] RandomizeTail(ulong seed, ProtogenTextureKit kit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) int magic = 9472735; Color mainColor = kit.mainColor; List<int> list = DeckShuffle(seed, 4); int num = (int)(GenerateRandomNumber(mainColor, magic, seed) % list.Count()); Color[] array = null; switch ((num < list.Count) ? list[num] : (-1)) { case 0: array = ProtogenPrefabs.fur_tail_striped.GetPixels(); break; case 1: array = ProtogenPrefabs.fur_tail_spotty.GetPixels(); break; case 2: array = ProtogenPrefabs.fur_tail_shapes.GetPixels(); break; case 3: array = ProtogenPrefabs.fur_tail_regal.GetPixels(); break; } Color[] array2 = TextureTools.FlatColor(512, 512, kit.isDark ? kit.mainColor : kit.secondaryColor); Color color = (kit.isDark ? kit.secondaryColor : kit.mainColor); for (int i = 0; i < array2.Length; i++) { if (array != null) { array2[i] = PixelKit.Lerp_Mask(array2[i], array[i], color); } } return array2; } public static MaterialPropertyBlock CreateProperty(Texture texture) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetTexture("_BaseColorMap", texture); return val; } public static MaterialPropertyBlock CreateEmissiveProperty(Texture texture) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetTexture("_BaseColorMap", texture); val.SetTexture("_EmissiveColorMap", texture); return val; } public static List<int> DeckShuffle(ulong seed, int size) { List<int> list = new List<int>(); for (int i = 0; i < size; i++) { if (seed << list.Count % 2 == 0L) { list.Insert(0, i); } else { list.Add(i); } } return list; } public static uint GenerateRandomNumber(Color salt, int magic, ulong seed) { //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_000d: Unknown result type (might be due to invalid IL or missing references) Random random = new Random((int)((ulong)((salt.r + salt.g + salt.b) * (float)magic) ^ seed)); byte[] array = new byte[4]; random.NextBytes(array); return BitConverter.ToUInt32(array, 0); } } internal class ProtogenUtil { public static bool IsLocal(PlayerControllerB player) { return (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController; } public static ulong GetPlayerID(PlayerControllerB player) { if (GameNetworkManager.Instance.disableSteam) { return player.actualClientId; } return player.playerSteamId; } public static Texture2D GetPlayerIcon(ulong steamID) { Texture2D val = null; if (!GameNetworkManager.Instance.disableSteam) { Image? avatarSynchronously = GetAvatarSynchronously(steamID); if (avatarSynchronously.HasValue) { val = HUDManager.GetTextureFromImage(avatarSynchronously); } } if (!Object.op_Implicit((Object)(object)val)) { val = Object.Instantiate<Texture2D>(ProtogenPrefabs.icon_default); } return val; } private static Image? GetAvatarSynchronously(ulong steamID) { Task<Image?> task = Task.Run(async delegate { try { return await SteamFriends.GetLargeAvatarAsync(SteamId.op_Implicit(steamID)); } catch (Exception ex) { Debug.Log((object)ex); return null; } }); task.Wait(); return task.Result; } } } namespace CompanyIssuedProtogen.Patches { [HarmonyPatch] internal static class DeadBodyPatch { public static void ApplyValidBodyMesh(ref DeadBodyInfo __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (ProtogenManager.HasProtogen(__instance.playerScript, out var protogen)) { SkinnedMeshRenderer componentInChildren = ((Component)__instance).GetComponentInChildren<SkinnedMeshRenderer>(); if ((int)__instance.causeOfDeath != 0) { protogen.validDeadbody = true; ((Renderer)componentInChildren).enabled = false; } else { protogen.validDeadbody = false; ((Renderer)componentInChildren).enabled = true; } } } [HarmonyPatch(typeof(DeadBodyInfo), "Start")] [HarmonyPostfix] private static void DeadBodyPatch_Start_Postfix_Patch(ref DeadBodyInfo __instance) { ApplyValidBodyMesh(ref __instance); } [HarmonyPatch(typeof(DeadBodyInfo), "ChangeMesh")] [HarmonyPostfix] private static void DeadBodyPatch_ChangeMesh_Postfix_Patch(ref DeadBodyInfo __instance) { ApplyValidBodyMesh(ref __instance); } [HarmonyPatch(typeof(DeadBodyInfo), "OnDestroy")] [HarmonyPostfix] private static void DeadBodyPatch_OnDestroy_Postfix_Patch(ref DeadBodyInfo __instance) { ApplyValidBodyMesh(ref __instance); PlayerPatch.PatchAllPlayer(); } } [HarmonyPatch] internal static class HUDManagerPatch { [HarmonyPatch(typeof(HUDManager), "SetLevelOfPlayer")] [HarmonyPostfix] public static void HUDManagerPatch_SetLevelOfPlayer_Postfix_Patch(ref HUDManager __instance, PlayerControllerB playerScript, int playerLevelIndex, bool hasBeta) { } } [HarmonyPatch] internal static class PlayerPatch { public static void AutoPatchVisuals(PlayerControllerB player) { LODGroup componentInChildren = ((Component)player).GetComponentInChildren<LODGroup>(); ((Renderer)((Component)((Component)componentInChildren).transform.Find("LOD1")).GetComponent<SkinnedMeshRenderer>()).enabled = false; ((Renderer)((Component)((Component)componentInChildren).transform.Find("LOD2")).GetComponent<SkinnedMeshRenderer>()).enabled = false; ((Renderer)((Component)((Component)componentInChildren).transform.Find("LOD3")).GetComponent<SkinnedMeshRenderer>()).enabled = false; componentInChildren.enabled = false; ProtogenManager.GetProtogen(player); } public static void PatchAllPlayer() { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { AutoPatchVisuals(allPlayerScripts[i]); } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void PlayerControllerB_Start_Postfix_Patch(PlayerControllerB __instance) { PatchAllPlayer(); } [HarmonyPatch(typeof(PlayerControllerB), "DisablePlayerModel")] [HarmonyPostfix] public static void PlayerControllerB_DisablePlayerModel_Postfix_Patch(PlayerControllerB __instance) { PatchAllPlayer(); } [HarmonyPatch(typeof(PlayerControllerB), "SpawnPlayerAnimation")] [HarmonyPostfix] public static void PlayerControllerB_SpawnPlayerAnimation_Postfix_Patch(PlayerControllerB __instance) { PatchAllPlayer(); } [HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadBody")] [HarmonyPrefix] public static void PlayerControllerB_SpawnDeadBody_Prefix_Patch(PlayerControllerB __instance) { PatchAllPlayer(); if (ProtogenManager.HasProtogen(__instance, out var protogen)) { protogen.validDeadbody = true; } } [HarmonyPatch(typeof(PlayerControllerB), "OnDestroy")] [HarmonyPostfix] private static void PlayerControllerB_OnDestroy_Postfix_Patch(ref PlayerControllerB __instance) { ProtogenManager.RemoveProtogen(__instance); } } [HarmonyPatch] internal static class QuickMenuManagerPatch { [HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")] [HarmonyPostfix] public static void AddUserToPlayerList_Postfix_Patch(QuickMenuManager __instance) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { if (ProtogenManager.HasProtogen(allPlayerScripts[i], out var protogen)) { protogen.UpdateCosmetics(); } } } [HarmonyPatch(typeof(QuickMenuManager), "RemoveUserFromPlayerList")] [HarmonyPostfix] public static void RemoveUserFromPlayerList_Postfix_Patch(QuickMenuManager __instance) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { if (ProtogenManager.HasProtogen(allPlayerScripts[i], out var protogen)) { protogen.UpdateCosmetics(); } } } } [HarmonyPatch] internal class UnlockableSuitPatch { [HarmonyPatch(typeof(UnlockableSuit), "SwitchSuitForPlayer")] [HarmonyPostfix] public static void UnlockableSuitPatch_SwitchSuitForPlayer_Postfix_Patch(UnlockableSuit __instance, PlayerControllerB player, int suitID, bool playAudio) { if (ProtogenManager.HasProtogen(player, out var protogen)) { protogen.UpdateCosmetics(); } } } }