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 Iaido Katana v0.4.1
Iaido_Katana.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; using UnityEngine.PostProcessing; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Iaido_Katana")] [assembly: AssemblyDescription("A two-handed katana for Valheim that strikes back on a perfect parry")] [assembly: AssemblyFileVersion("0.4.1.0")] [assembly: InternalsVisibleTo("KatanaCheck")] [assembly: InternalsVisibleTo("StancePreview")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.4.1.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 Iaido_Katana { internal static class AnimationSafety { internal sealed class SpeedState { internal float GameSpeed; internal float LastSpeed; internal bool Written; internal void Write(float speed) { LastSpeed = speed; Written = true; } internal bool Restore(float current, out float speed) { speed = GameSpeed; bool result = Written && Math.Abs(current - LastSpeed) <= 0.0001f; Written = false; return result; } } internal sealed class Progress { private bool _seen; private int _state; private int _next; private float _time; private float _nextTime; private float _held; internal void Reset() { _seen = false; _held = 0f; } internal bool Step(int state, float time, int next, float nextTime, bool paused, float dt) { bool flag = !_seen || state != _state || next != _next || Math.Abs(time - _time) > 1E-05f || Math.Abs(nextTime - _nextTime) > 1E-05f; _seen = true; _state = state; _next = next; _time = time; _nextTime = nextTime; _held = ((flag || paused) ? 0f : (_held + Math.Max(0f, dt))); return _held >= 4f; } } internal const float EntryGrace = 0.5f; internal const float StallSeconds = 4f; internal const float SpeedTolerance = 0.0001f; internal const float ProgressTolerance = 1E-05f; internal static readonly FieldRef<Humanoid, Attack> CurrentAttack = AccessTools.FieldRefAccess<Humanoid, Attack>("m_currentAttack"); internal static readonly FieldRef<Character, Animator> AnimatorOf = AccessTools.FieldRefAccess<Character, Animator>("m_animator"); internal static readonly FieldRef<Character, CharacterAnimEvent> AnimEvent = AccessTools.FieldRefAccess<Character, CharacterAnimEvent>("m_animEvent"); internal static readonly FieldRef<CharacterAnimEvent, float> PauseTimer = AccessTools.FieldRefAccess<CharacterAnimEvent, float>("m_pauseTimer"); internal static readonly FieldRef<CharacterAnimEvent, float> PauseSpeed = AccessTools.FieldRefAccess<CharacterAnimEvent, float>("m_pauseSpeed"); internal static bool SameOwner(object player, object animator, object weapon, object attack, object currentPlayer, object currentAnimator, object currentWeapon, object currentAttack, bool requireAttack) { if (player != null && animator != null && weapon != null && player == currentPlayer && animator == currentAnimator && weapon == currentWeapon) { if (requireAttack) { if (attack != null) { return attack == currentAttack; } return false; } return true; } return false; } internal static int AttackLayer(Animator animator) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < animator.layerCount; i++) { if (i > 0 && animator.GetLayerWeight(i) <= 0f) { continue; } AnimatorStateInfo val = animator.GetCurrentAnimatorStateInfo(i); if (!((AnimatorStateInfo)(ref val)).IsTag("attack")) { if (!animator.IsInTransition(i)) { continue; } val = animator.GetNextAnimatorStateInfo(i); if (!((AnimatorStateInfo)(ref val)).IsTag("attack")) { continue; } } return i; } return 0; } internal static bool Attacking(Animator animator) { //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_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) if (!Object.op_Implicit((Object)(object)animator) || !animator.isInitialized) { return false; } for (int i = 0; i < animator.layerCount; i++) { if (i > 0 && animator.GetLayerWeight(i) <= 0f) { continue; } AnimatorStateInfo val = animator.GetCurrentAnimatorStateInfo(i); if (!((AnimatorStateInfo)(ref val)).IsTag("attack")) { if (!animator.IsInTransition(i)) { continue; } val = animator.GetNextAnimatorStateInfo(i); if (!((AnimatorStateInfo)(ref val)).IsTag("attack")) { continue; } } return true; } return false; } } internal sealed class AnimationLease { internal Player Player; internal Animator Animator; private ItemData _weapon; private Attack _attack; private bool _requireAttack; private readonly AnimationSafety.SpeedState _speed = new AnimationSafety.SpeedState(); private readonly AnimationSafety.Progress _progress = new AnimationSafety.Progress(); internal bool Current { get { if (Object.op_Implicit((Object)(object)Player) && Object.op_Implicit((Object)(object)Animator)) { return Matches(Player, Animator); } return false; } } internal void Begin(Player player, Attack attack, bool requireAttack) { Clear(); Player = player; Animator = (Object.op_Implicit((Object)(object)player) ? AnimationSafety.AnimatorOf.Invoke((Character)(object)player) : null); _weapon = (Object.op_Implicit((Object)(object)player) ? ((Humanoid)player).GetCurrentWeapon() : null); _attack = attack; _requireAttack = requireAttack; if (Object.op_Implicit((Object)(object)Animator)) { CharacterAnimEvent val = AnimationSafety.AnimEvent.Invoke((Character)(object)player); _speed.GameSpeed = ((Object.op_Implicit((Object)(object)val) && AnimationSafety.PauseTimer.Invoke(val) > 0f) ? AnimationSafety.PauseSpeed.Invoke(val) : Animator.speed); } } internal bool Matches(Player player, Animator animator) { if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)animator) && animator.isInitialized && (Object)(object)player == (Object)(object)Player.m_localPlayer && !((Character)player).IsDead() && !((Character)player).InDodge() && !((Character)player).IsStaggering()) { return AnimationSafety.SameOwner(Player, Animator, _weapon, _attack, player, animator, ((Humanoid)player).GetCurrentWeapon(), AnimationSafety.CurrentAttack.Invoke((Humanoid)(object)player), _requireAttack); } return false; } internal void GameSpeed(float speed) { _speed.GameSpeed = speed; } internal void Write(float speed) { _speed.Write(speed); Animator.speed = speed; } internal bool Stalled(float dt, bool paused) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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 (!_speed.Written || !Object.op_Implicit((Object)(object)Animator)) { _progress.Reset(); return false; } int num = AnimationSafety.AttackLayer(Animator); AnimatorStateInfo currentAnimatorStateInfo = Animator.GetCurrentAnimatorStateInfo(num); AnimatorStateInfo val = (AnimatorStateInfo)(Animator.IsInTransition(num) ? Animator.GetNextAnimatorStateInfo(num) : default(AnimatorStateInfo)); return _progress.Step(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash, ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime, ((AnimatorStateInfo)(ref val)).fullPathHash, ((AnimatorStateInfo)(ref val)).normalizedTime, paused, dt); } internal void Restore() { if (!Object.op_Implicit((Object)(object)Animator)) { _speed.Written = false; return; } CharacterAnimEvent val = (Object.op_Implicit((Object)(object)Player) ? AnimationSafety.AnimEvent.Invoke((Character)(object)Player) : null); float speed2; if (Object.op_Implicit((Object)(object)val) && AnimationSafety.PauseTimer.Invoke(val) > 0f) { if (_speed.Restore(AnimationSafety.PauseSpeed.Invoke(val), out var speed)) { AnimationSafety.PauseSpeed.Invoke(val) = speed; } } else if (_speed.Restore(Animator.speed, out speed2)) { Animator.speed = speed2; } } internal void Clear() { Restore(); Player = null; Animator = null; _weapon = null; _attack = null; _progress.Reset(); } } internal sealed class BladeShape { internal Vector3[] Spine; internal float[] Half; internal Mesh Strip; } internal static class BladeFx { internal const int SpineSlices = 16; internal const float StripShare = 0.7f; internal const int ArcLines = 7; internal const int ForkLines = 4; internal const int ArcSteps = 3; internal const float ArcWidth = 0.011f; internal const float ArcAcross = 0.8f; internal const float ArcOff = 0.008f; internal const float ArcSeconds = 0.07f; internal const float ForkLength = 0.095f; internal const float ForkChance = 0.6f; internal const float ArcStretchMin = 0.3f; internal const float ArcStretchMax = 0.45f; internal const float ArcEnds = 0.2f; internal static readonly Color ArcHot = new Color(1f, 0.62f, 0.5f, 1f); internal static readonly Color ArcDeep = new Color(1f, 0.17f, 0f, 1f); internal static readonly Color StormHot = new Color(0.86f, 0.96f, 1f, 1f); internal static readonly Color StormDeep = new Color(0.48f, 0.8f, 1f, 1f); internal const float StormSize = 1.56f; internal const float StormBright = 1.3f; private static readonly string[] BrightColours = new string[3] { "_Color", "_TintColor", "_EmissionColor" }; internal const float SparkSize = 0.68f; internal const float SparkRate = 3f; internal const float LightningLight = 0.5f; internal const float FlameSize = 0.18f; internal const float FlameRise = 0.22f; internal const float FlameAlpha = 0.35f; internal const float FlameRate = 1.1f; internal const float GlowSize = 0.21f; internal const float GlowAlpha = 0.3f; internal const float GlowRate = 0.5f; internal const float FrostLight = 0.35f; internal const string ForkName = "fork"; internal static BladeShape Shape(List<Vector3> v, float from) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) float num = float.MinValue; foreach (Vector3 item in v) { num = Mathf.Max(num, item.y); } List<Vector3> list = new List<Vector3>(); List<float> list2 = new List<float>(); float num2 = (num - from) / 16f; for (int i = 0; i < 16; i++) { float num3 = from + (float)i * num2; float num4 = num3 + num2; float num5 = float.MaxValue; float num6 = float.MinValue; foreach (Vector3 item2 in v) { if (item2.y >= num3 && item2.y <= num4) { num5 = Mathf.Min(num5, item2.x); num6 = Mathf.Max(num6, item2.x); } } if (!(num6 < num5)) { list.Add(new Vector3((num5 + num6) * 0.5f, num3 + num2 * 0.5f, 0f)); list2.Add((num6 - num5) * 0.5f); } } Vector3 val = Vector3.zero; int num7 = 0; foreach (Vector3 item3 in v) { if (item3.y > num - 0.004f) { val += item3; num7++; } } if (num7 > 0) { list.Add(new Vector3(val.x / (float)num7, num, 0f)); list2.Add(0f); } return new BladeShape { Spine = list.ToArray(), Half = list2.ToArray() }; } private static Mesh Strip(BladeShape shape) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)shape.Strip)) { return shape.Strip; } int num = shape.Spine.Length; Vector3[] array = (Vector3[])(object)new Vector3[num * 2]; int[] array2 = new int[Mathf.Max(0, num - 1) * 6]; Vector3 val = default(Vector3); for (int i = 0; i < num; i++) { ((Vector3)(ref val))..ctor(Mathf.Max(0.002f, shape.Half[i] * 0.7f), 0f, 0f); array[i * 2] = shape.Spine[i] - val; array[i * 2 + 1] = shape.Spine[i] + val; } int j = 0; int num2 = 0; for (; j < num - 1; j++) { int num3 = j * 2; array2[num2++] = num3; array2[num2++] = num3 + 2; array2[num2++] = num3 + 1; array2[num2++] = num3 + 1; array2[num2++] = num3 + 2; array2[num2++] = num3 + 3; } Mesh val2 = new Mesh { name = "IaidoKatana_blade_strip", vertices = array, triangles = array2 }; val2.RecalculateNormals(); val2.RecalculateBounds(); shape.Strip = val2; return val2; } internal static Vector3 At(Vector3[] spine, float[] half, float u, out float width) { //IL_0030: 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_0042: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(u) * (float)(spine.Length - 1); int num2 = Mathf.Min((int)num, spine.Length - 2); width = Mathf.Lerp(half[num2], half[num2 + 1], num - (float)num2); return Vector3.Lerp(spine[num2], spine[num2 + 1], num - (float)num2); } internal static GameObject Lightning(Transform node, BladeShape blade, Transform vfx, string name, Color hot, Color deep, float size = 1f, float bright = 1f) { //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_001a: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_0225: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_023c: Unknown result type (might be due to invalid IL or missing references) int layer = ((Component)node).gameObject.layer; GameObject val = new GameObject(name) { layer = layer }; val.SetActive(false); val.transform.SetParent(node, false); Transform val2 = vfx.Find("Lightning"); ParticleSystemRenderer val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<ParticleSystemRenderer>() : null); Material val4 = (Object.op_Implicit((Object)(object)val3) ? val3.trailMaterial : null); if (Object.op_Implicit((Object)(object)val4)) { BladeArcs bladeArcs = val.AddComponent<BladeArcs>(); bladeArcs.Spine = blade.Spine; bladeArcs.Half = blade.Half; bladeArcs.Size = size; if (bright != 1f) { val4 = new Material(val4); string[] brightColours = BrightColours; foreach (string text in brightColours) { if (val4.HasProperty(text)) { Color color = val4.GetColor(text); val4.SetColor(text, new Color(color.r * bright, color.g * bright, color.b * bright, color.a)); } } } for (int j = 0; j < 11; j++) { bool flag = j >= 7; GameObject val5 = new GameObject(flag ? "fork" : "arc", new Type[1] { typeof(LineRenderer) }) { layer = layer }; val5.transform.SetParent(val.transform, false); LineRenderer component = val5.GetComponent<LineRenderer>(); ((Renderer)component).sharedMaterial = val4; component.useWorldSpace = false; component.textureMode = (LineTextureMode)0; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; component.widthMultiplier = ((flag || j == 0) ? 0.0066000004f : 0.011f) * size; component.numCornerVertices = 2; component.widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[4] { new Keyframe(0f, 0.2f), new Keyframe(0.15f, 1f), new Keyframe(0.85f, 1f), new Keyframe(1f, 0.1f) }); component.startColor = ((j == 0) ? hot : deep); component.endColor = ((j == 0) ? hot : deep); } bladeArcs.Roll(); } Transform val6 = vfx.Find("Sparcs"); if (Object.op_Implicit((Object)(object)val6)) { ParticleSystem obj = OnBlade(val6, val.transform, blade, layer); MainModule main = obj.main; ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.68f; EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 3f; } Lamp(vfx.Find("Point light"), val.transform, blade, layer, 0.5f * bright); val.SetActive(true); return val; } internal static GameObject Flames(Transform node, BladeShape blade, Transform burny, string name) { //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_001a: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) int layer = ((Component)node).gameObject.layer; GameObject val = new GameObject(name) { layer = layer }; val.SetActive(false); val.transform.SetParent(node, false); Transform val2 = burny.Find("flames"); if (Object.op_Implicit((Object)(object)val2)) { ParticleSystem obj = OnBlade(val2, val.transform, blade, layer); MainModule main = obj.main; ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.18f; ((MainModule)(ref main)).startColor = Dim(((MainModule)(ref main)).startColor, 0.35f); EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 1.1f; VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier * 0.22f; } Transform val3 = burny.Find("fx_Torch_Basic"); if (Object.op_Implicit((Object)(object)val3)) { ParticleSystem obj2 = OnBlade(val3, val.transform, blade, layer); MainModule main2 = obj2.main; ((MainModule)(ref main2)).startSizeMultiplier = ((MainModule)(ref main2)).startSizeMultiplier * 0.21f; ((MainModule)(ref main2)).startColor = Dim(((MainModule)(ref main2)).startColor, 0.3f); EmissionModule emission2 = obj2.emission; ((EmissionModule)(ref emission2)).rateOverTimeMultiplier = ((EmissionModule)(ref emission2)).rateOverTimeMultiplier * 0.5f; } Lamp(burny.Find("Point light"), val.transform, blade, layer, 0.35f); val.SetActive(true); return val; } private static ParticleSystem OnBlade(Transform part, Transform root, BladeShape blade, int layer) { //IL_0020: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)part).gameObject, root, false); ((Object)val).name = ((Object)part).name; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = layer; } val.SetActive(true); ParticleSystem component = val.GetComponent<ParticleSystem>(); MainModule main = component.main; ((MainModule)(ref main)).prewarm = ((MainModule)(ref main)).loop; ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)6; ((ShapeModule)(ref shape)).meshShapeType = (ParticleSystemMeshShapeType)2; ((ShapeModule)(ref shape)).mesh = Strip(blade); ((ShapeModule)(ref shape)).position = Vector3.zero; ((ShapeModule)(ref shape)).rotation = Vector3.zero; ((ShapeModule)(ref shape)).scale = Vector3.one; ((ShapeModule)(ref shape)).normalOffset = 0f; return component; } private static void Lamp(Transform part, Transform root, BladeShape blade, int layer, float share) { //IL_0042: 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) if (Object.op_Implicit((Object)(object)part)) { GameObject obj = Object.Instantiate<GameObject>(((Component)part).gameObject, root, false); ((Object)obj).name = ((Object)part).name; obj.layer = layer; obj.transform.localPosition = At(blade.Spine, blade.Half, 0.5f, out var _); obj.transform.localScale = Vector3.one; obj.SetActive(true); Light[] componentsInChildren = obj.GetComponentsInChildren<Light>(true); foreach (Light obj2 in componentsInChildren) { obj2.range *= share; obj2.intensity *= share; } } } private static MinMaxGradient Dim(MinMaxGradient g, float k) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected I4, but got Unknown //IL_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_003e: 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_004c: 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_007a: Unknown result type (might be due to invalid IL or missing references) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode; switch ((int)mode) { case 0: return new MinMaxGradient(C(((MinMaxGradient)(ref g)).color)); case 2: return new MinMaxGradient(C(((MinMaxGradient)(ref g)).colorMin), C(((MinMaxGradient)(ref g)).colorMax)); case 3: return new MinMaxGradient(G(((MinMaxGradient)(ref g)).gradientMin), G(((MinMaxGradient)(ref g)).gradientMax)); default: { MinMaxGradient result = default(MinMaxGradient); ((MinMaxGradient)(ref result))..ctor(G(((MinMaxGradient)(ref g)).gradient)); ((MinMaxGradient)(ref result)).mode = ((MinMaxGradient)(ref g)).mode; return result; } } Color C(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, c.a * k); } Gradient G(Gradient from) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (from != null) { GradientAlphaKey[] alphaKeys = from.alphaKeys; for (int i = 0; i < alphaKeys.Length; i++) { alphaKeys[i].alpha *= k; } Gradient val = new Gradient { mode = from.mode }; val.SetKeys(from.colorKeys, alphaKeys); return val; } return null; } } } internal sealed class BladeArcs : MonoBehaviour { public Vector3[] Spine; public float[] Half; public float Size = 1f; private LineRenderer[] _lines; private Vector3[] _points; private float _next; private void Update() { if (!(Time.time < _next)) { _next = Time.time + 0.07f; Roll(); } } internal void Roll() { if (Spine == null || Spine.Length < 2) { return; } if (_lines == null || _lines.Length == 0) { _lines = ((Component)this).GetComponentsInChildren<LineRenderer>(true); } int num = 0; int num2 = 0; LineRenderer[] lines = _lines; for (int i = 0; i < lines.Length; i++) { if (((Object)lines[i]).name == "fork") { num2++; } else { num++; } } int num3 = 0; int num4 = 0; for (int j = 0; j < _lines.Length; j++) { if (((Object)_lines[j]).name == "fork") { Fork(_lines[j], num4++, num2); } else { Arc(_lines[j], num3++, num); } } } private void Arc(LineRenderer line, int k, int count) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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) int num = (Spine.Length - 1) * 3 + 1; if (_points == null || _points.Length != num) { _points = (Vector3[])(object)new Vector3[num]; } float num2 = Random.Range(0f, 0.05f); float num3 = Random.Range(0.95f, 1f); if (k > 0 && count > 1) { float num4 = Random.Range(0.3f, 0.45f); num2 = Mathf.Clamp(((float)(k - 1) + Random.value) / (float)(count - 1) - num4 * 0.5f, 0f, 1f - num4); num3 = num2 + num4; } for (int i = 0; i < num; i++) { float num5 = (float)i / (float)(num - 1); float width; Vector3 val = BladeFx.At(Spine, Half, Mathf.Lerp(num2, num3, num5), out width); float num6 = Mathf.Clamp01(Mathf.Min(num5, 1f - num5) / 0.2f); _points[i] = val + new Vector3(Random.Range(-1f, 1f) * width * 0.8f, 0f, Random.Range(-1f, 1f) * 0.008f) * (num6 * Size); } line.positionCount = num; line.SetPositions(_points); } private void Fork(LineRenderer line, int k, int count) { //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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) ((Renderer)line).enabled = Random.value < 0.6f; if (((Renderer)line).enabled) { float width; Vector3 val = BladeFx.At(Spine, Half, Mathf.Lerp(0.05f, 0.97f, ((float)k + Random.value) / (float)Mathf.Max(1, count)), out width); Vector3 val2 = new Vector3((Random.value < 0.5f) ? (-1f) : 1f, Random.Range(0.2f, 0.9f), Random.Range(-0.4f, 0.4f)); Vector3 normalized = ((Vector3)(ref val2)).normalized; line.positionCount = 4; for (int i = 0; i < 4; i++) { Vector3 val3 = ((i == 0) ? Vector3.zero : (new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * (0.095f * Size * 0.15f))); line.SetPosition(i, val + normalized * (0.095f * Size * (float)i / 3f) + val3); } } } } internal static class Chop { private static int? _mask; private const float Near = 1f; internal static int Mask { get { int? mask = _mask; if (!mask.HasValue) { int? num = (_mask = LayerMask.GetMask(new string[3] { "Default", "static_solid", "Default_small" })); return num.Value; } return mask.GetValueOrDefault(); } } internal static bool On(ItemData weapon) { if (Plugin.ChopOn.Value) { return Katana.IsKatana(weapon); } return false; } internal static float Damage(ItemData weapon) { if (!Katana.IsThunderblood(weapon)) { if (!Plugin.IsFlametal(weapon)) { return Plugin.SteelChop.Value; } return Plugin.FlametalChop.Value; } return Plugin.ThunderbloodChop.Value; } internal static int Tier(ItemData weapon) { if (!Katana.IsThunderblood(weapon)) { if (!Plugin.IsFlametal(weapon)) { return Plugin.SteelChopTier.Value; } return Plugin.FlametalChopTier.Value; } return Plugin.ThunderbloodChopTier.Value; } internal static IDestructible Tree(Collider collider) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 IDestructible val = (Object.op_Implicit((Object)(object)collider) ? ((Component)collider).GetComponentInParent<IDestructible>() : null); Component val2 = (Component)(object)((val is Component) ? val : null); if (val2 == null || !Object.op_Implicit((Object)(object)val2) || (int)val.GetDestructibleType() != 2) { return null; } return val; } internal static void Hit(Player player, ItemData weapon, IDestructible tree, Vector3 point, Vector3 dir, float share = 1f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) HitData val = new HitData(); val.m_damage.m_chop = Damage(weapon) * share; val.m_toolTier = (short)Tier(weapon); val.m_point = point; val.m_dir = dir; val.m_attacker = ((Character)player).GetZDOID(); val.m_skill = (SkillType)13; val.m_hitType = (HitType)2; tree.Damage(val); } internal static int CutAround(Player player, ItemData weapon, Vector3 from, Vector3 ahead, float range, float angle, float height) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) HashSet<IDestructible> hashSet = new HashSet<IDestructible>(); Collider[] array = Physics.OverlapSphere(from, Mathf.Max(range, height) + 1f, Mask); foreach (Collider collider in array) { IDestructible val = Tree(collider); if (val != null && !hashSet.Contains(val)) { Vector3 val2 = Closest(collider, from); Vector3 val3 = val2 - from; Vector3 val4 = new Vector3(val3.x, 0f, val3.z); if (((((Vector3)(ref val4)).sqrMagnitude < 1f && Vector3.Dot(new Vector3(val3.x, 0f, val3.z), ahead) > -0.1f && Mathf.Abs(val3.y) <= height) || Katana.InSwing(val3, ahead, 0f, range, angle, height)) && !Blocked(from, val2, val)) { hashSet.Add(val); Vector3 val5 = val2 - from; Hit(player, weapon, val, val2, (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val5)).normalized : ahead); } } } return hashSet.Count; } private static Vector3 Closest(Collider collider, Vector3 from) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!(collider is BoxCollider) && !(collider is SphereCollider) && !(collider is CapsuleCollider)) { MeshCollider val = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val == null || !val.convex) { return collider.ClosestPointOnBounds(from); } } return collider.ClosestPoint(from); } private static bool Blocked(Vector3 from, Vector3 point, IDestructible tree) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Linecast(from, point, ref val, Thunderclap.Walls)) { return Tree(((RaycastHit)(ref val)).collider) != tree; } return false; } } internal static class ClipSwap { private sealed class Swap { internal RuntimeAnimatorController Original; internal AnimatorOverrideController Override; internal int Replaced; internal float CheckAt; internal readonly List<KeyValuePair<AnimationClip, AnimationClip>> Buffer = new List<KeyValuePair<AnimationClip, AnimationClip>>(); } private const string Resource = "Iaido_Katana.iaido_anims"; private static readonly FieldRef<Character, Animator> AnimatorOf = AccessTools.FieldRefAccess<Character, Animator>("m_animator"); internal const string HeavyTrigger = "swing_sledge"; internal const string HeavyOutTrigger = "greatsword_secondary"; private const string HeavyOutClip = "Iaido Heavy Out"; private const float CheckInterval = 1f; private static readonly Dictionary<string, string> Replaces = new Dictionary<string, string> { ["Greatsword BaseAttack (1)"] = "Iaido Draw", ["Greatsword BaseAttack (2)"] = "Iaido Overhead", ["Greatsword BaseAttack (3)"] = "Iaido Diagonal", ["Sledge-Attack1"] = "Iaido Heavy", ["Greatsword Secondary Attack"] = "Iaido Heavy Out" }; private static readonly Dictionary<string, AnimationClip> Clips = new Dictionary<string, AnimationClip>(); private static readonly ConditionalWeakTable<Animator, Swap> Swaps = new ConditionalWeakTable<Animator, Swap>(); private static bool _loaded; private static bool _traceSeen; private static string _traceWhy; private static bool _traceWant; private static bool _traceOn; private static bool _traceOriginal; private static bool _traceAlive; private static RuntimeAnimatorController _traceController; private static int _traceLines; private const int TraceLimit = 300; private const float TraceWindow = 60f; private static float _traceSince; internal static bool HasHeavyOut => Clips.ContainsKey("Iaido Heavy Out"); internal static bool IsOwn(string clipName) { return Clips.ContainsKey(clipName); } internal static bool On(Player player) { Animator val = (Object.op_Implicit((Object)(object)player) ? AnimatorOf.Invoke((Character)(object)player) : null); if (Object.op_Implicit((Object)(object)val) && Swaps.TryGetValue(val, out var value) && Object.op_Implicit((Object)(object)value.Override)) { return (Object)(object)val.runtimeAnimatorController == (Object)(object)value.Override; } return false; } internal static int StepOf(string clipName) { foreach (KeyValuePair<string, string> replace in Replaces) { if (!(replace.Value != clipName)) { string key = replace.Key; if (key.StartsWith("Greatsword BaseAttack (") && key.Length == "Greatsword BaseAttack (".Length + 2) { return key["Greatsword BaseAttack (".Length] - 49; } return (key == "Greatsword Secondary Attack") ? 4 : 3; } } return -1; } internal static void Load() { if (_loaded) { return; } _loaded = true; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Iaido_Katana.iaido_anims"); if (stream == null) { return; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } AssetBundle val = AssetBundle.LoadFromMemory(array); if (!Object.op_Implicit((Object)(object)val)) { Plugin.Log.LogWarning((object)"own animation clips: the bundle did not load (made for another Unity version?)"); return; } AnimationClip[] array2 = val.LoadAllAssets<AnimationClip>(); foreach (AnimationClip val2 in array2) { Clips[((Object)val2).name] = val2; } Plugin.Log.LogInfo((object)string.Format("own animation clips: {0} loaded ({1})", Clips.Count, string.Join(", ", Clips.Keys))); } internal static void Step(Player player, bool validate = false) { if (Clips.Count == 0 || !Object.op_Implicit((Object)(object)player)) { return; } Animator val = AnimatorOf.Invoke((Character)(object)player); if (!Object.op_Implicit((Object)(object)val) || !val.isInitialized) { Trace(player, "animator not ready", want: false, on: false, null, null); return; } bool flag = Moves.FullBody && IaiStance.HoldsKatana(player); RuntimeAnimatorController runtimeAnimatorController = val.runtimeAnimatorController; Swaps.TryGetValue(val, out var value); bool flag2 = value != null && Object.op_Implicit((Object)(object)value.Override) && (Object)(object)runtimeAnimatorController == (Object)(object)value.Override; if (flag != flag2 && (((Character)player).InAttack() || AnimationSafety.Attacking(val))) { Trace(player, "controller change deferred until attack ends", flag, flag2, runtimeAnimatorController, value); return; } Trace(player, "checked", flag, flag2, runtimeAnimatorController, value); if (flag && flag2 && (validate || Time.time >= value.CheckAt) && !((Character)player).InAttack() && !AnimationSafety.Attacking(val)) { value.CheckAt = Time.time + 1f; int num = Repair(value); if (num > 0) { Diagnostics.Snapshot($"repaired {num} custom animation mappings before an attack", player, val); } } if (flag == flag2) { return; } if (!flag) { Assign(val, value.Original); return; } if (!Object.op_Implicit((Object)(object)runtimeAnimatorController)) { Trace(player, "no controller to build on", flag, flag2, runtimeAnimatorController, value); return; } bool flag3 = value != null && value.Replaced > 0 && !Object.op_Implicit((Object)(object)value.Override); if (NeedsRebuild(value, runtimeAnimatorController)) { if (flag3) { Diagnostics.Snapshot("rebuilding an invalid animation override", player, val); } if (value != null) { Swaps.Remove(val); } value = new Swap { Original = runtimeAnimatorController, Override = Build(runtimeAnimatorController, out var replaced) }; value.Replaced = replaced; Swaps.Add(val, value); if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)$"own animation clips for {player.GetPlayerName()}: {replaced} of the game's clips replaced"); } } if (Object.op_Implicit((Object)(object)value.Override)) { Assign(val, (RuntimeAnimatorController)(object)value.Override); } } private static bool NeedsRebuild(Swap swap, RuntimeAnimatorController current) { if (swap != null && !((Object)(object)current != (Object)(object)swap.Original)) { if (swap.Replaced > 0) { return !Object.op_Implicit((Object)(object)swap.Override); } return false; } return true; } private static int Repair(Swap swap) { swap.Override.GetOverrides(swap.Buffer); int num = 0; for (int i = 0; i < swap.Buffer.Count; i++) { KeyValuePair<AnimationClip, AnimationClip> keyValuePair = swap.Buffer[i]; if (Object.op_Implicit((Object)(object)keyValuePair.Key) && Replaces.TryGetValue(((Object)keyValuePair.Key).name, out var value) && Clips.TryGetValue(value, out var value2) && Object.op_Implicit((Object)(object)value2) && !((Object)(object)keyValuePair.Value == (Object)(object)value2)) { swap.Buffer[i] = new KeyValuePair<AnimationClip, AnimationClip>(keyValuePair.Key, value2); num++; } } if (num > 0) { swap.Override.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)swap.Buffer); } return num; } private static void Trace(Player player, string why, bool want, bool on, RuntimeAnimatorController current, Swap swap) { if (!Plugin.LogCounters.Value || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return; } bool flag = swap != null && (Object)(object)current == (Object)(object)swap.Original; bool flag2 = swap != null && Object.op_Implicit((Object)(object)swap.Override); if (_traceSeen && _traceWhy == why && _traceWant == want && _traceOn == on && _traceOriginal == flag && _traceAlive == flag2 && (Object)(object)_traceController == (Object)(object)current) { return; } _traceSeen = true; _traceWhy = why; _traceWant = want; _traceOn = on; _traceOriginal = flag; _traceAlive = flag2; _traceController = current; string text = string.Format("clip swap: {0}, katana held {1}, own clips on {2}, controller {3}{4}, own override {5}", why, want, on, Object.op_Implicit((Object)(object)current) ? ((Object)current).name : "none", flag ? " (the game's)" : "", (swap == null) ? "not built" : (flag2 ? "alive" : "destroyed")); Diagnostics.Remember(text); if (Time.time - _traceSince >= 60f) { _traceSince = Time.time; _traceLines = 0; } if (++_traceLines > 300) { if (_traceLines == 301) { Plugin.Log.LogInfo((object)$"clip swap: {300} state lines this minute, recent history still retained"); } } else { Plugin.Log.LogInfo((object)text); } } private static AnimatorOverrideController Build(RuntimeAnimatorController original, out int replaced) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown AnimatorOverrideController val = new AnimatorOverrideController(original) { name = "IaidoKatana_clips" }; List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(val.overridesCount); AnimatorOverrideController val2 = (AnimatorOverrideController)(object)((original is AnimatorOverrideController) ? original : null); if (val2 != null) { val2.GetOverrides(list); } else { val.GetOverrides(list); } replaced = 0; for (int i = 0; i < list.Count; i++) { AnimationClip key = list[i].Key; if (Object.op_Implicit((Object)(object)key) && Replaces.TryGetValue(((Object)key).name, out var value) && Clips.TryGetValue(value, out var value2)) { list[i] = new KeyValuePair<AnimationClip, AnimationClip>(key, value2); replaced++; } } if (replaced == 0) { return null; } val.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list); return val; } private static RuntimeAnimatorController BaseOf(RuntimeAnimatorController controller) { while (true) { AnimatorOverrideController val = (AnimatorOverrideController)(object)((controller is AnimatorOverrideController) ? controller : null); if (val == null) { break; } controller = val.runtimeAnimatorController; } return controller; } private static void Assign(Animator animator, RuntimeAnimatorController controller) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Invalid comparison between Unknown and I4 //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Invalid comparison between Unknown and I4 //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Invalid comparison between Unknown and I4 //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Invalid comparison between Unknown and I4 if (controller is AnimatorOverrideController && (Object)(object)BaseOf(animator.runtimeAnimatorController) == (Object)(object)BaseOf(controller)) { animator.runtimeAnimatorController = controller; return; } int layerCount = animator.layerCount; int[] array = new int[layerCount]; float[] array2 = new float[layerCount]; float[] array3 = new float[layerCount]; for (int i = 0; i < layerCount; i++) { AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(i); array[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash; array2[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime; array3[i] = animator.GetLayerWeight(i); } AnimatorControllerParameter[] parameters = animator.parameters; float[] array4 = new float[parameters.Length]; int[] array5 = new int[parameters.Length]; bool[] array6 = new bool[parameters.Length]; for (int j = 0; j < parameters.Length; j++) { AnimatorControllerParameter val = parameters[j]; if ((int)val.type == 1) { array4[j] = animator.GetFloat(val.nameHash); } else if ((int)val.type == 3) { array5[j] = animator.GetInteger(val.nameHash); } else if ((int)val.type == 4) { array6[j] = animator.GetBool(val.nameHash); } } animator.runtimeAnimatorController = controller; for (int k = 0; k < parameters.Length; k++) { AnimatorControllerParameter val2 = parameters[k]; if ((int)val2.type == 1) { animator.SetFloat(val2.nameHash, array4[k]); } else if ((int)val2.type == 3) { animator.SetInteger(val2.nameHash, array5[k]); } else if ((int)val2.type == 4) { animator.SetBool(val2.nameHash, array6[k]); } } for (int l = 0; l < layerCount && l < animator.layerCount; l++) { animator.SetLayerWeight(l, array3[l]); if (array[l] != 0) { animator.Play(array[l], l, array2[l]); } } } } internal static class Counter { private const float CounterPush = 5f; private const float SwingTimeout = 0.6f; private const float SwingMaxTime = 1f; private static readonly FieldRef<Character, ZSyncAnimation> ZAnim = AccessTools.FieldRefAccess<Character, ZSyncAnimation>("m_zanim"); private static readonly FieldRef<Character, CharacterAnimEvent> AnimEvent = AccessTools.FieldRefAccess<Character, CharacterAnimEvent>("m_animEvent"); private static bool _swinging; private static bool _swingSeen; private static float _swingStart; private static readonly AnimationLease _lease = new AnimationLease(); private static Player _player; private static Character _attacker; private static bool _ranged; private static float _parryTime; private static int _id; private static readonly List<(Character Who, bool Reflected)> AlsoParried = new List<(Character, bool)>(); private static readonly Dictionary<Character, float> CutAt = new Dictionary<Character, float>(); private const float CutAgain = 0.15f; internal const float AreaHeight = 3f; private const float GatherFor = 1f; private static Player _beatPlayer; private static Character _beatAttacker; private static float _beatFactor; internal static bool AnimationPlaying => _swinging; internal static bool OwnsSwing { get { if (_swinging) { return _lease.Current; } return false; } } internal static void StepSwing(Player player, Animator animator, bool paused) { if (!_swinging) { return; } if (!_lease.Matches(player, animator)) { EndSwing(); return; } if (Time.time - _swingStart > 1f || (!((Character)player).InAttack() && (_swingSeen || Time.time - _swingStart > 0.3f))) { EndSwing(); return; } if (((Character)player).InAttack()) { _swingSeen = true; } if (!paused) { _lease.Write(Plugin.CounterAnimationSpeed.Value); } } internal static void EndSwing() { if (_swinging) { Diagnostics.Record("counter animation released its speed"); } _swinging = false; _lease.Clear(); } internal static void RecordGameSpeed(float speed) { if (_swinging) { _lease.GameSpeed(speed); } } internal static void Cancel(Player player) { if ((Object)(object)_lease.Player == (Object)(object)player) { EndSwing(); } if (!((Object)(object)_player != (Object)(object)player)) { _id++; _player = null; _attacker = null; AlsoParried.Clear(); Diagnostics.Record("pending counter canceled on weapon removal"); } } internal static void Start(Player player, Character attacker, bool ranged) { if (!Plugin.CounterEnabled.Value || !Object.op_Implicit((Object)(object)attacker) || (attacker.IsPlayer() && !Plugin.CounterInPvP.Value)) { return; } if ((Object)(object)_player == (Object)(object)player && Object.op_Implicit((Object)(object)_attacker) && (Object)(object)attacker != (Object)(object)_attacker && Time.time - _parryTime < 1f) { if (!AlsoParried.Exists(((Character Who, bool Reflected) p) => (Object)(object)p.Who == (Object)(object)attacker)) { AlsoParried.Add((attacker, ranged)); } return; } AlsoParried.Clear(); SwingWarp.Cancel("parry counter took over", snapshot: false); EndSwing(); _player = player; _attacker = attacker; _ranged = ranged; _parryTime = Time.time; _id++; if (Daisho.Parries(player)) { IaiStance.StartDaishoParry(player); ((MonoBehaviour)player).StartCoroutine(StrikeAfter(_id, Mathf.Max(Plugin.CounterDelay.Value, 0.11f))); } else if (IaiStance.SlashOn && IaiStance.HoldsKatana(player)) { IaiStance.StartSlash(player); ((MonoBehaviour)player).StartCoroutine(StrikeAfter(_id, Mathf.Max(Plugin.CounterDelay.Value, 0.11f))); } else { bool flag = Plugin.CounterAnimation.Value && PlaySwing(player); ((MonoBehaviour)player).StartCoroutine(StrikeAfter(_id, flag ? 0.6f : Plugin.CounterDelay.Value)); } } internal static void OnSwingHit() { if (Object.op_Implicit((Object)(object)_player)) { float num = Plugin.CounterDelay.Value - (Time.time - _parryTime); if (num > 0f) { ((MonoBehaviour)_player).StartCoroutine(StrikeAfter(_id, num)); } else { Strike(_id); } } } private static bool PlaySwing(Player player) { Attack val = ((Humanoid)player).GetCurrentWeapon()?.m_shared.m_attack; if (val == null || string.IsNullOrEmpty(val.m_attackAnimation)) { return false; } _lease.Begin(player, null, requireAttack: false); ZAnim.Invoke((Character)(object)player).SetTrigger((val.m_attackChainLevels > 1) ? (val.m_attackAnimation + "0") : val.m_attackAnimation); _swinging = true; _swingSeen = false; _swingStart = Time.time; return true; } internal static void LocalFreeze(Character character, float seconds) { CharacterAnimEvent val = ((seconds > 0f && Object.op_Implicit((Object)(object)character)) ? AnimEvent.Invoke(character) : null); if (Object.op_Implicit((Object)(object)val)) { val.FreezeFrame(seconds); } } private static IEnumerator StrikeAfter(int id, float seconds) { yield return (object)new WaitForSeconds(seconds); Strike(id); } private static void Strike(int id) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) if (id != _id) { return; } Player player = _player; Character attacker = _attacker; bool ranged = _ranged; _player = null; _attacker = null; if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead() || !Object.op_Implicit((Object)(object)attacker) || attacker.IsDead()) { return; } ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); if (!Katana.IsKatana(currentWeapon)) { return; } float num = Factor(ranged); HitData val = Hit(player, attacker, currentWeapon, num); attacker.Damage(val); CutAt[attacker] = Time.time; KatanaFx.HitEffect(currentWeapon.m_shared.m_hitEffect, val.m_point, Quaternion.LookRotation(val.m_dir), ImpactFrame.InkHides); bool num2 = IaiStance.DaishoPlaying(player, parry: true); float seconds = (num2 ? 0.05f : Plugin.ImpactFreeze.Value); LocalFreeze((Character)(object)player, seconds); LocalFreeze(attacker, seconds); if (num2) { IaiStance.HoldDaisho(player, seconds); _beatPlayer = player; _beatAttacker = attacker; _beatFactor = num; } else { IaiStance.HoldSlash(player, seconds); } ImpactFrame.Play(val.m_point); ((Character)player).RaiseSkill((SkillType)1, 1f); if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)string.Format("counter on {0}: {1:0} before resistances and stagger (x{2:0.00} of the katana{3}{4}, {5:0.00} s after the parry)", attacker.m_name, ((DamageTypes)(ref val.m_damage)).GetTotalDamage(), num, ranged ? ", reflected" : "", Plugin.ParryPrecise.Value ? ", precise" : "", Time.time - _parryTime)); } bool flag = !ranged; foreach (var (val2, flag2) in AlsoParried) { if (Object.op_Implicit((Object)(object)val2) && !val2.IsDead()) { float num3 = Factor(flag2); HitData val3 = Hit(player, val2, currentWeapon, num3); val2.Damage(val3); CutAt[val2] = Time.time; KatanaFx.HitEffect(currentWeapon.m_shared.m_hitEffect, val3.m_point, Quaternion.LookRotation(val3.m_dir), ImpactFrame.InkHides); LocalFreeze(val2, Plugin.ImpactFreeze.Value); flag = flag || !flag2; if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)string.Format("counter on {0}, parried with it: {1:0} before resistances and stagger (x{2:0.00} of the katana{3})", val2.m_name, ((DamageTypes)(ref val3.m_damage)).GetTotalDamage(), num3, flag2 ? ", reflected" : "")); } } } AlsoParried.Clear(); if (flag && Plugin.CounterArea.Value) { CutAround(player, attacker, currentWeapon); } float Factor(bool reflected) { return Katana.CounterFactor(((Character)player).GetRandomSkillFactor((SkillType)1), ((Character)player).GetSkillFactor((SkillType)6), reflected, Plugin.CounterMultiplier.Value, Plugin.BlockBonusMax.Value, Plugin.ReflectMultiplier.Value) * Katana.PreciseFactor(Plugin.ParryPrecise.Value, Plugin.ParryPreciseBonus.Value); } } internal static void WakizashiBeat(Player player) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_beatPlayer != (Object)(object)player) { return; } Character beatAttacker = _beatAttacker; float beatFactor = _beatFactor; _beatPlayer = null; _beatAttacker = null; ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); if (!Katana.IsThunderblood(currentWeapon)) { return; } Vector3 point = ((Object.op_Implicit((Object)(object)beatAttacker) && !beatAttacker.IsDead()) ? beatAttacker.GetCenterPoint() : (((Character)player).GetCenterPoint() + ((Component)player).transform.forward * 1.5f)); if (Object.op_Implicit((Object)(object)beatAttacker) && !beatAttacker.IsDead()) { HitData val = Hit(player, beatAttacker, currentWeapon, beatFactor * Plugin.WakizashiParryShare.Value); val.m_damage = Daisho.Frostify(val.m_damage); beatAttacker.Damage(val); KatanaFx.HitEffect(currentWeapon.m_shared.m_hitEffect, val.m_point, Quaternion.LookRotation(val.m_dir), ImpactFrame.InkHides); LocalFreeze(beatAttacker, Plugin.ImpactFreeze.Value); if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)$"wakizashi on {beatAttacker.m_name}: {((DamageTypes)(ref val.m_damage)).GetTotalDamage():0} before resistances (x{beatFactor * Plugin.WakizashiParryShare.Value:0.00} of the katana, half frost)"); } } if (Plugin.CounterArea.Value) { CutAround(player, beatAttacker, currentWeapon, wakizashi: true); } LocalFreeze((Character)(object)player, Plugin.ImpactFreeze.Value); IaiStance.HoldDaisho(player, Plugin.ImpactFreeze.Value); ImpactFrame.Play(point, crash: true, flip: true); } private static HitData Hit(Player player, Character target, ItemData weapon, float factor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown HitData val = new HitData { m_damage = weapon.GetDamage() }; ((DamageTypes)(ref val.m_damage)).Modify(factor); val.m_point = target.GetCenterPoint(); Vector3 val2 = val.m_point - ((Character)player).GetCenterPoint(); val.m_dir = ((Vector3)(ref val2)).normalized; val.m_attacker = ((Character)player).GetZDOID(); val.m_skill = (SkillType)1; val.m_hitType = (HitType)2; val.m_toolTier = (short)weapon.m_shared.m_toolTier; val.m_pushForce = 5f; val.m_blockable = false; val.m_dodgeable = false; return val; } private static void CutAround(Player player, Character attacker, ItemData weapon, bool wakizashi = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0061: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_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_016b: 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_019b: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0274: 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) Vector3 centerPoint = ((Character)player).GetCenterPoint(); Vector3 ahead = (Object.op_Implicit((Object)(object)attacker) ? (((Component)attacker).transform.position - ((Component)player).transform.position) : ((Component)player).transform.forward); ahead.y = 0f; ahead = ((((Vector3)(ref ahead)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref ahead)).normalized : ((Component)player).transform.forward); foreach (Character item in (from c in CutAt where !Object.op_Implicit((Object)(object)c.Key) || Time.time - c.Value > 0.15f select c.Key).ToList()) { CutAt.Remove(item); } foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || (Object)(object)allCharacter == (Object)(object)player || allCharacter.IsDead() || (!wakizashi && CutAt.ContainsKey(allCharacter)) || (wakizashi && (Object)(object)allCharacter == (Object)(object)attacker) || !Thunderclap.Enemy(player, allCharacter)) { continue; } Vector3 centerPoint2 = allCharacter.GetCenterPoint(); if (Katana.InSwing(centerPoint2 - centerPoint, ahead, allCharacter.GetRadius(), Plugin.CounterAreaRange.Value, Plugin.CounterAreaAngle.Value, 3f) && !Physics.Linecast(centerPoint, centerPoint2, Thunderclap.Walls)) { HitData val = Hit(player, allCharacter, weapon, Plugin.CounterAreaMultiplier.Value * ((Character)player).GetRandomSkillFactor((SkillType)1) * (wakizashi ? Plugin.WakizashiParryShare.Value : 1f)); if (wakizashi) { val.m_damage = Daisho.Frostify(val.m_damage); } allCharacter.Damage(val); if (!wakizashi) { CutAt[allCharacter] = Time.time; } KatanaFx.HitEffect(weapon.m_shared.m_hitEffect, centerPoint2, Quaternion.LookRotation(val.m_dir), ImpactFrame.InkHides); LocalFreeze(allCharacter, Plugin.ImpactFreeze.Value); if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)$"counter cut on {allCharacter.m_name}: {((DamageTypes)(ref val.m_damage)).GetTotalDamage():0} before resistances ({Vector3.Distance(centerPoint, centerPoint2):0.0} m away)"); } } } if (!wakizashi && Chop.On(weapon)) { int num = Chop.CutAround(player, weapon, centerPoint, ahead, Plugin.CounterAreaRange.Value, Plugin.CounterAreaAngle.Value, 3f); if (Plugin.LogCounters.Value) { Plugin.Log.LogInfo((object)$"counter chop: {num} trees, logs or stumps (chop {Chop.Damage(weapon):0}, tier {Chop.Tier(weapon)}, {Plugin.CounterAreaAngle.Value:0} degrees, {Plugin.CounterAreaRange.Value:0.#} m)"); } } } } internal sealed class Crescent : MonoBehaviour { internal sealed class Group { internal readonly HashSet<Character> Hit = new HashSet<Character>(); internal readonly HashSet<IDestructible> Chopped = new HashSet<IDestructible>(); internal Player Owner; internal bool Wakizashi; internal float DamageShare; internal bool Local; } internal const float Range = 15f; internal const float FlySeconds = 1.35f; internal const float HoldSeconds = 0.5f; internal const float FadeSeconds = 0.5f; internal const float Feather = 0.35f; internal const float StartLength = 4f; internal const float Growth = 2.8f; internal const float FinisherScale = 1.35f; internal const float Height = 1.1f; internal const float BarWidth = 0.16f; internal const float WakeLength = 4.5f; internal const float MinWidth = 3f; internal const float ReachUp = 1.4f; internal const float Depth = 0.7f; internal const int Points = 13; internal const int MaxAlive = 24; private static readonly Color[] RedWave = (Color[])(object)new Color[2] { new Color(1f, 0.45f, 0.3f, 1f), new Color(1f, 0.17f, 0f, 0.85f) }; private static readonly Color[] FrostWave = (Color[])(object)new Color[2] { new Color(0.45f, 0.9f, 1f, 1f), new Color(0.09f, 0.66f, 0.86f, 0.85f) }; internal const float Brightness = 0.6f; private static readonly List<Crescent> Alive = new List<Crescent>(); private Vector3 _origin; private Quaternion _rotation; private Vector3 _forward; private Vector3 _along; private float _angle; private float _scale; private Group _group; private int _look; private ParticleSystem _sparks; private float _born; private Mesh _mesh; private Vector3[] _vertices; private Color[] _colours; private bool _built; internal static float AngleOf(Vector3[] path) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (path == null || path.Length < 2) { return (float)Math.PI / 4f; } Vector3 val = path[^1] - path[0]; if (!(val.x * val.x + val.y * val.y < 0.04f)) { return Mathf.Atan2(val.y, val.x); } return (float)Math.PI / 4f; } internal static void Spawn(Vector3[] path, Vector3 origin, Quaternion root, int look, Group group, float scale) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) if (path == null || path.Length < 2 || (!Plugin.AfterimageOn.Value && !group.Local)) { return; } Material val = KatanaFx.ArcMaterial(); if (!Object.op_Implicit((Object)(object)val)) { return; } Alive.RemoveAll((Crescent c) => !Object.op_Implicit((Object)(object)c)); while (Alive.Count >= 24) { Crescent crescent = Alive[0]; Alive.RemoveAt(0); if (Object.op_Implicit((Object)(object)crescent)) { Object.Destroy((Object)(object)((Component)crescent).gameObject); } } Crescent crescent2 = new GameObject("IaidoKatana_wave", new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }).AddComponent<Crescent>(); crescent2.Begin(AngleOf(path), origin, root, look, group, val, scale); Alive.Add(crescent2); } private void Begin(float angle, Vector3 origin, Quaternion rotation, int look, Group group, Material material, float scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown _origin = origin; _rotation = rotation; _forward = rotation * Vector3.forward; _angle = angle; _along = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0f); _scale = scale; _look = look; _group = group; _born = Time.time; ((Component)this).transform.position = origin; ((Component)this).transform.rotation = rotation; _mesh = new Mesh { name = "IaidoKatana_wave" }; _mesh.MarkDynamic(); ((Component)this).GetComponent<MeshFilter>().sharedMesh = _mesh; MeshRenderer component = ((Component)this).GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = material; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; _sparks = KatanaFx.WaveSparks(((Component)this).transform, look); _vertices = (Vector3[])(object)new Vector3[65]; _colours = (Color[])(object)new Color[65]; int[] array = Triangles(13); int[] array2 = WakeTriangles(13); int[] array3 = new int[array.Length + array2.Length]; array.CopyTo(array3, 0); array2.CopyTo(array3, array.Length); _mesh.vertices = _vertices; _mesh.colors = _colours; _mesh.triangles = array3; _built = true; Draw(0f); } internal static int[] Triangles(int points) { int[] array = new int[Mathf.Max(0, points - 1) * 24]; int num = 0; for (int i = 0; i < points - 1; i++) { for (int j = 0; j < 2; j++) { int num2 = i * 3 + j; int num3 = num2 + 3; array[num++] = num2; array[num++] = num3; array[num++] = num2 + 1; array[num++] = num2 + 1; array[num++] = num3; array[num++] = num3 + 1; array[num++] = num2; array[num++] = num2 + 1; array[num++] = num3; array[num++] = num2 + 1; array[num++] = num3 + 1; array[num++] = num3; } } return array; } internal static int[] WakeTriangles(int points) { int[] array = new int[Mathf.Max(0, points - 1) * 12]; int num = 0; for (int i = 0; i < points - 1; i++) { int num2 = points * 3 + i * 2; int num3 = num2 + 1; int num4 = num2 + 2; int num5 = num2 + 3; array[num++] = num2; array[num++] = num3; array[num++] = num4; array[num++] = num4; array[num++] = num3; array[num++] = num5; array[num++] = num2; array[num++] = num4; array[num++] = num3; array[num++] = num4; array[num++] = num5; array[num++] = num3; } return array; } internal static float DistanceAt(float age) { float num = Mathf.Clamp01(age / 1.35f); return 15f * (1f - (1f - num) * (1f - num)); } internal static float GrowthOver(float distance) { return 1f + 1.8f * Mathf.Clamp01(distance / 15f); } internal static float GrowthAt(float age) { return GrowthOver(DistanceAt(age)); } internal static float AlphaAt(float age, float u) { if (age < 0f) { return 0f; } float num = Mathf.Clamp01((Mathf.Clamp01((age - 0.5f) / 0.5f) * 1.35f - u) / 0.35f); return 1f - num * num * (3f - 2f * num); } internal static void VolumeAt(Vector3 origin, Quaternion rotation, float angle, float scale, float age, out Vector3 middle, out Vector3 half, out Quaternion frame) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_008c: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) float num = GrowthAt(age); Vector3 val = rotation * Vector3.forward; float num2 = Mathf.Sqrt(val.x * val.x + val.z * val.z); float num3 = Mathf.Atan2(val.x, val.z) * 0.5f; frame = new Quaternion(0f, Mathf.Sin(num3), 0f, Mathf.Cos(num3)); middle = origin + frame * new Vector3(0f, 1.4f, DistanceAt(age) * num2); float num4 = 2f * scale * num * Mathf.Abs(Mathf.Cos(angle)); half = new Vector3(Mathf.Max(num4, 1.5f * num), 1.4f, 0.35f); } private void LateUpdate() { if (!_built) { return; } float num = Time.time - _born; if (num >= 1.05f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (_group != null && _group.Local) { CutThrough(num); } Draw(num); Sparkle(num); } private void Sparkle(float age) { //IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_sparks)) { return; } if (age >= 0.5f) { if (_sparks.isEmitting) { _sparks.Stop(true, (ParticleSystemStopBehavior)1); } } else { float num = DistanceAt(age); float num2 = 2f * _scale * GrowthOver(num); Vector3 val = ((Component)this).transform.rotation * _along; KatanaFx.WaveSparksAlong(_sparks, ((Component)this).transform.TransformPoint(new Vector3(0f, 1.1f, num)) - val * num2, val, num2 * 2f); } } private void OnDestroy() { Alive.Remove(this); if (Object.op_Implicit((Object)(object)_mesh)) { Object.Destroy((Object)(object)_mesh); } } private void Draw(float age) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0173: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_02e5: Unknown result type (might be due to invalid IL or missing references) Color[] array = ((_look == 3) ? FrostWave : RedWave); Camera main = Camera.main; Vector3 val = (Vector3)(Object.op_Implicit((Object)(object)main) ? ((Component)this).transform.InverseTransformPoint(((Component)main).transform.position) : new Vector3(0f, 1.1f, -5f)); float num = DistanceAt(age); float num2 = Mathf.Max(0f, num - 4.5f); float num3 = 2f * _scale * GrowthOver(num); float num4 = 2f * _scale * GrowthOver(num2); float num5 = 0.08f; Color val2 = Color.Lerp(array[0], array[1], Mathf.Clamp01(age / 1f)); float a = AlphaAt(age, 1f) * 0.6f; float num6 = AlphaAt(age, 0.55f) * 0.6f; for (int i = 0; i < 13; i++) { float num7 = (float)i / 12f; float num8 = num7 * 2f - 1f; float num9 = Mathf.Sin((float)Math.PI * Mathf.Clamp01(0.06f + 0.88f * num7)); Vector3 val3 = new Vector3(0f, 1.1f, num) + _along * (num8 * num3); Vector3 val4 = Vector3.Cross(_along, val - val3); val4 = ((((Vector3)(ref val4)).sqrMagnitude < 1E-06f) ? Vector3.up : ((Vector3)(ref val4)).normalized); float num10 = num5 * (0.3f + 0.7f * num9); Color val5 = array[1]; val5.a = 0f; Color val6 = val2; val6.a = a; _vertices[i * 3] = val3 - val4 * num10; _vertices[i * 3 + 1] = val3; _vertices[i * 3 + 2] = val3 + val4 * num10; _colours[i * 3] = val5; _colours[i * 3 + 1] = val6; _colours[i * 3 + 2] = val5; Color val7 = array[1]; val7.a = num6 * num9 * ((i % 2 == 0) ? 0.55f : 0.14f); Color val8 = array[1]; val8.a = 0f; int num11 = 39 + i * 2; _vertices[num11] = val3; _vertices[num11 + 1] = new Vector3(0f, 1.1f, num2) + _along * (num8 * num4); _colours[num11] = val7; _colours[num11 + 1] = val8; } _mesh.vertices = _vertices; _mesh.colors = _colours; _mesh.RecalculateBounds(); } private void CutThrough(float age) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) Player owner = _group.Owner; if (age > 1.35f || !Object.op_Implicit((Object)(object)owner) || ((Character)owner).IsDead()) { return; } VolumeAt(_origin, _rotation, _angle, _scale, age, out var middle, out var half, out var frame); VolumeAt(_origin, _rotation, _angle, _scale, Mathf.Max(0f, age - Time.deltaTime), out var middle2, out var _, out var _); ItemData currentWeapon = ((Humanoid)owner).GetCurrentWeapon(); bool flag = Chop.On(currentWeapon) && Katana.IsThunderblood(currentWeapon); int num = Mathf.Clamp(Mathf.CeilToInt(Vector3.Distance(middle2, middle) / (7f / 30f)), 1, 24); for (int i = 1; i <= num; i++) { Vector3 val = Vector3.Lerp(middle2, middle, (float)i / (float)num); Collider[] array = Physics.OverlapBox(val, half, frame, Daisho.Creatures); foreach (Collider val2 in array) { Character val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponentInParent<Character>() : null); if (Object.op_Implicit((Object)(object)val3) && !((Object)(object)val3 == (Object)(object)owner) && !val3.IsDead() && !_group.Hit.Contains(val3) && Thunderclap.Enemy(owner, val3) && !Physics.Linecast(((Character)owner).GetCenterPoint(), val3.GetCenterPoint(), Thunderclap.Rock)) { _group.Hit.Add(val3); Daisho.CrescentHit(_group, val3, _forward); } } if (!flag) { continue; } array = Physics.OverlapBox(val, half, frame, Chop.Mask); foreach (Collider val4 in array) { IDestructible val5 = Chop.Tree(val4); if (val5 != null && _group.Chopped.Add(val5)) { Daisho.WaveChop(_group, currentWeapon, val5, val4.ClosestPointOnBounds(val), _forward); } } } } } internal static class Daisho { private static readonly Action<Player> ClearQueue = AccessTools.MethodDelegate<Action<Player>>(AccessTools.Method(typeof(Player), "ClearActionQueue", (Type[])null, (Type[])null), (object)null, true); internal const float ParryKatanaAt = 0.11f; internal const float ParryWakizashiAt = 0.21f; internal const float FirstBeatFreeze = 0.05f; private const float AimTurn = 120f; private const float Push = 4f; private const float FrostShare = 0.5f; private const float WaveChopShare = 0.25f; private static int? _creatures; private static Player _player; private static float _start = -1f; internal co