Decompiled source of BadAssEmotes v1.8.4
plugins/BadAssEmotes.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.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BadAssEmotes; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSSPluginSpace; using EmotesAPI; using ExamplePlugin; using HG.BlendableTypes; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using TC; using TC.Internal; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; using testMod; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BadAssEmotes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+73f16f2abf9a6b45e3c2f91a3efd1afdd0c33615")] [assembly: AssemblyProduct("BadAssEmotes")] [assembly: AssemblyTitle("BadAssEmotes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } public class ColorCubeEmission : MonoBehaviour { private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_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) int num = 0; ParticleProto[] array = new ParticleProto[512000]; for (int i = 0; i < 80; i++) { for (int j = 0; j < 80; j++) { for (int k = 0; k < 80; k++) { array[num].Position = new Vector3((float)i / 80f, (float)j / 80f, (float)k / 80f) * 2f - Vector3.one; array[num].Color = Color.HSVToRGB((float)i / 80f, (float)j / 80f, (float)k / 80f); array[num].Size = 1f; array[num].Velocity = Vector3.zero; num++; } } } ((Component)this).GetComponent<TCParticleSystem>().Emit(array); } } public class ForceEnable : MonoBehaviour { public Text CurrentForceText; public TCForce ForceTarget; public OrbitCam Cam; private string m_startText; private void OnEnable() { if ((Object)(object)ForceTarget != (Object)null) { ((Behaviour)ForceTarget).enabled = false; } m_startText = CurrentForceText.text; ForceTarget.forceType = ForceType.Radial; ForceTarget.power = -60f; } private void Update() { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: 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_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (Input.GetMouseButton(0)) { ((Behaviour)ForceTarget).enabled = true; Ray val = ((Component)this).GetComponent<Camera>().ScreenPointToRay(Input.mousePosition); Plane val2 = default(Plane); ((Plane)(ref val2))..ctor(Vector3.Cross(((Component)this).transform.up, ((Component)this).transform.right), ((Component)Cam.Target).transform.position); float num = default(float); if (((Plane)(ref val2)).Raycast(val, ref num)) { ((Component)ForceTarget).transform.position = ((Component)this).transform.position + ((Ray)(ref val)).direction * num; } } else { ((Behaviour)ForceTarget).enabled = false; } CurrentForceText.text = m_startText + Environment.NewLine + "(Current Type: " + ForceTarget.forceType.ToString() + ")"; if (Input.GetKey((KeyCode)49)) { ForceTarget.forceType = ForceType.Radial; ForceTarget.power = -60f; } else if (Input.GetKey((KeyCode)50)) { ForceTarget.forceType = ForceType.Vortex; ForceTarget.power = 60f; } else if (Input.GetKey((KeyCode)51)) { ForceTarget.forceType = ForceType.Turbulence; ForceTarget.power = 60f; } else if (Input.GetKey((KeyCode)52)) { ForceTarget.forceType = ForceType.Vector; ForceTarget.power = 60f; } else if (Input.GetKey((KeyCode)53)) { ForceTarget.forceType = ForceType.Drag; ForceTarget.power = 60f; } } } public struct ColorHSV { private float _h; private float _s; private float _v; private float _a; public float H { get { return _h; } set { _h = value % 360f; } } public float S { get { return _s; } set { if (value < 0f) { _s = 0f; } else if (value > 100f) { _s = 100f; } else { _s = value; } } } public float V { get { return _v; } set { if (value < 0f) { _v = 0f; } else if (value > 100f) { _v = 100f; } else { _v = value; } } } public float A { get { return _a; } set { if (value < 0f) { _a = 0f; } else if (value > 100f) { _a = 100f; } else { _a = value; } } } public ColorHSV(float h, float s, float v) { this = default(ColorHSV); H = h; S = s; V = v; A = 100f; } public ColorHSV(float h, float s, float v, float a) { this = default(ColorHSV); H = h; S = s; V = v; A = a; } public ColorHSV(Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) this = default(ColorHSV); Color32 colorHSV = Color32.op_Implicit(color); SetColorHSV(colorHSV); } public ColorHSV(Color32 color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) this = default(ColorHSV); SetColorHSV(color); } private void SetColorHSV(Color32 color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) float num = 20f / 51f; _a = (float)(int)color.a * num; _h = 0f; float num2 = Mathf.Min(Mathf.Min((int)color.r, (int)color.g), (int)color.b); float num3 = Mathf.Max(Mathf.Max((int)color.r, (int)color.g), (int)color.b); float num4 = num3 - num2; _v = num3; if (num3 != 0f) { _s = 255f * num4 / num3; } else { _s = 0f; } if (_s != 0f) { if ((float)(int)color.r == num3) { _h = (float)(color.g - color.b) / num4; } else if ((float)(int)color.g == num3) { _h = 2f + (float)(color.b - color.r) / num4; } else if ((float)(int)color.b == num3) { _h = 4f + (float)(color.r - color.g) / num4; } } else { _h = -1f; } _h *= 60f; if (_h < 0f) { _h += 360f; } _s *= num; _v *= num; } public Color ToColor() { //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_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_0011: Unknown result type (might be due to invalid IL or missing references) return Color32.op_Implicit(ToColor32()); } public Color32 ToColor32() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0133: 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_012f: Unknown result type (might be due to invalid IL or missing references) float num = _s * 0.01f; float num2 = _v * 2.55f; int num3 = (int)Mathf.Floor(_h / 60f) % 6; float num4 = _h / 60f - Mathf.Floor(_h / 60f); byte b = (byte)Mathf.Round(num2); byte b2 = (byte)Mathf.Round(num2 * (1f - num)); byte b3 = (byte)Mathf.Round(num2 * (1f - num4 * num)); byte b4 = (byte)Mathf.Round(num2 * (1f - (1f - num4) * num)); byte b5 = (byte)Mathf.Round(_a * 2.55f); return (Color32)(num3 switch { 0 => new Color32(b, b4, b2, b5), 1 => new Color32(b3, b, b2, b5), 2 => new Color32(b2, b, b4, b5), 3 => new Color32(b2, b3, b, b5), 4 => new Color32(b4, b2, b, b5), _ => new Color32(b, b2, b3, b5), }); } } public class ParticleRandomColor : MonoBehaviour { private ColorHSV col; private TCParticleSystem syst; private void Start() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) col = new ColorHSV { A = 100f, H = Random.value * 360f, S = Random.value * 100f, V = Random.value * 100f }; syst = ((Component)this).GetComponent<TCParticleSystem>(); syst.ParticleRenderer.Material = Object.Instantiate<Material>(syst.ParticleRenderer.Material); syst.ParticleRenderer.Material.SetColor("_Color", col.ToColor()); } private void Update() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) col.H += Mathf.PerlinNoise(Time.time, 0f) * 0.25f; col.S += Mathf.PerlinNoise(Time.time, 1f) * 0.1f; col.V += Mathf.PerlinNoise(Time.time, 2f) * 0.1f; syst.ParticleRenderer.Material.SetColor("_Color", col.ToColor()); } } public class PointCloudEnableSim : MonoBehaviour { private void Update() { if (Input.GetKeyDown((KeyCode)32)) { TCParticleSystem[] array = Object.FindObjectsOfType<TCParticleSystem>(); TCParticleSystem[] array2 = array; foreach (TCParticleSystem tCParticleSystem in array2) { tCParticleSystem.Manager.NoSimulation = !tCParticleSystem.Manager.NoSimulation; } } } } internal class DetonationSpawner : MonoBehaviour { public GameObject myFusion; public GameObject myFusion2; private void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Input.GetMouseButtonUp(0)) { Object.Instantiate<GameObject>(myFusion, Vector3.zero, Random.rotation); } if (Input.GetMouseButtonUp(1)) { Object.Instantiate<GameObject>(myFusion2, Vector3.zero, Random.rotation); } } } public class EmissionFade : MonoBehaviour { private TCParticleSystem system; private float startEmission; private float startTime; public AnimationCurve fadeCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); private void Start() { system = ((Component)this).GetComponent<TCParticleSystem>(); startEmission = system.EmissionRate; } private void Update() { //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) system.EmissionRate = startEmission * fadeCurve.Evaluate(system.Lifespan); float lifespan = system.Lifespan; Keyframe val = fadeCurve[fadeCurve.length - 1]; if (lifespan > ((Keyframe)(ref val)).time) { Object.Destroy((Object)(object)((Component)this).gameObject, 0.5f); } } } public class LightFade : MonoBehaviour { public AnimationCurve animationCurve = new AnimationCurve(); public float duration = 5f; private float startIntensity; private float startTime; private void Start() { startIntensity = ((Component)this).GetComponent<Light>().intensity; startTime = Time.time; } private void Update() { if ((Object)(object)((Component)this).GetComponent<Light>() != (Object)null) { ((Component)this).GetComponent<Light>().intensity = animationCurve.Evaluate(Mathf.Min(1f, (Time.time - startTime) / duration)) * startIntensity; } } } [AddComponentMenu("Camera-Control/Mouse Look")] public class MouseLook : MonoBehaviour { public enum RotationAxes { MouseXAndY, MouseX, MouseY } public RotationAxes axes = RotationAxes.MouseXAndY; public float sensitivityX = 15f; public float sensitivityY = 15f; public float minimumX = -360f; public float maximumX = 360f; public float minimumY = -60f; public float maximumY = 60f; private float rotationY = 0f; private void Update() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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) if (axes == RotationAxes.MouseXAndY) { float num = ((Component)this).transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp(rotationY, minimumY, maximumY); ((Component)this).transform.localEulerAngles = new Vector3(0f - rotationY, num, 0f); } else if (axes == RotationAxes.MouseX) { ((Component)this).transform.Rotate(0f, Input.GetAxis("Mouse X") * sensitivityX, 0f); } else { rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp(rotationY, minimumY, maximumY); ((Component)this).transform.localEulerAngles = new Vector3(0f - rotationY, ((Component)this).transform.localEulerAngles.y, 0f); } } private void Start() { if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<Rigidbody>())) { ((Component)this).GetComponent<Rigidbody>().freezeRotation = true; } } } public class PlasmaGun : MonoBehaviour { public enum Gun { PlasmaBolt, GrenadeLauncher, Firethrower } public GameObject plasmaBolt; public GameObject grenade; public GameObject firethrower; public float MoveSpeed = 0.3f; public float plasmaRefireRate = 1f; public float plasmaShotPower; public float grenadeRefireRate = 0.5f; public float grenadeShotPower = 1f; public float grenadeVerticalPower = 1f; public Transform fireTransform; private TCParticleSystem fireSystem; public Gun selectedGun; private bool canFire = true; private CharacterController cc; private void Awake() { cc = ((Component)this).GetComponent<CharacterController>(); fireSystem = firethrower.GetComponent<TCParticleSystem>(); } private void Update() { //IL_00b6: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fireSystem != (Object)null) { fireSystem.Emitter.DoEmit = false; } if (Input.GetMouseButton(0) && canFire) { switch (selectedGun) { case Gun.PlasmaBolt: ((MonoBehaviour)this).StartCoroutine(FirePlasma()); break; case Gun.GrenadeLauncher: ((MonoBehaviour)this).StartCoroutine(FireGrenade()); break; case Gun.Firethrower: fireSystem.Emitter.DoEmit = true; break; } } float num = MoveSpeed * Time.deltaTime; if (Input.GetKey((KeyCode)119)) { cc.Move(((Component)this).transform.forward * num); } if (Input.GetKey((KeyCode)97)) { cc.Move(-((Component)this).transform.right * num); } if (Input.GetKey((KeyCode)115)) { cc.Move(-((Component)this).transform.forward * num); } if (Input.GetKey((KeyCode)100)) { cc.Move(((Component)this).transform.right * num); } if (Input.GetKeyDown((KeyCode)49)) { selectedGun = Gun.PlasmaBolt; } else if (Input.GetKeyDown((KeyCode)50)) { selectedGun = Gun.GrenadeLauncher; } else if (Input.GetKeyDown((KeyCode)51)) { selectedGun = Gun.Firethrower; } float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis < 0f && selectedGun != 0) { selectedGun--; } else if (axis > 0f && selectedGun != Gun.Firethrower) { selectedGun++; } } private IEnumerator FireGrenade() { canFire = false; GameObject gr = Object.Instantiate<GameObject>(grenade, fireTransform.position + cc.velocity * Time.deltaTime, Quaternion.identity); gr.GetComponent<Rigidbody>().velocity = ((Component)Camera.main).transform.forward * grenadeShotPower + cc.velocity + new Vector3(0f, grenadeVerticalPower, 0f); yield return (object)new WaitForSeconds(grenadeRefireRate); canFire = true; } private IEnumerator FirePlasma() { canFire = false; GameObject plasma = Object.Instantiate<GameObject>(plasmaBolt, fireTransform.position + cc.velocity * Time.deltaTime, Quaternion.identity); plasma.GetComponent<Rigidbody>().velocity = ((Component)Camera.main).transform.forward * plasmaShotPower + cc.velocity; yield return (object)new WaitForSeconds(plasmaRefireRate); canFire = true; } } public class PowerFade : MonoBehaviour { public AnimationCurve animationCurve = new AnimationCurve(); public float duration = 5f; private float m_startPower; private float m_startTime; private TCForce m_force; private void Start() { m_force = ((Component)this).GetComponent<TCForce>(); m_startPower = m_force.power; m_startTime = Time.time; } private void Update() { if ((Object)(object)m_force != (Object)null) { m_force.power = animationCurve.Evaluate(Mathf.Min(1f, (Time.time - m_startTime) / duration)) * m_startPower; } } } public class Projectile : MonoBehaviour { public float life; public GameObject spawnObject; public float spawnDelay; private IEnumerator Death() { yield return (object)new WaitForSeconds(life); Object.Destroy((Object)(object)((Component)this).gameObject); } private IEnumerator Spawn() { if (!((Object)(object)spawnObject == (Object)null)) { yield return (object)new WaitForSeconds(spawnDelay); Object.Instantiate<GameObject>(spawnObject, ((Component)this).transform.position, Quaternion.identity); } } private void Start() { ((MonoBehaviour)this).StartCoroutine(Death()); ((MonoBehaviour)this).StartCoroutine(Spawn()); } } public class OrbitCam : MonoBehaviour { public Transform Target; public float XSpeed = 120f; public float YSpeed = 120f; public float YMinLimit = -20f; public float YMaxLimit = 80f; public float Distance = 5f; public float DistanceMin = 0.5f; public float DistanceMax = 15f; private float m_x; private float m_y; private void OnEnable() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 eulerAngles = ((Component)this).transform.eulerAngles; m_x = eulerAngles.y; m_y = eulerAngles.x; Rigidbody component = ((Component)this).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component)) { component.freezeRotation = true; } } private void LateUpdate() { //IL_0077: 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_00c3: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) m_x += Input.GetAxis("Mouse X") * XSpeed * 0.02f; m_y -= Input.GetAxis("Mouse Y") * YSpeed * 0.02f; m_y = ClampAngle(m_y, YMinLimit, YMaxLimit); Quaternion val = Quaternion.Euler(m_y, m_x, 0f); Distance = Mathf.Clamp(Distance - Input.GetAxis("Mouse ScrollWheel") * 25f, DistanceMin, DistanceMax); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f, 0f - Distance); Vector3 val3 = val * val2 + Target.position; ((Component)this).transform.SetPositionAndRotation(val3, val); } public static float ClampAngle(float angle, float min, float max) { if (angle < -360f) { angle += 360f; } if (angle > 360f) { angle -= 360f; } return Mathf.Clamp(angle, min, max); } } public class SmoothRandomRotate : MonoBehaviour { public float strength = 1f; private float m_seed; private Vector3 m_rotateSpeed; private float m_friction = 0.99f; private Rigidbody m_rigid; private void OnEnable() { m_seed = Random.Range(0f, 100f); m_rigid = ((Component)this).GetComponent<Rigidbody>(); } private float SmoothRand(float y) { return Mathf.PerlinNoise(Time.time + m_seed, y) * 2f - 1f; } private void Update() { //IL_0003: 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_0034: 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_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_0052: 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_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_0086: Unknown result type (might be due to invalid IL or missing references) m_rotateSpeed += new Vector3(SmoothRand(0f), SmoothRand(1f), SmoothRand(2f)) * strength * Time.deltaTime * 3f; m_rotateSpeed *= m_friction; if ((Object)(object)m_rigid == (Object)null) { ((Component)this).transform.Rotate(m_rotateSpeed); } } private void FixedUpdate() { //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) if ((Object)(object)m_rigid != (Object)null) { m_rigid.MoveRotation(Quaternion.Euler(m_rotateSpeed)); } } } public class SpringParticles : MonoBehaviour { public ComputeShader SpringPosCompute; public bool DoSpring = true; public float SpringConstant = 0.1f; public float SpringDamping = 0.5f; private ComputeBuffer m_initialPositions; private TCParticleSystem m_system; private int m_updateKernel; private int m_writePosKernel; private void OnEnable() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown m_system = ((Component)this).GetComponent<TCParticleSystem>(); m_initialPositions = new ComputeBuffer(m_system.MaxParticles, 12); ParticleEmitter emitter = m_system.Emitter; emitter.OnEmissionCallback = (ParticleEmitter.EmissionCallbackCB)Delegate.Combine(emitter.OnEmissionCallback, new ParticleEmitter.EmissionCallbackCB(OnEmissionCallback)); ParticleManager manager = m_system.Manager; manager.OnPostSimulationCallback = (ParticleManager.SimulationCB)Delegate.Combine(manager.OnPostSimulationCallback, new ParticleManager.SimulationCB(OnPostSimulationCallback)); m_writePosKernel = SpringPosCompute.FindKernel("WriteInitialPos"); m_updateKernel = SpringPosCompute.FindKernel("UpdateSpring"); } private void OnEmissionCallback(int emittedCount) { SpringPosCompute.SetBuffer(m_writePosKernel, "_InitialPos", m_initialPositions); m_system.Emitter.DispatchEmitExtensionKernel(SpringPosCompute, m_writePosKernel); } private void OnPostSimulationCallback() { if (DoSpring) { SpringPosCompute.SetBuffer(m_updateKernel, "_InitialPos", m_initialPositions); SpringPosCompute.SetFloat("_SpringConstant", SpringConstant); float num = Mathf.Pow(Mathf.Abs(1f - SpringDamping), m_system.ParticleTimeDelta); SpringPosCompute.SetFloat("_SpringDamping", num); m_system.Manager.DispatchExtensionKernel(SpringPosCompute, m_updateKernel); } } private void OnDisable() { m_initialPositions.Dispose(); ParticleEmitter emitter = m_system.Emitter; emitter.OnEmissionCallback = (ParticleEmitter.EmissionCallbackCB)Delegate.Remove(emitter.OnEmissionCallback, new ParticleEmitter.EmissionCallbackCB(OnEmissionCallback)); ParticleManager manager = m_system.Manager; manager.OnPostSimulationCallback = (ParticleManager.SimulationCB)Delegate.Remove(manager.OnPostSimulationCallback, new ParticleManager.SimulationCB(OnPostSimulationCallback)); } } public class SpringParticlesDemo : MonoBehaviour { private void Update() { ((Component)this).GetComponent<SpringParticles>().DoSpring = Input.GetKey((KeyCode)32); } } public class LivingParticlesAudioModule : MonoBehaviour { public Transform audioPosition; public LivingParticlesAudioSource LPaSourse; public bool useBuffer; public bool firstAndLastPixelBlack = false; private Texture2D t2d; private float[] finalSpectrum; private Color col = Color.black; private ParticleSystemRenderer psr; private void Start() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown psr = ((Component)this).GetComponent<ParticleSystemRenderer>(); switch (LPaSourse.numberOfBands) { case LivingParticlesAudioSource._numberOfBands.Bands8: if (firstAndLastPixelBlack) { t2d = new Texture2D(10, 1); } else { t2d = new Texture2D(8, 1); } break; case LivingParticlesAudioSource._numberOfBands.Bands16: if (firstAndLastPixelBlack) { t2d = new Texture2D(18, 1); } else { t2d = new Texture2D(16, 1); } break; } ((Texture)t2d).wrapMode = (TextureWrapMode)0; } private void Update() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (useBuffer) { switch (LPaSourse.numberOfBands) { case LivingParticlesAudioSource._numberOfBands.Bands8: finalSpectrum = LPaSourse.finalBands8Buffer; break; case LivingParticlesAudioSource._numberOfBands.Bands16: finalSpectrum = LPaSourse.finalBands16Buffer; break; } } else { switch (LPaSourse.numberOfBands) { case LivingParticlesAudioSource._numberOfBands.Bands8: finalSpectrum = LPaSourse.finalBands8; break; case LivingParticlesAudioSource._numberOfBands.Bands16: finalSpectrum = LPaSourse.finalBands16; break; } } for (int i = 0; i < finalSpectrum.Length; i++) { col.r = finalSpectrum[i]; if (firstAndLastPixelBlack) { t2d.SetPixel(i + 1, 0, col); } else { t2d.SetPixel(i, 0, col); } } if (firstAndLastPixelBlack) { t2d.SetPixel(0, 0, Color.black); switch (LPaSourse.numberOfBands) { case LivingParticlesAudioSource._numberOfBands.Bands8: t2d.SetPixel(9, 0, Color.black); break; case LivingParticlesAudioSource._numberOfBands.Bands16: t2d.SetPixel(17, 0, Color.black); break; } } t2d.Apply(); ((Renderer)psr).material.SetTexture("_AudioSpectrum", (Texture)(object)t2d); ((Renderer)psr).material.SetVector("_AudioPosition", Vector4.op_Implicit(audioPosition.position)); switch (LPaSourse.numberOfBands) { case LivingParticlesAudioSource._numberOfBands.Bands8: { int num = 1; AKRESULT rTPCValue = AkSoundEngine.GetRTPCValue("Band1", (GameObject)null, 0u, ref LPaSourse.amplitudeBuffer8, ref num); float amplitudeBuffer = (LPaSourse.amplitudeBuffer8 + 48f) / 48f; LPaSourse.amplitudeBuffer8 = amplitudeBuffer; ((Renderer)psr).material.SetFloat("_AudioAverageAmplitude", LPaSourse.amplitudeBuffer8); break; } case LivingParticlesAudioSource._numberOfBands.Bands16: ((Renderer)psr).material.SetFloat("_AudioAverageAmplitude", LPaSourse.amplitudeBuffer16); break; } } } public class LivingParticlesAudioSource : MonoBehaviour { public enum _numberOfBands { Bands8, Bands16 } public AudioClip audioClip; [Range(0.1f, 2f)] public float bufferInitialDecreaseSpeed = 1f; [Range(0f, 10f)] public float bufferDecreaseSpeedMultiply = 5f; public float freqBandsPower = 10f; public float audioProfileInitialValue = 5f; public bool audioProfileDecreasing = true; public float audioProfileDecreasingSpeed = 0.1f; public _numberOfBands numberOfBands = _numberOfBands.Bands8; private float[] initialSamplesL = new float[512]; private float[] initialSamplesR = new float[512]; private float[] freqBands8 = new float[8]; private float[] freqBands8Buffer = new float[8]; private float[] freqBands8BufferDecrease = new float[8]; private float[] freqBands8Highest = new float[8]; private float[] freqBands16 = new float[16]; private float[] freqBands16Buffer = new float[16]; private float[] freqBands16BufferDecrease = new float[16]; private float[] freqBands16Highest = new float[16]; private AudioSource audioSource; [HideInInspector] public float[] finalBands8 = new float[8]; [HideInInspector] public float[] finalBands8Buffer = new float[8]; [HideInInspector] public float[] finalBands16 = new float[16]; [HideInInspector] public float[] finalBands16Buffer = new float[16]; [HideInInspector] public float amplitude8; [HideInInspector] public float amplitudeBuffer8; [HideInInspector] public float amplitude16; [HideInInspector] public float amplitudeBuffer16; private float amplitudeHighest; private static bool speaking; private uint _length = 0u; private bool yote = false; private float[] left; private float[] right; private double[] _window; private void Start() { audioSource = ((Component)this).GetComponent<AudioSource>(); AudioProfile(audioProfileInitialValue); } public void StartAudio() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Expected O, but got Unknown Reset(); uint num = AkAudioInputManager.PostAudioInputEvent("IFUTestInput", ((Component)this).gameObject, new AudioSamplesDelegate(WavBufferToWwise), new AudioFormatDelegate(BeforePlayingAudio)); } public void Reset() { _length = 0u; } private void BeforePlayingAudio(uint playingID, AkAudioFormat format) { left = (right = new float[0]); readWav("C:\\Users\\dwelx\\Documents\\GitHub\\BadAssEmotes\\ExamplePlugin\\Ifu.wav", out left, out right, out var samplerate, out var channels); format.channelConfig.uNumChannels = channels; format.uSampleRate = samplerate; yote = true; } private static bool readWav(string filename, out float[] L, out float[] R, out uint samplerate, out uint channels) { speaking = true; L = (R = null); samplerate = 0u; channels = 0u; try { using FileStream input = File.Open(filename, FileMode.Open); BinaryReader binaryReader = new BinaryReader(input); int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); int num5 = binaryReader.ReadInt32(); int num6 = binaryReader.ReadInt16(); int num7 = binaryReader.ReadInt16(); int num8 = binaryReader.ReadInt32(); int num9 = binaryReader.ReadInt32(); int num10 = binaryReader.ReadInt16(); int num11 = binaryReader.ReadInt16(); samplerate = (uint)num8; channels = (uint)num7; if (num5 == 18) { int count = binaryReader.ReadInt16(); binaryReader.ReadBytes(count); } int num12 = binaryReader.ReadInt32(); int num13 = binaryReader.ReadInt32(); byte[] src = binaryReader.ReadBytes(num13); int num14 = num11 / 8; int num15 = num13 / num14; float[] array = null; switch (num11) { case 64: { double[] array3 = new double[num15]; Buffer.BlockCopy(src, 0, array3, 0, num13); array = Array.ConvertAll(array3, (double e) => (float)e); break; } case 32: array = new float[num15]; Buffer.BlockCopy(src, 0, array, 0, num13); break; case 16: { short[] array2 = new short[num15]; Buffer.BlockCopy(src, 0, array2, 0, num13); array = Array.ConvertAll(array2, (short e) => (float)e / 32768f); break; } default: return false; } switch (channels) { case 1u: L = array; R = null; return true; case 2u: { int num16 = num15 / 2; L = new float[num16]; R = new float[num16]; int i = 0; int num17 = 0; for (; i < num16; i++) { L[i] = array[num17++]; R[i] = array[num17++]; } return true; } default: return false; } } catch { Debug.Log((object)("...Failed to load: " + filename)); return false; } } private bool WavBufferToWwise(uint playingID, uint channelIndex, float[] samples) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (left.Length == 0) { DebugClass.Log((object)"There was an error playing the audio file, The audio buffer is empty!"); } if (_length >= (uint)left.Length) { _length = (uint)left.Length; } initialSamplesL = new float[samples.Length]; initialSamplesR = new float[samples.Length]; try { uint num = 0u; for (num = 0u; num < samples.Length; num++) { if (num + _length >= left.Length) { speaking = false; AkSoundEngine.ExecuteActionOnEvent(3183910552u, (AkActionOnEventType)0); _length = 0u; break; } initialSamplesL[num] = left[num + _length]; initialSamplesR[num] = right[num + _length]; samples[num] = 0f; } _length += num; } catch (Exception) { Debug.Log((object)"--------end of audio???"); throw; } if (_length >= (uint)left.Length) { _length = (uint)left.Length; speaking = false; } DoSpectrumDataStuff(); return speaking; } private void ApplyWindow() { int num = initialSamplesL.Length; CreateWindow(num); for (int i = 0; i < num; i++) { initialSamplesL[i] = (float)((double)initialSamplesL[i] * _window[i]); initialSamplesR[i] = (float)((double)initialSamplesR[i] * _window[i]); } } private void DoSpectrumDataStuff() { ApplyWindow(); switch (numberOfBands) { case _numberOfBands.Bands8: CreateFreqBands8(); CreateBandBuffer8(); CreateFinalBands8(); CreateAmplitude8(); break; case _numberOfBands.Bands16: CreateFreqBands16(); CreateBandBuffer16(); CreateFinalBands16(); CreateAmplitude16(); break; } } private void CreateWindow(int size, bool normalize = false) { _window = new double[size]; for (int i = 0; i < size; i++) { double num = (double)i / (double)(size - 1); _window[i] = (double)(0.42f - 0.5f * Mathf.Cos((float)(i / size))) + 0.08 * (double)Mathf.Cos(2f * (float)i / (float)size); } if (normalize) { double num2 = 0.0; for (int j = 0; j < _window.Length; j++) { num2 += _window[j]; } for (int k = 0; k < _window.Length; k++) { _window[k] /= num2; } } } private void AudioProfile(float audioProfileValue) { for (int i = 0; i < 8; i++) { freqBands8Highest[i] = audioProfileValue; } for (int j = 0; j < 16; j++) { freqBands16Highest[j] = audioProfileValue; } } private void CreateAmplitude8() { float num = 0f; float num2 = 0f; for (int i = 0; i < 8; i++) { num += finalBands8[i]; num2 += finalBands8Buffer[i]; } if (num > amplitudeHighest) { amplitudeHighest = num; } amplitude8 = num / amplitudeHighest; amplitudeBuffer8 = num2 / amplitudeHighest; } private void CreateAmplitude16() { float num = 0f; float num2 = 0f; for (int i = 0; i < 16; i++) { num += finalBands16[i]; num2 += finalBands16Buffer[i]; } if (num > amplitudeHighest) { amplitudeHighest = num; } amplitude16 = num / amplitudeHighest; amplitudeBuffer16 = num2 / amplitudeHighest; } private void CreateFinalBands8() { for (int i = 0; i < 8; i++) { if (audioProfileDecreasing) { freqBands8Highest[i] -= audioProfileDecreasingSpeed * Time.deltaTime; } if (freqBands8[i] > freqBands8Highest[i]) { freqBands8Highest[i] = freqBands8[i]; } finalBands8[i] = freqBands8[i] / freqBands8Highest[i]; finalBands8Buffer[i] = freqBands8Buffer[i] / freqBands8Highest[i]; } } private void CreateFinalBands16() { for (int i = 0; i < 16; i++) { if (audioProfileDecreasing) { freqBands16Highest[i] -= audioProfileDecreasingSpeed * Time.deltaTime; } if (freqBands16[i] > freqBands16Highest[i]) { freqBands16Highest[i] = freqBands16[i]; } finalBands16[i] = freqBands16[i] / freqBands16Highest[i]; finalBands16Buffer[i] = freqBands16Buffer[i] / freqBands16Highest[i]; } } private void CreateBandBuffer8() { for (int i = 0; i < 8; i++) { if (freqBands8[i] > freqBands8Buffer[i]) { freqBands8Buffer[i] = freqBands8[i]; freqBands8BufferDecrease[i] = bufferInitialDecreaseSpeed * freqBands8Highest[i] * Time.deltaTime; } if (freqBands8[i] < freqBands8Buffer[i]) { freqBands8Buffer[i] -= freqBands8BufferDecrease[i]; freqBands8BufferDecrease[i] *= 1f + bufferDecreaseSpeedMultiply * Time.deltaTime; } } } private void CreateBandBuffer16() { for (int i = 0; i < 16; i++) { if (freqBands16[i] > freqBands16Buffer[i]) { freqBands16Buffer[i] = freqBands16[i]; freqBands16BufferDecrease[i] = bufferInitialDecreaseSpeed * freqBands16Highest[i] * Time.deltaTime; } if (freqBands16[i] < freqBands16Buffer[i]) { freqBands16Buffer[i] -= freqBands16BufferDecrease[i]; freqBands16BufferDecrease[i] *= 1f + bufferDecreaseSpeedMultiply * Time.deltaTime; } } } private void CreateFreqBands8() { //IL_0018: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) int num = 1; AkSoundEngine.GetRTPCValue("Band1", (GameObject)null, 0u, ref freqBands8[0], ref num); freqBands8[0] = (freqBands8[0] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band1", (GameObject)null, 0u, ref freqBands8[1], ref num); freqBands8[1] = (freqBands8[1] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band2", (GameObject)null, 0u, ref freqBands8[2], ref num); freqBands8[2] = (freqBands8[2] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band2", (GameObject)null, 0u, ref freqBands8[3], ref num); freqBands8[3] = (freqBands8[3] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band3", (GameObject)null, 0u, ref freqBands8[4], ref num); freqBands8[4] = (freqBands8[4] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band3", (GameObject)null, 0u, ref freqBands8[5], ref num); freqBands8[5] = (freqBands8[5] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band4", (GameObject)null, 0u, ref freqBands8[6], ref num); freqBands8[6] = (freqBands8[6] + 48f) / 48f; AkSoundEngine.GetRTPCValue("Band4", (GameObject)null, 0u, ref freqBands8[7], ref num); freqBands8[7] = (freqBands8[7] + 48f) / 48f; } private void CreateFreqBands16() { int num = 0; int num2 = 1; int num3 = 0; for (int i = 0; i < 16; i++) { float num4 = 0f; if (i == 2 || i == 4 || i == 6 || i == 8 || i == 10 || i == 12 || i == 14) { num3++; num2 = (int)Mathf.Pow(2f, (float)num3); if (num3 == 7) { num2++; } } for (int j = 0; j < num2; j++) { num4 += (initialSamplesL[num] + initialSamplesR[num]) * (float)(num + 1); num++; } num4 /= (float)num; freqBands16[i] = num4 * freqBandsPower * 2f; } } } namespace TC { [Serializable] public class ParticleColliderManager : ParticleComponent { private struct Collider { public float Bounciness; public float LifeLoss; public Vector3 Position; public float Radius; public Vector3 BoxSize; public Vector3 AxisX; public Vector3 AxisY; public Vector3 AxisZ; public Vector3 Velocity; public uint Vtype; public uint IsInverse; public float Stickiness; } [SerializeField] private int _maxColliders = 1; [SerializeField] [Range(0f, 1f)] private float _particleThickness = 0.25f; [SerializeField] [Range(0f, 1f)] private float _bounciness = 0.3f; [SerializeField] private bool overrideBounciness; [SerializeField] [Range(0f, 1f)] private float _stickiness = 0.3f; [SerializeField] private bool overrideStickiness; private Collider[] m_colliderStruct; private TCCollider[] m_colliderReference; private ComputeBuffer m_colliderBuffer; private List<TCCollider> m_collidersList; [SerializeField] private LayerMask _colliderLayers = LayerMask.op_Implicit(-1); [SerializeField] private List<TCCollider> _baseColliders = new List<TCCollider>(); private Comparison<TCCollider> m_colliderSort; public int MaxColliders { get { return _maxColliders; } set { _maxColliders = value; } } public int NumColliders => (m_collidersList != null) ? Mathf.Min(m_collidersList.Count, _maxColliders) : 0; public float ParticleThickness { get { return _particleThickness; } set { _particleThickness = value; } } public float Bounciness { get { return _bounciness; } set { _bounciness = Mathf.Clamp(value, 0f, 1f); } } public bool OverrideBounciness { get { return overrideBounciness; } set { overrideBounciness = value; } } public float Stickiness { get { return _stickiness; } set { _stickiness = Mathf.Clamp(value, 0f, 1f); } } public bool OverrideStickiness { get { return overrideStickiness; } set { overrideStickiness = value; } } public LayerMask ColliderLayers { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _colliderLayers; } set { //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) _colliderLayers = value; } } public List<TCCollider> BaseColliders => _baseColliders; [EditorBrowsable(EditorBrowsableState.Never)] protected override void Initialize() { CreateBuffers(); } private void CreateBuffers() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown m_colliderStruct = new Collider[MaxColliders]; m_colliderReference = new TCCollider[MaxColliders]; if (_maxColliders != 0) { m_colliderBuffer = new ComputeBuffer(_maxColliders, 96); } } internal void Update() { if (_maxColliders != 0 && m_colliderStruct.Length != MaxColliders) { CreateBuffers(); } } private void DistributeColliders() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (m_colliderReference == null || MaxColliders == 0) { return; } if (m_collidersList == null) { m_collidersList = new List<TCCollider>(); } else { m_collidersList.Clear(); } for (int i = 0; i < Tracker<TCCollider>.Count; i++) { TCCollider tCCollider = Tracker<TCCollider>.All[i]; if (LayerMask.op_Implicit(ColliderLayers) == (LayerMask.op_Implicit(ColliderLayers) | (1 << ((Component)tCCollider).gameObject.layer))) { m_collidersList.Add(tCCollider); } } if (m_collidersList.Count > MaxColliders) { if (m_colliderSort == null) { m_colliderSort = (TCCollider c1, TCCollider c2) => GetColliderPoints(c2).CompareTo(GetColliderPoints(c1)); } m_collidersList.Sort(m_colliderSort); } for (int j = 0; j < m_collidersList.Count; j++) { TCCollider tCCollider2 = m_collidersList[j]; if (j >= MaxColliders) { break; } int num = 1 << ((Component)tCCollider2).gameObject.layer; LayerMask colliderLayers = ColliderLayers; if ((((LayerMask)(ref colliderLayers)).value & num) > 0) { m_colliderReference[j] = tCCollider2; } } } [EditorBrowsable(EditorBrowsableState.Never)] protected override void Bind() { //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0647: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) DistributeColliders(); if (MaxColliders == 0 || m_collidersList.Count == 0) { return; } Vector3 val = Vector3.zero; Transform transform = ((Component)SystemComp).transform; if ((Object)(object)transform.parent != (Object)null) { val = transform.parent.position; } for (int i = 0; i < NumColliders; i++) { TCCollider tCCollider = m_colliderReference[i]; Collider collider = default(Collider); collider.Position = tCCollider.Position; collider.Radius = 0f; collider.BoxSize = Vector3.zero; Collider collider2 = collider; Transform transform2 = ((Component)tCCollider).transform; Vector3 localScale = transform2.localScale; float num = Mathf.Max(localScale.x, localScale.z); float num2 = Mathf.Max(Mathf.Max(localScale.x, localScale.y), localScale.z); float y = localScale.y; switch (tCCollider.shape) { case ColliderShape.PhysxShape: if ((Object)(object)tCCollider.SphereCollider != (Object)null) { collider2.Radius = tCCollider.SphereCollider.radius * num2; collider2.BoxSize = Vector3.zero; collider2.Vtype = 0u; } else if ((Object)(object)tCCollider.CapsuleCollider != (Object)null) { collider2.Radius = tCCollider.CapsuleCollider.radius * num; collider2.BoxSize = new Vector3(0f, Mathf.Max(0f, tCCollider.CapsuleCollider.height / 2f * y - collider2.Radius * 2f), 0f); collider2.Vtype = 1u; } else if ((Object)(object)tCCollider.BoxCollider != (Object)null) { collider2.Radius = 0.5f; collider2.BoxSize = Vector3.Scale(tCCollider.BoxCollider.size * 0.5f, localScale); collider2.BoxSize = new Vector3(Mathf.Max(0f, collider2.BoxSize.x - collider2.Radius), Mathf.Max(0f, collider2.BoxSize.y - collider2.Radius), Mathf.Max(0f, collider2.BoxSize.z - collider2.Radius)); collider2.Vtype = 2u; } break; case ColliderShape.RoundedBox: collider2.Radius = Mathf.Max(0.1f, tCCollider.rounding); collider2.BoxSize = Vector3.Scale(tCCollider.boxSize * 0.5f, localScale); collider2.BoxSize = new Vector3(Mathf.Max(0f, collider2.BoxSize.x - collider2.Radius), Mathf.Max(0f, collider2.BoxSize.y - collider2.Radius), Mathf.Max(0f, collider2.BoxSize.z - collider2.Radius)); collider2.Vtype = 2u; break; case ColliderShape.Hemisphere: collider2.Radius = 0.05f; collider2.BoxSize = new Vector3(tCCollider.radius.Max * num2, tCCollider.radius.Max * num2, tCCollider.radius.Max * num2); collider2.Vtype = 3u; break; case ColliderShape.Disc: { float num3 = (tCCollider.radius.IsConstant ? 0f : (tCCollider.radius.Min * num)); float num4 = tCCollider.radius.Max * num; collider2.Radius = Mathf.Max(0.1f, tCCollider.rounding); collider2.BoxSize = new Vector3(num3, tCCollider.discHeight / 2f * y - tCCollider.rounding, num4); switch (tCCollider.discType) { case DiscType.Full: collider2.Vtype = 4u; break; case DiscType.Half: collider2.Vtype = 5u; break; case DiscType.Quarter: collider2.Vtype = 6u; break; } break; } case ColliderShape.Terrain: { Terrain component = ((Component)tCCollider).GetComponent<Terrain>(); if ((Object)(object)component == (Object)null) { collider2.BoxSize = Vector3.zero; } else { TerrainData terrainData = component.terrainData; Vector3 heightmapScale = terrainData.heightmapScale; collider2.BoxSize = new Vector3(heightmapScale.x * (float)terrainData.heightmapResolution, heightmapScale.y, heightmapScale.z * (float)terrainData.heightmapResolution); } collider2.Vtype = 7u; break; } default: collider2.Vtype = 0u; break; } collider2.AxisX = transform2.right; collider2.AxisY = transform2.up; collider2.AxisZ = transform2.forward; float bounciness = 1.01f + Mathf.Lerp(0f, 0.98f, overrideBounciness ? Bounciness : tCCollider.Bounciness); collider2.Bounciness = bounciness; collider2.Velocity = tCCollider.InheritVelocity * 0.5f * tCCollider.Velocity; collider2.LifeLoss = tCCollider.ParticleLifeLoss * base.Emitter.Lifetime.Max * base.Manager.ParticleTimeDelta; collider2.IsInverse = (tCCollider.inverse ? 1u : 0u); float num5 = (overrideStickiness ? Stickiness : tCCollider.Stickiness); float stickiness = Mathf.Clamp01(1f - Mathf.Pow(num5, 0.05f / base.Manager.ParticleTimeDelta)); collider2.Stickiness = stickiness; switch (base.Manager.SimulationSpace) { case Space.Local: collider2.Position = transform.InverseTransformPoint(collider2.Position); collider2.AxisX = transform.InverseTransformDirection(collider2.AxisX); collider2.AxisY = transform.InverseTransformDirection(collider2.AxisY); collider2.AxisZ = transform.InverseTransformDirection(collider2.AxisZ); collider2.Velocity = transform.InverseTransformDirection(collider2.Velocity); break; case Space.Parent: { ref Vector3 position = ref collider2.Position; position -= val; break; } } m_colliderStruct[i] = collider2; } } internal void Dispatch() { if (NumColliders <= 0 || m_colliderReference == null) { return; } m_colliderBuffer.SetData((Array)m_colliderStruct); ComputeShader.SetBuffer(UpdateCollidersKernel, SID._Colliders, m_colliderBuffer); ComputeShader.SetTexture(UpdateCollidersKernel, SID._TerrainTexture, (Texture)(object)Texture2D.whiteTexture); bool flag = false; for (int i = 0; i < NumColliders; i++) { if (m_colliderReference[i].shape == ColliderShape.Terrain) { if (flag) { Debug.LogError((object)"You currently Cannot have multiple terrain colliders act on a particle system!"); break; } ComputeShader.SetTexture(UpdateCollidersKernel, SID._TerrainTexture, (Texture)(object)m_colliderReference[i].Heightmap); flag = true; } } base.Manager.BindPariclesToKernel(ComputeShader, UpdateCollidersKernel); if (base.Manager.DispatchCount > 0) { ComputeShader.Dispatch(UpdateCollidersKernel, base.Manager.DispatchCount, NumColliders, 1); } } private float GetColliderPoints(TCCollider collider) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (BaseColliders != null && BaseColliders.Contains(collider)) { return float.MaxValue; } if (!((Behaviour)collider).enabled) { return float.MinValue; } float num = 0f; if ((Object)(object)((Component)collider).transform.parent == (Object)(object)((Component)SystemComp).transform) { num += 10000f; } if (collider.shape == ColliderShape.Terrain) { num += 500000f; } float num2 = num; Vector3 val = ((Component)collider).transform.position - ((Component)SystemComp).transform.position; return num2 - ((Vector3)(ref val)).sqrMagnitude * 100f; } internal void OnDestroy() { Release(ref m_colliderBuffer); } } [Serializable] public class ParticleForceManager : ParticleComponent { private struct Force { public uint type; public uint attenType; public float force; public Vector3 axis; public float attenuation; public float minRadius; public float inwardForce; public float enclosingRadius; public Vector3 pos; public float radius; public Vector3 boxSize; public Vector3 axisX; public Vector3 axisY; public Vector3 axisZ; public Vector3 velocity; public uint vtype; public float turbulencePosFac; } private enum ForceTypeKernel { Normal, Turbulence, Count } private const int c_forceTypeKernelCount = 2; [SerializeField] private int _maxForces = 1; [SerializeField] private List<TCForce> _baseForces = new List<TCForce>(); public bool useBoidsFlocking; [Range(0f, 2f)] public float boidsPositionStrength = 0.5f; [Range(0f, 5f)] public float boidsVelocityStrength = 1f; [Range(0f, 5f)] public float boidsCenterStrength = 1f; private Comparison<TCForce> m_forceSort; private ComputeBuffer[] m_forcesBuffer; private TCParticlesBoidsFlock m_boidsFlock; private Force[][] m_forcesStruct; private TCForce[][] m_forcesReference; private int[] m_forcesCount; private List<TCForce> m_forcesList; [SerializeField] private LayerMask _forceLayers = LayerMask.op_Implicit(-1); public int MaxForces { get { return _maxForces; } set { _maxForces = value; } } public int NumForcesTotal => (m_forcesList != null) ? Mathf.Min(m_forcesList.Count, _maxForces) : 0; public List<TCForce> BaseForces => _baseForces; public LayerMask ForceLayers { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _forceLayers; } set { //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) _forceLayers = value; } } private void CreateBuffers() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (MaxForces == 0) { return; } for (int i = 0; i < 2; i++) { if (m_forcesBuffer[i] != null) { m_forcesBuffer[i].Release(); } m_forcesBuffer[i] = new ComputeBuffer(MaxForces, 124); m_forcesStruct[i] = new Force[MaxForces]; m_forcesReference[i] = new TCForce[MaxForces]; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override void Initialize() { m_forcesBuffer = (ComputeBuffer[])(object)new ComputeBuffer[2]; m_forcesCount = new int[2]; m_forcesStruct = new Force[2][]; m_forcesReference = new TCForce[2][]; CreateBuffers(); if (useBoidsFlocking) { CreateBoids(); } } internal void Update() { if (MaxForces != 0 && ((m_forcesBuffer[0] != null && m_forcesBuffer[0].count != MaxForces) || (m_forcesBuffer[1] != null && m_forcesBuffer[1].count != MaxForces))) { CreateBuffers(); } } private void CreateBoids() { m_boidsFlock = new TCParticlesBoidsFlock(base.Manager, this, ComputeShader); } [EditorBrowsable(EditorBrowsableState.Never)] protected override void Bind() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) DistributeForces(); if (MaxForces == 0 || NumForcesTotal == 0) { return; } Transform transform = ((Component)SystemComp).transform; Vector3 val = Vector3.zero; if ((Object)(object)transform.parent != (Object)null) { val = transform.parent.position; } for (int i = 0; i < 2; i++) { for (int j = 0; j < m_forcesCount[i]; j++) { Force force = m_forcesStruct[i][j]; TCForce tCForce = m_forcesReference[i][j]; Transform transform2 = ((Component)tCForce).transform; Vector3 position = transform2.position; force.type = (uint)tCForce.forceType; force.axisX = transform2.right; force.axisY = transform2.up; force.axisZ = transform2.forward; force.minRadius = -1f; force.attenuation = tCForce.Attenuation; switch (tCForce.shape) { case ForceShape.Sphere: force.radius = tCForce.radius.Max; if (tCForce.radius.IsConstant) { force.minRadius = -1f; } else { force.minRadius = tCForce.radius.Min * tCForce.radius.Min; } force.enclosingRadius = tCForce.radius.Max; force.boxSize = Vector3.zero; force.vtype = 0u; break; case ForceShape.Capsule: { Transform transform3 = ((Component)tCForce).transform; Vector3 localScale = transform3.localScale; float num2 = Mathf.Max(localScale.x, localScale.z); float num3 = tCForce.height / 2f * localScale.y - tCForce.radius.Max * num2; num3 = Mathf.Max(0f, num3); force.boxSize = new Vector3(0f, num3 * localScale.y, 0f); force.radius = tCForce.radius.Max; force.enclosingRadius = force.radius + tCForce.height / 2f * localScale.y; force.vtype = 1u; break; } case ForceShape.Box: force.radius = 0.1f; force.boxSize = tCForce.boxSize * 0.5f - new Vector3(0.1f, 0.1f, 0.1f); force.boxSize = Vector3.Scale(force.boxSize, transform2.localScale); force.enclosingRadius = Mathf.Max(new float[3] { tCForce.boxSize.x, tCForce.boxSize.y, tCForce.boxSize.z }) * 0.5f; force.vtype = 2u; force.attenuation = 0f; break; case ForceShape.Hemisphere: force.radius = 0.1f; force.boxSize = Vector3.Scale(new Vector3(tCForce.radius.Max, tCForce.radius.Max, tCForce.radius.Max), ((Component)tCForce).transform.localScale); force.enclosingRadius = tCForce.radius.Max; force.vtype = 3u; break; case ForceShape.Disc: { force.minRadius = -1f; force.vtype = (uint)tCForce.discType; force.radius = Mathf.Max(0.1f, tCForce.discRounding); float num = (tCForce.radius.IsConstant ? 0f : tCForce.radius.Min); float max = tCForce.radius.Max; force.boxSize = new Vector3(num, tCForce.discHeight / 2f - tCForce.discRounding, max); force.enclosingRadius = Mathf.Max(tCForce.discHeight / 2f, tCForce.radius.Max + tCForce.discRounding); switch (tCForce.discType) { case DiscType.Full: force.vtype = 4u; break; case DiscType.Half: force.vtype = 5u; break; case DiscType.Quarter: force.vtype = 6u; break; } break; } case ForceShape.Constant: force.radius = 0.1f; force.attenuation = 0f; force.enclosingRadius = -1f; force.vtype = 7u; break; } force.force = tCForce.power * base.Manager.ParticleTimeDelta; switch (tCForce.forceType) { case ForceType.Vector: if (tCForce.forceDirection != Vector3.zero) { if (tCForce.forceDirectionSpace == TCForce.ForceSpace.World) { force.axis = Vector3.Normalize(tCForce.forceDirection); } else { force.axis = ((Component)tCForce).transform.TransformDirection(Vector3.Normalize(tCForce.forceDirection)); } } break; case ForceType.Vortex: force.axis = tCForce.vortexAxis; force.inwardForce = tCForce.inwardForce / 1000f * base.Manager.ParticleTimeDelta * 60f; break; case ForceType.Turbulence: case ForceType.TurbulenceTexture: force.axis = tCForce.noiseExtents; break; default: force.axis = Vector3.zero; break; } if (tCForce.IsPrimaryForce) { force.velocity = tCForce.Velocity * tCForce.InheritVelocity; } else { force.velocity = Vector3.zero; } force.attenType = (uint)tCForce.attenuationType; force.turbulencePosFac = 1f - tCForce.smoothness; force.pos = position; switch (base.Manager.SimulationSpace) { case Space.Local: force.pos = transform.InverseTransformPoint(force.pos); force.axisX = transform.InverseTransformDirection(force.axisX); force.axisY = transform.InverseTransformDirection(force.axisY); force.axisZ = transform.InverseTransformDirection(force.axisZ); break; case Space.Parent: force.pos = position - val; break; } m_forcesStruct[i][j] = force; } } } private void DistributeForces() { //IL_0059: 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) if (m_forcesBuffer == null || MaxForces == 0) { return; } if (m_forcesList == null) { m_forcesList = new List<TCForce>(32); } else { m_forcesList.Clear(); } for (int i = 0; i < Tracker<TCForce>.Count; i++) { TCForce tCForce = Tracker<TCForce>.All[i]; if (LayerMask.op_Implicit(ForceLayers) == (LayerMask.op_Implicit(ForceLayers) | (1 << ((Component)tCForce).gameObject.layer))) { m_forcesList.Add(tCForce); } } if (m_forcesList.Count > MaxForces) { if (m_forceSort == null) { m_forceSort = (TCForce f1, TCForce f2) => GetForcePoints(f2).CompareTo(GetForcePoints(f1)); } m_forcesList.Sort(m_forceSort); } for (int j = 0; j < 2; j++) { m_forcesCount[j] = 0; } for (int k = 0; k < Mathf.Min(MaxForces, m_forcesList.Count); k++) { TCForce tCForce2 = m_forcesList[k]; int num = ((tCForce2.forceType == ForceType.Turbulence || tCForce2.forceType == ForceType.TurbulenceTexture) ? 1 : 0); m_forcesReference[num][m_forcesCount[num]] = tCForce2; m_forcesCount[num]++; } } internal void Dispatch() { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) if (useBoidsFlocking) { if (m_boidsFlock == null) { CreateBoids(); } m_boidsFlock.UpdateBoids(((Component)SystemComp).transform); } if (MaxForces == 0) { return; } if (m_forcesCount[0] > 0) { m_forcesBuffer[0].SetData((Array)m_forcesStruct[0]); ComputeShader.SetBuffer(UpdateForcesKernel, SID._Forces, m_forcesBuffer[0]); base.Manager.BindPariclesToKernel(ComputeShader, UpdateForcesKernel); if (base.Manager.DispatchCount > 0) { ComputeShader.Dispatch(UpdateForcesKernel, base.Manager.DispatchCount, m_forcesCount[0], 1); } } if (m_forcesCount[1] <= 0) { return; } m_forcesBuffer[1].SetData((Array)m_forcesStruct[1]); ComputeShader.SetBuffer(UpdateTurbulenceForcesKernel, SID._TurbulenceForces, m_forcesBuffer[1]); for (int i = 0; i < m_forcesCount[1]; i++) { TCForce tCForce = m_forcesReference[1][i]; if (!((Object)(object)tCForce.CurrentForceVolume == (Object)null)) { ComputeShader.SetTexture(UpdateTurbulenceForcesKernel, SID._TurbulenceTexture, tCForce.CurrentForceVolume); Matrix4x4 val = Matrix4x4.TRS(Vector3.zero, ((Component)tCForce).transform.rotation, Vector3.one); ComputeShader.SetMatrix(SID._TurbulenceRotation, val); ComputeShader.SetMatrix(SID._TurbulenceRotationInv, ((Matrix4x4)(ref val)).inverse); ComputeShader.SetInt("turbulenceKernelOffset", i); base.Manager.BindPariclesToKernel(ComputeShader, UpdateTurbulenceForcesKernel); if (base.Manager.DispatchCount > 0) { ComputeShader.Dispatch(UpdateTurbulenceForcesKernel, base.Manager.DispatchCount, 1, 1); } } } } private float GetForcePoints(TCForce force) { //IL_0080: 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_0095: 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) if (BaseForces != null && BaseForces.Contains(force)) { return float.MaxValue; } if (!((Behaviour)force).enabled) { return float.MinValue; } if ((Object)(object)((Component)force).transform.parent == (Object)(object)((Component)SystemComp).transform) { return float.MaxValue; } float num = force.power; Vector3 val = ((Component)force).transform.position - ((Component)SystemComp).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; switch (force.attenuationType) { case AttenuationType.Linear: case AttenuationType.EaseInOut: num *= 1f - magnitude / force.radius.Max * force.Attenuation; break; case AttenuationType.Divide: num = Mathf.Lerp(num, num / magnitude, force.Attenuation); break; } return Mathf.Abs(num); } internal void OnDestroy() { for (int i = 0; i < 2; i++) { ComputeBuffer[] forcesBuffer = m_forcesBuffer; if (((forcesBuffer != null) ? forcesBuffer[i] : null) != null) { Release(ref m_forcesBuffer[i]); } } if (m_boidsFlock != null) { m_boidsFlock.ReleaseBuffers(); } } } [Serializable] public class MinMax { public enum MinMaxMode { Constant, Between } [SerializeField] private float minProp; [SerializeField] private float maxProp = 1f; [SerializeField] private float valueProp; [SerializeField] private MinMaxMode modeProp; public MinMaxMode Mode { get { return modeProp; } set { if (IsConstant && value == MinMaxMode.Between) { minProp = valueProp; maxProp = valueProp; } modeProp = value; } } public float Min { get { return IsConstant ? valueProp : minProp; } set { if (IsConstant) { valueProp = value; } minProp = value; } } public float Max { get { return IsConstant ? valueProp : maxProp; } set { if (IsConstant) { valueProp = value; } maxProp = value; } } public float Value { get { if (IsConstant) { return valueProp; } return (Min + Max) / 2f; } set { if (IsConstant) { valueProp = value; return; } Min = value; Max = value; } } public bool IsConstant => Mode == MinMaxMode.Constant; public static MinMax Constant(float value) { return new MinMax { Mode = MinMaxMode.Constant, Value = value }; } } [Serializable] public class MinMaxRandom { public enum MinMaxMode { Constant, Curve, RandomBetween, RandomBetweenCurves } [SerializeField] private float minProp; [SerializeField] private float maxProp = 1f; [SerializeField] private float valueProp; public AnimationCurve minCurve = AnimationCurve.Linear(0f, 0f, 1f, 0f); public AnimationCurve maxCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); public AnimationCurve valueCurve = AnimationCurve.Linear(0f, 0f, 1f, 0f); public float t; [SerializeField] private MinMaxMode modeProp; private bool IsCurve => Mode == MinMaxMode.Curve || Mode == MinMaxMode.RandomBetweenCurves; public MinMaxMode Mode { get { return modeProp; } set { if (IsConstant && (value == MinMaxMode.RandomBetween || value == MinMaxMode.RandomBetweenCurves)) { minProp = valueProp; maxProp = valueProp; minCurve = valueCurve; maxCurve = valueCurve; } modeProp = value; } } public float Min { get { return Mode switch { MinMaxMode.Constant => valueProp, MinMaxMode.Curve => valueProp, MinMaxMode.RandomBetween => minProp, MinMaxMode.RandomBetweenCurves => minCurve.Evaluate(t), _ => 0f, }; } set { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (IsCurve) { minCurve.MoveKey(0, new Keyframe(0f, value)); } minProp = value; if (IsConstant) { valueProp = value; } } } public float Max { get { return Mode switch { MinMaxMode.Constant => valueProp, MinMaxMode.Curve => valueCurve.Evaluate(t), MinMaxMode.RandomBetween => maxProp, MinMaxMode.RandomBetweenCurves => maxCurve.Evaluate(t), _ => 0f, }; } set { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (IsCurve) { maxCurve.MoveKey(0, new Keyframe(0f, value)); } maxProp = value; if (IsConstant) { valueProp = value; } } } public float Value { get { if (IsConstant) { if (IsCurve) { return valueCurve.Evaluate(t); } return valueProp; } if (IsCurve) { return (minCurve.Evaluate(t) + maxCurve.Evaluate(t)) / 2f; } return (Min + Max) / 2f; } set { //IL_0023: Unknown result type (might be due to invalid IL or missing references) valueProp = value; minProp = value; maxProp = value; valueCurve.MoveKey(0, new Keyframe(0f, value)); } } public bool IsConstant => Mode == MinMaxMode.Constant || Mode == MinMaxMode.Curve; public static MinMaxRandom Constant(float value) { return new MinMaxRandom { Mode = MinMaxMode.Constant, Value = value }; } } public class TCShapeEmitTag : ScriptableObject { } [ExecuteInEditMode] [AddComponentMenu("TC Particles/Shape Emitter")] public class TCShapeEmitter : MonoBehaviour, ITracked { private int m_index = -1; public ParticleEmitterShape ShapeData = new ParticleEmitterShape(); public float EmissionRate; public ParticleEmitter.EmissionMethod EmissionType; public bool Emit = true; [NonSerialized] internal Vector3 PrevPos; [NonSerialized] internal Vector3 PrevSpeed; [SerializeField] private TCShapeEmitTag m_tag; private bool m_firstEmit; private float m_femit; public int Index { get { return m_index; } set { m_index = value; } } public TCShapeEmitTag Tag { get { return m_tag; } set { m_tag = value; } } private void Awake() { m_firstEmit = true; } private void OnEnable() { Tracker<TCShapeEmitter>.Register(this); } private void OnDisable() { Tracker<TCShapeEmitter>.Deregister(this); } public void BurstEmit(int particles) { if (((Behaviour)this).enabled) { m_femit += particles; } } public void BurstEmit(Vector3[] positions) { BurstEmit(positions.Select(delegate(Vector3 pos) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) ParticleProto result = default(ParticleProto); result.Position = pos; return result; }).ToArray(), useColor: false, useSize: false, useVelocity: false); } public void BurstEmit(ParticleProto[] prototypes, bool useColor = true, bool useSize = true, bool useVelocity = true, bool usePosition = true) { BurstEmit(prototypes, prototypes.Length, useColor, useSize, useVelocity, usePosition); } public void BurstEmit(ParticleProto[] prototypes, int count, bool useColor = true, bool useSize = true, bool useVelocity = true, bool usePosition = true) { if (((Behaviour)this).enabled) { ShapeData.SetPrototypeEmission(prototypes, count, useColor, useSize, useVelocity, usePosition); m_femit += count; } } public bool LinksToTag(TCShapeEmitTag emitTag) { return (Object)(object)emitTag == (Object)(object)m_tag; } internal int TickEmission(TCParticleSystem system) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Vector3 emitPos = ParticleEmitter.GetEmitPos(system, ((Component)this).transform); if (m_firstEmit) { PrevPos = emitPos; PrevSpeed = Vector3.zero; m_firstEmit = false; } if (EmissionType == ParticleEmitter.EmissionMethod.PerSecond) { m_femit += system.Manager.ParticleTimeDelta * EmissionRate; } else { Vector3 val = emitPos; Vector3 val2 = val - PrevPos; m_femit += ((Vector3)(ref val2)).magnitude * EmissionRate; } int num = Mathf.FloorToInt(m_femit); m_femit -= num; return num; } private void OnDrawGizmosSelected() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; Vector3 position = transform.position; Gizmos.DrawIcon(position, "TCParticles.png", true); Matrix4x4 matrix = Matrix4x4.TRS(position, transform.rotation, transform.localScale); Gizmos.matrix = matrix; if (ShapeData.shape == EmitShapes.Box) { Gizmos.DrawWireCube(Vector3.zero, ShapeData.cubeSize); } } } [Serializable] public class ParticleEmitter : ParticleComponent { public enum EmissionMethod { PerSecond, PerUnit } [Serializable] public class Burst { public int amount; public float time; public float life; } private struct BindSettings { public int Offset; public int Count; } [EditorBrowsable(EditorBrowsableState.Never)] public delegate void OnParticleEvent(ComputeShader shader, int kern); public delegate void EmissionCallbackCB(int emittedCount); [SerializeField] private ParticleEmitterShape pes = new ParticleEmitterShape(); [SerializeField] private MinMaxRandom _speed = MinMaxRandom.Constant(0f); [SerializeField] private MinMaxRandom _energy = MinMaxRandom.Constant(3f); [SerializeField] private MinMaxRandom _size = MinMaxRandom.Constant(0.5f); [SerializeField] private MinMaxRandom _rotation = MinMaxRandom.Constant(0f); [SerializeField] private float _angularVelocity; [SerializeField] private Vector3Curve _constantForce = Vector3Curve.Zero(); [SerializeField] private float _emissionRate = 100f; [SerializeField] private EmissionMethod m_emissionType; [SerializeField] private AnimationCurve _sizeOverLifetime = AnimationCurve.Linear(0f, 1f, 1f, 1f); [SerializeField] private Vector3Curve _velocityOverLifetime = Vector3Curve.Zero(); private Texture2D m_lifetimeTexture; [SerializeField] private bool emit = true; [SerializeField] [Range(0f, 1f)] private float _inheritVelocity; private bool m_doSizeOverLifetime; [SerializeField] private TCShapeEmitTag m_emitTag; [SerializeField] private List<Burst> bursts = new List<Burst>(); private readonly Queue<Burst> m_burstsDone = new Queue<Burst>(100); private BindSettings m_currentEmitBind; private ParticleEmitterData[] m_emitSet; private Vector3 m_emitPrevPos; private Vector3 m_emitPrevSpeed; private Vector3 m_prevPosition; private Vector3 m_velocity = Vector3.zero; private Quaternion m_lastRot; private Vector3 m_lastScale; private Matrix4x4 m_emitMatrix; private Matrix4x4 m_emitRotationMatrix; private ComputeBuffer m_emitBuffer; private ComputeBuffer m_dummyBuffer; private float m_femit; private const int c_texDim = 128; private static readonly Color[] Colors = (Color[])(object)new Color[128]; public EmissionCallbackCB OnEmissionCallback; public EmitShapes Shape { get { return pes.shape; } set { pes.shape = value; } } public MinMax Radius => pes.radius; public Vector3 CubeSize { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return pes.cubeSize; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) pes.cubeSize = value; } } public Mesh EmitMesh { get { return pes.emitMesh; } set { pes.emitMesh = value; } } public Texture MeshTexture { get { return pes.texture; } set { pes.texture = value; } } public float ConeAngle { get { return pes.coneAngle; } set { pes.coneAngle = value; } } public float ConeHeight { get { return pes.coneHeight; } set { pes.coneHeight = value; } } public float ConeRadius { get { return pes.coneRadius; } set { pes.coneRadius = value; } } public float RingOuterRadius { get { return pes.ringOuterRadius; } set { pes.ringOuterRadius = value; } } public float RingRadius { get { return pes.ringRadius; } set { pes.ringRadius = value; } } public float LineLength { get { return pes.lineLength; } set { pes.lineLength = value; } } public MinMaxRandom Speed => _speed; [Obsolete("Obsolete: Use Lifetime instead.")] public MinMaxRandom Energy => _energy; public MinMaxRandom Lifetime { get { return _energy; } set { _energy = value; } } public MinMaxRandom Size { get { return _size; } set { _size = value; } } public MinMaxRandom Rotation => _rotation; public float AngularVelocity { get { return _angularVelocity; } set { _angularVelocity = value; } } public Vector3Curve ConstantForce { get { return _constantForce; } set { _constantForce = value; } } public float EmissionRate { get { return _emissionRate; } set { _emissionRate = value; } } public EmissionMethod EmissionType { get { return m_emissionType; } set { m_emissionType = value; } } public AnimationCurve SizeOverLifetime { get { return _sizeOverLifetime; } set { _sizeOverLifetime = value; UpdateSizeOverLifetime(); } } public float StartSizeMultiplier { get { return _sizeOverLifetime.Evaluate(0f); } set { //IL_000e: Unknown result type (might be due to invalid IL or missing references) _sizeOverLifetime.MoveKey(0, new Keyframe(0f, value)); UpdateSizeOverLifetime(); } } public Vector3Curve VelocityOverLifetime { get { return _velocityOverLifetime; } set { _velocityOverLifetime = value; UpdateVelocityOverLifetime(); } } public bool DoEmit { get { return emit; } set { emit = value; } } public Color StartColor => base.Renderer.ColorOverLifetime.Evaluate(0f); public float InheritVelocity { get { return _inheritVelocity; } set { _inheritVelocity = value; } } public StartDirection StartDirectionType { get { return pes.startDirectionType; } set { pes.startDirectionType = value; } } public Vector3 StartDirectionVector { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return pes.startDirectionVector; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) pes.startDirectionVector = value; } } public float StartDirectionRandomAngle { get { return pes.startDirectionRandomAngle; } set { pes.startDirectionRandomAngle = value; } } public EmitShapes EmitShape { get { return pes.shape; } set { pes.shape = value; } } public ParticleEmitterShape ShapeData => pes; public Texture2D LifetimeTexture => m_lifetimeTexture; public bool DoSizeOverLifetime => m_doSizeOverLifetime; public int ParticleCount { get; private set; } public int Offset { get; private set; } public TCShapeEmitTag Tag { get { return m_emitTag; } set { m_emitTag = value; } } public PointCloudData PointCloud { get { return pes.pointCloud; } set { pes.pointCloud = value; } } public event OnParticleEvent OnEmissionBind; public void UpdateCacheForEmitMesh() {