using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using StaffsOfFracturing.Blood; using StaffsOfFracturing.Configuration; using StaffsOfFracturing.Items; using StaffsOfFracturing.Lightning; using StaffsOfFracturing.Localization; using StaffsOfFracturing.Networking; using StaffsOfFracturing.Plugin; using StaffsOfFracturing.Poison; using StaffsOfFracturing.Projectiles; using StaffsOfFracturing.Utilities; using StaffsOfFracturing.VFX; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("StaffsOfFracturing")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5")] [assembly: AssemblyProduct("StaffsOfFracturing")] [assembly: AssemblyTitle("StaffsOfFracturing")] [assembly: AssemblyVersion("1.0.5.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 StaffsOfFracturing.VFX { internal sealed class ShrapnelMotionVisuals : MonoBehaviour { private bool applied; internal void Initialize(float speedMultiplier) { if (!applied) { applied = true; if (speedMultiplier > 1f) { VfxStyler.CompensateShrapnelMotion(((Component)this).gameObject, speedMultiplier); } } } private void Start() { ZNetView component = ((Component)this).GetComponent(); if (!applied && Object.op_Implicit((Object)(object)component) && component.IsValid()) { Initialize(ModConfig.ShrapnelSpeedMultiplier.Value); } } } internal sealed class StaffHeadArcVisuals : MonoBehaviour { private static readonly string[] ChildNames = new string[2] { "sof_head_arc_0", "sof_head_arc_1" }; private const int PointCount = 6; private const float MaximumRadius = 0.145f; [SerializeField] private Material arcMaterial; private readonly LineRenderer[] lines = (LineRenderer[])(object)new LineRenderer[2]; private readonly Vector3[] points = (Vector3[])(object)new Vector3[6]; private Random random; private float nextChange; private bool started; private bool ready; internal void Initialize(Material material) { arcMaterial = material; if (started) { ConfigureLines(); } } private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 for (int i = 0; i < lines.Length; i++) { Transform val = ((Component)this).transform.Find(ChildNames[i]); if (Object.op_Implicit((Object)(object)val)) { lines[i] = ((Component)val).GetComponent(); } } HideLines(); if ((int)SystemInfo.graphicsDeviceType == 4) { ((Behaviour)this).enabled = false; } else { random = new Random((((Object)this).GetInstanceID() * 397) ^ Environment.TickCount); } } private void Start() { started = true; ConfigureLines(); } private void OnEnable() { nextChange = 0f; HideLines(); } private void OnDisable() { nextChange = 0f; HideLines(); } private void ConfigureLines() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_005b: Unknown result type (might be due to invalid IL or missing references) ready = false; HideLines(); if (!Object.op_Implicit((Object)(object)arcMaterial) || (int)SystemInfo.graphicsDeviceType == 4) { return; } for (int i = 0; i < lines.Length; i++) { if (!Object.op_Implicit((Object)(object)lines[i])) { Transform val = ((Component)this).transform.Find(ChildNames[i]); if (!Object.op_Implicit((Object)(object)val)) { val = new GameObject(ChildNames[i]).transform; val.SetParent(((Component)this).transform, false); } lines[i] = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); } LineRenderer obj = lines[i]; ((Component)obj).gameObject.layer = ((Component)this).gameObject.layer; ((Component)obj).transform.localPosition = Vector3.zero; ((Component)obj).transform.localRotation = Quaternion.identity; ((Component)obj).transform.localScale = Vector3.one; ((Renderer)obj).sharedMaterial = arcMaterial; obj.useWorldSpace = false; obj.loop = false; obj.positionCount = 6; obj.alignment = (LineAlignment)0; obj.textureMode = (LineTextureMode)0; obj.numCapVertices = 0; obj.numCornerVertices = 0; obj.startColor = new Color(0.65f, 0.86f, 1f, 0.95f); obj.endColor = new Color(0.35f, 0.65f, 1f, 0.75f); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; ((Renderer)obj).lightProbeUsage = (LightProbeUsage)0; ((Renderer)obj).reflectionProbeUsage = (ReflectionProbeUsage)0; ((Renderer)obj).enabled = false; } nextChange = 0f; ready = true; } private void Update() { //IL_0078: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00d4: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0132: Unknown result type (might be due to invalid IL or missing references) if (!ready || Time.time < nextChange) { return; } nextChange = Time.time + Range(0.07f, 0.18f); for (int i = 0; i < lines.Length; i++) { LineRenderer val = lines[i]; ((Renderer)val).enabled = random.NextDouble() < ((i == 0) ? 0.85 : 0.6); if (((Renderer)val).enabled) { Vector3 val2 = Direction() * Range(0.085f, 0.125f); Vector3 val3 = Direction() * Range(0.085f, 0.125f); Vector3 val4 = val3 - val2; if (((Vector3)(ref val4)).sqrMagnitude < 0.0036f) { val3 = -val2; } points[0] = val2; points[5] = val3; for (int j = 1; j < 5; j++) { Vector3 val5 = Vector3.Lerp(val2, val3, (float)j / 5f); points[j] = Vector3.ClampMagnitude(val5 + Direction() * Range(0.012f, 0.04f), 0.145f); } float endWidth = (val.startWidth = Range(0.004f, 0.007f)); val.endWidth = endWidth; val.SetPositions(points); } } } private Vector3 Direction() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) float num = Range(-1f, 1f); float num2 = Range(0f, (float)Math.PI * 2f); float num3 = Mathf.Sqrt(1f - num * num); return new Vector3(num3 * Mathf.Cos(num2), num3 * Mathf.Sin(num2), num); } private float Range(float minimum, float maximum) { return minimum + (float)random.NextDouble() * (maximum - minimum); } private void HideLines() { for (int i = 0; i < lines.Length; i++) { if (Object.op_Implicit((Object)(object)lines[i])) { ((Renderer)lines[i]).enabled = false; } } } } internal static class StaffHeadMaterial { internal static void Apply(Transform model, Color color, float emissionStrength) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0150: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model) || (int)SystemInfo.graphicsDeviceType == 4) { return; } MeshFilter component = ((Component)model).GetComponent(); MeshRenderer component2 = ((Component)model).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component.sharedMesh)) { return; } Material[] sharedMaterials = ((Renderer)component2).sharedMaterials; if (sharedMaterials.Length != 1 || !Object.op_Implicit((Object)(object)sharedMaterials[0]) || !((Object)sharedMaterials[0]).name.StartsWith("FragStaff_mat", StringComparison.Ordinal)) { Logger.LogWarning((object)"Staff-head coloring skipped: the native staff material layout has changed."); return; } Material val = sharedMaterials[0]; if (val.HasProperty("_MainTex")) { Texture texture = val.GetTexture("_MainTex"); Texture2D val2 = (Texture2D)(object)((texture is Texture2D) ? texture : null); if (val2 != null) { Mesh orCreate = StaffHeadMesh.GetOrCreate(component.sharedMesh); if (!Object.op_Implicit((Object)(object)orCreate)) { return; } Material val3 = null; Texture2D val4 = null; Texture2D val5 = null; Mesh sharedMesh = component.sharedMesh; try { RenderTexture active = RenderTexture.active; try { val4 = AssetUtils.DuplicateTexture(val2); } finally { RenderTexture.active = active; } if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Could not copy the staff diffuse texture."); } ((Object)val4).name = "SOF_StaffHeadDiffuse_" + ColorUtility.ToHtmlStringRGB(color); CopySampling((Texture)(object)val2, (Texture)(object)val4); Color[] pixels = val4.GetPixels(); Color[] array = (Color[])(object)new Color[pixels.Length]; for (int i = 0; i < pixels.Length; i++) { Color val6 = pixels[i]; float num = val6.r * 0.3f + val6.g * 0.59f + val6.b * 0.11f; Color val7 = color * Mathf.Clamp01(num * 1.5f + 0.06f); val7.a = val6.a; pixels[i] = Color.Lerp(val6, val7, 0.9f); array[i] = color * (num * emissionStrength); array[i].a = val6.a; } val4.SetPixels(pixels); val4.Apply(true, false); val3 = new Material(val) { name = "FragStaff_mat_SOF_Head_" + ColorUtility.ToHtmlStringRGB(color) }; val3.SetTexture("_MainTex", (Texture)(object)val4); if (val3.HasProperty("_EmissionMap") && val3.HasProperty("_EmissionColor")) { val5 = new Texture2D(((Texture)val4).width, ((Texture)val4).height, (TextureFormat)4, ((Texture)val4).mipmapCount > 1) { name = "SOF_StaffHeadEmission_" + ColorUtility.ToHtmlStringRGB(color) }; CopySampling((Texture)(object)val2, (Texture)(object)val5); val5.SetPixels(array); val5.Apply(true, false); val3.SetTexture("_EmissionMap", (Texture)(object)val5); val3.SetTextureScale("_EmissionMap", val.GetTextureScale("_MainTex")); val3.SetTextureOffset("_EmissionMap", val.GetTextureOffset("_MainTex")); val3.SetColor("_EmissionColor", Color.white); val3.EnableKeyword("_EMISSION"); } component.sharedMesh = orCreate; ((Renderer)component2).sharedMaterials = (Material[])(object)new Material[2] { val, val3 }; return; } catch (Exception ex) { component.sharedMesh = sharedMesh; ((Renderer)component2).sharedMaterials = sharedMaterials; if (Object.op_Implicit((Object)(object)val3)) { Object.DestroyImmediate((Object)(object)val3); } if (Object.op_Implicit((Object)(object)val4)) { Object.DestroyImmediate((Object)(object)val4); } if (Object.op_Implicit((Object)(object)val5)) { Object.DestroyImmediate((Object)(object)val5); } Logger.LogWarning((object)("Staff-head coloring skipped; native appearance preserved: " + ex.Message)); return; } } } Logger.LogWarning((object)"Staff-head coloring skipped: the native staff diffuse texture was not found."); } private static void CopySampling(Texture source, Texture destination) { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) destination.filterMode = source.filterMode; destination.wrapModeU = source.wrapModeU; destination.wrapModeV = source.wrapModeV; destination.wrapModeW = source.wrapModeW; destination.anisoLevel = source.anisoLevel; destination.mipMapBias = source.mipMapBias; } } internal static class StaffHeadMesh { private const float HeadMinimumY = 1.09f; private const int ExpectedVertexCount = 3049; private const int ExpectedIndexCount = 10980; private const int ExpectedHeadTriangleCount = 3252; private const int ExpectedLowerTriangleCount = 408; private static readonly Vector3 ExpectedCenter = new Vector3(0.064486995f, 1.0441985f, 0f); private static readonly Vector3 ExpectedExtents = new Vector3(0.127459f, 1.0736005f, 0.209847f); private static readonly Dictionary Cache = new Dictionary(); private static readonly HashSet Unavailable = new HashSet(); internal static Mesh GetOrCreate(Mesh source) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)source) || (int)SystemInfo.graphicsDeviceType == 4) { return null; } if (Cache.TryGetValue(source, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } if (Unavailable.Contains(source)) { return null; } Mesh val = null; try { ValidateSource(source); VertexAttributeDescriptor[] vertexAttributes = source.GetVertexAttributes(); int vertexBufferCount = source.vertexBufferCount; if (vertexBufferCount < 1 || vertexBufferCount > 4) { throw new InvalidOperationException("Unsupported vertex stream count."); } byte[][] array = new byte[vertexBufferCount][]; int[] array2 = new int[vertexBufferCount]; for (int i = 0; i < vertexBufferCount; i++) { int vertexBufferStride = source.GetVertexBufferStride(i); if (vertexBufferStride <= 0 || vertexBufferStride > 256) { throw new InvalidOperationException("Unsupported vertex buffer stride."); } array2[i] = vertexBufferStride; array[i] = ReadBuffer(source.GetVertexBuffer(i), checked(source.vertexCount * vertexBufferStride)); } int vertexAttributeStream = source.GetVertexAttributeStream((VertexAttribute)0); int vertexAttributeOffset = source.GetVertexAttributeOffset((VertexAttribute)0); if (vertexAttributeStream < 0 || vertexAttributeStream >= vertexBufferCount || vertexAttributeOffset < 0 || vertexAttributeOffset + 12 > array2[vertexAttributeStream]) { throw new InvalidOperationException("Invalid position attribute layout."); } float[] array3 = new float[source.vertexCount]; Bounds bounds = source.bounds; ((Bounds)(ref bounds)).Expand(0.002f); Vector3 val2 = default(Vector3); for (int j = 0; j < array3.Length; j++) { int num = checked(j * array2[vertexAttributeStream] + vertexAttributeOffset); byte[] value2 = array[vertexAttributeStream]; ((Vector3)(ref val2))..ctor(BitConverter.ToSingle(value2, num), BitConverter.ToSingle(value2, num + 4), BitConverter.ToSingle(value2, num + 8)); if (!IsFinite(val2.x) || !IsFinite(val2.y) || !IsFinite(val2.z) || !((Bounds)(ref bounds)).Contains(val2)) { throw new InvalidOperationException("GPU vertex data does not match the verified staff bounds."); } array3[j] = val2.y; } SubMeshDescriptor subMesh = source.GetSubMesh(0); int num2 = (((int)source.indexFormat == 0) ? 2 : 4); int num3; byte[] array4; List list; List list2; checked { num3 = ((SubMeshDescriptor)(ref subMesh)).indexStart + ((SubMeshDescriptor)(ref subMesh)).indexCount; array4 = ReadBuffer(source.GetIndexBuffer(), num3 * num2); list = new List(((SubMeshDescriptor)(ref subMesh)).indexCount); list2 = new List(((SubMeshDescriptor)(ref subMesh)).indexCount); } for (int k = ((SubMeshDescriptor)(ref subMesh)).indexStart; k < num3; k += 3) { bool flag = true; for (int l = 0; l < 3; l++) { int startIndex = checked((k + l) * num2); long num4 = ((num2 == 2) ? BitConverter.ToUInt16(array4, startIndex) : BitConverter.ToUInt32(array4, startIndex)) + ((SubMeshDescriptor)(ref subMesh)).baseVertex; if (num4 < 0 || num4 >= array3.Length) { throw new InvalidOperationException("GPU index data references an invalid vertex."); } flag &= array3[(int)num4] >= 1.09f; } List obj = (flag ? list2 : list); obj.Add(k); obj.Add(k + 1); obj.Add(k + 2); } if (list2.Count != 9756 || list.Count != 1224 || list2.Count + list.Count != ((SubMeshDescriptor)(ref subMesh)).indexCount) { throw new InvalidOperationException("The staff head could not be separated conservatively."); } byte[] array5 = new byte[checked(((SubMeshDescriptor)(ref subMesh)).indexCount * num2)]; CopyIndices(array4, array5, list, num2, 0); CopyIndices(array4, array5, list2, num2, list.Count); val = new Mesh { name = ((Object)source).name + "_SOF_HeadPartition" }; val.SetVertexBufferParams(source.vertexCount, vertexAttributes); if (val.vertexBufferCount != vertexBufferCount) { throw new InvalidOperationException("Cloned vertex stream layout differs from the native mesh."); } VertexAttributeDescriptor[] array6 = vertexAttributes; for (int m = 0; m < array6.Length; m++) { VertexAttributeDescriptor val3 = array6[m]; if (val.GetVertexAttributeStream(((VertexAttributeDescriptor)(ref val3)).attribute) != source.GetVertexAttributeStream(((VertexAttributeDescriptor)(ref val3)).attribute) || val.GetVertexAttributeOffset(((VertexAttributeDescriptor)(ref val3)).attribute) != source.GetVertexAttributeOffset(((VertexAttributeDescriptor)(ref val3)).attribute)) { throw new InvalidOperationException("Cloned vertex attribute layout differs from the native mesh."); } } for (int n = 0; n < vertexBufferCount; n++) { if (val.GetVertexBufferStride(n) != array2[n]) { throw new InvalidOperationException("Cloned vertex buffer stride differs from the native mesh."); } byte[] array7 = array[n]; val.SetVertexBufferData(array7, 0, 0, array7.Length, n, (MeshUpdateFlags)8); } val.SetIndexBufferParams(((SubMeshDescriptor)(ref subMesh)).indexCount, source.indexFormat); if ((int)source.indexFormat == 0) { ushort[] array8 = new ushort[((SubMeshDescriptor)(ref subMesh)).indexCount]; Buffer.BlockCopy(array5, 0, array8, 0, array5.Length); val.SetIndexBufferData(array8, 0, 0, array8.Length, (MeshUpdateFlags)8); } else { uint[] array9 = new uint[((SubMeshDescriptor)(ref subMesh)).indexCount]; Buffer.BlockCopy(array5, 0, array9, 0, array5.Length); val.SetIndexBufferData(array9, 0, 0, array9.Length, (MeshUpdateFlags)8); } val.subMeshCount = 2; val.SetSubMesh(0, MakeSubmesh(subMesh, 0, list.Count), (MeshUpdateFlags)8); val.SetSubMesh(1, MakeSubmesh(subMesh, list.Count, list2.Count), (MeshUpdateFlags)8); val.bounds = source.bounds; Cache[source] = val; return val; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val)) { Object.DestroyImmediate((Object)(object)val); } Unavailable.Add(source); Logger.LogWarning((object)("Staff-head mesh styling skipped for '" + ((Object)source).name + "': " + ex.Message)); return null; } } private static void ValidateSource(Mesh source) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_006e: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Invalid comparison between Unknown and I4 //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (BitConverter.IsLittleEndian && source.vertexCount == 3049 && source.subMeshCount == 1 && source.blendShapeCount == 0) { Bounds bounds = source.bounds; if (Near(((Bounds)(ref bounds)).center, ExpectedCenter)) { bounds = source.bounds; if (Near(((Bounds)(ref bounds)).extents, ExpectedExtents)) { SubMeshDescriptor subMesh = source.GetSubMesh(0); if ((int)((SubMeshDescriptor)(ref subMesh)).topology != 0 || ((SubMeshDescriptor)(ref subMesh)).indexCount != 10980 || ((SubMeshDescriptor)(ref subMesh)).indexStart < 0 || ((int)source.indexFormat != 0 && (int)source.indexFormat != 1) || !source.HasVertexAttribute((VertexAttribute)0) || (int)source.GetVertexAttributeFormat((VertexAttribute)0) != 0 || source.GetVertexAttributeDimension((VertexAttribute)0) != 3) { throw new InvalidOperationException("Unsupported staff triangle or position data."); } return; } } } throw new InvalidOperationException("Mesh metadata differs from the verified StaffClusterbomb model."); } private static byte[] ReadBuffer(GraphicsBuffer buffer, int byteCount) { try { if (buffer == null || !buffer.IsValid() || byteCount <= 0 || (long)buffer.count * (long)buffer.stride < byteCount) { throw new InvalidOperationException("The staff GPU buffer is unavailable or too small."); } byte[] array = new byte[byteCount]; buffer.GetData((Array)array); return array; } finally { ((IDisposable)buffer)?.Dispose(); } } private static void CopyIndices(byte[] source, byte[] destination, List indices, int indexSize, int start) { for (int i = 0; i < indices.Count; i++) { checked { Buffer.BlockCopy(source, indices[i] * indexSize, destination, (start + i) * indexSize, indexSize); } } } private static SubMeshDescriptor MakeSubmesh(SubMeshDescriptor original, int start, int count) { //IL_0038: 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) SubMeshDescriptor result = default(SubMeshDescriptor); ((SubMeshDescriptor)(ref result))..ctor(start, count, (MeshTopology)0); ((SubMeshDescriptor)(ref result)).baseVertex = ((SubMeshDescriptor)(ref original)).baseVertex; ((SubMeshDescriptor)(ref result)).firstVertex = ((SubMeshDescriptor)(ref original)).firstVertex; ((SubMeshDescriptor)(ref result)).vertexCount = ((SubMeshDescriptor)(ref original)).vertexCount; ((SubMeshDescriptor)(ref result)).bounds = ((SubMeshDescriptor)(ref original)).bounds; return result; } private static bool Near(Vector3 actual, Vector3 expected) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (IsFinite(actual.x) && IsFinite(actual.y) && IsFinite(actual.z) && Mathf.Abs(actual.x - expected.x) <= 0.001f && Mathf.Abs(actual.y - expected.y) <= 0.001f) { return Mathf.Abs(actual.z - expected.z) <= 0.001f; } return false; } private static bool IsFinite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } } internal static class StaffHeadVfx { private const string RootName = "SOF_StaffHeadVfx"; private static readonly Vector3 HeadCenter = new Vector3(0.065f, 1.7f, 0f); private static readonly Color ElectricColor = new Color(0.56f, 0.8f, 1f, 1f); private static Mesh sharpParticleMesh; internal static void Attach(GameObject itemPrefab, ElementTheme theme) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) if (!Object.op_Implicit((Object)(object)itemPrefab) || (int)SystemInfo.graphicsDeviceType == 4) { return; } Transform val = itemPrefab.transform.Find("attach"); Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.Find("default") : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { Logger.LogWarning((object)("Staff-head cosmetics skipped for '" + ((Object)itemPrefab).name + "': attach/default was not found.")); } else if (!Object.op_Implicit((Object)(object)val.Find("SOF_StaffHeadVfx"))) { GameObject val3 = CreateChild(val, "SOF_StaffHeadVfx"); val3.SetActive(false); val3.transform.localPosition = val.InverseTransformPoint(val2.TransformPoint(HeadCenter)); switch (theme) { case ElementTheme.Lightning: StaffHeadMaterial.Apply(val2, ElectricColor, 0.65f); BuildElectric(val3.transform); AddLight(val3.transform, ElectricColor, 0.45f, 0.45f); break; case ElementTheme.Poison: StaffHeadMaterial.Apply(val2, VfxStyler.Poison, 0.35f); BuildHaze(val3.transform); AddLight(val3.transform, VfxStyler.Poison, 0.25f, 0.35f); break; case ElementTheme.Blood: StaffHeadMaterial.Apply(val2, VfxStyler.Blood, 0.25f); BuildBlood(val3.transform); AddLight(val3.transform, VfxStyler.Blood, 0.18f, 0.3f); break; } val3.SetActive(true); } } private static void BuildElectric(Transform parent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Material source = FindParticleMaterial("AtgeirHimminAfl", "attach/equiped/Sparcs"); Material val = VfxStyler.CreateCosmeticMaterial(source, ElectricColor, 1.7f); if (Object.op_Implicit((Object)(object)val)) { CreateEmitter(parent, "SOF_HeadSparks", val, 0.09f, 18f, 8, 0.08f, 0.2f, 0.006f, 0.018f, 0.06f, 0.18f, 0.8f); } Material val2 = VfxStyler.CreateCosmeticMaterial(source, ElectricColor, 1.7f, untextured: true); if (Object.op_Implicit((Object)(object)val2)) { ((Component)parent).gameObject.AddComponent().Initialize(val2); } } private static void BuildHaze(Transform parent) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0081: 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) Material val = VfxStyler.CreateCosmeticMaterial(FindParticleMaterial("poisoncloud", string.Empty), VfxStyler.Poison, 0.55f); if (Object.op_Implicit((Object)(object)val)) { VelocityOverLifetimeModule velocityOverLifetime = CreateEmitter(parent, "SOF_HeadPoisonHaze", val, 0.065f, 7f, 12, 0.65f, 0.95f, 0.055f, 0.1f, 0.018f, 0.035f, 0.2f).velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(0.012f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(0.012f); } } private static void BuildBlood(Transform parent) { //IL_0010: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) Material source = FindParticleMaterial("AtgeirHimminAfl", "attach/equiped/Sparcs"); Material val = VfxStyler.CreateCosmeticMaterial(source, VfxStyler.Blood, 0.65f, untextured: true); if (Object.op_Implicit((Object)(object)val)) { ParticleSystem obj = CreateEmitter(parent, "SOF_HeadBloodDrips", val, 0.05f, 4f, 4, 0.22f, 0.42f, 0.008f, 0.016f, 0f, 0f, 0.7f); VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(-0.16f); ParticleSystemRenderer component = ((Component)obj).GetComponent(); component.renderMode = (ParticleSystemRenderMode)1; component.lengthScale = 1.8f; component.velocityScale = 0f; component.cameraVelocityScale = 0f; } Material val2 = VfxStyler.CreateCosmeticMaterial(source, VfxStyler.Blood, 0.65f, untextured: true); if (Object.op_Implicit((Object)(object)val2)) { ParticleSystem obj2 = CreateEmitter(parent, "SOF_HeadFloatingBloodShards", val2, 0.1f, 3f, 7, 1f, 1.6f, 0.04f, 0.065f, 0.007f, 0.02f, 0.8f); MainModule main = obj2.main; ((MainModule)(ref main)).startRotation3D = true; ((MainModule)(ref main)).startRotationX = new MinMaxCurve(-(float)Math.PI, (float)Math.PI); ((MainModule)(ref main)).startRotationY = new MinMaxCurve(-(float)Math.PI, (float)Math.PI); ((MainModule)(ref main)).startRotationZ = new MinMaxCurve(-(float)Math.PI, (float)Math.PI); RotationOverLifetimeModule rotationOverLifetime = obj2.rotationOverLifetime; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).separateAxes = true; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).x = MinMaxCurve.op_Implicit(0.35f); ((RotationOverLifetimeModule)(ref rotationOverLifetime)).y = MinMaxCurve.op_Implicit(0.5f); ((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = MinMaxCurve.op_Implicit(0.25f); ParticleSystemRenderer component2 = ((Component)obj2).GetComponent(); component2.renderMode = (ParticleSystemRenderMode)4; component2.alignment = (ParticleSystemRenderSpace)2; component2.mesh = GetSharpParticleMesh(); } } private static ParticleSystem CreateEmitter(Transform parent, string name, Material material, float radius, float rate, int maximum, float minLifetime, float maxLifetime, float minSize, float maxSize, float minSpeed, float maxSpeed, float opacity) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_008f: 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_00b1: 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_00c1: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) ParticleSystem val = CreateChild(parent, name).AddComponent(); val.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val.main; ((MainModule)(ref main)).duration = 2f; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).prewarm = false; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; ((MainModule)(ref main)).cullingMode = (ParticleSystemCullingMode)2; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ((MainModule)(ref main)).maxParticles = maximum; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(minLifetime, maxLifetime); ((MainModule)(ref main)).startSize = new MinMaxCurve(minSize, maxSize); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(minSpeed, maxSpeed); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f); EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate); ((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f); ShapeModule shape = val.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = radius; ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(opacity, 0.15f), new GradientAlphaKey(opacity, 0.55f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val2); ParticleSystemRenderer component = ((Component)val).GetComponent(); ((Renderer)component).sharedMaterial = material; component.renderMode = (ParticleSystemRenderMode)0; component.SetActiveVertexStreams(new List { (ParticleSystemVertexStream)0, (ParticleSystemVertexStream)1, (ParticleSystemVertexStream)3, (ParticleSystemVertexStream)4 }); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; ((Renderer)component).lightProbeUsage = (LightProbeUsage)0; ((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0; return val; } private static Material FindParticleMaterial(string prefabName, string path) { GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); Transform val = ((!Object.op_Implicit((Object)(object)prefab)) ? null : (string.IsNullOrEmpty(path) ? prefab.transform : prefab.transform.Find(path))); if (Object.op_Implicit((Object)(object)val)) { ParticleSystemRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials; foreach (Material val2 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader)) { return val2; } } } } Logger.LogWarning((object)("Staff-head material '" + prefabName + "/" + path + "' unavailable; that cosmetic is skipped.")); return null; } private static GameObject CreateChild(Transform parent, string name) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); return val; } private static void AddLight(Transform parent, Color color, float intensity, float range) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) Light obj = CreateChild(parent, "SOF_HeadLight").AddComponent(); obj.type = (LightType)2; obj.color = color; obj.intensity = intensity; obj.range = range; obj.shadows = (LightShadows)0; } private static Mesh GetSharpParticleMesh() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003b: 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_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c7: 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_00f7: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)sharpParticleMesh)) { return sharpParticleMesh; } Mesh val = new Mesh(); ((Object)val).name = "SOF_DecorativeBloodShard"; val.vertices = (Vector3[])(object)new Vector3[6] { new Vector3(0f, 0.5f, 0f), new Vector3(0f, -0.5f, 0f), new Vector3(-0.12f, 0f, 0f), new Vector3(0f, 0f, 0.09f), new Vector3(0.12f, 0f, 0f), new Vector3(0f, 0f, -0.09f) }; val.triangles = new int[24] { 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 2, 1, 3, 2, 1, 4, 3, 1, 5, 4, 1, 2, 5 }; val.colors = (Color[])(object)new Color[6] { Color.white, Color.white, Color.white, Color.white, Color.white, Color.white }; val.uv = (Vector2[])(object)new Vector2[6] { Vector2.up, Vector2.zero, Vector2.zero, Vector2.right, Vector2.one, Vector2.up }; sharpParticleMesh = val; sharpParticleMesh.RecalculateNormals(); sharpParticleMesh.RecalculateBounds(); return sharpParticleMesh; } } internal enum ElementTheme { Lightning, Poison, Blood } internal static class VfxFactory { internal static GameObject LightningArcPrefab { get; private set; } internal static GameObject PoisonZonePrefab { get; private set; } internal static GameObject BloodShrapnelPrefab { get; private set; } internal static GameObject LightningHitPrefab { get; private set; } internal static GameObject PoisonHitPrefab { get; private set; } internal static GameObject BloodHitPrefab { get; private set; } internal static void BuildSharedPrefabs() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) LightningArcPrefab = Clone("SOF_LightningArc", "fx_chainlightning_spread"); TimedDestruction component = LightningArcPrefab.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_timeout = 0.9f; component.m_triggerOnAwake = true; } LightningArcPrefab.AddComponent(); VfxStyler.StyleHierarchy(LightningArcPrefab, VfxStyler.Lightning, 2.4f); Register(LightningArcPrefab); PoisonZonePrefab = BuildPoisonZone(); Register(PoisonZonePrefab); LightningHitPrefab = Clone("SOF_LightningHit", "fx_chainlightning_hit"); VfxStyler.StyleHierarchy(LightningHitPrefab, VfxStyler.Lightning, 2.2f); Register(LightningHitPrefab); PoisonHitPrefab = Clone("SOF_PoisonHit", "fx_clusterbombstaff_hit"); VfxStyler.StyleHierarchy(PoisonHitPrefab, VfxStyler.Poison, 1.7f); VfxStyler.TuneParticles(PoisonHitPrefab, 1.35f, 0.8f, 1.1f); Register(PoisonHitPrefab); BloodHitPrefab = Clone("SOF_BloodHit", "fx_clusterbombstaff_hit"); VfxStyler.StyleHierarchy(BloodHitPrefab, VfxStyler.Blood, 2.1f); Register(BloodHitPrefab); BloodShrapnelPrefab = BuildBloodShrapnel(); Register(BloodShrapnelPrefab); } internal static void SpawnLightningArc(Vector3 start, Vector3 end) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)LightningArcPrefab)) { Vector3 val = end - start; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { Object.Instantiate(LightningArcPrefab, start, Quaternion.LookRotation(end - start)).GetComponent()?.Initialize(start, end); } } } internal static void StyleProjectile(GameObject projectile, ElementTheme theme, bool secondary) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Color color = GetColor(theme); VfxStyler.StyleHierarchy(projectile, color, (theme == ElementTheme.Lightning) ? 2.4f : 1.9f); if (secondary) { switch (theme) { case ElementTheme.Lightning: AttachVisual(projectile.transform, "StaffLightning", "attach/Loaded/Lightning", "SOF_BallLightning", Vector3.zero, Quaternion.identity, Vector3.one * 0.18f, color, 0.7f, 0.55f, 0.7f); break; case ElementTheme.Poison: AttachVisual(projectile.transform, "poisoncloud", string.Empty, "SOF_BallPoison", Vector3.zero, Quaternion.identity, Vector3.one * 0.22f, color, 0.42f, 0.35f, 0.65f); break; } } } internal static void StyleStaff(GameObject itemPrefab, ElementTheme theme) { StaffHeadVfx.Attach(itemPrefab, theme); } private static GameObject BuildPoisonZone() { //IL_0069: 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_0089: 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) GameObject val = Clone("SOF_PoisonZone", "fx_chainlightning_spread"); RemoveChildren(val.transform); TimedDestruction component = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_timeout = 12.5f; component.m_triggerOnAwake = true; } GameObject obj = CloneUnregistered("poisoncloud"); ((Object)obj).name = "SOF_PoisonHaze"; obj.transform.SetParent(val.transform, false); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; StripNetworkComponents(obj); VfxStyler.StyleHierarchy(obj, VfxStyler.Poison, 1.6f); VfxStyler.TuneParticles(obj, 0.8f, 0.65f, 1f); val.AddComponent(); return val; } private static GameObject BuildBloodShrapnel() { //IL_0018: 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) GameObject obj = Clone("SOF_BloodShrapnel", "projectile_splitner_lightning"); Projectile component = obj.GetComponent(); component.m_type = (ProjectileType)10; component.m_aoe = 0f; component.m_bounce = false; component.m_canHitWater = false; component.m_gravity = 4f; component.m_drag = 0.015f; component.m_rayRadius = 0.06f; component.m_ttl = 4f; component.m_respawnItemOnHit = false; component.m_showBreakMessage = false; component.m_spawnOnHit = null; component.m_spawnOnTtl = false; component.m_randomSpawnOnHit.Clear(); component.m_randomSpawnOnHitCount = 0; component.m_projectilesInheritHitData = false; component.m_onlySpawnedProjectilesDealDamage = false; VfxStyler.StyleHierarchy(obj, VfxStyler.Blood, 3f); VfxStyler.TuneParticles(obj, 0.72f, 0.8f, 0.7f); VfxStyler.CompactShrapnelVisuals(obj); obj.AddComponent(); return obj; } private static GameObject AttachVisual(Transform parent, string sourcePrefabName, string sourcePath, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Color color, float sizeMultiplier, float emissionMultiplier, float lifetimeMultiplier) { //IL_0077: 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_0091: 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) GameObject val = RequiredPrefab(sourcePrefabName); Transform val2 = (string.IsNullOrEmpty(sourcePath) ? val.transform : val.transform.Find(sourcePath)); if (!Object.op_Implicit((Object)(object)val2)) { throw new InvalidOperationException("Required visual path '" + sourcePrefabName + "/" + sourcePath + "' was not found."); } GameObject obj = Object.Instantiate(((Component)val2).gameObject, parent, false); ((Object)obj).name = name; obj.transform.localPosition = localPosition; obj.transform.localRotation = localRotation; obj.transform.localScale = localScale; obj.SetActive(true); StripNetworkComponents(obj); VfxStyler.StyleHierarchy(obj, color, 2f); VfxStyler.TuneParticles(obj, sizeMultiplier, emissionMultiplier, lifetimeMultiplier); return obj; } private static void StripNetworkComponents(GameObject root) { ZSyncTransform[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ZNetView[] componentsInChildren2 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } TimedDestruction[] componentsInChildren3 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } } private static void RemoveChildren(Transform root) { for (int num = root.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)root.GetChild(num)).gameObject); } } private static EffectList CreateHitEffects(GameObject prefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0029: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab, m_enabled = true, m_variant = -1, m_attach = false, m_follow = false, m_randomRotation = true } }; return val; } internal static EffectList GetHitEffects(ElementTheme theme) { return (EffectList)(theme switch { ElementTheme.Lightning => CreateHitEffects(LightningHitPrefab), ElementTheme.Poison => CreateHitEffects(PoisonHitPrefab), _ => CreateHitEffects(BloodHitPrefab), }); } private static Color GetColor(ElementTheme theme) { //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_0015: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ElementTheme.Lightning => VfxStyler.Lightning, ElementTheme.Poison => VfxStyler.Poison, _ => VfxStyler.Blood, }); } private static GameObject Clone(string name, string baseName) { GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, baseName); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Could not clone required prefab '" + baseName + "' as '" + name + "'."); } return val; } private static GameObject CloneUnregistered(string baseName) { return Object.Instantiate(RequiredPrefab(baseName)); } private static GameObject RequiredPrefab(string name) { GameObject prefab = PrefabManager.Instance.GetPrefab(name); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Required vanilla prefab '" + name + "' was not found."); } return prefab; } private static void Register(GameObject prefab) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown PrefabManager.Instance.AddPrefab(new CustomPrefab(prefab, false)); } } internal static class VfxStyler { internal static readonly Color Lightning = new Color(0.24f, 0.62f, 1f, 1f); internal static readonly Color Poison = new Color(0.24f, 0.95f, 0.3f, 1f); internal static readonly Color Blood = new Color(1f, 0.045f, 0.075f, 1f); private static readonly int ColorProperty = Shader.PropertyToID("_Color"); private static readonly int BaseColorProperty = Shader.PropertyToID("_BaseColor"); private static readonly int TintColorProperty = Shader.PropertyToID("_TintColor"); private static readonly int EmissionColorProperty = Shader.PropertyToID("_EmissionColor"); internal static Material CreateCosmeticMaterial(Material source, Color color, float emissionStrength, bool untextured = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)source) || !Object.op_Implicit((Object)(object)source.shader) || (int)SystemInfo.graphicsDeviceType == 4) { return null; } Material val = null; try { val = new Material(source) { name = ((Object)source).name + "_SOF_Head" }; ApplySupportedColors(val, color, emissionStrength); if (untextured) { if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)Texture2D.whiteTexture); } } return val; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val)) { Object.DestroyImmediate((Object)(object)val); } Logger.LogWarning((object)("Could not create staff-head material '" + ((Object)source).name + "': " + ex.Message)); return null; } } internal static void StyleHierarchy(GameObject root, Color color, float emissionStrength, bool tintParticles = true) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_00c1: 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_00e0: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)root)) { return; } if (tintParticles) { ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).startColor = new MinMaxGradient(color); } } Light[] componentsInChildren2 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].color = color; } if ((int)SystemInfo.graphicsDeviceType == 4) { return; } Renderer[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren3) { Material[] sharedMaterials = val.sharedMaterials; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.shader)) { array[j] = val2; continue; } try { Material val3 = new Material(val2) { name = ((Object)val2).name + "_SOF_" + ColorUtility.ToHtmlStringRGB(color) }; ApplySupportedColors(val3, color, emissionStrength); array[j] = val3; } catch (Exception ex) { Logger.LogWarning((object)("Could not style material '" + ((Object)val2).name + "': " + ex.Message)); array[j] = val2; } } val.sharedMaterials = array; } } internal static Sprite CreateTintedIcon(Sprite source, Color tint) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //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_003d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0085: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c9: 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_0101: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)source) || (int)SystemInfo.graphicsDeviceType == 4) { return source; } try { Texture2D val = AssetUtils.DuplicateTexture(source); if (!Object.op_Implicit((Object)(object)val)) { return source; } Color[] pixels = val.GetPixels(); for (int i = 0; i < pixels.Length; i++) { Color val2 = pixels[i]; float num = val2.r * 0.3f + val2.g * 0.59f + val2.b * 0.11f; Color val3 = tint * Mathf.Clamp01(num * 1.55f + 0.12f); pixels[i] = Color.Lerp(val2, val3, 0.72f).WithAlpha(val2.a); } val.SetPixels(pixels); val.Apply(false, false); ((Object)val).name = ((Object)source).name + "_SOF_" + ColorUtility.ToHtmlStringRGB(tint); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), source.pixelsPerUnit); } catch (Exception ex) { Logger.LogWarning((object)("Could not create a tinted inventory icon: " + ex.Message)); return source; } } internal static void TuneParticles(GameObject root, float sizeMultiplier, float emissionMultiplier, float lifetimeMultiplier) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); foreach (ParticleSystem obj in componentsInChildren) { MainModule main = obj.main; ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * sizeMultiplier; ((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * lifetimeMultiplier; EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * emissionMultiplier; } } internal static void CompactShrapnelVisuals(GameObject root) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; if (((MainModule)(ref main)).startSize3D) { ((MainModule)(ref main)).startSizeXMultiplier = ((MainModule)(ref main)).startSizeXMultiplier * 0.35f; ((MainModule)(ref main)).startSizeYMultiplier = ((MainModule)(ref main)).startSizeYMultiplier * 0.35f; ((MainModule)(ref main)).startSizeZMultiplier = ((MainModule)(ref main)).startSizeZMultiplier * 0.35f; } else { ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.35f; } ((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 0.25f; } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (ParticleSystemRenderer val in componentsInChildren2) { if ((int)val.renderMode == 1) { val.lengthScale *= 0.71428573f; val.velocityScale *= 0.25f; val.cameraVelocityScale *= 0.25f; } } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (TrailRenderer obj in componentsInChildren3) { obj.widthMultiplier *= 0.35f; obj.time *= 0.25f; obj.minVertexDistance *= 0.25f; } } internal static void CompensateShrapnelMotion(GameObject root, float speedMultiplier) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 float num = 1f / speedMultiplier; ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); foreach (ParticleSystem val in componentsInChildren) { MainModule main = val.main; if ((int)((MainModule)(ref main)).simulationSpace != 0) { ((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * num; EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * speedMultiplier; } } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (ParticleSystemRenderer val2 in componentsInChildren2) { if ((int)val2.renderMode == 1) { val2.velocityScale *= num; } } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (TrailRenderer obj in componentsInChildren3) { obj.time *= num; } } private static void ApplySupportedColors(Material material, Color color, float emissionStrength) { //IL_0013: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(BaseColorProperty)) { material.SetColor(BaseColorProperty, color); } if (material.HasProperty(ColorProperty)) { material.SetColor(ColorProperty, color); } if (material.HasProperty(TintColorProperty)) { material.SetColor(TintColorProperty, color); } if (material.HasProperty(EmissionColorProperty)) { material.SetColor(EmissionColorProperty, color * emissionStrength); material.EnableKeyword("_EMISSION"); } } private static Color WithAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } } namespace StaffsOfFracturing.Utilities { internal static class DamageUtility { private const float QualityStep = 0.25f; private static readonly Collider[] ColliderBuffer = (Collider[])(object)new Collider[128]; internal static float ScaleForQuality(float baseValue, int itemQuality) { return baseValue * (1f + (float)Mathf.Max(0, itemQuality - 1) * 0.25f); } internal static Character FindCharacter(Collider collider) { if (!Object.op_Implicit((Object)(object)collider)) { return null; } GameObject val = Projectile.FindHitObject(collider); if (!Object.op_Implicit((Object)(object)val)) { return null; } return val.GetComponent(); } internal static bool IsValidEnemy(Character owner, Character candidate) { if (!Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)candidate) || (Object)(object)owner == (Object)(object)candidate || candidate.IsDead()) { return false; } if (!BaseAI.IsEnemy(owner, candidate)) { if (Object.op_Implicit((Object)(object)candidate.GetBaseAI()) && candidate.GetBaseAI().IsAggravatable()) { return owner.IsPlayer(); } return false; } return true; } internal static Character FindNearestEnemy(Character owner, Character excluded, Vector3 origin, float radius) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_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) int mask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); int num = Physics.OverlapSphereNonAlloc(origin, radius, ColliderBuffer, mask, (QueryTriggerInteraction)2); Character result = null; float num2 = float.MaxValue; HashSet hashSet = new HashSet(); for (int i = 0; i < num; i++) { Character val = FindCharacter(ColliderBuffer[i]); if (Object.op_Implicit((Object)(object)val) && !((Object)(object)val == (Object)(object)excluded) && hashSet.Add(val) && IsValidEnemy(owner, val)) { Vector3 val2 = val.GetCenterPoint() - origin; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; result = val; } } } return result; } internal static int FindEnemiesInSphere(Character owner, Vector3 origin, float radius, Character[] results) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); int num = Physics.OverlapSphereNonAlloc(origin, radius, ColliderBuffer, mask, (QueryTriggerInteraction)2); int num2 = 0; HashSet hashSet = new HashSet(); for (int i = 0; i < num; i++) { if (num2 >= results.Length) { break; } Character val = FindCharacter(ColliderBuffer[i]); if (Object.op_Implicit((Object)(object)val) && hashSet.Add(val) && IsValidEnemy(owner, val)) { results[num2++] = val; } } return num2; } internal static int FindEnemiesAlongSegment(Character owner, Vector3 start, Vector3 end, float radius, Character[] results) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); int num = Physics.OverlapCapsuleNonAlloc(start, end, radius, ColliderBuffer, mask, (QueryTriggerInteraction)2); int num2 = 0; HashSet hashSet = new HashSet(); for (int i = 0; i < num; i++) { if (num2 >= results.Length) { break; } Character val = FindCharacter(ColliderBuffer[i]); if (Object.op_Implicit((Object)(object)val) && hashSet.Add(val) && IsValidEnemy(owner, val)) { results[num2++] = val; } } return num2; } internal static void DealDamage(Character owner, Character target, Vector3 point, Vector3 direction, DamageTypes damage, SkillType skill) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: 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_0070: 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_0085: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)target) && !target.IsDead()) { HitData val = new HitData { m_damage = damage, m_point = point, m_dir = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.up), m_pushForce = 0f, m_backstabBonus = 1f, m_staggerMultiplier = 1f, m_dodgeable = false, m_blockable = false, m_ranged = true, m_skill = skill, m_skillLevel = owner.GetSkillLevel(skill), m_skillRaiseAmount = 0f, m_hitType = (HitType)((!owner.IsPlayer()) ? 1 : 2) }; val.SetAttacker(owner); target.Damage(val); } } } } namespace StaffsOfFracturing.Projectiles { internal abstract class FractureBallBehaviour : MonoBehaviour { private bool initialized; protected Projectile Projectile { get; private set; } protected Character Owner { get; private set; } protected ItemData Weapon { get; private set; } protected int ItemQuality { get; private set; } = 1; internal bool IsLive { get; private set; } = true; internal Character ShotOwner => Owner; internal int ShotQuality => ItemQuality; protected virtual void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Projectile = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)Projectile)) { Projectile projectile = Projectile; projectile.m_onHit = (OnProjectileHit)Delegate.Combine((Delegate?)(object)projectile.m_onHit, (Delegate?)new OnProjectileHit(HandleHit)); } } internal void Initialize(Character owner, ItemData weapon, HitData originalHit) { if (!initialized) { initialized = true; Owner = owner; Weapon = weapon; ItemQuality = ((weapon == null) ? 1 : Mathf.Max(1, weapon.m_quality)); OnInitialized(originalHit); } } protected abstract void OnInitialized(HitData originalHit); protected abstract void OnImpact(Collider collider, Vector3 hitPoint, bool water); private void HandleHit(Collider collider, Vector3 hitPoint, bool water) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (IsLive) { IsLive = false; if (initialized && Object.op_Implicit((Object)(object)Owner)) { OnImpact(collider, hitPoint, water); } } } protected virtual void OnDestroy() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown IsLive = false; if (Object.op_Implicit((Object)(object)Projectile)) { Projectile projectile = Projectile; projectile.m_onHit = (OnProjectileHit)Delegate.Remove((Delegate?)(object)projectile.m_onHit, (Delegate?)new OnProjectileHit(HandleHit)); } } } [HarmonyPatch(typeof(Projectile), "Setup", new Type[] { typeof(Character), typeof(Vector3), typeof(float), typeof(HitData), typeof(ItemData), typeof(ItemData) })] internal static class ProjectileSetupPatch { private static void Postfix(Projectile __instance, Character __0, HitData __3, ItemData __4) { ((Component)__instance).GetComponent()?.Initialize(__0, __4, __3); } } } namespace StaffsOfFracturing.Poison { internal sealed class NetworkPoisonZone : MonoBehaviour { private static readonly int RadiusHash = StringExtensionMethods.GetStableHashCode("sof_poison_radius"); private static readonly int ImmobilizedHash = StringExtensionMethods.GetStableHashCode("Immobilized"); private static readonly Character[] Targets = (Character[])(object)new Character[64]; private static readonly Dictionary NextTargetCheck = new Dictionary(); private ZNetView networkView; private Character owner; private int itemQuality; private float radius; private float expiresAt; private float nextCheck; private bool initialized; private bool visualScaleApplied; private void Awake() { networkView = ((Component)this).GetComponent(); } internal void Initialize(Character source, int quality, float areaRadius, float duration) { if (Object.op_Implicit((Object)(object)networkView) && networkView.IsValid() && networkView.IsOwner() && Object.op_Implicit((Object)(object)source)) { owner = source; itemQuality = Mathf.Max(1, quality); radius = areaRadius; expiresAt = Time.time + duration; nextCheck = Time.time + ModConfig.ImmobilizeCheckInterval.Value; initialized = true; networkView.GetZDO().Set(RadiusHash, radius); ApplyVisualScale(radius); } } private void Update() { if (!visualScaleApplied && Object.op_Implicit((Object)(object)networkView) && networkView.IsValid()) { float num = networkView.GetZDO().GetFloat(RadiusHash, 0f); if (num > 0f) { ApplyVisualScale(num); } } if (initialized && Object.op_Implicit((Object)(object)networkView) && networkView.IsValid() && networkView.IsOwner()) { if (!Object.op_Implicit((Object)(object)owner) || Time.time >= expiresAt) { DestroyNetworked(); } else if (!(Time.time < nextCheck)) { float value = ModConfig.ImmobilizeCheckInterval.Value; nextCheck = Time.time + value; CheckTargets(value); } } } private void CheckTargets(float interval) { //IL_000c: 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_004d: 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_0069: Unknown result type (might be due to invalid IL or missing references) int num = DamageUtility.FindEnemiesInSphere(owner, ((Component)this).transform.position, radius, Targets); float time = Time.time; for (int i = 0; i < num; i++) { Character val = Targets[i]; Targets[i] = null; if (!Object.op_Implicit((Object)(object)val)) { continue; } ZDOID zDOID = val.GetZDOID(); if (!NextTargetCheck.TryGetValue(zDOID, out var value) || !(time < value)) { NextTargetCheck[zDOID] = time + interval; SEMan sEMan = val.GetSEMan(); if (!sEMan.HaveStatusEffect(ImmobilizedHash) && Random.value <= ModConfig.ImmobilizeChance.Value) { sEMan.AddStatusEffect(ImmobilizedHash, false, itemQuality, owner.GetSkillLevel((SkillType)9), (short)(-1)); } } } if (NextTargetCheck.Count > 256) { PruneCooldowns(time - 30f); } } private static void PruneCooldowns(float olderThan) { //IL_0028: 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_0062: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (KeyValuePair item in NextTargetCheck) { if (item.Value < olderThan) { list.Add(item.Key); } } foreach (ZDOID item2 in list) { NextTargetCheck.Remove(item2); } } private void ApplyVisualScale(float areaRadius) { //IL_0006: 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) ((Component)this).transform.localScale = Vector3.one * Mathf.Clamp(areaRadius / 3.5f, 0.35f, 1.75f); visualScaleApplied = true; } private void DestroyNetworked() { initialized = false; if (Object.op_Implicit((Object)(object)ZNetScene.instance)) { ZNetScene.instance.Destroy(((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } internal sealed class PoisonBallBehaviour : FractureBallBehaviour { protected override void OnInitialized(HitData originalHit) { //IL_001d: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) base.Projectile.m_aoe = ModConfig.PoisonExplosionRadius.Value; base.Projectile.m_damage = new DamageTypes { m_blunt = DamageUtility.ScaleForQuality(ModConfig.PoisonBluntDamage.Value, base.ItemQuality), m_poison = DamageUtility.ScaleForQuality(ModConfig.PoisonDamage.Value, base.ItemQuality) }; base.Projectile.m_type = (ProjectileType)17410; } protected override void OnImpact(Collider collider, Vector3 hitPoint, bool water) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ContentRegistry.PoisonZonePrefab)) { Object.Instantiate(ContentRegistry.PoisonZonePrefab, hitPoint, Quaternion.identity).GetComponent()?.Initialize(base.Owner, base.ItemQuality, ModConfig.PoisonExplosionRadius.Value, ModConfig.PoisonDuration.Value); } } } } namespace StaffsOfFracturing.Plugin { [BepInPlugin("com.l4zershark.staffsoffracturing", "Staffs of Fracturing", "1.0.5")] [BepInDependency("com.jotunn.jotunn", "2.30.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public sealed class StaffsOfFracturingPlugin : BaseUnityPlugin { public const string ModGuid = "com.l4zershark.staffsoffracturing"; public const string ModName = "Staffs of Fracturing"; public const string ModVersion = "1.0.5"; private Harmony harmony; internal static StaffsOfFracturingPlugin Instance { get; private set; } internal ManualLogSource ModLogger => ((BaseUnityPlugin)this).Logger; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Instance = this; ModConfig.Bind(((BaseUnityPlugin)this).Config); harmony = new Harmony("com.l4zershark.staffsoffracturing"); harmony.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += RegisterContent; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Staffs of Fracturing 1.0.5 initialized; waiting for vanilla prefabs."); } private void RegisterContent() { try { ContentRegistry.RegisterAll(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Content registration failed: {arg}"); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterContent; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } namespace StaffsOfFracturing.Networking { internal sealed class NetworkArcBehaviour : MonoBehaviour { private static readonly int StartHash = StringExtensionMethods.GetStableHashCode("sof_arc_start"); private static readonly int EndHash = StringExtensionMethods.GetStableHashCode("sof_arc_end"); private ZNetView networkView; private bool applied; private void Awake() { networkView = ((Component)this).GetComponent(); } internal void Initialize(Vector3 start, Vector3 end) { //IL_0038: 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_0055: 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) if (Object.op_Implicit((Object)(object)networkView) && networkView.IsValid() && networkView.IsOwner()) { networkView.GetZDO().Set(StartHash, start); networkView.GetZDO().Set(EndHash, end); Apply(start, end); } } private void Update() { //IL_004e: 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 (!applied && Object.op_Implicit((Object)(object)networkView) && networkView.IsValid()) { ZDO zDO = networkView.GetZDO(); Vector3 start = default(Vector3); Vector3 end = default(Vector3); if (zDO.GetVec3(StartHash, ref start) && zDO.GetVec3(EndHash, ref end)) { Apply(start, end); } } } private void Apply(Vector3 start, Vector3 end) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_0042: 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) Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.05f)) { ((Component)this).transform.position = start; ((Component)this).transform.rotation = Quaternion.LookRotation(val / magnitude); ((Component)this).transform.localScale = Vector3.one * magnitude; applied = true; } } } } namespace StaffsOfFracturing.Localization { internal static class EnglishLocalization { internal static void Register() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary { { "sof_staff_iolite", "Iolite Staff of Fracturing" }, { "sof_staff_iolite_desc", "A fractured galdr staff awakened by iolite. Its splinters shock foes, leap to nearby enemies, and weave brief arcs between one another." }, { "sof_staff_jade", "Jade Staff of Fracturing" }, { "sof_staff_jade_desc", "A fractured galdr staff corrupted by jade. Its splinters burst into broad poison fields that can immobilize enemies caught within." }, { "sof_staff_bloodstone", "Bloodstone Staff of Fracturing" }, { "sof_staff_bloodstone_desc", "A fractured galdr staff steeped in bloodstone. Its splinters erupt with blunt force and launch bright, piercing blood shards." } }); } } } namespace StaffsOfFracturing.Lightning { internal sealed class LightningBallBehaviour : FractureBallBehaviour { protected override void OnInitialized(HitData originalHit) { //IL_0018: 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_003b: 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) base.Projectile.m_aoe = 0.6f; base.Projectile.m_damage = new DamageTypes { m_lightning = DamageUtility.ScaleForQuality(ModConfig.LightningDamage.Value, base.ItemQuality) }; base.Projectile.m_type = (ProjectileType)147458; LightningWebCoordinator.Register(this); } protected override void OnImpact(Collider collider, Vector3 hitPoint, bool water) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00c5: Unknown result type (might be due to invalid IL or missing references) if (water || Random.value > ModConfig.EnemyChainChance.Value) { return; } Character val = DamageUtility.FindCharacter(collider); if (DamageUtility.IsValidEnemy(base.Owner, val)) { Character val2 = DamageUtility.FindNearestEnemy(base.Owner, val, val.GetCenterPoint(), ModConfig.ChainRange.Value); if (Object.op_Implicit((Object)(object)val2)) { Vector3 val3 = val.GetCenterPoint() + Vector3.up * 0.15f; Vector3 val4 = val2.GetCenterPoint() + Vector3.up * 0.15f; VfxFactory.SpawnLightningArc(val3, val4); DamageTypes damage = new DamageTypes { m_lightning = DamageUtility.ScaleForQuality(ModConfig.LightningDamage.Value, base.ItemQuality) }; DamageUtility.DealDamage(base.Owner, val2, val4, val4 - val3, damage, (SkillType)9); } } } } internal static class LightningWebCoordinator { private readonly struct ShotKey : IEquatable { private readonly ZDOID owner; private readonly int frame; internal ShotKey(ZDOID owner, int frame) { //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) this.owner = owner; this.frame = frame; } public bool Equals(ShotKey other) { //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_000a: Unknown result type (might be due to invalid IL or missing references) ZDOID val = owner; if (((ZDOID)(ref val)).Equals(other.owner)) { return frame == other.frame; } return false; } public override bool Equals(object obj) { if (obj is ShotKey other) { return Equals(other); } return false; } public override int GetHashCode() { //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) return (((object)owner/*cast due to .constrained prefix*/).GetHashCode() * 397) ^ frame; } } private const int MaximumLinksPerShot = 24; private const float FormationDelay = 0.13f; private const float SegmentRadius = 0.3f; private static readonly Dictionary> Shots = new Dictionary>(); private static readonly Character[] SegmentTargets = (Character[])(object)new Character[64]; internal static void Register(LightningBallBehaviour ball) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ball) && Object.op_Implicit((Object)(object)ball.ShotOwner) && Object.op_Implicit((Object)(object)StaffsOfFracturingPlugin.Instance)) { ShotKey key = new ShotKey(ball.ShotOwner.GetZDOID(), Time.frameCount); if (!Shots.TryGetValue(key, out var value)) { value = new List(12); Shots.Add(key, value); ((MonoBehaviour)StaffsOfFracturingPlugin.Instance).StartCoroutine(FormWeb(key)); } value.Add(ball); } } private static IEnumerator FormWeb(ShotKey key) { yield return (object)new WaitForSeconds(0.13f); if (!Shots.TryGetValue(key, out var value)) { yield break; } Shots.Remove(key); List list = new List(value.Count); foreach (LightningBallBehaviour item in value) { if (Object.op_Implicit((Object)(object)item) && item.IsLive) { list.Add(item); } } if (list.Count < 2) { yield break; } Character shotOwner = list[0].ShotOwner; int shotQuality = list[0].ShotQuality; Dictionary cooldowns = new Dictionary(); int num = 0; float num2 = ModConfig.ChainRange.Value * 1.5f; for (int i = 0; i < list.Count - 1; i++) { if (num >= 24) { break; } for (int j = i + 1; j < list.Count; j++) { if (num >= 24) { break; } LightningBallBehaviour lightningBallBehaviour = list[i]; LightningBallBehaviour lightningBallBehaviour2 = list[j]; if (Object.op_Implicit((Object)(object)lightningBallBehaviour) && Object.op_Implicit((Object)(object)lightningBallBehaviour2) && lightningBallBehaviour.IsLive && lightningBallBehaviour2.IsLive) { Vector3 position = ((Component)lightningBallBehaviour).transform.position; Vector3 position2 = ((Component)lightningBallBehaviour2).transform.position; Vector3 val = position2 - position; if (!(((Vector3)(ref val)).sqrMagnitude > num2 * num2) && !(Random.value > ModConfig.BallChainChance.Value)) { num++; VfxFactory.SpawnLightningArc(position, position2); DamageSegment(shotOwner, shotQuality, position, position2, cooldowns); } } } } } private static void DamageSegment(Character owner, int quality, Vector3 start, Vector3 end, Dictionary cooldowns) { //IL_001b: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)owner) || ModConfig.LightningWebDamage.Value <= 0f) { return; } int num = DamageUtility.FindEnemiesAlongSegment(owner, start, end, 0.3f, SegmentTargets); float time = Time.time; for (int i = 0; i < num; i++) { Character val = SegmentTargets[i]; SegmentTargets[i] = null; if (Object.op_Implicit((Object)(object)val) && (!cooldowns.TryGetValue(val, out var value) || !(time - value < ModConfig.LightningWebHitCooldown.Value))) { cooldowns[val] = time; Vector3 centerPoint = val.GetCenterPoint(); DamageTypes damage = new DamageTypes { m_lightning = DamageUtility.ScaleForQuality(ModConfig.LightningWebDamage.Value, quality) }; DamageUtility.DealDamage(owner, val, centerPoint, end - start, damage, (SkillType)9); } } } } } namespace StaffsOfFracturing.Items { internal static class ContentRegistry { private sealed class VariantDefinition { internal string ItemPrefabName { get; } internal string PrimaryPrefabName { get; } internal string SecondaryPrefabName { get; } internal string NameToken { get; } internal string DescriptionToken { get; } internal string GemPrefabName { get; } internal ElementTheme Theme { get; } internal VariantDefinition(string itemPrefabName, string primaryPrefabName, string secondaryPrefabName, string nameToken, string descriptionToken, string gemPrefabName, ElementTheme theme) { ItemPrefabName = itemPrefabName; PrimaryPrefabName = primaryPrefabName; SecondaryPrefabName = secondaryPrefabName; NameToken = nameToken; DescriptionToken = descriptionToken; GemPrefabName = gemPrefabName; Theme = theme; } } private readonly struct VanillaSnapshot { private readonly SharedData shared; private readonly string name; private readonly float blunt; private readonly float fire; private readonly GameObject attackProjectile; private readonly GameObject spawnedSecondary; private readonly int spawnCount; private VanillaSnapshot(SharedData shared, string name, float blunt, float fire, GameObject attackProjectile, GameObject spawnedSecondary, int spawnCount) { this.shared = shared; this.name = name; this.blunt = blunt; this.fire = fire; this.attackProjectile = attackProjectile; this.spawnedSecondary = spawnedSecondary; this.spawnCount = spawnCount; } internal static VanillaSnapshot Capture() { ItemDrop val = ContentRegistry.RequireComponent(RequiredPrefab("StaffClusterbomb")); Projectile val2 = ContentRegistry.RequireComponent(RequiredPrefab("staff_clusterbombstaff_projectile")); return new VanillaSnapshot(val.m_itemData.m_shared, val.m_itemData.m_shared.m_name, val.m_itemData.m_shared.m_damages.m_blunt, val.m_itemData.m_shared.m_damages.m_fire, val.m_itemData.m_shared.m_attack.m_attackProjectile, val2.m_spawnOnHit, val2.m_spawnCount); } internal void AssertUnchanged() { ItemDrop obj = ContentRegistry.RequireComponent(RequiredPrefab("StaffClusterbomb")); Projectile val = ContentRegistry.RequireComponent(RequiredPrefab("staff_clusterbombstaff_projectile")); SharedData val2 = obj.m_itemData.m_shared; if (shared != val2 || val2.m_name != name || !Mathf.Approximately(val2.m_damages.m_blunt, blunt) || !Mathf.Approximately(val2.m_damages.m_fire, fire) || (Object)(object)val2.m_attack.m_attackProjectile != (Object)(object)attackProjectile || (Object)(object)val.m_spawnOnHit != (Object)(object)spawnedSecondary || val.m_spawnCount != spawnCount) { throw new InvalidOperationException("The vanilla Staff of Fracturing mutation audit failed."); } } } private const string VanillaStaff = "StaffClusterbomb"; private const string VanillaPrimary = "staff_clusterbombstaff_projectile"; private const string VanillaSecondary = "staff_clusterbombstaff_splinter_projectile"; private static bool registered; private static CustomItem ioliteItem; private static CustomItem jadeItem; private static CustomItem bloodstoneItem; internal static GameObject PoisonZonePrefab => VfxFactory.PoisonZonePrefab; internal static GameObject BloodShrapnelPrefab => VfxFactory.BloodShrapnelPrefab; private static ManualLogSource Log => StaffsOfFracturingPlugin.Instance.ModLogger; internal static void RegisterAll() { if (!registered) { ValidateVanillaDependencies(); VanillaSnapshot vanillaSnapshot = VanillaSnapshot.Capture(); EnglishLocalization.Register(); VfxFactory.BuildSharedPrefabs(); ioliteItem = CreateVariant(new VariantDefinition("SOF_StaffFracturingIolite", "SOF_StaffFracturingIolite_Projectile", "SOF_StaffFracturingIolite_Ball", "$sof_staff_iolite", "$sof_staff_iolite_desc", "GemstoneBlue", ElementTheme.Lightning)); jadeItem = CreateVariant(new VariantDefinition("SOF_StaffFracturingJade", "SOF_StaffFracturingJade_Projectile", "SOF_StaffFracturingJade_Ball", "$sof_staff_jade", "$sof_staff_jade_desc", "GemstoneGreen", ElementTheme.Poison)); bloodstoneItem = CreateVariant(new VariantDefinition("SOF_StaffFracturingBloodstone", "SOF_StaffFracturingBloodstone_Projectile", "SOF_StaffFracturingBloodstone_Ball", "$sof_staff_bloodstone", "$sof_staff_bloodstone_desc", "GemstoneRed", ElementTheme.Blood)); registered = true; RefreshDisplayedDamage(); vanillaSnapshot.AssertUnchanged(); AuditCustomContent(); Log.LogInfo((object)"Registered three gemstone staffs, six fracture prefabs, bounded network VFX, recipes and localization."); } } internal static void RefreshDisplayedDamage() { //IL_002e: 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_0048: 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_0099: 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_00c4: 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_012c: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) CustomItem obj = ioliteItem; if (Object.op_Implicit((Object)(object)((obj != null) ? obj.ItemDrop : null))) { SetDamage(ioliteItem.ItemDrop.m_itemData.m_shared, new DamageTypes { m_lightning = ModConfig.LightningDamage.Value }, new DamageTypes { m_lightning = ModConfig.LightningDamage.Value * 0.25f }); } CustomItem obj2 = jadeItem; if (Object.op_Implicit((Object)(object)((obj2 != null) ? obj2.ItemDrop : null))) { SetDamage(jadeItem.ItemDrop.m_itemData.m_shared, new DamageTypes { m_blunt = ModConfig.PoisonBluntDamage.Value, m_poison = ModConfig.PoisonDamage.Value }, new DamageTypes { m_blunt = ModConfig.PoisonBluntDamage.Value * 0.25f, m_poison = ModConfig.PoisonDamage.Value * 0.25f }); } CustomItem obj3 = bloodstoneItem; if (Object.op_Implicit((Object)(object)((obj3 != null) ? obj3.ItemDrop : null))) { SetDamage(bloodstoneItem.ItemDrop.m_itemData.m_shared, new DamageTypes { m_blunt = ModConfig.BloodExplosionBluntDamage.Value }, new DamageTypes { m_blunt = ModConfig.BloodExplosionBluntDamage.Value * 0.25f }); } } private static CustomItem CreateVariant(VariantDefinition definition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_0228: Unknown result type (might be due to invalid IL or missing references) GameObject val = CloneRequired(definition.SecondaryPrefabName, "staff_clusterbombstaff_splinter_projectile"); ConfigureSecondary(val, definition.Theme); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); GameObject val2 = CloneRequired(definition.PrimaryPrefabName, "staff_clusterbombstaff_projectile"); Projectile obj = RequireComponent(val2); obj.m_spawnOnHit = val; obj.m_hitEffects = VfxFactory.GetHitEffects(definition.Theme); VfxFactory.StyleProjectile(val2, definition.Theme, secondary: false); PrefabManager.Instance.AddPrefab(new CustomPrefab(val2, false)); ItemConfig val3 = new ItemConfig(); val3.Name = definition.NameToken; val3.Description = definition.DescriptionToken; val3.CraftingStation = CraftingStations.GaldrTable; val3.RepairStation = CraftingStations.GaldrTable; val3.MinStationLevel = 2; val3.Amount = 1; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("StaffClusterbomb", 1, 0, true), new RequirementConfig("FlametalNew", 5, 5, true), new RequirementConfig(definition.GemPrefabName, 1, 1, true) }; ItemConfig val4 = val3; CustomItem val5 = new CustomItem(definition.ItemPrefabName, "StaffClusterbomb", val4); if (!Object.op_Implicit((Object)(object)val5.ItemPrefab) || !Object.op_Implicit((Object)(object)val5.ItemDrop)) { throw new InvalidOperationException("Could not create item '" + definition.ItemPrefabName + "'."); } ItemDrop val6 = RequireComponent(RequiredPrefab("StaffClusterbomb")); SharedData shared = val5.ItemDrop.m_itemData.m_shared; if (shared == val6.m_itemData.m_shared || shared.m_attack == val6.m_itemData.m_shared.m_attack) { throw new InvalidOperationException("Clone '" + definition.ItemPrefabName + "' unexpectedly shares mutable item data with the vanilla staff."); } shared.m_attack.m_attackProjectile = val2; shared.m_skillType = (SkillType)9; shared.m_attackStatusEffect = null; shared.m_attackStatusEffectChance = 1f; shared.m_projectileToolTip = true; Sprite val7 = ((shared.m_icons != null && shared.m_icons.Length != 0) ? shared.m_icons[0] : null); Color tint = ThemeColor(definition.Theme); if (Object.op_Implicit((Object)(object)val7)) { shared.m_icons = (Sprite[])(object)new Sprite[1] { VfxStyler.CreateTintedIcon(val7, tint) }; } VfxFactory.StyleStaff(val5.ItemPrefab, definition.Theme); ItemManager.Instance.AddItem(val5); return val5; } private static void ConfigureSecondary(GameObject secondary, ElementTheme theme) { Projectile val = RequireComponent(secondary); val.m_spawnOnHit = null; val.m_spawnOnTtl = false; val.m_spawnCount = 0; val.m_randomSpawnOnHit.Clear(); val.m_randomSpawnOnHitCount = 0; val.m_respawnItemOnHit = false; val.m_projectilesInheritHitData = false; val.m_onlySpawnedProjectilesDealDamage = false; val.m_hitEffects = VfxFactory.GetHitEffects(theme); switch (theme) { case ElementTheme.Lightning: { float num = val.m_ttl * 2f; if (num <= 0f || float.IsNaN(num) || float.IsInfinity(num)) { throw new InvalidOperationException("The vanilla fracture ball has no finite positive lifetime to extend."); } val.m_ttl = num; secondary.AddComponent(); break; } case ElementTheme.Poison: secondary.AddComponent(); break; case ElementTheme.Blood: val.m_bounce = false; val.m_bounceOnWater = false; val.m_onlyStopOnTerrain = false; val.m_stayAfterHitStatic = false; val.m_stayAfterHitDynamic = false; secondary.AddComponent(); break; default: throw new ArgumentOutOfRangeException("theme", theme, null); } VfxFactory.StyleProjectile(secondary, theme, secondary: true); } private static void SetDamage(SharedData shared, DamageTypes baseDamage, DamageTypes perLevel) { //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) shared.m_damages = baseDamage; shared.m_damagesPerLevel = perLevel; } private static void ValidateVanillaDependencies() { string[] array = new string[14] { "StaffClusterbomb", "staff_clusterbombstaff_projectile", "staff_clusterbombstaff_splinter_projectile", "StaffLightning", "fx_chainlightning_hit", "fx_chainlightning_spread", "fx_clusterbombstaff_hit", "poisoncloud", "vfx_Poison", "projectile_splitner_lightning", "GemstoneBlue", "GemstoneGreen", "GemstoneRed", "FlametalNew" }; for (int i = 0; i < array.Length; i++) { RequiredPrefab(array[i]); } } private static void AuditCustomContent() { AssertBall("SOF_StaffFracturingIolite_Ball"); AssertBall("SOF_StaffFracturingJade_Ball"); AssertBall("SOF_StaffFracturingBloodstone_Ball"); Projectile val = RequireComponent(BloodShrapnelPrefab); if (Object.op_Implicit((Object)(object)val.m_spawnOnHit) || val.m_spawnOnTtl || val.m_respawnItemOnHit || Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { throw new InvalidOperationException("Blood shrapnel recursion guard audit failed."); } if (!Object.op_Implicit((Object)(object)VfxFactory.LightningArcPrefab.GetComponent()) || !Object.op_Implicit((Object)(object)PoisonZonePrefab.GetComponent())) { throw new InvalidOperationException("Network VFX audit failed: a temporary effect lacks ZNetView."); } } private static void AssertBall(string prefabName) where T : Component { GameObject obj = RequiredPrefab(prefabName); Projectile val = RequireComponent(obj); if (!Object.op_Implicit((Object)(object)obj.GetComponent()) || Object.op_Implicit((Object)(object)val.m_spawnOnHit) || val.m_spawnOnTtl) { throw new InvalidOperationException("Fracture-ball audit failed for '" + prefabName + "'."); } } private static GameObject CloneRequired(string name, string baseName) { GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, baseName); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Could not clone '" + baseName + "' as '" + name + "'."); } return val; } private static GameObject RequiredPrefab(string name) { GameObject prefab = PrefabManager.Instance.GetPrefab(name); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Required prefab '" + name + "' was not found in the current Valheim build."); } return prefab; } private static T RequireComponent(GameObject gameObject) where T : Component { T component = gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { throw new InvalidOperationException("Prefab '" + ((Object)gameObject).name + "' lacks required component " + typeof(T).Name + "."); } return component; } private static Color ThemeColor(ElementTheme theme) { //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_0015: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ElementTheme.Lightning => VfxStyler.Lightning, ElementTheme.Poison => VfxStyler.Poison, _ => VfxStyler.Blood, }); } } } namespace StaffsOfFracturing.Configuration { internal static class ModConfig { internal static ConfigEntry EnemyChainChance { get; private set; } internal static ConfigEntry BallChainChance { get; private set; } internal static ConfigEntry LightningDamage { get; private set; } internal static ConfigEntry ChainRange { get; private set; } internal static ConfigEntry LightningWebDamage { get; private set; } internal static ConfigEntry LightningWebHitCooldown { get; private set; } internal static ConfigEntry PoisonExplosionRadius { get; private set; } internal static ConfigEntry PoisonBluntDamage { get; private set; } internal static ConfigEntry PoisonDamage { get; private set; } internal static ConfigEntry PoisonDuration { get; private set; } internal static ConfigEntry ImmobilizeChance { get; private set; } internal static ConfigEntry ImmobilizeCheckInterval { get; private set; } internal static ConfigEntry BloodExplosionRadius { get; private set; } internal static ConfigEntry BloodExplosionBluntDamage { get; private set; } internal static ConfigEntry ShrapnelCount { get; private set; } internal static ConfigEntry ShrapnelPierceDamage { get; private set; } internal static ConfigEntry ShrapnelVelocity { get; private set; } internal static ConfigEntry ShrapnelSpeedMultiplier { get; private set; } internal static ConfigEntry ShrapnelLifetime { get; private set; } internal static void Bind(ConfigFile config) { EnemyChainChance = Bind(config, "Lightning", "EnemyChainChance", 0.25f, "Independent chance that a lightning-ball enemy hit arcs once to the nearest other enemy.", 0f, 1f); BallChainChance = Bind(config, "Lightning", "BallChainChance", 0.25f, "Independent chance for each unordered pair of balls from one shot to form a web link.", 0f, 1f); LightningDamage = Bind(config, "Lightning", "LightningDamage", 18f, "Base lightning damage dealt by each fracture ball and a successful enemy chain.", 1f, 80f); ChainRange = Bind(config, "Lightning", "ChainRange", 8f, "Maximum enemy-chain range in metres; also bounds web-link length.", 2f, 20f); LightningWebDamage = Bind(config, "Lightning", "LightningWebDamage", 4f, "Lightning damage from intersecting a ball-to-ball web segment.", 0f, 30f); LightningWebHitCooldown = Bind(config, "Lightning", "LightningWebHitCooldown", 0.35f, "Minimum seconds before the same target may be damaged by another link from the shot.", 0.1f, 2f); PoisonExplosionRadius = Bind(config, "Poison", "ExplosionRadius", 3.5f, "Radius in metres of each Jade fracture-ball detonation and its lingering haze.", 1f, 6f); PoisonBluntDamage = Bind(config, "Poison", "BluntDamage", 8f, "Base blunt damage dealt by each Jade fracture-ball explosion.", 0f, 50f); PoisonDamage = Bind(config, "Poison", "PoisonDamage", 12f, "Base native poison damage applied by each Jade fracture-ball explosion.", 0f, 60f); PoisonDuration = Bind(config, "Poison", "PoisonDuration", 5f, "Lifetime in seconds of each poison-control area and its immobilization checks.", 1f, 12f); ImmobilizeChance = Bind(config, "Poison", "ImmobilizeChance", 0.2f, "Independent chance per affected enemy per check to apply Valheim's Immobilized effect.", 0f, 1f); ImmobilizeCheckInterval = Bind(config, "Poison", "ImmobilizeCheckInterval", 1f, "Seconds between per-enemy immobilization checks.", 0.25f, 3f); BloodExplosionRadius = Bind(config, "Blood", "ExplosionRadius", 2.25f, "Radius in metres of each Bloodstone fracture-ball blunt explosion.", 0.75f, 5f); BloodExplosionBluntDamage = Bind(config, "Blood", "ExplosionBluntDamage", 12f, "Base blunt damage dealt by each Bloodstone fracture-ball explosion.", 0f, 60f); ShrapnelCount = ConfigFileExtensions.BindConfigInOrder(config, "Blood", "ShrapnelCount", 5, "Number of non-recursive projectiles launched by each detonation.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(1, 8), (Action)null, (ConfigurationManagerAttributes)null); ShrapnelPierceDamage = Bind(config, "Blood", "ShrapnelPierceDamage", 7f, "Base pierce damage dealt by each shrapnel projectile.", 0f, 40f); ShrapnelVelocity = Bind(config, "Blood", "ShrapnelVelocity", 28f, "Base launch velocity of Bloodstone shrapnel in metres per second, before ShrapnelSpeedMultiplier.", 8f, 55f); ShrapnelSpeedMultiplier = Bind(config, "Blood", "ShrapnelSpeedMultiplier", 2f, "Multiplies ShrapnelVelocity: 1 keeps the original speed, 1.5 is 50% faster, and 2 is 100% faster. Projectile lifetime is unchanged.", 1f, 2f); ShrapnelLifetime = Bind(config, "Blood", "ShrapnelLifetime", 1.6f, "Lifetime of each shrapnel projectile in seconds.", 0.4f, 4f); SubscribeBalanceRefresh(LightningDamage); SubscribeBalanceRefresh(PoisonBluntDamage); SubscribeBalanceRefresh(PoisonDamage); SubscribeBalanceRefresh(BloodExplosionBluntDamage); } private static ConfigEntry Bind(ConfigFile config, string section, string key, float defaultValue, string description, float minimum, float maximum) { return ConfigFileExtensions.BindConfigInOrder(config, section, key, defaultValue, description, true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(minimum, maximum), (Action)null, (ConfigurationManagerAttributes)null); } private static void SubscribeBalanceRefresh(ConfigEntry entry) { entry.SettingChanged += delegate { ContentRegistry.RefreshDisplayedDamage(); }; } } } namespace StaffsOfFracturing.Blood { internal sealed class BloodBallBehaviour : FractureBallBehaviour { protected override void OnInitialized(HitData originalHit) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) base.Projectile.m_aoe = ModConfig.BloodExplosionRadius.Value; base.Projectile.m_damage = new DamageTypes { m_blunt = DamageUtility.ScaleForQuality(ModConfig.BloodExplosionBluntDamage.Value, base.ItemQuality) }; base.Projectile.m_type = (ProjectileType)16394; } protected override void OnImpact(Collider collider, Vector3 hitPoint, bool water) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ContentRegistry.BloodShrapnelPrefab)) { return; } int value = ModConfig.ShrapnelCount.Value; float pierce = DamageUtility.ScaleForQuality(ModConfig.ShrapnelPierceDamage.Value, base.ItemQuality); float value2 = ModConfig.ShrapnelSpeedMultiplier.Value; float num = ModConfig.ShrapnelVelocity.Value * value2; for (int i = 0; i < value; i++) { Vector3 val = Random.onUnitSphere; if (val.y < -0.15f) { val.y = (0f - val.y) * 0.4f; } val = ((Vector3)(ref val)).normalized; Vector3 val2 = hitPoint + val * 0.2f + Vector3.up * 0.12f; GameObject val3 = Object.Instantiate(ContentRegistry.BloodShrapnelPrefab, val2, Quaternion.LookRotation(val)); Projectile component = val3.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_ttl = ModConfig.ShrapnelLifetime.Value; val3.GetComponent()?.Initialize(value2); HitData val4 = new HitData { m_damage = new DamageTypes { m_pierce = pierce }, m_pushForce = 4f, m_backstabBonus = 1f, m_staggerMultiplier = 1f, m_dodgeable = true, m_blockable = true, m_ranged = true, m_skill = (SkillType)9, m_skillLevel = base.Owner.GetSkillLevel((SkillType)9), m_skillRaiseAmount = 0f, m_itemLevel = (short)base.ItemQuality, m_hitType = (HitType)((!base.Owner.IsPlayer()) ? 1 : 2) }; val4.SetAttacker(base.Owner); component.Setup(base.Owner, val * num, 20f, val4, base.Weapon, (ItemData)null); } } } } }