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 Lacia v0.2.47
BepInEx/plugins/LaciaMod/LaciaMod.dll
Decompiled 21 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using BepInEx; using EntityStates; using EntityStates.Huntress.HuntressWeapon; using EntityStates.Railgunner.Weapon; using EntityStates.VoidSurvivor.Weapon; using HarmonyLib; using KinematicCharacterController; using Lacia.Content; using Lacia.RoR2Mod; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using R2API; using RoR2; using RoR2.ConVar; using RoR2.ContentManagement; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LaciaMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LaciaMod")] [assembly: AssemblyTitle("LaciaMod")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Lacia.Content { public enum LaciaAirState { Grounded, Rising, Falling, Landing } [Serializable] public sealed class LaciaClipRange { public string name; public int start; public int end; } [Serializable] public sealed class LaciaMeshTrack { public string name; public string role; public int material; public float[] visibility; } [Serializable] public sealed class LaciaMaterialInfo { public int index; public string texture; public bool transparent; } [Serializable] public sealed class LaciaPresentationData { public LaciaClipRange[] clips; public LaciaMeshTrack[] meshes; public LaciaMaterialInfo[] materials; } public sealed class LaciaPresentation : MonoBehaviour { public Animator animator; public TextAsset sourceData; private LaciaPresentationData data; private readonly Dictionary<string, Renderer> renderers = new Dictionary<string, Renderer>(); private readonly Dictionary<int, LaciaClipRange> clips = new Dictionary<int, LaciaClipRange>(); private string currentState; private Mesh muzzleMesh; private Transform pelvis; private Transform leftThigh; private Transform rightThigh; private Transform combatSpine; public float CombatPitch; private int legLayer = -1; private Vector3 movement; private Vector3 runPelvis; private Vector3 runLeftPosition; private Vector3 runRightPosition; private Quaternion runLeftRotation; private Quaternion runRightRotation; private Quaternion freeFacing; private float locomotionClock; private float legYaw; private bool splitPose; private Transform[] poseTransforms; private Vector3[] displayedPositions; private Vector3[] fromPositions; private Quaternion[] displayedRotations; private Quaternion[] fromRotations; private Quaternion displayedFacing; private Quaternion fromFacing; private string blendKey; private float blendAge = 1f; private float blendSeconds = 0.12f; private float idleClock; private readonly Dictionary<Renderer, int[]> meshBoneIndices = new Dictionary<Renderer, int[]>(); private readonly Dictionary<Renderer, bool> fromVisibility = new Dictionary<Renderer, bool>(); private readonly Dictionary<Renderer, bool> displayedVisibility = new Dictionary<Renderer, bool>(); private bool[] snapBones; private bool[] holdBones; private bool cloaked; private readonly Dictionary<Renderer, Material[]> normalMaterials = new Dictionary<Renderer, Material[]>(); private readonly Dictionary<Material, Material> cloakMaterials = new Dictionary<Material, Material>(); private float airPhase; public string CurrentState => currentState; public float CurrentPhase { get; private set; } public bool InstantPreview { get; set; } public float CloakOpacity { get { if (!Cloaked) { return 1f; } return 0.3f; } } public bool Cloaked { get { return cloaked; } set { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) if (cloaked == value) { return; } Initialize(); cloaked = value; foreach (KeyValuePair<Renderer, Material[]> normalMaterial in normalMaterials) { if (!value) { normalMaterial.Key.sharedMaterials = normalMaterial.Value; continue; } Material[] array = (Material[])(object)new Material[normalMaterial.Value.Length]; for (int i = 0; i < array.Length; i++) { Material val = normalMaterial.Value[i]; if (Object.op_Implicit((Object)(object)val)) { if (!cloakMaterials.TryGetValue(val, out var value2)) { value2 = new Material(val) { name = ((Object)val).name + " cloak preview" }; value2.SetFloat("_Mode", 3f); value2.SetInt("_SrcBlend", 5); value2.SetInt("_DstBlend", 10); value2.SetInt("_ZWrite", 0); value2.DisableKeyword("_ALPHATEST_ON"); value2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); value2.EnableKeyword("_ALPHABLEND_ON"); value2.renderQueue = 3000; Color color = value2.color; color.a = 0.3f; value2.color = color; cloakMaterials[val] = value2; } array[i] = value2; } } normalMaterial.Key.sharedMaterials = array; } } } public float TransitionProgress { get { if (!InstantPreview) { return Mathf.Clamp01(blendAge / Mathf.Max(0.001f, blendSeconds)); } return 1f; } } public LaciaAirState AirState { get; private set; } private bool AirPose => AirState != LaciaAirState.Grounded; public string AirClip { get { if (AirState != LaciaAirState.Landing) { return "single_skill_01_a"; } return "single_skill_01_a_end"; } } public bool Moving => ((Vector3)(ref movement)).sqrMagnitude > 0.01f; public bool SplitPose => splitPose; public float LegHeading => legYaw; public float LocomotionTime => locomotionClock; public bool Sprinting { get; private set; } public string LocomotionClip { get { if (!Sprinting) { return "bat_run"; } return "single_run"; } } public void SetSprinting(bool sprinting) { Sprinting = sprinting; } public void SetAirState(LaciaAirState state, float phase) { AirState = state; airPhase = Mathf.Clamp01(phase); } public void AdvanceTransitions(float seconds) { blendAge += Mathf.Max(0f, seconds); idleClock += Mathf.Max(0f, seconds) / 1.67f; } private void BeginSample(string key, float seconds) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (blendKey == key) { return; } blendKey = key; blendAge = 0f; blendSeconds = seconds; Array.Copy(displayedPositions, fromPositions, poseTransforms.Length); Array.Copy(displayedRotations, fromRotations, poseTransforms.Length); fromFacing = displayedFacing; foreach (KeyValuePair<Renderer, int[]> meshBoneIndex in meshBoneIndices) { fromVisibility[meshBoneIndex.Key] = meshBoneIndex.Key.enabled; } } private void FinishSample() { //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.SmoothStep(0f, 1f, TransitionProgress); Array.Clear(snapBones, 0, snapBones.Length); Array.Clear(holdBones, 0, holdBones.Length); foreach (KeyValuePair<Renderer, int[]> meshBoneIndex in meshBoneIndices) { if (!fromVisibility.TryGetValue(meshBoneIndex.Key, out var value)) { continue; } bool enabled = meshBoneIndex.Key.enabled; if (enabled && !value) { int[] value2 = meshBoneIndex.Value; foreach (int num2 in value2) { snapBones[num2] = true; } meshBoneIndex.Key.enabled = num >= 0.8f; } else if (!enabled && value && num < 0.8f) { meshBoneIndex.Key.enabled = true; int[] value2 = meshBoneIndex.Value; foreach (int num3 in value2) { holdBones[num3] = true; } } } for (int j = 0; j < poseTransforms.Length; j++) { Transform val = poseTransforms[j]; float num4 = (holdBones[j] ? 0f : (snapBones[j] ? 1f : num)); val.localPosition = Vector3.Lerp(fromPositions[j], val.localPosition, num4); val.localRotation = Quaternion.Slerp(fromRotations[j], val.localRotation, num4); displayedPositions[j] = val.localPosition; displayedRotations[j] = val.localRotation; } ((Component)this).transform.rotation = Quaternion.Slerp(fromFacing, ((Component)this).transform.rotation, num); displayedFacing = ((Component)this).transform.rotation; foreach (KeyValuePair<Renderer, int[]> meshBoneIndex2 in meshBoneIndices) { displayedVisibility[meshBoneIndex2.Key] = meshBoneIndex2.Key.enabled; } } public void PlayAir() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) Initialize(); BeginSample("air:" + AirState, 0.1f); splitPose = false; if (legLayer >= 0) { animator.SetLayerWeight(legLayer, 0f); } ((Component)this).transform.rotation = freeFacing; animator.speed = 0f; animator.Play(AirClip, 0, Mathf.Min(airPhase, 0.99999f)); animator.Update(0f); currentState = AirClip; CurrentPhase = airPhase; ApplyFrame(AirClip, airPhase); FinishSample(); } public void RestoreLocomotion(Vector3 velocity, float clock, Quaternion facing, float heading = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_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_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_0043: Unknown result type (might be due to invalid IL or missing references) Initialize(); movement = Vector3.ProjectOnPlane(velocity, Vector3.up); locomotionClock = clock; legYaw = heading; freeFacing = facing; displayedFacing = (fromFacing = facing); ((Component)this).transform.rotation = facing; } public void SetLocomotion(Vector3 velocity, float deltaTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_005e: 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_006f: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Initialize(); movement = Vector3.ProjectOnPlane(velocity, Vector3.up); float num = (Sprinting ? (2f / 3f) : 0.8f); locomotionClock += deltaTime * ((Vector3)(ref movement)).magnitude / 7f / num; if (Moving) { freeFacing = Quaternion.RotateTowards(freeFacing, Quaternion.LookRotation(movement), 900f * deltaTime); } Vector3 val = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? ((Component)this).transform.parent.forward : ((Component)this).transform.forward); float num2 = (Moving ? Vector3.SignedAngle(val, movement, Vector3.up) : 0f); if (Mathf.Abs(num2) > 90f) { num2 = Mathf.DeltaAngle(0f, num2 + 180f); } legYaw = Mathf.MoveTowardsAngle(legYaw, Mathf.Clamp(num2, -60f, 60f), 540f * deltaTime); } private void ApplyLegHeading() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: 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_003e: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (splitPose) { Vector3 position = pelvis.position; Quaternion val = Quaternion.AngleAxis(AirPose ? 0f : legYaw, Vector3.up); leftThigh.SetPositionAndRotation(position + val * (runLeftPosition - runPelvis), val * runLeftRotation); rightThigh.SetPositionAndRotation(position + val * (runRightPosition - runPelvis), val * runRightRotation); } } public Vector3 MuzzlePosition(bool monolith, Transform owner) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) Initialize(); if (!Object.op_Implicit((Object)(object)muzzleMesh)) { muzzleMesh = new Mesh { name = "Temporary muzzle sample" }; } Vector3 val = owner.position + Vector3.up * 1.35f + owner.forward * 0.55f; float num = float.NegativeInfinity; LaciaMeshTrack[] meshes = data.meshes; Vector3 val4 = default(Vector3); foreach (LaciaMeshTrack laciaMeshTrack in meshes) { if (!renderers.TryGetValue(laciaMeshTrack.name, out var value) || !value.enabled) { continue; } SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((value is SkinnedMeshRenderer) ? value : null); if (!Object.op_Implicit((Object)(object)val2)) { continue; } bool num2; if (!monolith) { num2 = laciaMeshTrack.role != "sidearm"; } else { if (laciaMeshTrack.role == "sidearm") { continue; } num2 = val2.sharedMesh.vertexCount > 5000; } if (num2) { continue; } val2.BakeMesh(muzzleMesh); Vector3 localScale = ((Component)val2).transform.localScale; Vector3[] vertices = muzzleMesh.vertices; foreach (Vector3 val3 in vertices) { ((Vector3)(ref val4))..ctor(val3.x / localScale.x, val3.y / localScale.y, val3.z / localScale.z); Vector3 val5 = ((Component)val2).transform.TransformPoint(val4); float num3 = Vector3.Dot(val5 - owner.position, owner.forward); if (num3 > num) { num = num3; val = val5; } } } return val + owner.forward * 0.03f; } private void OnDestroy() { if (Object.op_Implicit((Object)(object)muzzleMesh)) { Object.Destroy((Object)(object)muzzleMesh); } foreach (Material value in cloakMaterials.Values) { if (Object.op_Implicit((Object)(object)value)) { Object.Destroy((Object)(object)value); } } } public void PoseAt(string state, float phase) { //IL_0057: 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_005c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) Initialize(); int num = Animator.StringToHash(state); if (!animator.HasState(0, num)) { throw new InvalidOperationException("Missing animation: " + state); } Vector3 val = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? ((Component)this).transform.parent.forward : ((Component)this).transform.forward); string text = (AirPose ? AirState.ToString() : (Moving ? (LocomotionClip + ((Vector3.Dot(val, movement) < 0f) ? ":back" : ":forward")) : "stand")); BeginSample("combat:" + state + ":" + text, (state == "single_skill_02_b") ? 0.025f : 0.05f); ((Component)this).transform.localRotation = Quaternion.identity; freeFacing = ((Component)this).transform.rotation; CurrentPhase = Mathf.Clamp01(phase); animator.speed = 0f; splitPose = (Moving || AirPose) && legLayer >= 0; if (legLayer >= 0) { animator.SetLayerWeight(legLayer, 0f); } if (splitPose) { float num2 = Vector3.SignedAngle(((Component)this).transform.forward, movement, Vector3.up); bool flag = Mathf.Abs(num2) > 90f; float num3 = (AirPose ? airPhase : Mathf.Repeat(flag ? (0f - locomotionClock) : locomotionClock, 1f)); string text2 = (AirPose ? AirClip : LocomotionClip); if (flag) { num2 = Mathf.DeltaAngle(0f, num2 + 180f); } animator.Play(text2, 0, Mathf.Min(num3, 0.99999f)); animator.Update(0f); runPelvis = pelvis.position; runLeftPosition = leftThigh.position; runLeftRotation = leftThigh.rotation; runRightPosition = rightThigh.position; runRightRotation = rightThigh.rotation; animator.Play(text2, legLayer, Mathf.Min(num3, 0.99999f)); animator.SetLayerWeight(legLayer, 1f); } animator.Play(num, 0, Mathf.Min(CurrentPhase, 0.99999f)); animator.Update(0f); ApplyLegHeading(); currentState = state; ApplyFrame(state, CurrentPhase); if (Object.op_Implicit((Object)(object)combatSpine) && Mathf.Abs(CombatPitch) > 0.01f) { combatSpine.rotation = Quaternion.AngleAxis(Mathf.Clamp(CombatPitch, -70f, 70f), ((Component)this).transform.right) * combatSpine.rotation; } FinishSample(); } private void Awake() { } public void Initialize() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) if (data != null) { return; } if (!Object.op_Implicit((Object)(object)animator)) { animator = ((Component)this).GetComponentInChildren<Animator>(true); } data = JsonConvert.DeserializeObject<LaciaPresentationData>(sourceData.text); if (data == null || data.clips == null) { throw new InvalidOperationException("Lacia animation metadata failed to deserialize: " + ((Object)sourceData).name); } Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { renderers[((Object)val).name] = val; normalMaterials[val] = val.sharedMaterials; } LaciaClipRange[] array = data.clips; foreach (LaciaClipRange laciaClipRange in array) { clips[Animator.StringToHash(laciaClipRange.name)] = laciaClipRange; } Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren2) { if (((Object)val2).name == "Bip001 Spine") { combatSpine = val2; } if (((Object)val2).name == "Bip001 Pelvis") { pelvis = val2; } else if (((Object)val2).name == "Bip001 L Thigh") { leftThigh = val2; } else if (((Object)val2).name == "Bip001 R Thigh") { rightThigh = val2; } } legLayer = animator.GetLayerIndex("Moving legs"); freeFacing = ((Component)this).transform.rotation; poseTransforms = ((Component)this).GetComponentsInChildren<Transform>(true); List<Transform> list = new List<Transform>(poseTransforms); list.Remove(((Component)this).transform); poseTransforms = list.ToArray(); displayedPositions = (Vector3[])(object)new Vector3[poseTransforms.Length]; fromPositions = (Vector3[])(object)new Vector3[poseTransforms.Length]; displayedRotations = (Quaternion[])(object)new Quaternion[poseTransforms.Length]; fromRotations = (Quaternion[])(object)new Quaternion[poseTransforms.Length]; for (int j = 0; j < poseTransforms.Length; j++) { displayedPositions[j] = (fromPositions[j] = poseTransforms[j].localPosition); displayedRotations[j] = (fromRotations[j] = poseTransforms[j].localRotation); } displayedFacing = (fromFacing = ((Component)this).transform.rotation); snapBones = new bool[poseTransforms.Length]; holdBones = new bool[poseTransforms.Length]; Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>(); for (int k = 0; k < poseTransforms.Length; k++) { dictionary[poseTransforms[k]] = k; } SkinnedMeshRenderer[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val3 in componentsInChildren3) { HashSet<int> hashSet = new HashSet<int>(); HashSet<int> hashSet2 = new HashSet<int>(); BoneWeight[] boneWeights = val3.sharedMesh.boneWeights; for (int l = 0; l < boneWeights.Length; l++) { BoneWeight val4 = boneWeights[l]; if (((BoneWeight)(ref val4)).weight0 > 0f) { hashSet2.Add(((BoneWeight)(ref val4)).boneIndex0); } if (((BoneWeight)(ref val4)).weight1 > 0f) { hashSet2.Add(((BoneWeight)(ref val4)).boneIndex1); } if (((BoneWeight)(ref val4)).weight2 > 0f) { hashSet2.Add(((BoneWeight)(ref val4)).boneIndex2); } if (((BoneWeight)(ref val4)).weight3 > 0f) { hashSet2.Add(((BoneWeight)(ref val4)).boneIndex3); } } foreach (int item in hashSet2) { Transform val5 = val3.bones[item]; while (Object.op_Implicit((Object)(object)val5) && (Object)(object)val5 != (Object)(object)((Component)this).transform && !((Object)val5).name.StartsWith("Bip001")) { if (dictionary.TryGetValue(val5, out var value)) { hashSet.Add(value); } val5 = val5.parent; } } int[] array2 = new int[hashSet.Count]; hashSet.CopyTo(array2); meshBoneIndices[(Renderer)(object)val3] = array2; } } public void Play(string state, float speed = 1f, bool restart = false) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) Initialize(); if (state == "bat_run") { state = LocomotionClip; } BeginSample("ground:" + state, 0.12f); splitPose = false; if (legLayer >= 0) { animator.SetLayerWeight(legLayer, 0f); } ((Component)this).transform.rotation = freeFacing; int num = Animator.StringToHash(state); if (animator.HasState(0, num)) { CurrentPhase = Mathf.Repeat((state == "bat_run" || state == "single_run") ? locomotionClock : idleClock, 1f); animator.speed = 0f; animator.Play(num, 0, CurrentPhase); animator.Update(0f); currentState = state; ApplyFrame(state, CurrentPhase); FinishSample(); } } public void ApplyFrame(string sourceClip, float normalizedTime) { Initialize(); if (clips.TryGetValue(Animator.StringToHash(sourceClip), out var value)) { ApplyVisibility(value, normalizedTime); } } private void LateUpdate() { //IL_0019: 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_0052: Unknown result type (might be due to invalid IL or missing references) Initialize(); for (int i = 0; i < poseTransforms.Length; i++) { poseTransforms[i].localPosition = displayedPositions[i]; poseTransforms[i].localRotation = displayedRotations[i]; } ((Component)this).transform.rotation = displayedFacing; foreach (KeyValuePair<Renderer, bool> item in displayedVisibility) { item.Key.enabled = item.Value; } } private void ApplyVisibility(LaciaClipRange range, float time) { int num = Mathf.RoundToInt(Mathf.Lerp((float)range.start, (float)range.end, Mathf.Clamp01(time))); LaciaMeshTrack[] meshes = data.meshes; foreach (LaciaMeshTrack laciaMeshTrack in meshes) { if (renderers.TryGetValue(laciaMeshTrack.name, out var value) && laciaMeshTrack.visibility.Length != 0) { value.enabled = laciaMeshTrack.visibility[Mathf.Clamp(num, 0, laciaMeshTrack.visibility.Length - 1)] >= 0.001f; } } } } [Serializable] public class LaciaEffectDefinition { [Serializable] public class Bone { public string name; public float[] positions; public float[] rotations; public float[] scales; public float[] inverseBind; public float[] visibility; } [Serializable] public class Surface { public string texture; public int flags; public float[] uvSpeed; public float[] colors; public float[] offsets; } [Serializable] public class Geometry { public string name; public int material; public int mainBone; public bool billboard; public float[] vertices; public float[] uv; public float[] weights; public int[] triangles; public int[] indices; } [Serializable] public class Emitter { public string name; public string texture; public int bone; public int count; public float speed; public float speedVariation; public float coneAngle; public float gravity; public float lifeSeconds; public float emissionRate; public float width; public float height; public int[] atlas; public int[] colors; public int[] alpha; public float[] sizes; } public string key; public string source; public string sha256; public int frames; public float fps; public Bone[] bones; public Surface[] materials; public Geometry[] meshes; public Emitter[] emitters; } public sealed class LaciaSourceEffect : MonoBehaviour { public TextAsset sourceData; public Transform[] effectBones; public SkinnedMeshRenderer[] surfaces; public int[] surfaceMaterials; public int[] surfaceBones; public ParticleSystem[] particles; public int[] particleBones; public bool loop; public float lifetime = 1.2f; public float heldTime = -1f; public Vector3 originOffset; private static readonly Dictionary<string, LaciaEffectDefinition> Cache = new Dictionary<string, LaciaEffectDefinition>(); private static readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>(); private MaterialPropertyBlock block; private LaciaEffectDefinition definition; private float nextSample; private bool settledUtility; public float Age { get; private set; } public string SourceKey => Data.key; private LaciaEffectDefinition Data { get { if (definition != null) { return definition; } if (!Cache.TryGetValue(((Object)sourceData).name, out var value)) { value = JsonConvert.DeserializeObject<LaciaEffectDefinition>(sourceData.text); Cache[((Object)sourceData).name] = value; } definition = value; return value; } } public int SamplesTaken { get; private set; } private void Awake() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown block = new MaterialPropertyBlock(); } private void Update() { Step(Time.deltaTime); } public void Step(float seconds) { Age += Mathf.Max(0f, seconds); bool num = Data.key.StartsWith("Utility"); if (!num || Age >= nextSample) { Sample(Age + 0.04f); nextSample = Age + 1f / 30f; } if (num && loop && !settledUtility && Age >= 0.25f) { settledUtility = true; for (int i = 0; i < particles.Length; i++) { string name = Data.emitters[i].name; if (name.Contains("kuosan") || name.Contains("dimian") || name.Contains("tiaoshang") || name.Contains("konghzong")) { particles[i].Stop(false, (ParticleSystemStopBehavior)1); } } } if (!loop && Age >= 0.18f) { ParticleSystem[] array = particles; foreach (ParticleSystem val in array) { if (Object.op_Implicit((Object)(object)val) && val.isEmitting) { val.Stop(false, (ParticleSystemStopBehavior)1); } } } if (lifetime > 0f && Age >= lifetime) { ((Component)this).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)this).gameObject); } } private static Vector3 V(float[] a, int frame, Vector3 fallback) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (a == null || a.Length < 3) { return fallback; } int num = Mathf.Min(frame, a.Length / 3 - 1) * 3; return new Vector3(a[num], a[num + 1], a[num + 2]); } public void Sample(float seconds) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_0840: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)sourceData)) { return; } SamplesTaken++; LaciaEffectDefinition data = Data; bool flag = data.key.StartsWith("MonolithCharge"); bool flag2 = data.key.StartsWith("Utility"); bool flag3 = data.key.StartsWith("SpecialLoop"); float num = ((heldTime >= 0f) ? heldTime : seconds); if (flag3) { num = 0.7f - 0.5f * Mathf.Cos(seconds * MathF.PI); } int num2 = Mathf.FloorToInt(Mathf.Max(0f, num) * data.fps); num2 = (loop ? (num2 % Mathf.Max(1, data.frames)) : Mathf.Min(num2, data.frames - 1)); int num3 = Mathf.Min(num2 + 1, data.frames - 1); float num4 = (flag3 ? Mathf.Repeat(num * data.fps, 1f) : 0f); for (int i = 0; i < effectBones.Length; i++) { LaciaEffectDefinition.Bone bone = data.bones[i]; effectBones[i].localPosition = Vector3.Lerp(V(bone.positions, num2, Vector3.zero), V(bone.positions, num3, Vector3.zero), num4) + originOffset; effectBones[i].localScale = Vector3.Lerp(V(bone.scales, num2, Vector3.one), V(bone.scales, num3, Vector3.one), num4); if (bone.rotations.Length >= 4) { int num5 = Mathf.Min(num2, bone.rotations.Length / 4 - 1) * 4; int num6 = Mathf.Min(num3, bone.rotations.Length / 4 - 1) * 4; Transform obj = effectBones[i]; Quaternion val = new Quaternion(bone.rotations[num5], bone.rotations[num5 + 1], bone.rotations[num5 + 2], bone.rotations[num5 + 3]); Quaternion normalized = ((Quaternion)(ref val)).normalized; val = new Quaternion(bone.rotations[num6], bone.rotations[num6 + 1], bone.rotations[num6 + 2], bone.rotations[num6 + 3]); obj.localRotation = Quaternion.Slerp(normalized, ((Quaternion)(ref val)).normalized, num4); } } if (flag || flag2 || flag3) { for (int j = 0; j < effectBones.Length; j++) { float num7 = (flag ? ((j % 2 == 0) ? 28 : (-19)) : (flag2 ? ((j % 2 == 0) ? 24 : (-17)) : ((j % 2 == 0) ? 14 : (-11)))); Quaternion val2 = Quaternion.AngleAxis(Age * (num7 + (float)(j % 3 * 3)), Vector3.up); effectBones[j].localPosition = val2 * effectBones[j].localPosition; effectBones[j].localRotation = val2 * effectBones[j].localRotation; } } if (flag) { CenterChargeFlashes(data); } if (block == null) { block = new MaterialPropertyBlock(); } for (int k = 0; k < surfaces.Length; k++) { LaciaEffectDefinition.Surface surface = data.materials[surfaceMaterials[k]]; LaciaEffectDefinition.Bone bone2 = data.bones[surfaceBones[k]]; float num8 = ((bone2.visibility.Length != 0) ? Mathf.Lerp(bone2.visibility[Mathf.Min(num2, bone2.visibility.Length - 1)], bone2.visibility[Mathf.Min(num3, bone2.visibility.Length - 1)], num4) : 1f); Color val3 = Color.white; if (surface.colors.Length >= 4) { int num9 = Mathf.Min(num2, surface.colors.Length / 4 - 1) * 4; int num10 = Mathf.Min(num3, surface.colors.Length / 4 - 1) * 4; val3 = Color.Lerp(new Color(surface.colors[num9], surface.colors[num9 + 1], surface.colors[num9 + 2], surface.colors[num9 + 3]), new Color(surface.colors[num10], surface.colors[num10 + 1], surface.colors[num10 + 2], surface.colors[num10 + 3]), num4); } val3.a *= num8; if (flag3) { surface.texture.StartsWith("251_"); } else _ = 0; bool flag4 = flag && (data.meshes[k].name.Contains("shanguang") || data.meshes[k].name.Contains("guangci") || data.meshes[k].name.Contains("gya#") || data.meshes[k].name.Contains("guangdian")); if (flag4 && surface.colors.Length >= 4) { int num11 = 0; for (int l = 4; l < surface.colors.Length; l += 4) { if (surface.colors[l + 3] > surface.colors[num11 + 3]) { num11 = l; } } ((Color)(ref val3))..ctor(surface.colors[num11], surface.colors[num11 + 1], surface.colors[num11 + 2], surface.colors[num11 + 3] * (0.65f + 0.2f * Mathf.Sin(Age * 5f + (float)k))); } if (flag) { val3.a *= 0.9f + 0.1f * Mathf.Sin(Age * 5f + (float)k * 0.7f); } bool flag5 = flag3 && data.key.EndsWith("_Skin5") && data.meshes[k].name.StartsWith("avmesh.gb#9"); bool flag6 = flag && data.key.EndsWith("_Skin5") && data.meshes[k].name.StartsWith("avmesh.feng1"); string name = data.meshes[k].name; bool flag7 = flag3 && (name.Contains("gy#") || name.Contains("yun#") || name.Contains("shang#") || name.Contains("Plane001")); bool flag8 = data.key.StartsWith("MonolithFire") && name.StartsWith("avmesh.chongjibo"); ((Renderer)surfaces[k]).enabled = !flag5 && !flag6 && !flag7 && !flag8 && val3.a > 0.001f; Vector2 val4 = Vector2.zero; if (surface.offsets.Length >= 2) { int num12 = Mathf.Min(num2, surface.offsets.Length / 2 - 1) * 2; int num13 = Mathf.Min(num3, surface.offsets.Length / 2 - 1) * 2; val4 = Vector2.Lerp(new Vector2(surface.offsets[num12], 0f - surface.offsets[num12 + 1]), new Vector2(surface.offsets[num13], 0f - surface.offsets[num13 + 1]), num4); } if (surface.uvSpeed.Length >= 2) { val4 += new Vector2(surface.uvSpeed[0], 0f - surface.uvSpeed[1]) * seconds; } if (flag4) { val4 = Vector2.zero; } else if (flag || flag2 || flag3) { val4.y += Age * ((k % 2 == 0) ? 0.065f : (-0.045f)); } block.Clear(); if (!flag2) { block.SetFloat("_Intensity", 1f); } block.SetColor("_Color", val3); block.SetVector("_MainTex_ST", new Vector4(1f, 1f, val4.x, val4.y)); ((Renderer)surfaces[k]).SetPropertyBlock(block); } } private void CenterChargeFlashes(LaciaEffectDefinition data) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) HashSet<int> hashSet = new HashSet<int>(); LaciaEffectDefinition.Geometry[] meshes = data.meshes; foreach (LaciaEffectDefinition.Geometry geometry in meshes) { if (!geometry.name.Contains("shanguang") && !geometry.name.Contains("guangci") && !geometry.name.Contains("gya#")) { continue; } int mainBone = geometry.mainBone; if (!hashSet.Add(mainBone) || geometry.vertices.Length == 0) { continue; } Vector3 val = Vector3.zero; for (int j = 0; j < geometry.vertices.Length; j += 3) { val += new Vector3(geometry.vertices[j], geometry.vertices[j + 1], geometry.vertices[j + 2]); } val /= (float)(geometry.vertices.Length / 3); float[] inverseBind = data.bones[mainBone].inverseBind; Matrix4x4 val2 = default(Matrix4x4); for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { ((Matrix4x4)(ref val2))[k, l] = inverseBind[k * 4 + l]; } } Transform val3 = effectBones[mainBone]; val3.localScale = V(data.bones[mainBone].scales, 8, Vector3.one); if (geometry.name.Contains("guangci")) { val3.localScale *= 0.5f; } Matrix4x4 val4 = Matrix4x4.TRS(val3.localPosition, val3.localRotation, val3.localScale) * val2; Vector3 val5 = ((Matrix4x4)(ref val4)).MultiplyPoint3x4(val); val3.localPosition -= val5; } } public static LaciaSourceEffect Spawn(string key, bool skin5, Vector3 point, Quaternion rotation, float scale = 1f, Transform parent = null, bool loop = false, float lifetime = 1.2f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return LaciaAssets.Effect(key, skin5, point, rotation, scale, parent, loop, lifetime); } } } namespace Lacia.RoR2Mod { public sealed class LaciaFirstStageReward : MonoBehaviour { private Run run; private Stage firstStage; private Transform trackedPod; private bool sawStage; private bool expired; private bool consumed; private bool hasPod; private Vector3 podPosition; private Vector3 podRight; public static void Install() { Run.onRunStartGlobal += OnRunStart; } private static void OnRunStart(Run run) { if (NetworkServer.active && !Object.op_Implicit((Object)(object)((Component)run).GetComponent<LaciaFirstStageReward>())) { ((Component)run).gameObject.AddComponent<LaciaFirstStageReward>(); } } private void Awake() { run = ((Component)this).GetComponent<Run>(); Stage.onStageStartGlobal += OnStageStart; VehicleSeat.onPassengerEnterGlobal += RememberPod; VehicleSeat.onPassengerExitGlobal += RememberPod; CharacterBody.onBodyStartGlobal += OnBodyStart; BossGroup.onBossGroupDefeatedServer += OnBossDefeated; } private void OnStageStart(Stage stage) { if (!sawStage) { sawStage = true; firstStage = stage; if (run.stageClearCount != 0) { expired = true; } } else if ((Object)(object)stage != (Object)(object)firstStage) { expired = true; } } private void RememberPod(VehicleSeat seat, GameObject passenger) { if (!NetworkServer.active || expired || consumed || !Object.op_Implicit((Object)(object)run) || run.stageClearCount != 0 || !Object.op_Implicit((Object)(object)seat) || !Object.op_Implicit((Object)(object)passenger)) { return; } if (hasPod) { if ((Object)(object)((Component)seat).transform == (Object)(object)trackedPod) { RememberPodPosition(); } return; } CharacterBody component = passenger.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && component.isPlayerControlled && Object.op_Implicit((Object)(object)((Component)component).GetComponent<LaciaController>()) && Object.op_Implicit((Object)(object)((Component)seat).GetComponentInParent<SurvivorPodController>()) && Object.op_Implicit((Object)(object)Stage.instance)) { if (!sawStage) { sawStage = true; firstStage = Stage.instance; } if (!((Object)(object)Stage.instance != (Object)(object)firstStage)) { trackedPod = ((Component)seat).transform; hasPod = true; RememberPodPosition(); } } } private void OnBodyStart(CharacterBody body) { if (!NetworkServer.active || expired || consumed || hasPod || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)((Component)body).GetComponent<LaciaController>())) { return; } CharacterMaster master = body.master; if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)((Component)master).GetComponent<PlayerCharacterMasterController>())) { VehicleSeat val = VehicleSeat.FindVehicleSeatWithPassenger(((Component)body).gameObject, (VehicleSeat)null); if (Object.op_Implicit((Object)(object)val)) { RememberPod(val, ((Component)body).gameObject); } } } private void RememberPodPosition() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)trackedPod)) { podPosition = trackedPod.position; podRight = trackedPod.right; podRight.y = 0f; podRight = ((((Vector3)(ref podRight)).sqrMagnitude > 0.001f) ? ((Vector3)(ref podRight)).normalized : Vector3.right); } } private unsafe void OnBossDefeated(BossGroup group) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || expired || consumed || !Object.op_Implicit((Object)(object)run) || run.stageClearCount != 0 || !sawStage || (Object)(object)Stage.instance != (Object)(object)firstStage) { return; } TeleporterInteraction instance = TeleporterInteraction.instance; if (!Object.op_Implicit((Object)(object)instance) || (Object)(object)group != (Object)(object)instance.bossGroup) { return; } consumed = true; if (!hasPod) { return; } RememberPodPosition(); PickupIndex val = PickupCatalog.FindPickupIndex(Items.UtilitySkillMagazine.itemIndex); if (val == PickupIndex.none) { return; } Vector3 val2 = podPosition + podRight * 3f + Vector3.up; Vector3[] array = (Vector3[])(object)new Vector3[4] { podRight, -podRight, Vector3.forward, Vector3.back }; RaycastHit val5 = default(RaycastHit); foreach (Vector3 val3 in array) { Vector3 val4 = podPosition + val3 * 3f + Vector3.up * 6f; Vector3 down = Vector3.down; LayerIndex world = LayerIndex.world; if (Physics.Raycast(val4, down, ref val5, 20f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) && ((RaycastHit)(ref val5)).normal.y > 0.5f) { val2 = ((RaycastHit)(ref val5)).point + Vector3.up; break; } } PickupDropletController.CreatePickupDroplet(val, val2, Vector3.up * 8f); Vector3 val6 = podPosition; string? text = ((object)(*(Vector3*)(&val6))/*cast due to .constrained prefix*/).ToString(); val6 = val2; Debug.Log((object)("LACIA_FIRST_STAGE_AFTERBURNER spawned once at pod=" + text + " pickup=" + ((object)(*(Vector3*)(&val6))/*cast due to .constrained prefix*/).ToString())); } private void OnDestroy() { Stage.onStageStartGlobal -= OnStageStart; VehicleSeat.onPassengerEnterGlobal -= RememberPod; VehicleSeat.onPassengerExitGlobal -= RememberPod; CharacterBody.onBodyStartGlobal -= OnBodyStart; BossGroup.onBossGroupDefeatedServer -= OnBossDefeated; } } public enum LaciaControlKind { Stun, Freeze, Shock, Pain, Root, Silence, InventoryLock } public sealed class LaciaControlResistance : MonoBehaviour { private sealed class Lease { public BuffIndex buff; public int count; public bool active = true; } private CharacterBody body; private readonly Dictionary<LaciaControlKind, float> immuneUntil = new Dictionary<LaciaControlKind, float>(); private readonly HashSet<LaciaControlKind> rewarded = new HashSet<LaciaControlKind>(); private readonly List<Lease> leases = new List<Lease>(); private readonly Dictionary<BuffIndex, int> removalDebt = new Dictionary<BuffIndex, int>(); internal int buffDepth; internal int stateDepth; internal int removalDepth; internal float stateLimit; internal LaciaControlKind stateKind; private static readonly FieldInfo Overrides = AccessTools.Field(typeof(GenericSkill), "skillOverrides"); private static readonly FieldInfo CurrentOverride = AccessTools.Field(typeof(GenericSkill), "currentSkillOverride"); public int RefundEvents { get; private set; } private void Awake() { body = ((Component)this).GetComponent<CharacterBody>(); body.onSkillActivatedServer += OnSkill; } private void OnSkill(GenericSkill skill) { if (IsR(Object.op_Implicit((Object)(object)skill) ? skill.skillDef : null)) { ResetRewards(); } } public void ResetRewards() { rewarded.Clear(); } public void Clear() { //IL_0076: 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) ((MonoBehaviour)this).StopAllCoroutines(); foreach (Lease lease in leases) { if (!lease.active || !Object.op_Implicit((Object)(object)body) || !NetworkServer.active) { continue; } lease.active = false; buffDepth++; for (int i = 0; i < lease.count; i++) { if (body.GetBuffCount(lease.buff) <= 0) { break; } body.RemoveBuff(lease.buff); } buffDepth--; } leases.Clear(); removalDebt.Clear(); immuneUntil.Clear(); rewarded.Clear(); buffDepth = (stateDepth = (removalDepth = 0)); } public float ImmunityRemaining(LaciaControlKind kind) { if (!immuneUntil.TryGetValue(kind, out var value)) { return 0f; } return Mathf.Max(0f, value - Time.fixedTime); } public bool Receive(LaciaControlKind kind, ref float duration, bool indefinite = false) { if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive || duration <= 0f || float.IsNaN(duration)) { return true; } bool num = ImmunityRemaining(kind) > 0f; if (!num) { immuneUntil[kind] = Time.fixedTime + 30f; duration = ((indefinite || float.IsInfinity(duration)) ? 0.2f : (duration * 0.1f)); } if (rewarded.Add(kind)) { RefundInstalledRs(); RefundEvents++; } return !num; } internal void Untimed(BuffDef buff, int count) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (count <= 0 || !LaciaControlHooks.Kind(buff, out var kind)) { return; } float duration = 0.2f; if (!Receive(kind, ref duration, indefinite: true)) { Debt(buff.buffIndex, count); return; } buffDepth++; try { for (int i = 0; i < count; i++) { body.AddBuff(buff); } } finally { buffDepth--; } Lease lease = new Lease { buff = buff.buffIndex, count = count }; leases.Add(lease); ((MonoBehaviour)this).StartCoroutine(Expire(lease)); } private void Debt(BuffIndex index, int count) { //IL_0006: 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) removalDebt.TryGetValue(index, out var value); removalDebt[index] = value + count; } private IEnumerator Expire(Lease lease) { yield return (object)new WaitForSeconds(0.2f); if (!lease.active) { yield break; } lease.active = false; buffDepth++; try { for (int i = 0; i < lease.count; i++) { if (body.GetBuffCount(lease.buff) <= 0) { break; } body.RemoveBuff(lease.buff); } } finally { buffDepth--; } Debt(lease.buff, lease.count); leases.Remove(lease); } internal bool ExternalRemove(BuffIndex index) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (removalDebt.TryGetValue(index, out var value) && value > 0) { removalDebt[index] = value - 1; return false; } Lease lease = leases.FirstOrDefault((Lease l) => l.active && l.buff == index); if (lease != null) { lease.count--; if (lease.count <= 0) { lease.active = false; leases.Remove(lease); } } return body.GetBuffCount(index) > 0; } private static bool IsR(SkillDef def) { if (Object.op_Implicit((Object)(object)def)) { if (!(((SerializableEntityStateType)(ref def.activationState)).stateType == typeof(LaciaTeamDefense))) { return ((SerializableEntityStateType)(ref def.activationState)).stateType == typeof(LaciaPVirus); } return true; } return false; } private static float Interval(GenericSkill slot, SkillDef def) { float rechargeInterval = def.GetRechargeInterval(slot); return Mathf.Min(rechargeInterval, Mathf.Max(0.5f, rechargeInterval * slot.cooldownScale - slot.flatCooldownReduction)) + slot.temporaryCooldownPenalty; } private void RefundInstalledRs() { GenericSkill[] components = ((Component)this).GetComponents<GenericSkill>(); foreach (GenericSkill val in components) { if (IsR(val.skillDef) && val.stock < val.maxStock) { val.RunRecharge(Mathf.Max(0f, val.cooldownRemaining) * 0.1f); } int num = (int)CurrentOverride.GetValue(val); if (IsR(val.baseSkill) && num >= 0 && val.GetBaseStock() < val.GetBaseMaxStock()) { val.baseRechargeStopwatch += Mathf.Max(0f, Interval(val, val.baseSkill) - val.baseRechargeStopwatch) * 0.1f; } SkillOverride[] array = (SkillOverride[])Overrides.GetValue(val); for (int j = 0; j < array.Length; j++) { if (j != num && IsR(array[j].skillDef) && array[j].stock < array[j].skillDef.GetMaxStock(val)) { SkillOverride obj = array[j]; obj.rechargeStopwatch += Mathf.Max(0f, Interval(val, array[j].skillDef) - array[j].rechargeStopwatch) * 0.1f; } } } } private void OnDisable() { Clear(); } private void OnDestroy() { if (Object.op_Implicit((Object)(object)body)) { body.onSkillActivatedServer -= OnSkill; } } } public static class LaciaControlHooks { private sealed class StateStamp { public float limit; public float started; } private static readonly ConditionalWeakTable<EntityState, StateStamp> States = new ConditionalWeakTable<EntityState, StateStamp>(); private static LaciaControlResistance Actor(Component owner) { LaciaControlResistance laciaControlResistance = (Object.op_Implicit((Object)(object)owner) ? owner.GetComponent<LaciaControlResistance>() : null); if (!Object.op_Implicit((Object)(object)laciaControlResistance) || !((Behaviour)laciaControlResistance).isActiveAndEnabled) { return null; } return laciaControlResistance; } public static void Install(Harmony harmony) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00ad: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_0196: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown //IL_0331: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Expected O, but got Unknown string[] array = new string[7] { "SetStun", "OverrideStun", "SetFrozen", "SetMidasTouchFrozen", "SetShock", "SetPain", "SetImmobilize" }; foreach (string text in array) { harmony.Patch((MethodBase)AccessTools.Method(typeof(SetStateOnHurt), text, (Type[])null, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), (text == "SetPain" || text == "SetImmobilize") ? "HurtRequest" : "HurtDuration", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaControlHooks), "HurtEnd", (Type[])null), (HarmonyMethod)null); } foreach (MethodInfo item in from m in typeof(CharacterBody).GetMethods(BindingFlags.Instance | BindingFlags.Public) where m.Name == "AddTimedBuff" || m.Name == "AddTimedBuffDontRefreshDuration" select m) { ParameterInfo[] parameters = item.GetParameters(); if (parameters.Length >= 2 && (parameters[0].ParameterType == typeof(BuffDef) || parameters[0].ParameterType == typeof(BuffIndex)) && parameters[1].ParameterType == typeof(float)) { harmony.Patch((MethodBase)item, new HarmonyMethod(typeof(LaciaControlHooks), "TimedBuff", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaControlHooks), "BuffEnd", (Type[])null), (HarmonyMethod)null); } } harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), "AddBuff", new Type[1] { typeof(BuffIndex) }, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), "UntimedBuff", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), "AddUnmanagedBuff", new Type[2] { typeof(BuffIndex), typeof(int) }, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), "UnmanagedBuff", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), "RemoveBuff", new Type[1] { typeof(BuffIndex) }, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), "RemoveBuff", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); array = new string[2] { "UpdateBuffs", "ClearTimedBuffs" }; foreach (string text2 in array) { harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), text2, (text2 == "ClearTimedBuffs") ? new Type[1] { typeof(BuffIndex) } : new Type[1] { typeof(float) }, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), "ManagedRemoval", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaControlHooks), "ManagedRemovalEnd", (Type[])null), (HarmonyMethod)null); } harmony.Patch((MethodBase)AccessTools.Method(typeof(EntityStateMachine), "SetInterruptState", (Type[])null, (Type[])null), new HarmonyMethod(typeof(LaciaControlHooks), "Interrupt", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Type[] array2 = new Type[3] { typeof(StunState), typeof(HurtState), typeof(ImmobilizeState) }; foreach (Type type in array2) { harmony.Patch((MethodBase)AccessTools.DeclaredMethod(type, "OnEnter", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaControlHooks), "StateEnter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (type != typeof(StunState)) { harmony.Patch((MethodBase)AccessTools.DeclaredMethod(type, "FixedUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaControlHooks), "StateTick", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } internal static bool Kind(BuffDef buff, out LaciaControlKind kind) { kind = LaciaControlKind.Stun; if (!Object.op_Implicit((Object)(object)buff)) { return false; } if ((Object)(object)buff == (Object)(object)Buffs.Entangle || (Object)(object)buff == (Object)(object)Buffs.Nullified || (Object)(object)buff == (Object)(object)Buffs.LunarSecondaryRoot || (Object)(object)buff == (Object)(object)Buffs.VultureRoot || (Object)(object)buff == (Object)(object)Buffs.Jailed) { kind = LaciaControlKind.Root; return true; } if ((Object)(object)buff == (Object)(object)Buffs.DisableAllSkills) { kind = LaciaControlKind.Silence; return true; } if ((Object)(object)buff == (Object)(object)Buffs.InventoryDisable) { kind = LaciaControlKind.InventoryLock; return true; } return false; } private static bool UntimedBuff(CharacterBody __instance, BuffIndex buffType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); BuffDef buffDef = BuffCatalog.GetBuffDef(buffType); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)laciaControlResistance) || laciaControlResistance.buffDepth > 0 || !Kind(buffDef, out var _)) { return true; } laciaControlResistance.Untimed(buffDef, 1); return false; } private static bool UnmanagedBuff(CharacterBody __instance, BuffIndex buffType, int count) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); BuffDef buffDef = BuffCatalog.GetBuffDef(buffType); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)laciaControlResistance) || laciaControlResistance.buffDepth > 0 || !Kind(buffDef, out var _)) { return true; } laciaControlResistance.Untimed(buffDef, count); return false; } private static bool RemoveBuff(CharacterBody __instance, BuffIndex buffType) { //IL_0028: 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) LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)laciaControlResistance) || laciaControlResistance.buffDepth > 0 || laciaControlResistance.removalDepth > 0 || !Kind(BuffCatalog.GetBuffDef(buffType), out var _)) { return true; } return laciaControlResistance.ExternalRemove(buffType); } private static void ManagedRemoval(CharacterBody __instance, out LaciaControlResistance __state) { __state = Actor((Component)(object)__instance); if (Object.op_Implicit((Object)(object)__state)) { __state.removalDepth++; } } private static Exception ManagedRemovalEnd(Exception __exception, LaciaControlResistance __state) { if (Object.op_Implicit((Object)(object)__state)) { __state.removalDepth = Mathf.Max(0, __state.removalDepth - 1); } return __exception; } private static bool TimedBuff(CharacterBody __instance, object[] __args, [HarmonyArgument(1)] ref float duration, out LaciaControlResistance __state) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) __state = null; if (!NetworkServer.active) { return true; } LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); if (!Object.op_Implicit((Object)(object)laciaControlResistance) || laciaControlResistance.buffDepth > 0) { return true; } object obj = __args[0]; BuffDef val = (BuffDef)((obj is BuffDef) ? obj : null); if (!Kind((val != null) ? val : BuffCatalog.GetBuffDef((BuffIndex)__args[0]), out var kind)) { return true; } if (!laciaControlResistance.Receive(kind, ref duration)) { return false; } laciaControlResistance.buffDepth++; __state = laciaControlResistance; return true; } private static Exception BuffEnd(Exception __exception, LaciaControlResistance __state) { if (Object.op_Implicit((Object)(object)__state)) { __state.buffDepth = Mathf.Max(0, __state.buffDepth - 1); } return __exception; } private static bool HurtDuration(SetStateOnHurt __instance, MethodBase __originalMethod, [HarmonyArgument(0)] ref float duration, out LaciaControlResistance __state) { object[] array = new object[1] { duration }; bool result = HurtRequest(__instance, __originalMethod, array, out __state); duration = (float)array[0]; return result; } private static bool HurtRequest(SetStateOnHurt __instance, MethodBase __originalMethod, object[] __args, out LaciaControlResistance __state) { __state = null; if (!NetworkServer.active) { return true; } LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); if (!Object.op_Implicit((Object)(object)laciaControlResistance) || laciaControlResistance.stateDepth > 0) { return true; } string name = __originalMethod.Name; LaciaControlKind laciaControlKind = (name.Contains("Frozen") ? LaciaControlKind.Freeze : (name switch { "SetImmobilize" => LaciaControlKind.Root, "SetPain" => LaciaControlKind.Pain, "SetShock" => LaciaControlKind.Shock, _ => LaciaControlKind.Stun, })); if ((laciaControlKind == LaciaControlKind.Freeze && !__instance.canBeFrozen) || ((laciaControlKind == LaciaControlKind.Stun || laciaControlKind == LaciaControlKind.Shock) && !__instance.canBeStunned) || (laciaControlKind == LaciaControlKind.Pain && !__instance.canBeHitStunned)) { return true; } float duration = ((__args.Length != 0 && __args[0] is float num) ? num : ((laciaControlKind == LaciaControlKind.Root) ? ImmobilizeState.GiveupDuration : 0.35f)); if (!laciaControlResistance.Receive(laciaControlKind, ref duration)) { return false; } if (__args.Length != 0 && __args[0] is float) { __args[0] = duration; } laciaControlResistance.stateKind = laciaControlKind; laciaControlResistance.stateLimit = duration; laciaControlResistance.stateDepth++; __state = laciaControlResistance; return true; } private static Exception HurtEnd(Exception __exception, LaciaControlResistance __state) { if (Object.op_Implicit((Object)(object)__state)) { __state.stateDepth = Mathf.Max(0, __state.stateDepth - 1); } return __exception; } private static bool Interrupt(EntityStateMachine __instance, [HarmonyArgument(0)] EntityState newState) { LaciaControlResistance laciaControlResistance = Actor((Component)(object)__instance); if (!Object.op_Implicit((Object)(object)laciaControlResistance) || newState == null) { return true; } StunState val = (StunState)(object)((newState is StunState) ? newState : null); float duration; LaciaControlKind laciaControlKind; if (val != null) { duration = val.stunDuration; laciaControlKind = LaciaControlKind.Stun; } else { FrozenState val2 = (FrozenState)(object)((newState is FrozenState) ? newState : null); if (val2 != null) { duration = val2.freezeDuration; laciaControlKind = LaciaControlKind.Freeze; } else { ShockState val3 = (ShockState)(object)((newState is ShockState) ? newState : null); if (val3 != null) { duration = val3.shockDuration; laciaControlKind = LaciaControlKind.Shock; } else if (newState is HurtState) { duration = 0.35f; laciaControlKind = LaciaControlKind.Pain; } else { if (!(newState is ImmobilizeState)) { return true; } duration = ImmobilizeState.GiveupDuration; laciaControlKind = LaciaControlKind.Root; } } } if (laciaControlResistance.stateDepth > 0) { duration = laciaControlResistance.stateLimit; } else if (NetworkServer.active) { if (!laciaControlResistance.Receive(laciaControlKind, ref duration)) { return false; } } else if (laciaControlKind == LaciaControlKind.Root) { duration *= 0.1f; } StunState val4 = (StunState)(object)((newState is StunState) ? newState : null); if (val4 != null) { val4.stunDuration = duration; } FrozenState val5 = (FrozenState)(object)((newState is FrozenState) ? newState : null); if (val5 != null) { val5.freezeDuration = duration; } ShockState val6 = (ShockState)(object)((newState is ShockState) ? newState : null); if (val6 != null) { val6.shockDuration = duration; } States.Remove(newState); States.Add(newState, new StateStamp { limit = duration, started = Time.fixedTime }); return true; } private static void StateEnter(EntityState __instance) { if (States.TryGetValue(__instance, out var value)) { value.started = Time.fixedTime; if (__instance is HurtState) { FieldInfo fieldInfo = AccessTools.Field(typeof(HurtState), "duration"); value.limit = Mathf.Max(0f, (float)fieldInfo.GetValue(__instance)) * 0.1f; fieldInfo.SetValue(__instance, value.limit); } else if (__instance is StunState) { AccessTools.Field(typeof(StunState), "duration").SetValue(__instance, value.limit); } } } private static void StateTick(EntityState __instance) { if (States.TryGetValue(__instance, out var value) && Time.fixedTime - value.started >= value.limit && Object.op_Implicit((Object)(object)__instance.outer) && Util.HasEffectiveAuthority(((Component)__instance.outer).gameObject)) { __instance.outer.SetNextStateToMain(); } } } public sealed class LaciaEliteLearning : MonoBehaviour { private readonly HashSet<BodyIndex> species = new HashSet<BodyIndex>(); public int AwardCount { get; private set; } public static void Install() { Run.onRunStartGlobal += StartRun; } private static void StartRun(Run run) { if (NetworkServer.active && !Object.op_Implicit((Object)(object)((Component)run).GetComponent<LaciaEliteLearning>())) { ((Component)run).gameObject.AddComponent<LaciaEliteLearning>(); } } private void Awake() { Stage.onStageStartGlobal += StartStage; GlobalEventManager.onCharacterDeathServer += OnDeath; } private void StartStage(Stage stage) { species.Clear(); } private static bool HasLacia() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster val = (Object.op_Implicit((Object)(object)instance) ? instance.master : null); if (!Object.op_Implicit((Object)(object)val) || (int)val.teamIndex != 1) { continue; } CharacterBody body = val.GetBody(); bool num; if (!Object.op_Implicit((Object)(object)body)) { if (!Object.op_Implicit((Object)(object)val.bodyPrefab)) { continue; } num = Object.op_Implicit((Object)(object)val.bodyPrefab.GetComponent<LaciaController>()); } else { num = Object.op_Implicit((Object)(object)((Component)body).GetComponent<LaciaController>()); } if (num) { return true; } } return false; } private unsafe void OnDeath(DamageReport report) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0025: 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_0033: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || report == null || !report.victimIsElite || (int)report.victimBodyIndex == -1 || (int)report.victimTeamIndex == 1 || (int)report.victimTeamIndex == 0 || (int)report.victimTeamIndex == -1 || (int)report.attackerTeamIndex != 1 || !HasLacia() || !species.Add(report.victimBodyIndex)) { return; } TeamManager instance = TeamManager.instance; if (Object.op_Implicit((Object)(object)instance)) { uint teamLevel = instance.GetTeamLevel((TeamIndex)1); if (teamLevel < TeamManager.naturalLevelCap) { ulong num = TeamManager.GetExperienceForLevel(teamLevel + 1) - TeamManager.GetExperienceForLevel(teamLevel); instance.GiveTeamExperience((TeamIndex)1, num); AwardCount++; string[] obj = new string[6] { "LACIA_ELITE_LEARNING species=", null, null, null, null, null }; BodyIndex victimBodyIndex = report.victimBodyIndex; obj[1] = ((object)(*(BodyIndex*)(&victimBodyIndex))/*cast due to .constrained prefix*/).ToString(); obj[2] = " level="; obj[3] = teamLevel.ToString(); obj[4] = "->"; obj[5] = instance.GetTeamLevel((TeamIndex)1).ToString(); Debug.Log((object)string.Concat(obj)); } } } private void OnDestroy() { Stage.onStageStartGlobal -= StartStage; GlobalEventManager.onCharacterDeathServer -= OnDeath; } } public sealed class LaciaChargeRing : MonoBehaviour { public const float Diameter = 74f; public const float FullWhiteDuration = 0.14f; public const float BasePulsePeriod = 1.2f; public static readonly Color DeepBlue = new Color(0.025f, 0.13f, 0.55f, 1f); public static readonly Color ChargingColor = new Color(0.12f, 0.72f, 1f, 1f); public static readonly Color FullColor = new Color(1f, 0.075f, 0.045f, 1f); private static Sprite ringSprite; private static Sprite glowSprite; private static Sprite edgeSprite; private static Sprite dotSprite; public const float VirusDiameter = 52f; private GameObject virusRoot; private Image virusFill; private Image virusGlow; private Image virusEdge; private readonly Image[] ammo = (Image[])(object)new Image[4]; private bool virusWasActive; private float virusPhase; private float virusLastAt; private CrosshairManager manager; private CharacterBody target; private LaciaController actor; private GameObject root; private Image fill; private Image glow; private Image edge; private bool full; private float fullAt; private float pulsePhase; private float lastPulseAt; public bool VirusVisible { get { if (Object.op_Implicit((Object)(object)virusRoot)) { return virusRoot.activeInHierarchy; } return false; } } public RectTransform VirusTransform { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)virusRoot)) { return null; } return (RectTransform)virusRoot.transform; } } public Image VirusFill => virusFill; public Image[] AmmoImages => ammo; public bool Visible { get { if (Object.op_Implicit((Object)(object)root)) { return root.activeInHierarchy; } return false; } } public float Progress { get { if (!Object.op_Implicit((Object)(object)fill)) { return 0f; } return fill.fillAmount; } } public bool IsFull => full; public RectTransform RingTransform { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)root)) { return null; } return (RectTransform)root.transform; } } public Image FillImage => fill; public Image GlowImage => glow; public Image EdgeImage => edge; public float PulsePhase => pulsePhase; public float PulseFrequency => Mathf.Max(0.01f, Object.op_Implicit((Object)(object)target) ? target.attackSpeed : 1f) / 1.2f; public 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(CrosshairManager), "UpdateCrosshair", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaChargeRing), "AfterCrosshair", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(CrosshairManager), "OnDisable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LaciaChargeRing), "AfterDisable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void AfterCrosshair(CrosshairManager __instance, CharacterBody targetBody) { LaciaChargeRing laciaChargeRing = ((Component)__instance).GetComponent<LaciaChargeRing>(); if (!Object.op_Implicit((Object)(object)laciaChargeRing)) { if (!Object.op_Implicit((Object)(object)targetBody) || !Object.op_Implicit((Object)(object)((Component)targetBody).GetComponent<LaciaController>())) { return; } laciaChargeRing = ((Component)__instance).gameObject.AddComponent<LaciaChargeRing>(); laciaChargeRing.manager = __instance; } laciaChargeRing.Refresh(targetBody); } private static void AfterDisable(CrosshairManager __instance) { LaciaChargeRing component = ((Component)__instance).GetComponent<LaciaChargeRing>(); if (Object.op_Implicit((Object)(object)component)) { component.Hide(); } } public void Hide() { HideCharge(); if (Object.op_Implicit((Object)(object)virusRoot)) { virusRoot.SetActive(false); } virusWasActive = false; virusPhase = 0f; } private void HideCharge() { if (Object.op_Implicit((Object)(object)root) && root.activeSelf) { root.SetActive(false); } full = false; pulsePhase = 0f; } public void Refresh(CharacterBody body) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)(object)body) { Hide(); target = body; actor = (Object.op_Implicit((Object)(object)body) ? ((Component)body).GetComponent<LaciaController>() : null); } if (!Object.op_Implicit((Object)(object)manager) || !Object.op_Implicit((Object)(object)manager.cameraRigController) || manager.cameraRigController.localUserViewer == null || !((Object)(object)manager.cameraRigController.localUserViewer.cachedBody == (Object)(object)body) || !Object.op_Implicit((Object)(object)actor) || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive || body.hideCrosshair || Object.op_Implicit((Object)(object)body.currentVehicle) || !Object.op_Implicit((Object)(object)manager.crosshairController) || !((Component)manager.crosshairController).gameObject.activeInHierarchy || (!actor.Charging && !actor.FourShotActive)) { Hide(); return; } if (!Object.op_Implicit((Object)(object)root)) { Build(); } if (!Object.op_Implicit((Object)(object)root)) { return; } RefreshVirus(); if (!actor.Charging) { HideCharge(); return; } if (!root.activeSelf) { root.SetActive(true); } if (Object.op_Implicit((Object)(object)manager.crosshairController)) { ((Transform)RingTransform).position = ((Component)manager.crosshairController).transform.position; } float num = Mathf.Clamp01(actor.ChargeProgress); Image obj = fill; Image obj2 = glow; float num2 = (edge.fillAmount = num); float fillAmount = (obj2.fillAmount = num2); obj.fillAmount = fillAmount; if (num < 1f) { full = false; pulsePhase = 0f; ((Graphic)fill).color = Color.Lerp(DeepBlue, ChargingColor, Mathf.SmoothStep(0f, 1f, num)); ((Graphic)edge).color = new Color(1f, 1f, 1f, 0.12f + 0.83f * num); ((Graphic)glow).color = new Color(1f, 1f, 1f, 0.04f + 0.43f * num * num); return; } float time = Time.time; if (!full) { full = true; fullAt = (lastPulseAt = time); pulsePhase = 0f; } if (time - fullAt <= 0.14f) { ((Graphic)fill).color = Color.white; ((Graphic)edge).color = Color.white; ((Graphic)glow).color = new Color(1f, 1f, 1f, 0.78f); lastPulseAt = time; return; } float num5 = Mathf.Max(0f, time - Mathf.Max(lastPulseAt, fullAt + 0.14f)); lastPulseAt = time; pulsePhase = Mathf.Repeat(pulsePhase + num5 * PulseFrequency, 1f); float num6 = 0.5f - 0.5f * Mathf.Cos(pulsePhase * MathF.PI * 2f); Color color = Color.Lerp(Color.white, FullColor, num6); color.a = 1f - 0.12f * num6; ((Graphic)fill).color = color; Color color2 = Color.Lerp(Color.white, FullColor, num6 * 0.82f); color2.a = 1f - 0.08f * num6; ((Graphic)edge).color = color2; Color color3 = Color.Lerp(Color.white, FullColor, num6 * 0.6f); color3.a = Mathf.Lerp(0.78f, 0.48f, num6); ((Graphic)glow).color = color3; } private void RefreshVirus() { //IL_0044: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01