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 hololive 5th Generation v1.0.6
NePoLaBoSuit.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using ModelReplacement; using ModelReplacement.AvatarBodyUpdater; using ModelReplacement.Scripts.Enemies; using ModelReplacement.Scripts.Player; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCopyright("© 2016 cover corp.")] [assembly: AssemblyFileVersion("1.0.6")] [assembly: AssemblyInformationalVersion("1.0.6")] [assembly: AssemblyVersion("1.0.6.0")] namespace NePoLaBoSuit; public static class MaskedAppearanceCompatibility { private static readonly Type HostType = typeof(BodyReplacementBase).Assembly.GetType("ModelReplacement.Monobehaviors.Enemies.MaskedReplacementBase"); private static readonly FieldInfo ModelField = ((HostType == null) ? null : AccessTools.Field(HostType, "replacementModel")); private static readonly FieldInfo ActiveField = ((HostType == null) ? null : AccessTools.Field(HostType, "IsActive")); private static readonly PropertyInfo AvatarProperty = ((HostType == null) ? null : AccessTools.Property(HostType, "avatar")); private static readonly MethodInfo Replace = ((HostType == null) ? null : AccessTools.Method(HostType, "SetReplacement", new Type[1] { typeof(PlayerControllerB) }, (Type[])null)); private static readonly ManualLogSource Log = Logger.CreateLogSource("NePoLaBo masked compatibility"); public static void Install(Harmony harmony) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown if (Replace == null || ModelField == null || AvatarProperty == null) { Log.LogWarning((object)"Masked API entry points unavailable; player replacements remain enabled."); return; } harmony.Patch((MethodBase)Replace, new HarmonyMethod(typeof(MaskedAppearanceCompatibility), "Assign", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(MaskedPlayerEnemy), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaskedAppearanceCompatibility), "Spawned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool Owns(PlayerControllerB player, out BodyReplacementBase body) { body = null; if (Object.op_Implicit((Object)(object)player) && ModelReplacementAPI.GetPlayerModelReplacement(player, ref body) && Object.op_Implicit((Object)(object)body)) { return ((object)body).GetType().Assembly == typeof(Plugin).Assembly; } return false; } private static void Spawned(MaskedPlayerEnemy __instance) { if (Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<MaskedAppearanceRetry>())) { ((Component)__instance).gameObject.AddComponent<MaskedAppearanceRetry>().Enemy = __instance; } } internal static void Retry(MaskedPlayerEnemy enemy) { if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)enemy.mimickingPlayer) || !Owns(enemy.mimickingPlayer, out var body) || !Object.op_Implicit((Object)(object)body.replacementModel) || (Object)(object)body.viewState == (Object)null) { return; } Component component = ((Component)enemy).GetComponent(HostType); if (!Object.op_Implicit((Object)(object)component)) { ((Component)enemy).gameObject.AddComponent(HostType); return; } object? value = ModelField.GetValue(component); if (!Object.op_Implicit((Object)((value is GameObject) ? value : null))) { Replace.Invoke(component, new object[1] { enemy.mimickingPlayer }); } } private static bool Assign(object __instance, PlayerControllerB __0) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0172: Expected O, but got Unknown if (!Owns(__0, out var body)) { return true; } if (!Object.op_Implicit((Object)(object)body.replacementModel) || (Object)(object)body.viewState == (Object)null) { return false; } object obj = ((__instance is Component) ? __instance : null); MaskedPlayerEnemy val = ((obj != null) ? ((Component)obj).GetComponent<MaskedPlayerEnemy>() : null); if (!Object.op_Implicit((Object)(object)val)) { return true; } GameObject val2 = null; object? value = ModelField.GetValue(__instance); GameObject val3 = (GameObject)((value is GameObject) ? value : null); try { MaskedModelFaceDriver maskedModelFaceDriver = (Object.op_Implicit((Object)(object)val3) ? val3.GetComponent<MaskedModelFaceDriver>() : null); if (Object.op_Implicit((Object)(object)maskedModelFaceDriver) && (Object)(object)maskedModelFaceDriver.SourcePlayer == (Object)(object)__0 && (Object)(object)maskedModelFaceDriver.SourceModel == (Object)(object)body.replacementModel) { return false; } val2 = Object.Instantiate<GameObject>(body.replacementModel); ((Object)val2).name = ((Object)body.replacementModel).name + " (Masked)"; val2.transform.localPosition = Vector3.zero; MaskedModelFaceDriver.DetachPlayerControllers(val2); Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer obj2 in componentsInChildren) { ((Component)obj2).gameObject.layer = body.viewState.VisibleLayer; obj2.shadowCastingMode = (ShadowCastingMode)1; obj2.enabled = true; } Camera[] componentsInChildren2 = val2.GetComponentsInChildren<Camera>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } NaturalEyeSockets.Ensure(val2).Aim(Vector2.zero); val2.AddComponent<MaskedModelFaceDriver>().Initialize(val, __0, body.replacementModel); MaskedAvatarUpdater val4 = new MaskedAvatarUpdater(); val4.AssignModelReplacement(((Component)val).gameObject, val2); AvatarProperty.SetValue(__instance, val4, null); ModelField.SetValue(__instance, val2); ActiveField?.SetValue(__instance, true); val2.SetActive(true); SkinnedMeshRenderer[] array = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[3] { val.rendererLOD0, val.rendererLOD1, val.rendererLOD2 }; foreach (SkinnedMeshRenderer val5 in array) { if (Object.op_Implicit((Object)(object)val5)) { ((Renderer)val5).enabled = false; ((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0; } } if (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3 != (Object)(object)val2) { Object.Destroy((Object)(object)val3); } return false; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } Log.LogWarning((object)("Masked adapter could not initialize; retaining MRAPI fallback: " + ex)); return true; } } } public sealed class MaskedAppearanceRetry : MonoBehaviour { public MaskedPlayerEnemy Enemy; private float next; private void Update() { if (!(Time.unscaledTime < next)) { next = Time.unscaledTime + 1f; if (!Object.op_Implicit((Object)(object)Enemy) || ((EnemyAI)Enemy).isEnemyDead) { ((Behaviour)this).enabled = false; } else { MaskedAppearanceCompatibility.Retry(Enemy); } } } } [DefaultExecutionOrder(9000)] public sealed class MaskedModelFaceDriver : MonoBehaviour { private sealed class Face { public SkinnedMeshRenderer Renderer; public int Blink; public int Left; public int Right; public int Up; public int Down; } public PlayerControllerB SourcePlayer; public GameObject SourceModel; private MaskedPlayerEnemy enemy; private MaskedVanillaBadges.Binding vanillaBadges; private NaturalEyeSockets sockets; private Vector2 gaze; private bool morphGaze; private float nextBlink; private float blinkStart = -10f; private readonly List<Face> faces = new List<Face>(); private static int Shape(Mesh mesh, string name) { for (int i = 0; i < mesh.blendShapeCount; i++) { string blendShapeName = mesh.GetBlendShapeName(i); if (blendShapeName == name || blendShapeName.EndsWith("." + name, StringComparison.Ordinal) || blendShapeName.EndsWith("_" + name, StringComparison.Ordinal)) { return i; } } return -1; } private static void Set(Face face, int index, float value) { if (Object.op_Implicit((Object)(object)face.Renderer) && index >= 0) { face.Renderer.SetBlendShapeWeight(index, value); } } public static void DetachPlayerControllers(GameObject clone) { MaskedCloneIsolation.Detach(clone, typeof(MaskedModelFaceDriver).Namespace); } public void Initialize(MaskedPlayerEnemy masked, PlayerControllerB source, GameObject model) { RaidNightLod.Ensure(((Component)this).gameObject, null); enemy = masked; SourcePlayer = source; SourceModel = model; vanillaBadges = MaskedVanillaBadges.Bind(((Component)masked).gameObject, (Object)(object)this); sockets = NaturalEyeSockets.Ensure(((Component)this).gameObject); nextBlink = Time.time + (float)Random.Range(2, 5); SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val.sharedMesh) && ((Object)val).name.IndexOf("Ink", StringComparison.OrdinalIgnoreCase) < 0) { Mesh sharedMesh = val.sharedMesh; int num = Shape(sharedMesh, "blink"); if (num < 0) { num = Shape(sharedMesh, "Fac_Eye_Close"); } if (num >= 0) { Face face = new Face { Renderer = val, Blink = num, Left = Shape(sharedMesh, "eyes_look_left"), Right = Shape(sharedMesh, "eyes_look_right"), Up = Shape(sharedMesh, "eyes_look_up"), Down = Shape(sharedMesh, "eyes_look_down") }; morphGaze |= face.Left >= 0 && face.Right >= 0; faces.Add(face); } } } NePoLaBoAdaptiveLighting component = ((Component)this).GetComponent<NePoLaBoAdaptiveLighting>(); if (!Object.op_Implicit((Object)(object)component)) { return; } component.Rebind(); component.BindContext(delegate { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) bool factory = Object.op_Implicit((Object)(object)enemy) && !((EnemyAI)enemy).isOutside; int ship; if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)StartOfRound.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance.shipInnerRoomBounds)) { Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds; ship = (((Bounds)(ref bounds)).Contains(((Component)enemy).transform.position) ? 1 : 0); } else { ship = 0; } return new NePoLaBoLightingContext(factory, (byte)ship != 0); }); } private void OnDestroy() { MaskedVanillaBadges.Release(vanillaBadges, (Object)(object)this); } private void LateUpdate() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fa: 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_011a: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) if (!Object.op_Implicit((Object)(object)enemy)) { return; } vanillaBadges?.Hide(); if (!Object.op_Implicit((Object)(object)sockets)) { return; } Vector2 target = Vector2.zero; PlayerControllerB targetPlayer = ((EnemyAI)enemy).targetPlayer; if (!((EnemyAI)enemy).isEnemyDead && Plugin.Eyes.Value && Object.op_Implicit((Object)(object)targetPlayer) && !targetPlayer.isPlayerDead && Object.op_Implicit((Object)(object)sockets.Head)) { target = NaturalEyeMath.Target((Object.op_Implicit((Object)(object)targetPlayer.playerEye) ? targetPlayer.playerEye.position : (((Component)targetPlayer).transform.position + Vector3.up * 1.5f)) - sockets.Head.position, sockets.Forward, sockets.Up); } gaze = NaturalEyeMath.Smooth(gaze, target, Time.deltaTime); sockets.Aim(morphGaze ? Vector2.zero : gaze); if (Time.time >= nextBlink) { blinkStart = Time.time; nextBlink = Time.time + Random.Range(2.5f, 6f); } float num = Time.time - blinkStart; float value = ((!((EnemyAI)enemy).isEnemyDead && Plugin.Blink.Value && num >= 0f && num < 0.18f) ? (Mathf.Sin(num / 0.18f * (float)Math.PI) * 100f) : 0f); foreach (Face face in faces) { Set(face, face.Blink, value); Set(face, face.Left, Mathf.Max(0f, (0f - gaze.x) / 12f) * 20f); Set(face, face.Right, Mathf.Max(0f, gaze.x / 12f) * 20f); Set(face, face.Up, Mathf.Max(0f, (0f - gaze.y) / 7f) * 15f); Set(face, face.Down, Mathf.Max(0f, gaze.y / 9f) * 15f); } } } public static class MaskedCloneIsolation { private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool IsOwner(Type type) { Type type2 = type; while (type2 != null) { if (type2.Name == "PlayerControllerB" || type2.Name == "BodyReplacementBase") { return true; } type2 = type2.BaseType; } return false; } private static void Clear(Type type, MonoBehaviour component, string field, object value) { FieldInfo field2 = type.GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null && !field2.IsInitOnly) { field2.SetValue(component, value); } } public static void Detach(GameObject clone, string ownNamespace) { MonoBehaviour[] componentsInChildren = clone.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val) || ((object)val).GetType().Namespace != ownNamespace) { continue; } Type type = ((object)val).GetType(); bool flag = false; FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (IsOwner(fieldInfo.FieldType)) { if (!fieldInfo.IsInitOnly) { fieldInfo.SetValue(val, null); } flag = true; } } if (!(type.Name == "RaidNightLod")) { if (flag || type.Name.EndsWith("ReactionFace", StringComparison.Ordinal) || type.Name.Contains("HeadTracking") || type.Name.EndsWith("Face", StringComparison.Ordinal) || type.Name.Contains("FirstPerson") || type.Name.Contains("RenderDiagnostics") || type.Name.Contains("RuntimeMotionAudit")) { ((Behaviour)val).enabled = false; } if (type.Name.EndsWith("OutfitState", StringComparison.Ordinal)) { Clear(type, val, "HasPlayerBinding", false); Clear(type, val, "Corpse", false); Clear(type, val, "SourceState", null); Clear(type, val, "AutomaticEars", false); type.GetMethod("Rebind", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)?.Invoke(val, null); } } } } } public static class MaskedVanillaBadges { public sealed class Binding { internal GameObject Enemy; internal object[] State; public void Hide() { MeshRenderer[] array = (MeshRenderer[])State[1]; foreach (MeshRenderer val in array) { if (Object.op_Implicit((Object)(object)val) && ((Renderer)val).enabled) { ((Renderer)val).enabled = false; } } } } private const string Chest = "ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/"; private const string StateKey = "RaidNight.SuitMods.MaskedVanillaBadges.v1"; private static Dictionary<GameObject, object[]> Active { get { Dictionary<GameObject, object[]> dictionary = AppDomain.CurrentDomain.GetData("RaidNight.SuitMods.MaskedVanillaBadges.v1") as Dictionary<GameObject, object[]>; if (dictionary == null) { dictionary = new Dictionary<GameObject, object[]>(); AppDomain.CurrentDomain.SetData("RaidNight.SuitMods.MaskedVanillaBadges.v1", dictionary); } return dictionary; } } public static Binding Bind(GameObject enemy, Object owner) { if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit(owner)) { return null; } if (Active.TryGetValue(enemy, out var value)) { value[0] = owner; Binding binding = new Binding(); binding.Enemy = enemy; binding.State = value; binding.Hide(); return binding; } List<MeshRenderer> list = new List<MeshRenderer>(); string[] array = new string[2] { "LevelSticker", "BetaBadge" }; foreach (string text in array) { Transform val = enemy.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/" + text); MeshRenderer val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshRenderer>() : null); if (Object.op_Implicit((Object)(object)val2)) { list.Add(val2); } } bool[] array2 = new bool[list.Count]; for (int j = 0; j < list.Count; j++) { array2[j] = ((Renderer)list[j]).enabled; } object[] array3 = new object[3] { owner, list.ToArray(), array2 }; Binding obj = new Binding { Enemy = enemy, State = array3 }; Active.Add(enemy, array3); obj.Hide(); return obj; } public static void Release(Binding binding, Object owner) { if (binding == null || binding.State[0] != owner || !Active.TryGetValue(binding.Enemy, out var value) || value != binding.State) { return; } Active.Remove(binding.Enemy); MeshRenderer[] array = (MeshRenderer[])binding.State[1]; bool[] array2 = (bool[])binding.State[2]; for (int i = 0; i < array.Length; i++) { if (Object.op_Implicit((Object)(object)array[i])) { ((Renderer)array[i]).enabled = array2[i]; } } } } public static class NaturalEyeMath { public const float YawLimit = 12f; public const float UpLimit = 7f; public const float DownLimit = 9f; public const float SocketLimit = 12f; public const float MorphHorizontal = 20f; public const float MorphVertical = 15f; private static bool Finite(float v) { if (!float.IsNaN(v)) { return !float.IsInfinity(v); } return false; } public static Vector2 Clamp(Vector2 angles) { //IL_0000: 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_000d: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008b: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!Finite(angles.x) || !Finite(angles.y)) { return Vector2.zero; } float num = ((angles.y < 0f) ? 7f : 9f); angles.x = Mathf.Clamp(angles.x, -12f, 12f); angles.y = Mathf.Clamp(angles.y, -7f, 9f); float num2 = Mathf.Sqrt(angles.x * angles.x / 144f + angles.y * angles.y / (num * num)); if (!(num2 > 1f)) { return angles; } return angles / num2; } public static Vector2 Target(Vector3 local) { //IL_0000: 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_000d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (!Finite(local.x) || !Finite(local.y) || !Finite(local.z) || ((Vector3)(ref local)).sqrMagnitude < 1E-10f || local.z <= 0f) { return Vector2.zero; } float num = Mathf.Atan2(local.x, local.z) * 57.29578f; float num2 = (0f - Mathf.Atan2(local.y, Mathf.Sqrt(local.x * local.x + local.z * local.z))) * 57.29578f; float num3 = Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2)); float num4 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(60f, 90f, num3)); return Clamp(new Vector2(num, num2)) * num4; } public static Vector2 Smooth(Vector2 current, Vector2 target, float dt) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: 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) current = Clamp(current); target = Clamp(target); if (!Finite(dt) || dt <= 0f) { return current; } return Clamp(Vector2.Lerp(current, target, 1f - Mathf.Exp((0f - Mathf.Min(dt, 0.1f)) * 12f))); } public static Vector2 Target(Vector3 direction, Vector3 forward, Vector3 up) { //IL_0032: 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_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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (!(((Vector3)(ref forward)).sqrMagnitude < 1E-08f) && !(((Vector3)(ref up)).sqrMagnitude < 1E-08f)) { Vector3 val = Vector3.Cross(up, forward); if (!(((Vector3)(ref val)).sqrMagnitude < 1E-08f)) { return Target(Quaternion.Inverse(Quaternion.LookRotation(forward, up)) * direction); } } return Vector2.zero; } public static void Apply(Transform eye, Quaternion neutral, Vector3 forward, Vector3 up, Vector2 angles) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //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) //IL_003f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0070: 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) if (Object.op_Implicit((Object)(object)eye) && Object.op_Implicit((Object)(object)eye.parent)) { angles = Clamp(angles); Quaternion val = Quaternion.LookRotation(forward, up); Quaternion val2 = Quaternion.Inverse(eye.parent.rotation) * val; Quaternion val3 = val2 * Quaternion.Euler(angles.y, angles.x, 0f) * Quaternion.Inverse(val2) * neutral; eye.localRotation = Quaternion.RotateTowards(neutral, val3, 12f); } } } [DefaultExecutionOrder(10000)] public sealed class NaturalEyeSockets : MonoBehaviour { public Transform Left; public Transform Right; public Transform Head; public Quaternion LeftNeutral = Quaternion.identity; public Quaternion RightNeutral = Quaternion.identity; public Quaternion HeadToLook = Quaternion.identity; public bool Captured; public Vector3 Forward { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Head)) { return ((Component)this).transform.forward; } return Head.rotation * HeadToLook * Vector3.forward; } } public Vector3 Up { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Head)) { return ((Component)this).transform.up; } return Head.rotation * HeadToLook * Vector3.up; } } public static NaturalEyeSockets Ensure(GameObject model) { NaturalEyeSockets naturalEyeSockets = model.GetComponent<NaturalEyeSockets>(); if (!Object.op_Implicit((Object)(object)naturalEyeSockets)) { naturalEyeSockets = model.AddComponent<NaturalEyeSockets>(); } naturalEyeSockets.Capture(); return naturalEyeSockets; } private void Awake() { Capture(); } public void Capture() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) if (Captured) { return; } Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>(true); if (Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.isHuman) { Head = componentInChildren.GetBoneTransform((HumanBodyBones)10); Left = componentInChildren.GetBoneTransform((HumanBodyBones)21); Right = componentInChildren.GetBoneTransform((HumanBodyBones)22); } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "head.x" || (!Object.op_Implicit((Object)(object)Head) && (((Object)val).name == "DEF-spine.006" || ((Object)val).name == "spine.004"))) { Head = val; } if (((Object)val).name == "Skn_L_Eye") { Left = val; } if (((Object)val).name == "Skn_R_Eye") { Right = val; } } if (Object.op_Implicit((Object)(object)Left)) { LeftNeutral = Left.localRotation; } if (Object.op_Implicit((Object)(object)Right)) { RightNeutral = Right.localRotation; } Transform val2 = null; componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val3 in componentsInChildren) { if (((Object)val3).name.EndsWith("GazeFrame", StringComparison.Ordinal)) { val2 = val3; break; } } if (Object.op_Implicit((Object)(object)Head)) { HeadToLook = Quaternion.Inverse(Head.rotation) * (Object.op_Implicit((Object)(object)val2) ? val2.rotation : ((Component)this).transform.rotation); } Captured = Object.op_Implicit((Object)(object)Head); } private static void Limit(Transform eye, Quaternion neutral) { //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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)eye)) { eye.localRotation = Quaternion.RotateTowards(neutral, eye.localRotation, 12f); } } private void LateUpdate() { //IL_000d: 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) Capture(); Limit(Left, LeftNeutral); Limit(Right, RightNeutral); } public void Aim(Vector2 angles) { //IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Capture(); NaturalEyeMath.Apply(Left, LeftNeutral, Forward, Up, angles); NaturalEyeMath.Apply(Right, RightNeutral, Forward, Up, angles); } } [Serializable] public struct NePoLaBoLightingContext { public bool InsideFactory; public bool InsideShip; public bool Indoors { get { if (!InsideFactory) { return InsideShip; } return true; } } public float Floor { get { if (!Indoors) { return 0.075f; } return 0f; } } public NePoLaBoLightingContext(bool factory, bool ship) { InsideFactory = factory; InsideShip = ship; } } public sealed class NePoLaBoCorpseLightingContext { private NePoLaBoLightingContext context; private bool trackedItem; public NePoLaBoCorpseLightingContext(NePoLaBoLightingContext death) { context = death; } public NePoLaBoLightingContext Observe(bool bodyInShip, bool hasHolder, NePoLaBoLightingContext holder, bool hasItem, NePoLaBoLightingContext item) { if (hasHolder) { context = holder; trackedItem = true; } else if (hasItem && trackedItem) { context = item; } if (!bodyInShip) { return context; } return new NePoLaBoLightingContext(factory: false, ship: true); } } [DefaultExecutionOrder(600)] public sealed class NePoLaBoAdaptiveLighting : MonoBehaviour { private struct Draw { public Renderer Renderer; public int Slot; public bool Floor; public bool Ink; public Color InkColor; } public Renderer[] receivers; private readonly List<Draw> draws = new List<Draw>(); private MaterialPropertyBlock block; private Func<NePoLaBoLightingContext> contextReader; private bool initialized; private static readonly int FloorId = Shader.PropertyToID("_GflAmbientFloor"); private static readonly int InkId = Shader.PropertyToID("_InkColor"); public NePoLaBoLightingContext Context { get; private set; } public float CurrentFloor => Context.Floor; public int FloorSlots { get; private set; } public int InkSlots { get; private set; } private void Awake() { Rebind(); Refresh(); } private void OnEnable() { if (initialized) { Refresh(); } } public void Rebind() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) if (block == null) { block = new MaterialPropertyBlock(); } draws.Clear(); int floorSlots = (InkSlots = 0); FloorSlots = floorSlots; receivers = ((Component)this).GetComponentsInChildren<Renderer>(true); Renderer[] array = receivers; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { Material val2 = sharedMaterials[i]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } bool flag = val2.HasProperty(FloorId); bool flag2 = val2.HasProperty(InkId); if (flag || flag2) { draws.Add(new Draw { Renderer = val, Slot = i, Floor = flag, Ink = flag2, InkColor = (flag2 ? val2.GetColor(InkId) : Color.black) }); if (flag) { FloorSlots++; } if (flag2) { InkSlots++; } } } } initialized = true; Apply(Context); } public void BindContext(Func<NePoLaBoLightingContext> reader) { contextReader = reader; Refresh(); } public NePoLaBoLightingContext ReadContext() { if (contextReader == null) { return Context; } return contextReader(); } public void InheritContext(NePoLaBoAdaptiveLighting source) { if (Object.op_Implicit((Object)(object)source)) { BindContext(source.ReadContext); } } public void Refresh() { Apply(ReadContext()); } public void Apply(NePoLaBoLightingContext context) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { Rebind(); } Context = context; foreach (Draw draw in draws) { if (!Object.op_Implicit((Object)(object)draw.Renderer)) { continue; } block.Clear(); draw.Renderer.GetPropertyBlock(block, draw.Slot); if (draw.Floor) { block.SetFloat(FloorId, context.Floor); } if (draw.Ink) { Color inkColor = draw.InkColor; if (context.Indoors) { ((Color)(ref inkColor))..ctor(0f, 0f, 0f, inkColor.a); } block.SetColor(InkId, inkColor); } draw.Renderer.SetPropertyBlock(block, draw.Slot); } } private void LateUpdate() { Refresh(); } } internal static class NePoLaBoLightingControl { private sealed class Death { internal ulong Owner; internal NePoLaBoLightingContext Context; } private static readonly Dictionary<PlayerControllerB, Death> deaths = new Dictionary<PlayerControllerB, Death>(); private static readonly FieldInfo sourceField = AccessTools.Field(typeof(BodyReplacementBase), "replacementModel"); private static readonly FieldInfo shadowField = AccessTools.Field(typeof(BodyReplacementBase), "replacementModelShadow"); private static readonly FieldInfo viewField = AccessTools.Field(typeof(BodyReplacementBase), "replacementViewModel"); private static NePoLaBoLightingContext Native(PlayerControllerB player) { if (!Object.op_Implicit((Object)(object)player)) { return default(NePoLaBoLightingContext); } return new NePoLaBoLightingContext(player.isInsideFactory, player.isInHangarShipRoom); } internal static void Install(Harmony harmony) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(BodyReplacementBase), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(NePoLaBoLightingControl), "Created", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(BodyReplacementBase), "LoadRagdollReplacement", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(NePoLaBoLightingControl), "Ragdoll", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "KillPlayer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(NePoLaBoLightingControl), "CaptureDeath", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "SpawnDeadBody", (Type[])null, (Type[])null), new HarmonyMethod(typeof(NePoLaBoLightingControl), "CaptureRemoteDeath", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ReviveDeadPlayers", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(NePoLaBoLightingControl), "Clear", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void CaptureDeath(PlayerControllerB __instance) { if (Object.op_Implicit((Object)(object)__instance) && !__instance.isPlayerDead) { deaths[__instance] = new Death { Owner = ((NetworkBehaviour)__instance).OwnerClientId, Context = Native(__instance) }; } } private static void CaptureRemoteDeath(PlayerControllerB deadPlayerController) { if (Object.op_Implicit((Object)(object)deadPlayerController) && !((NetworkBehaviour)deadPlayerController).IsOwner) { deaths[deadPlayerController] = new Death { Owner = ((NetworkBehaviour)deadPlayerController).OwnerClientId, Context = Native(deadPlayerController) }; } } private static void Created(BodyReplacementBase __instance) { if (__instance is NePoLaBoBody nePoLaBoBody && Object.op_Implicit((Object)(object)((BodyReplacementBase)nePoLaBoBody).controller)) { FieldInfo[] array = new FieldInfo[3] { sourceField, shadowField, viewField }; for (int i = 0; i < array.Length; i++) { object? obj = array[i]?.GetValue(nePoLaBoBody); Bind((GameObject)((obj is GameObject) ? obj : null), ((BodyReplacementBase)nePoLaBoBody).controller); } } } internal static void AttachView(GameObject playerObject, GameObject view) { if (Object.op_Implicit((Object)(object)playerObject) && Object.op_Implicit((Object)(object)view) && Object.op_Implicit((Object)(object)view.GetComponent<NePoLaBoAdaptiveLighting>())) { Bind(view, playerObject.GetComponent<PlayerControllerB>()); } } private static void Ragdoll(BodyReplacementBase __instance, GameObject __result) { if (__instance is NePoLaBoBody nePoLaBoBody && Object.op_Implicit((Object)(object)((BodyReplacementBase)nePoLaBoBody).controller)) { Bind(__result, ((BodyReplacementBase)nePoLaBoBody).controller, corpse: true); } } private static void Bind(GameObject model, PlayerControllerB player, bool corpse = false) { if (!Object.op_Implicit((Object)(object)model) || !Object.op_Implicit((Object)(object)player)) { return; } NePoLaBoAdaptiveLighting nePoLaBoAdaptiveLighting = model.GetComponent<NePoLaBoAdaptiveLighting>() ?? model.AddComponent<NePoLaBoAdaptiveLighting>(); nePoLaBoAdaptiveLighting.Rebind(); ulong owner = ((NetworkBehaviour)player).OwnerClientId; if (!corpse) { nePoLaBoAdaptiveLighting.BindContext(() => (!Object.op_Implicit((Object)(object)player) || ((NetworkBehaviour)player).OwnerClientId != owner) ? default(NePoLaBoLightingContext) : Native(player)); return; } Death value; NePoLaBoLightingContext death = ((deaths.TryGetValue(player, out value) && value.Owner == owner) ? value.Context : Native(player)); NePoLaBoCorpseLightingContext corpseContext = new NePoLaBoCorpseLightingContext(death); DeadBodyInfo nativeBody = player.deadBody; nePoLaBoAdaptiveLighting.BindContext(delegate { if (!Object.op_Implicit((Object)(object)nativeBody)) { return corpseContext.Observe(bodyInShip: false, hasHolder: false, default(NePoLaBoLightingContext), hasItem: false, default(NePoLaBoLightingContext)); } GrabbableObject grabBodyObject = nativeBody.grabBodyObject; PlayerControllerB val = ((Object.op_Implicit((Object)(object)grabBodyObject) && grabBodyObject.isHeld) ? grabBodyObject.playerHeldBy : null); return corpseContext.Observe(nativeBody.isInShip || nativeBody.parentedToShip, Object.op_Implicit((Object)(object)val), Native(val), Object.op_Implicit((Object)(object)grabBodyObject), Object.op_Implicit((Object)(object)grabBodyObject) ? new NePoLaBoLightingContext(grabBodyObject.isInFactory, grabBodyObject.isInShipRoom) : default(NePoLaBoLightingContext)); }); } internal static void Clear() { deaths.Clear(); } } public enum AttentionKind { Player, Enemy, Item } public struct AttentionCandidate { public int Key; public AttentionKind Kind; public float Distance; public bool Speaking; public bool Eligible; public AttentionCandidate(int key, AttentionKind kind, float distance, bool speaking = true, bool eligible = true) { Key = key; Kind = kind; Distance = distance; Speaking = speaking; Eligible = eligible; } } public sealed class NePoLaBoAttentionSelection { private float lastSpeech; private float selectedAt; public int CurrentKey { get; private set; } public bool HasTarget { get; private set; } public AttentionKind CurrentKind { get; private set; } public void Reset() { HasTarget = false; CurrentKey = 0; lastSpeech = (selectedAt = 0f); } public int Choose(IList<AttentionCandidate> candidates, float now, float pauseHold = 1.2f) { AttentionCandidate attentionCandidate = default(AttentionCandidate); AttentionCandidate c = default(AttentionCandidate); AttentionCandidate c2 = default(AttentionCandidate); bool flag = false; bool flag2 = false; bool flag3 = false; foreach (AttentionCandidate candidate in candidates) { if (!candidate.Eligible || float.IsNaN(candidate.Distance) || float.IsInfinity(candidate.Distance) || candidate.Distance < 0f) { continue; } if (HasTarget && candidate.Key == CurrentKey && candidate.Kind == CurrentKind) { attentionCandidate = candidate; flag = true; } if (candidate.Kind == AttentionKind.Player) { if (candidate.Speaking && (!flag2 || candidate.Distance < c.Distance)) { c = candidate; flag2 = true; } } else if (!flag3 || candidate.Kind < c2.Kind || (candidate.Kind == c2.Kind && candidate.Distance < c2.Distance)) { c2 = candidate; flag3 = true; } } if (flag && attentionCandidate.Kind == AttentionKind.Player && attentionCandidate.Speaking) { lastSpeech = now; } if (flag2) { if (flag && attentionCandidate.Kind == AttentionKind.Player && attentionCandidate.Speaking && (now - selectedAt < 0.65f || c.Distance >= attentionCandidate.Distance * 0.7f)) { return CurrentKey; } return Select(c, now); } if (flag && attentionCandidate.Kind == AttentionKind.Player && now - lastSpeech <= Mathf.Clamp(pauseHold, 0f, 5f)) { return CurrentKey; } if (flag3) { if (flag && attentionCandidate.Kind == c2.Kind && attentionCandidate.Kind != AttentionKind.Player && (now - selectedAt < 1.5f || c2.Distance >= attentionCandidate.Distance * 0.7f)) { return CurrentKey; } return Select(c2, now); } Reset(); return 0; } private int Select(AttentionCandidate c, float now) { if (!HasTarget || c.Key != CurrentKey || c.Kind != CurrentKind) { selectedAt = now; } HasTarget = true; CurrentKey = c.Key; CurrentKind = c.Kind; if (c.Kind == AttentionKind.Player && c.Speaking) { lastSpeech = now; } return CurrentKey; } public static bool InView(Vector3 origin, Vector3 forward, Vector3 point, float radius) { //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_0007: 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_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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) Vector3 val = point - origin; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < 0.0225f || sqrMagnitude > radius * radius) { return false; } Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up); Vector3 val3 = Vector3.ProjectOnPlane(forward, Vector3.up); if (Vector3.Angle(val2, val3) <= 65f) { return Mathf.Abs(Mathf.Atan2(val.y, ((Vector3)(ref val2)).magnitude) * 57.29578f) <= 60f; } return false; } public static bool ActiveSpeech(bool speaking, float amplitude) { if (speaking && !float.IsNaN(amplitude) && !float.IsInfinity(amplitude)) { return amplitude >= 0.002f; } return false; } public static bool Visible(Vector3 origin, Vector3 point, int mask, Transform observer, Transform model, Transform target, RaycastHit[] hits) { //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_0007: 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_001b: 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) Vector3 val = point - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.05f) { return true; } int num = Physics.RaycastNonAlloc(origin, val / magnitude, hits, magnitude, mask, (QueryTriggerInteraction)1); if (num == hits.Length) { return false; } for (int i = 0; i < num; i++) { Transform transform = ((RaycastHit)(ref hits[i])).transform; if (Object.op_Implicit((Object)(object)transform) && (!Object.op_Implicit((Object)(object)observer) || !transform.IsChildOf(observer)) && (!Object.op_Implicit((Object)(object)model) || !transform.IsChildOf(model)) && (!Object.op_Implicit((Object)(object)target) || !transform.IsChildOf(target))) { return false; } } return true; } } public sealed class NePoLaBoAttention { private sealed class ItemRenderer { public GrabbableObject Item; public Renderer Renderer; } private readonly NePoLaBoAttentionSelection selection = new NePoLaBoAttentionSelection(); private readonly List<AttentionCandidate> candidates = new List<AttentionCandidate>(64); private readonly Dictionary<int, Object> objects = new Dictionary<int, Object>(); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[24]; private static EnemyAI[] enemies = (EnemyAI[])(object)new EnemyAI[0]; private static GrabbableObject[] items = (GrabbableObject[])(object)new GrabbableObject[0]; private static float nextSceneScan; private static StartOfRound scene; private static readonly Dictionary<int, ItemRenderer> itemRenderers = new Dictionary<int, ItemRenderer>(); private static readonly HashSet<int> aliveItems = new HashSet<int>(); private static readonly List<int> staleItems = new List<int>(); private Object target; private float nextScan; public void Reset() { selection.Reset(); target = null; nextScan = 0f; } private static void ScanScene(float now) { if ((Object)(object)scene != (Object)(object)StartOfRound.Instance) { scene = StartOfRound.Instance; nextSceneScan = 0f; itemRenderers.Clear(); } if (now < nextSceneScan) { return; } nextSceneScan = now + 1f; enemies = NePoLaBoSceneCache.Enemies(now); items = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); aliveItems.Clear(); GrabbableObject[] array = items; foreach (GrabbableObject val in array) { if (Object.op_Implicit((Object)(object)val)) { aliveItems.Add(((Object)val).GetInstanceID()); } } staleItems.Clear(); foreach (KeyValuePair<int, ItemRenderer> itemRenderer in itemRenderers) { if (!aliveItems.Contains(itemRenderer.Key)) { staleItems.Add(itemRenderer.Key); } } foreach (int staleItem in staleItems) { itemRenderers.Remove(staleItem); } } internal static void ClearSceneCache() { scene = null; nextSceneScan = 0f; enemies = (EnemyAI[])(object)new EnemyAI[0]; items = (GrabbableObject[])(object)new GrabbableObject[0]; itemRenderers.Clear(); aliveItems.Clear(); staleItems.Clear(); } private static Vector3 Point(Object value) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_0102: 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_0060: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00e6: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (PlayerControllerB)(object)((value is PlayerControllerB) ? value : null); if (val != null) { if (!Object.op_Implicit((Object)(object)val.playerEye)) { return ((Component)val).transform.position + Vector3.up * 1.6f; } return val.playerEye.position; } EnemyAI val2 = (EnemyAI)(object)((value is EnemyAI) ? value : null); if (val2 != null) { if (!Object.op_Implicit((Object)(object)val2.eye)) { return ((Component)val2).transform.position + Vector3.up; } return val2.eye.position; } GrabbableObject val3 = (GrabbableObject)(object)((value is GrabbableObject) ? value : null); if (val3 != null) { int instanceID = ((Object)val3).GetInstanceID(); if (!itemRenderers.TryGetValue(instanceID, out var value2) || (Object)(object)value2.Item != (Object)(object)val3) { value2 = new ItemRenderer { Item = val3, Renderer = ((Component)val3).GetComponentInChildren<Renderer>() }; itemRenderers[instanceID] = value2; } if (!Object.op_Implicit((Object)(object)value2.Renderer)) { return ((Component)val3).transform.position; } Bounds bounds = value2.Renderer.bounds; return ((Bounds)(ref bounds)).center; } return Vector3.zero; } private void Add(Component value, AttentionKind kind, Vector3 origin, Vector3 forward, float range, bool speaking, PlayerControllerB owner, Transform model) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) //IL_006c: 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) Vector3 val = Point((Object)(object)value); if (NePoLaBoAttentionSelection.InView(origin, forward, val, range)) { int mask = (Object.op_Implicit((Object)(object)StartOfRound.Instance) ? StartOfRound.Instance.collidersAndRoomMaskAndDefault : (-5)); if (NePoLaBoAttentionSelection.Visible(origin, val, mask, ((Component)owner).transform, model, value.transform, hits)) { int instanceID = ((Object)value).GetInstanceID(); objects[instanceID] = (Object)(object)value; candidates.Add(new AttentionCandidate(instanceID, kind, Vector3.Distance(origin, val), speaking)); } } } public bool Resolve(PlayerControllerB owner, Transform model, Vector3 origin, Vector3 forward, float now, out Vector3 direction) { //IL_0002: 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_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) direction = forward; if (!Object.op_Implicit((Object)(object)owner) || owner.isPlayerDead || !owner.isPlayerControlled || !Object.op_Implicit((Object)(object)StartOfRound.Instance)) { Reset(); return false; } if (now >= nextScan) { nextScan = now + 0.1f; candidates.Clear(); objects.Clear(); ScanScene(now); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Object.op_Implicit((Object)(object)val) && !((Object)(object)val == (Object)(object)owner) && val.isPlayerControlled && !val.isPlayerDead && ((Component)val).gameObject.activeInHierarchy) { bool flag = NePoLaBoVoiceActivity.IsSpeaking(val); if (flag || (selection.HasTarget && selection.CurrentKind == AttentionKind.Player && selection.CurrentKey == ((Object)val).GetInstanceID())) { Add((Component)(object)val, AttentionKind.Player, origin, forward, Plugin.TalkingPlayersRange.Value, flag, owner, model); } } } EnemyAI[] array = enemies; foreach (EnemyAI val2 in array) { if (Object.op_Implicit((Object)(object)val2) && !val2.isEnemyDead && ((Behaviour)val2).isActiveAndEnabled) { Add((Component)(object)val2, AttentionKind.Enemy, origin, forward, Plugin.EnemiesRange.Value, speaking: false, owner, model); } } GrabbableObject[] array2 = items; foreach (GrabbableObject val3 in array2) { if (Object.op_Implicit((Object)(object)val3) && !val3.isHeld && !val3.isPocketed && !val3.isHeldByEnemy && ((Behaviour)val3).isActiveAndEnabled) { Add((Component)(object)val3, AttentionKind.Item, origin, forward, Plugin.ItemsRange.Value, speaking: false, owner, model); } } int key = selection.Choose(candidates, now, Plugin.SpeechPauseHold.Value); target = ((selection.HasTarget && objects.TryGetValue(key, out var value)) ? value : null); } if (!Object.op_Implicit(target)) { return false; } Object obj = target; PlayerControllerB val4 = (PlayerControllerB)(object)((obj is PlayerControllerB) ? obj : null); if (val4 == null || (val4.isPlayerControlled && !val4.isPlayerDead)) { Object obj2 = target; EnemyAI val5 = (EnemyAI)(object)((obj2 is EnemyAI) ? obj2 : null); if (val5 == null || !val5.isEnemyDead) { Object obj3 = target; GrabbableObject val6 = (GrabbableObject)(object)((obj3 is GrabbableObject) ? obj3 : null); if (val6 == null || (!val6.isHeld && !val6.isPocketed && !val6.isHeldByEnemy)) { direction = Point(target) - origin; return ((Vector3)(ref direction)).sqrMagnitude > 1E-06f; } } } target = null; selection.Reset(); nextScan = 0f; return false; } } internal static class NePoLaBoVoiceActivity { private static object comms; private static readonly Dictionary<int, float> retry = new Dictionary<int, float>(); private static readonly Dictionary<int, object> states = new Dictionary<int, object>(); internal static bool IsSpeaking(PlayerControllerB player) { object obj = NePoLaBoFace.Read(player, "voicePlayerState") ?? NePoLaBoFace.Read(NePoLaBoFace.Read(player, "currentVoiceChatIngameSettings"), "_playerState"); int instanceID = ((Object)player).GetInstanceID(); if (obj == null && states.TryGetValue(instanceID, out var value)) { obj = value; } if (obj == null && (!retry.TryGetValue(instanceID, out var value2) || Time.unscaledTime >= value2)) { retry[instanceID] = Time.unscaledTime + 1f; comms = NePoLaBoFace.Read(StartOfRound.Instance, "voiceChatModule"); if (comms != null) { string text = (((NetworkBehaviour)player).IsOwner ? (NePoLaBoFace.Read(comms, "LocalPlayerName") as string) : (NePoLaBoFace.Read(player, "voicePlayerName") as string)); if (!string.IsNullOrEmpty(text)) { try { obj = NePoLaBoRuntimeMembers.CallString(comms, "FindPlayer", text); if (obj != null) { states[instanceID] = obj; } } catch { } } } } bool value3; bool flag = NePoLaBoRuntimeMembers.TryRead<bool>(obj, "IsSpeaking", out value3) && value3; if (NePoLaBoRuntimeMembers.TryRead<bool>(obj, "IsConnected", out var value4) && !value4) { return false; } if (!NePoLaBoRuntimeMembers.TryRead<float>(obj, "Amplitude", out var value5)) { return flag; } return NePoLaBoAttentionSelection.ActiveSpeech(flag, value5); } internal static void Clear() { comms = null; retry.Clear(); states.Clear(); } } public sealed class NePoLaBoBundleCache { public const string PackedSHA256 = "f65e8a6b0a43d21dd47adaf07308de4127ee38c6f43fcf390595009219f7b76a"; public const uint ContentCRC = 1978709304u; private string packedPath; private string pendingPath; private FileStream output; private SHA256 digest; public AssetBundle Bundle { get; private set; } public bool CacheHit { get; private set; } public bool Rebuilt { get; private set; } public bool UsedFallback { get; private set; } public string Warning { get; private set; } public string CachePath { get; private set; } private bool Prepare(string directory) { try { Directory.CreateDirectory(directory); CachePath = Path.Combine(directory, "f65e8a6b0a43d21dd47adaf07308de4127ee38c6f43fcf390595009219f7b76a.bundle"); string text = Guid.NewGuid().ToString("N"); packedPath = Path.Combine(directory, "f65e8a6b0a43d21dd47adaf07308de4127ee38c6f43fcf390595009219f7b76a." + text + ".packed"); pendingPath = Path.Combine(directory, "f65e8a6b0a43d21dd47adaf07308de4127ee38c6f43fcf390595009219f7b76a." + text + ".pending"); return true; } catch (Exception ex) { Warning = "Model cache unavailable: " + ex.Message; return false; } } private bool OpenOutput(Stream source) { try { source.Position = 0L; output = new FileStream(packedPath, FileMode.CreateNew, FileAccess.Write, FileShare.None); digest = SHA256.Create(); return true; } catch (Exception ex) { Warning = "Model cache staging failed: " + ex.Message; CloseOutput(); return false; } } private int Copy(Stream source, byte[] buffer) { try { int num = source.Read(buffer, 0, buffer.Length); if (num > 0) { output.Write(buffer, 0, num); digest.TransformBlock(buffer, 0, num, buffer, 0); } return num; } catch (Exception ex) { Warning = "Model cache write failed: " + ex.Message; return -1; } } private bool FinishOutput() { try { digest.TransformFinalBlock(Array.Empty<byte>(), 0, 0); if (BitConverter.ToString(digest.Hash).Replace("-", "").ToLowerInvariant() != "f65e8a6b0a43d21dd47adaf07308de4127ee38c6f43fcf390595009219f7b76a") { Warning = "Embedded model checksum differs; loading directly."; return false; } return true; } catch (Exception ex) { Warning = "Model checksum verification failed: " + ex.Message; return false; } finally { CloseOutput(); } } private void CloseOutput() { output?.Dispose(); output = null; digest?.Dispose(); digest = null; } private void RemoveOwnedTemporaryFiles() { CloseOutput(); string[] array = new string[2] { packedPath, pendingPath }; foreach (string text in array) { if (string.IsNullOrEmpty(text)) { continue; } try { if (File.Exists(text)) { File.Delete(text); } } catch (Exception) { } } } private bool Commit() { try { if (File.Exists(CachePath)) { File.Delete(CachePath); } File.Move(pendingPath, CachePath); return true; } catch (Exception ex) { Warning = "Model cache commit failed: " + ex.Message; return false; } } private AssetBundleCreateRequest LoadFile() { try { return AssetBundle.LoadFromFileAsync(CachePath, 1978709304u); } catch (Exception ex) { Warning = "Model cache load failed: " + ex.Message; return null; } } private AssetBundleRecompressOperation Recompress() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) try { return AssetBundle.RecompressAssetBundleAsync(packedPath, pendingPath, BuildCompression.LZ4Runtime, 1978709304u, (ThreadPriority)0); } catch (Exception ex) { Warning = "Model cache conversion failed: " + ex.Message; return null; } } private AssetBundleCreateRequest LoadDirect(Stream source) { try { source.Position = 0L; return AssetBundle.LoadFromStreamAsync(source, 1978709304u); } catch (Exception ex) { Warning = "Direct model load failed: " + ex.Message; return null; } } public IEnumerator Load(Stream source, string directory) { if (source == null) { Warning = "Missing embedded models."; yield break; } try { if (Prepare(directory)) { if (File.Exists(CachePath)) { AssetBundleCreateRequest warm = LoadFile(); if (warm != null) { yield return warm; if (Object.op_Implicit((Object)(object)warm.assetBundle)) { Bundle = warm.assetBundle; CacheHit = true; yield break; } } } bool staged = OpenOutput(source); if (staged) { byte[] buffer = new byte[2097152]; while (true) { int num = Copy(source, buffer); if (num < 0) { staged = false; break; } if (num == 0) { break; } yield return null; } if (staged) { staged = FinishOutput(); } else { CloseOutput(); } } if (staged) { AssetBundleRecompressOperation convert = Recompress(); if (convert != null) { yield return convert; if (convert.success && Commit()) { AssetBundleCreateRequest warm = LoadFile(); if (warm != null) { yield return warm; if (Object.op_Implicit((Object)(object)warm.assetBundle)) { Bundle = warm.assetBundle; Rebuilt = true; yield break; } } } else { Warning = "Model cache conversion did not complete: " + convert.humanReadableResult; } } } } UsedFallback = true; AssetBundleCreateRequest direct = LoadDirect(source); if (direct != null) { yield return direct; Bundle = direct.assetBundle; } } finally { RemoveOwnedTemporaryFiles(); } } } public sealed class NePoLaBoChestGazeTarget : MonoBehaviour { public Transform chest; public Transform[] breasts = (Transform[])(object)new Transform[0]; public Vector3 Point { get { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; int num = 0; Transform[] array = breasts; foreach (Transform val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { val += val2.position; num++; } } if (num <= 0) { if (!Object.op_Implicit((Object)(object)chest)) { return ((Component)this).transform.position + Vector3.up * 1.3f; } return chest.position; } return val / (float)num; } } } public enum NePoLaBoExpression : byte { Neutral, Frightened, Hurt, Happy, Surprised, VeryHappy, Dead } public struct NePoLaBoExpressionContext { public bool Dead; public bool Critical; public bool EnemyNear; public bool Fear; public bool Chased; public bool Dancing; public bool Unsafe { get { if (!EnemyNear && !Fear) { return Chased; } return true; } } } public sealed class NePoLaBoExpressionSelection { private double hurtUntil = -1.0; private double treasureUntil = -1.0; private bool surprised = true; private int pickups; public void Damage(double now) { hurtUntil = now + 2.0; } public void PickedUp(int value, double now) { if (value > 100) { treasureUntil = now + 3.5; surprised = pickups++ % 2 == 0; } } public void Reset() { hurtUntil = (treasureUntil = -1.0); pickups = 0; surprised = true; } public NePoLaBoExpression Choose(NePoLaBoExpressionContext c, double now) { if (c.Dead) { return NePoLaBoExpression.Dead; } if (c.Critical || now < hurtUntil) { return NePoLaBoExpression.Hurt; } if (c.Unsafe) { return NePoLaBoExpression.Frightened; } if (now < treasureUntil) { if (!surprised) { return NePoLaBoExpression.VeryHappy; } return NePoLaBoExpression.Surprised; } if (c.Dancing) { return NePoLaBoExpression.Happy; } return NePoLaBoExpression.Neutral; } } public struct NePoLaBoExpressionWeight { public string Shape; public float Weight; public bool Eyes; public bool Mouth; public NePoLaBoExpressionWeight(string shape, float weight, bool eyes = false, bool mouth = false) { Shape = "expr_" + shape; Weight = weight; Eyes = eyes; Mouth = mouth; } } public static class NePoLaBoExpressionProfiles { private static readonly NePoLaBoExpressionWeight[][] profiles = new NePoLaBoExpressionWeight[7][] { new NePoLaBoExpressionWeight[0], new NePoLaBoExpressionWeight[4] { B("worry", 0.75f), B("brow_up", 0.25f), E("surprise", 0.85f), M("triangle", 0.6f) }, new NePoLaBoExpressionWeight[4] { B("worry", 0.85f), B("serious", 0.25f), E("focus", 0.45f), M("clench", 0.8f) }, new NePoLaBoExpressionWeight[3] { B("happy_brows", 0.45f), E("smile_eyes", 0.65f), M("smile", 0.85f) }, new NePoLaBoExpressionWeight[3] { B("brow_up", 0.65f), E("surprise", 0.9f), M("o", 0.65f) }, new NePoLaBoExpressionWeight[3] { B("happy_brows", 0.65f), E("smile_eyes", 0.85f), M("laugh", 0.85f) }, new NePoLaBoExpressionWeight[2] { B("worry", 0.7f), M("clench", 0.55f) } }; private static NePoLaBoExpressionWeight B(string n, float w) { return new NePoLaBoExpressionWeight(n, w); } private static NePoLaBoExpressionWeight E(string n, float w) { return new NePoLaBoExpressionWeight(n, w, eyes: true); } private static NePoLaBoExpressionWeight M(string n, float w) { return new NePoLaBoExpressionWeight(n, w, eyes: false, mouth: true); } public static NePoLaBoExpressionWeight[] Weights(NePoLaBoExpression state) { return profiles[(uint)state]; } } public sealed class NePoLaBoExpressionMixer { private sealed class Binding { public SkinnedMeshRenderer Renderer; public int[] Indices; public int Blink; public int Open; public int Round; } private readonly List<string> shapes = new List<string>(); private readonly Dictionary<string, int> slots = new Dictionary<string, int>(); private readonly List<Binding> bindings = new List<Binding>(); private float[] values; private float[] target; private bool[] eyes; private bool[] mouth; private readonly List<Tuple<SkinnedMeshRenderer, int>> angerDraws = new List<Tuple<SkinnedMeshRenderer, int>>(); private readonly MaterialPropertyBlock angerBlock = new MaterialPropertyBlock(); public NePoLaBoExpressionMixer(GameObject model) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown NePoLaBoExpressionWeight[] array; foreach (NePoLaBoExpression value in Enum.GetValues(typeof(NePoLaBoExpression))) { array = NePoLaBoExpressionProfiles.Weights(value); for (int i = 0; i < array.Length; i++) { NePoLaBoExpressionWeight nePoLaBoExpressionWeight = array[i]; if (!slots.ContainsKey(nePoLaBoExpressionWeight.Shape)) { slots[nePoLaBoExpressionWeight.Shape] = shapes.Count; shapes.Add(nePoLaBoExpressionWeight.Shape); } } } array = NePoLaBoPersonalityProfiles.Managed; for (int i = 0; i < array.Length; i++) { NePoLaBoExpressionWeight nePoLaBoExpressionWeight2 = array[i]; if (!slots.ContainsKey(nePoLaBoExpressionWeight2.Shape)) { slots[nePoLaBoExpressionWeight2.Shape] = shapes.Count; shapes.Add(nePoLaBoExpressionWeight2.Shape); } } values = new float[shapes.Count]; target = new float[shapes.Count]; eyes = new bool[shapes.Count]; mouth = new bool[shapes.Count]; foreach (NePoLaBoExpression value2 in Enum.GetValues(typeof(NePoLaBoExpression))) { array = NePoLaBoExpressionProfiles.Weights(value2); for (int i = 0; i < array.Length; i++) { NePoLaBoExpressionWeight nePoLaBoExpressionWeight3 = array[i]; int num = slots[nePoLaBoExpressionWeight3.Shape]; eyes[num] |= nePoLaBoExpressionWeight3.Eyes; mouth[num] |= nePoLaBoExpressionWeight3.Mouth; } } array = NePoLaBoPersonalityProfiles.Managed; for (int i = 0; i < array.Length; i++) { NePoLaBoExpressionWeight nePoLaBoExpressionWeight4 = array[i]; int num2 = slots[nePoLaBoExpressionWeight4.Shape]; eyes[num2] |= nePoLaBoExpressionWeight4.Eyes; mouth[num2] |= nePoLaBoExpressionWeight4.Mouth; } SkinnedMeshRenderer[] componentsInChildren = model.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val.sharedMesh) || NePoLaBoInkOutline.IsInk(val)) { continue; } Binding binding = new Binding { Renderer = val, Indices = new int[shapes.Count], Blink = val.sharedMesh.GetBlendShapeIndex("blink"), Open = val.sharedMesh.GetBlendShapeIndex("speech_open"), Round = val.sharedMesh.GetBlendShapeIndex("speech_round") }; for (int j = 0; j < shapes.Count; j++) { binding.Indices[j] = val.sharedMesh.GetBlendShapeIndex(shapes[j]); } bindings.Add(binding); Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { if (Object.op_Implicit((Object)(object)sharedMaterials[k]) && ((Object)sharedMaterials[k]).name.Contains("_AngerMark_")) { angerDraws.Add(Tuple.Create<SkinnedMeshRenderer, int>(val, k)); } } } } public void Step(NePoLaBoExpression state, float delta, bool immediate = false) { Step("", new NePoLaBoFaceState(state), delta, immediate); } public void Step(string character, NePoLaBoFaceState face, float delta, bool immediate = false) { NePoLaBoExpression expression = face.Expression; Array.Clear(target, 0, target.Length); float num = ((face.Reaction == NePoLaBoReaction.None) ? 1f : ((float)(int)face.Strength / 255f)); NePoLaBoExpressionWeight[] array = NePoLaBoPersonalityProfiles.Weights(character, face); for (int i = 0; i < array.Length; i++) { NePoLaBoExpressionWeight nePoLaBoExpressionWeight = array[i]; target[slots[nePoLaBoExpressionWeight.Shape]] = nePoLaBoExpressionWeight.Weight * ((nePoLaBoExpressionWeight.Shape == "expr_anger_mark") ? 1f : num); } if (character == "ShishiroBotan" && face.Reaction == NePoLaBoReaction.Critical) { target[slots["expr_ears_side"]] = 1f; } if (character == "ShishiroBotan" && face.Reaction == NePoLaBoReaction.Stunned) { target[slots["expr_ears_up"]] = 1f; } foreach (Tuple<SkinnedMeshRenderer, int> angerDraw in angerDraws) { if (Object.op_Implicit((Object)(object)angerDraw.Item1)) { ((Renderer)angerDraw.Item1).GetPropertyBlock(angerBlock, angerDraw.Item2); angerBlock.SetFloat("_GflOpacity", (face.Reaction == NePoLaBoReaction.Angry) ? num : 0f); ((Renderer)angerDraw.Item1).SetPropertyBlock(angerBlock, angerDraw.Item2); } } float num2 = ((immediate || expression == NePoLaBoExpression.Dead) ? 1f : (1f - Mathf.Exp((0f - Mathf.Clamp(delta, 0f, 0.1f)) * 13f))); for (int j = 0; j < values.Length; j++) { values[j] = Mathf.Lerp(values[j], target[j], num2); } foreach (Binding binding in bindings) { if (!Object.op_Implicit((Object)(object)binding.Renderer)) { continue; } float num3 = ((binding.Blink < 0) ? 0f : Mathf.Clamp01(binding.Renderer.GetBlendShapeWeight(binding.Blink) / 100f)); float num4 = ((binding.Open < 0) ? 0f : Mathf.Clamp01(binding.Renderer.GetBlendShapeWeight(binding.Open) / 85f)); if (expression == NePoLaBoExpression.Dead) { num3 = 1f; num4 = 0f; if (binding.Blink >= 0) { binding.Renderer.SetBlendShapeWeight(binding.Blink, 100f); } if (binding.Open >= 0) { binding.Renderer.SetBlendShapeWeight(binding.Open, 0f); } if (binding.Round >= 0) { binding.Renderer.SetBlendShapeWeight(binding.Round, 0f); } } for (int k = 0; k < values.Length; k++) { if (binding.Indices[k] >= 0) { float num5 = values[k]; if (eyes[k]) { num5 *= 1f - num3; } if (mouth[k]) { num5 *= 1f - num4 * 0.55f; } binding.Renderer.SetBlendShapeWeight(binding.Indices[k], num5 * 100f); } } } } } [DefaultExecutionOrder(280)] public sealed class NePoLaBoDeathFace : MonoBehaviour { private NePoLaBoExpressionMixer mixer; public void Initialize() { mixer = new NePoLaBoExpressionMixer(((Component)this).gameObject); mixer.Step(NePoLaBoExpression.Dead, 0f, immediate: true); } private void LateUpdate() { if (mixer == null) { Initialize(); } mixer.Step(NePoLaBoExpression.Dead, 0f, immediate: true); } } public struct NePoLaBoExpressionRecord { public ulong PlayerId; public ulong Owner; public byte Character; public NePoLaBoExpression Expression; public uint Revision; public NePoLaBoReaction Reaction; public byte Strength; public ulong GazePlayerId; public float GazeWeight; } public sealed class NePoLaBoExpressionStore { private sealed class Entry { public NePoLaBoExpressionRecord Record; public double At; } private readonly Dictionary<ulong, Entry> records = new Dictionary<ulong, Entry>(); public bool Accept(ulong sender, ulong actualOwner, NePoLaBoExpressionRecord value, double now) { if (sender != actualOwner || value.Owner != actualOwner || !NePoLaBoPersonalityProfiles.Valid(value.Character, new NePoLaBoFaceState { Expression = value.Expression, Reaction = value.Reaction, Strength = value.Strength }) || float.IsNaN(value.GazeWeight) || float.IsInfinity(value.GazeWeight) || value.GazeWeight < 0f || value.GazeWeight > 1f || (value.GazeWeight > 0f && (value.Character != 3 || value.Reaction != NePoLaBoReaction.Hearts || value.GazePlayerId == value.PlayerId)) || double.IsNaN(now) || double.IsInfinity(now)) { return false; } if (records.TryGetValue(value.PlayerId, out var value2) && value2.Record.Owner == actualOwner && (value.Revision < value2.Record.Revision || (value.Revision == value2.Record.Revision && (value.Character != value2.Record.Character || value.Expression != value2.Record.Expression || value.Reaction != value2.Record.Reaction || value.Strength != value2.Record.Strength || value.GazePlayerId != value2.Record.GazePlayerId || value.GazeWeight != value2.Record.GazeWeight)))) { return false; } records[value.PlayerId] = new Entry { Record = value, At = now }; return true; } public bool TryGet(ulong id, double now, out NePoLaBoExpressionRecord value) { value = default(NePoLaBoExpressionRecord); if (!records.TryGetValue(id, out var value2) || now - value2.At > 5.0 || now < value2.At) { return false; } value = value2.Record; return true; } public uint NextRevision(ulong id, ulong owner) { if (!records.TryGetValue(id, out var value) || value.Record.Owner != owner) { return 1u; } return value.Record.Revision + 1; } public NePoLaBoExpressionRecord[] Snapshot(double now) { List<NePoLaBoExpressionRecord> list = new List<NePoLaBoExpressionRecord>(); foreach (Entry value in records.Values) { if (now >= value.At && now - value.At <= 5.0) { list.Add(value.Record); } } list.Sort((NePoLaBoExpressionRecord a, NePoLaBoExpressionRecord b) => a.PlayerId.CompareTo(b.PlayerId)); return list.ToArray(); } public void RemoveOwner(ulong owner) { List<ulong> list = new List<ulong>(); foreach (KeyValuePair<ulong, Entry> record in records) { if (record.Value.Record.Owner == owner) { list.Add(record.Key); } } foreach (ulong item in list) { records.Remove(item); } } public void Clear() { records.Clear(); } } public static class NePoLaBoFirstPersonMesh { private sealed class Entry { public Mesh Mesh; public int[] BoneIndices; public int[] MaterialSlots; } private static readonly Dictionary<Mesh, Entry> Cache = new Dictionary<Mesh, Entry>(); public static int CachedMeshes => Cache.Count; private static HashSet<Transform> ArmBones(GameObject model) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Animator componentInChildren = model.GetComponentInChildren<Animator>(true); if (!Object.op_Implicit((Object)(object)componentInChildren) || !componentInChildren.isHuman) { throw new InvalidOperationException("NePoLaBo first-person avatar must be humanoid."); } HashSet<Transform> hashSet = new HashSet<Transform>(); HumanBodyBones[] array = new HumanBodyBones[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); HumanBodyBones[] array2 = (HumanBodyBones[])(object)array; foreach (HumanBodyBones val in array2) { Transform boneTransform = componentInChildren.GetBoneTransform(val); if (Object.op_Implicit((Object)(object)boneTransform)) { Transform[] componentsInChildren = ((Component)boneTransform).GetComponentsInChildren<Transform>(true); foreach (Transform item in componentsInChildren) { hashSet.Add(item); } } } return hashSet; } public static void Prime(GameObject model) { HashSet<Transform> arms = ArmBones(model); SkinnedMeshRenderer[] componentsInChildren = model.GetComponentsInChildren<SkinnedMeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Get(componentsInChildren[i], arms); } } public static IEnumerator PrimeIncremental(GameObject model) { HashSet<Transform> arms = ArmBones(model); SkinnedMeshRenderer[] componentsInChildren = model.GetComponentsInChildren<SkinnedMeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Get(componentsInChildren[i], arms); yield return null; } } private static bool Allowed(BoneWeight weight, bool[] bones) { if ((((BoneWeight)(ref weight)).weight0 <= 0f || bones[((BoneWeight)(ref weight)).boneIndex0]) && (((BoneWeight)(ref weight)).weight1 <= 0f || bones[((BoneWeight)(ref weight)).boneIndex1]) && (((BoneWeight)(ref weight)).weight2 <= 0f || bones[((BoneWeight)(ref weight)).boneIndex2])) { if (!(((BoneWeight)(ref weight)).weight3 <= 0f)) { return bones[((BoneWeight)(ref weight)).boneIndex3]; } return true; } return false; } private static Entry Get(SkinnedMeshRenderer renderer, HashSet<Transform> arms) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = renderer.sharedMesh; if (!Object.op_Implicit((Object)(object)sharedMesh)) { return null; } if (Cache.TryGetValue(sharedMesh, out var value)) { return value; } if (!sharedMesh.isReadable) { throw new InvalidOperationException("NePoLaBo first-person source mesh is not readable: " + ((Object)sharedMesh).name); } Transform[] bones = renderer.bones; bool[] array = new bool[bones.Length]; for (int i = 0; i < array.Length; i++) { array[i] = Object.op_Implicit((Object)(object)bones[i]) && arms.Contains(bones[i]); } BoneWeight[] boneWeights = sharedMesh.boneWeights; if (boneWeights.Length != sharedMesh.vertexCount) { throw new InvalidOperationException("NePoLaBo arms require four-weight source skinning."); } bool[] array2 = new bool[sharedMesh.vertexCount]; for (int j = 0; j < boneWeights.Length; j++) { array2[j] = Allowed(boneWeights[j], array); } List<int> list = new List<int>(); Dictionary<int, int> dictionary = new Dictionary<int, int>(); List<int[]> list2 = new List<int[]>(); List<int> list3 = new List<int>(); for (int k = 0; k < sharedMesh.subMeshCount; k++) { int[] triangles = sharedMesh.GetTriangles(k); List<int> list4 = new List<int>(); for (int l = 0; l < triangles.Length; l += 3) { if (!array2[triangles[l]] || !array2[triangles[l + 1]] || !array2[triangles[l + 2]]) { continue; } for (int m = 0; m < 3; m++) { int num = triangles[l + m]; if (!dictionary.TryGetValue(num, out var value2)) { value2 = list.Count; dictionary.Add(num, value2); list.Add(num); } list4.Add(value2); } } if (list4.Count > 0) { list3.Add(k); list2.Add(list4.ToArray()); } } if (list.Count == 0) { Cache.Add(sharedMesh, null); return null; } List<int> list5 = new List<int>(); Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); BoneWeight[] array3 = (BoneWeight[])(object)new BoneWeight[list.Count]; for (int n = 0; n < array3.Length; n++) { BoneWeight val = boneWeights[list[n]]; int[] array4 = new int[4] { ((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).boneIndex3 }; float[] array5 = new float[4] { ((BoneWeight)(ref val)).weight0, ((BoneWeight)(ref val)).weight1, ((BoneWeight)(ref val)).weight2, ((BoneWeight)(ref val)).weight3 }; for (int num2 = 0; num2 < 4; num2++) { if (array5[num2] <= 0f) { array4[num2] = 0; continue; } if (!dictionary2.TryGetValue(array4[num2], out var value3)) { value3 = list5.Count; dictionary2.Add(array4[num2], value3); list5.Add(array4[num2]); } array4[num2] = value3; } ((BoneWeight)(ref val)).boneIndex0 = array4[0]; ((BoneWeight)(ref val)).boneIndex1 = array4[1]; ((BoneWeight)(ref val)).boneIndex2 = array4[2]; ((BoneWeight)(ref val)).boneIndex3 = array4[3]; array3[n] = val; } Mesh val2 = new Mesh { name = ((Object)sharedMesh).name + "_NePoLaBoFirstPerson", indexFormat = (IndexFormat)(list.Count > 65535) }; val2.vertices = Subset(sharedMesh.vertices, list); if (sharedMesh.normals.Length == sharedMesh.vertexCount) { val2.normals = Subset(sharedMesh.normals, list); } if (sharedMesh.tangents.Length == sharedMesh.vertexCount) { val2.tangents = Subset(sharedMesh.tangents, list); } if (sharedMesh.colors32.Length == sharedMesh.vertexCount) { val2.colors32 = Subset(sharedMesh.colors32, list); } for (int num3 = 0; num3 < 8; num3++) { List<Vector4> list6 = new List<Vector4>(); sharedMesh.GetUVs(num3, list6); if (list6.Count == sharedMesh.vertexCount) { val2.SetUVs(num3, Subset(list6.ToArray(), list)); } } for (int num4 = 0; num4 < sharedMesh.blendShapeCount; num4++) { string blendShapeName = sharedMesh.GetBlendShapeName(num4); if (!blendShapeName.StartsWith("opt_", StringComparison.Ordinal)) { continue; } Vector3[] array6 = (Vector3[])(object)new Vector3[sharedMesh.vertexCount]; sharedMesh.GetBlendShapeFrameVertices(num4, 0, array6, (Vector3[])null, (Vector3[])null); Vector3[] array7 = Subset(array6, list); bool flag = false; Vector3[] array8 = array7; for (int num5 = 0; num5 < array8.Length; num5++) { Vector3 val3 = array8[num5]; if (((Vector3)(ref val3)).sqrMagnitude > 1E-14f) { flag = true; break; } } if (flag) { val2.AddBlendShapeFrame(blendShapeName, sharedMesh.GetBlendShapeFrameWeight(num4, 0), array7, (Vector3[])null, (Vector3[])null); } } val2.boneWeights = array3; val2.bindposes = Subset(sharedMesh.bindposes, list5); val2.subMeshCount = list2.Count; for (int num6 = 0; num6 < list2.Count; num6++) { val2.SetTriangles(list2[num6], num6, false); } val2.RecalculateBounds(); value = new Entry { Mesh = val2, BoneIndices = list5.ToArray(), MaterialSlots = list3.ToArray() }; Cache.Add(sharedMesh, value); return value; } private static T[] Subset<T>(T[] source, List<int> indices) { T[] array = new T[indices.Count]; for (int i = 0; i < indices.Count; i++) { array[i] = source[indices[i]]; } return array; } public static GameObject Convert(GameObject model) { NePoLaBoSourceRotationGrant component = model.GetComponent<NePoLaBoSourceRotationGrant>(); NePoLaBoSourceRotationGrant.Grant[] sourceGrants = (Object.op_Implicit((Object)(object)component) ? component.grants : null); HashSet<Transform> arms = ArmBones(model); SkinnedMeshRenderer[] componentsInChildren = model.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { Entry entry = Get(val, arms); if (entry == null) { ((Renderer)val).enabled = false; Remove((Object)(object)val); continue; } Transform[] bones = val.bones; Material[] sharedMaterials = ((Renderer)val).sharedMaterials; Transform[] array = (Transform[])(object)new Transform[entry.BoneIndices.Length]; Material[] array2 = (Material[])(object)new Material[entry.MaterialSlots.Length]; for (int j = 0; j < array.Length; j++) { array[j] = bones[entry.BoneIndices[j]]; } for (int k = 0; k < array2.Length; k++) { array2[k] = sharedMaterials[entry.MaterialSlots[k]]; } val.sharedMesh = entry.Mesh; val.bones = array; ((Renderer)val).sharedMaterials = array2; val.quality = (SkinQuality)4; val.updateWhenOffscreen = true; ((Renderer)val).shadowCastingMode = (ShadowCastingMode)0; } StripSimulation(model); NePoLaBoViewModelPose obj = model.GetComponent<NePoLaBoViewModelPose>() ?? model.AddComponent<NePoLaBoViewModelPose>(); obj.SourceGrants = sourceGrants; obj.Initialize(); model.GetComponent<NePoLaBoAdaptiveLighting>()?.Rebind(); model.GetComponent<NePoLaBoOutfitState>()?.Rebind(); return model; } public static void StripSimulation(GameObject model) { Collider[] componentsInChildren = model.GetComponentsInChildren<Collider>(true); foreach (Collider obj in componentsInChildren) { obj.enabled = false; Remove((Object)(object)obj); } MonoBehaviour[] componentsInChildren2 = model.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val)) { switch (((object)val).GetType().FullName) { case "NePoLaBoSuit.NePoLaBoSecondaryMotion": case "NePoLaBoSuit.NePoLaBoHeadTracking": case "NePoLaBoSuit.NePoLaBoFace": case "NePoLaBoSuit.NePoLaBoToonFrame": case "NePoLaBoSuit.NePoLaBoSourceRotationGrant": case "NePoLaBoSuit.NePoLaBoReactionFace": case "JigglePhysics.JiggleRigBuilder": ((Behaviour)val).enabled = false; Remove((Object)(object)val); break; } } } } private static void Remove(Object component) { if (Application.isPlaying) { Object.Destroy(component); } else { Object.DestroyImmediate(component); } } public static void Clear() { foreach (Entry value in Cache.Values) { if (value != null && Object.op_Implicit((Object)(object)value.Mesh)) { Remove((Object)(object)value.Mesh); } } Cache.Clear(); } } public static class NePoLaBoFirstPersonPatch { public static void Install(Harmony harmony) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown Type type = typeof(BodyReplacementBase).Assembly.GetType("ModelReplacement.Scripts.MeshHelper", throwOnError: true); MethodInfo methodInfo = AccessTools.Method(type, "ConvertModelToViewModel", new Type[1] { typeof(GameObject) }, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(type.FullName, "ConvertModelToViewModel"); } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NePoLaBoFirstPersonPatch), "BeforeConvert", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(BodyReplacementBase), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(NePoLaBoFirstPersonPatch), "AfterBodyCreated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Type type2 = typeof(BodyReplacementBase).Assembly.GetType("ModelReplacement.Scripts.Player.ViewModelUpdater", throwOnError: true); MethodInfo methodInfo2 = AccessTools.Method(type2, "UpdateViewModel", Type.EmptyTypes, (Type[])null); if (methodInfo2 == null) { throw new MissingMethodException(type2.FullName, "UpdateViewModel"); } harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(NePoLaBoFirstPersonPatch), "BeforeViewPose", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type2, "AssignViewModelReplacement", new Type[2] { typeof(GameObject), typeof(GameObject) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(NePoLaBoFirstPersonPatch), "AfterViewAssigned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool BeforeConvert(GameObject __0, ref GameObject __result) { if (!Object.op_Implicit((Object)(object)__0) || !((Object)__0).name.StartsWith("NePoLaBo_", StringComparison.Ordinal)) { return true; } __result = NePoLaBoFirstPersonMesh.Convert(__0); return false; } private static void AfterBodyCreated(BodyReplacementBase __instance) { if (!(__instance is NePoLaBoBody)) { return; } object? value = AccessTools.Field(typeof(BodyReplacementBase), "replacementModel").GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); object? value2 = AccessTools.Field(typeof(BodyReplacementBase), "replacementModelShadow").GetValue(__instance); GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { NePoLaBoFirstPersonMesh.StripSimulation(val2); val2.AddComponent<NePoLaBoShadowPose>().Initialize(val); } object? value3 = AccessTools.Field(typeof(BodyReplacementBase), "replacementViewModel").GetValue(__instance); GameObject val3 = (GameObject)((value3 is GameObject) ? value3 : null); if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)__instance.controller)) { NePoLaBoViewModelPose component = val3.GetComponent<NePoLaBoViewModelPose>(); SkinnedMeshRenderer thisPlayerModelArms = __instance.controller.thisPlayerModelArms; if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)thisPlayerModelArms)) { component.Bind(thisPlayerModelArms, __instance.controller.playerModelArmsMetarig); } } } private static bool BeforeViewPose(ViewModelUpdater __instance) { GameObject replacementViewModel = __instance.replacementViewModel; if (!Object.op_Implicit((Object)(object)replacementViewModel)) { return true; } NePoLaBoViewModelPose component = replacementViewModel.GetComponent<NePoLaBoViewModelPose>(); if (Object.op_Implicit((Object)(object)co