Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of StaffsOfFracturing v1.0.5
BepInEx/plugins/L4zerShark_Team-StaffsOfFracturing/StaffsOfFracturing.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.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<ZNetView>(); 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<LineRenderer>(); } } 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<LineRenderer>() ?? ((Component)val).gameObject.AddComponent<LineRenderer>(); } 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<MeshFilter>(); MeshRenderer component2 = ((Component)model).GetComponent<MeshRenderer>(); 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<Mesh, Mesh> Cache = new Dictionary<Mesh, Mesh>(); private static readonly HashSet<Mesh> Unavailable = new HashSet<Mesh>(); 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<int> list; List<int> list2; checked { num3 = ((SubMeshDescriptor)(ref subMesh)).indexStart + ((SubMeshDescriptor)(ref subMesh)).indexCount; array4 = ReadBuffer(source.GetIndexBuffer(), num3 * num2); list = new List<int>(((SubMeshDescriptor)(ref subMesh)).indexCount); list2 = new List<int>(((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<int> 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<byte>(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<ushort>(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<uint>(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<int> 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<StaffHeadArcVisuals>().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<ParticleSystemRenderer>(); 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<ParticleSystemRenderer>(); 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<ParticleSystem>(); 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<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = material; component.renderMode = (ParticleSystemRenderMode)0; component.SetActiveVertexStreams(new List<ParticleSystemVertexStream> { (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<ParticleSystemRenderer>(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<Light>(); 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<TimedDestruction>(); if (Object.op_Implicit((Object)(object)component)) { component.m_timeout = 0.9f; component.m_triggerOnAwake = true; } LightningArcPrefab.AddComponent<NetworkArcBehaviour>(); 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<GameObject>(LightningArcPrefab, start, Quaternion.LookRotation(end - start)).GetComponent<NetworkArcBehaviour>()?.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<TimedDestruction>(); 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<NetworkPoisonZone>(); 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<Projectile>(); 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<ShrapnelMotionVisuals>(); 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<GameObject>(((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<ZSyncTransform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ZNetView[] componentsInChildren2 = root.GetComponentsInChildren<ZNetView>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } TimedDestruction[] componentsInChildren3 = root.GetComponentsInChildren<TimedDestruction>(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<GameObject>(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<ParticleSystem>(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<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].color = color; } if ((int)SystemInfo.graphicsDeviceType == 4) { return; } Renderer[] componentsInChildren3 = root.GetComponentsInChildren<Renderer>(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<ParticleSystem>(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<ParticleSystem>(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<ParticleSystemRenderer>(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<TrailRenderer>(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<ParticleSystem>(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<ParticleSystemRenderer>(true); foreach (ParticleSystemRenderer val2 in componentsInChildren2) { if ((int)val2.renderMode == 1) { val2.velocityScale *= num; } } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren<TrailRenderer>(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<Character>(); } 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<Character> hashSet = new HashSet<Character>(); 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<Character> hashSet = new HashSet<Character>(); 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<Character> hashSet = new HashSet<Character>(); 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<Projectile>(); 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<FractureBallBehaviour>()?.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<ZDOID, float> NextTargetCheck = new Dictionary<ZDOID, float>(); 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<ZNetView>(); } 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<ZDOID> list = new List<ZDOID>(); foreach (KeyValuePair<ZDOID, float> 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<GameObject>(ContentRegistry.PoisonZonePrefab, hitPoint, Quaternion.identity).GetComponent<NetworkPoisonZone>()?.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<ZNetView>(); } 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<string, string> { { "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_lightn