using System; using System.Collections.Generic; using UnityEngine; // Token: 0x020000E6 RID: 230 [RequireComponent(typeof(LineRenderer))] public class LineWaveCollider : MonoBehaviour { // Token: 0x06001510 RID: 5392 RVA: 0x001965EC File Offset: 0x001947EC private void Awake() { this.lrComp = base.GetComponent(); this.lrComp.useWorldSpace = false; this.lrComp.material = this.traceMaterial; this.linePositions = new List(); this.colliders = new List(); this.Colliders = new GameObject("Colliders"); this.Colliders.transform.parent = base.transform; this.colliderGO = new GameObject("col"); this.colliderGO.transform.position = base.transform.position; this.colliderGO.transform.parent = this.Colliders.transform; } // Token: 0x06001511 RID: 5393 RVA: 0x001966A4 File Offset: 0x001948A4 private void Update() { this.lrComp.startWidth = this.traceWidth; this.lrComp.endWidth = this.traceWidth; base.gameObject.transform.localScale = Vector3.one; if (this.targetOptional != null) { this.origin = LineWaveCollider.Origins.Start; this.lengh = (base.transform.position - this.targetOptional.transform.position).magnitude; base.transform.LookAt(this.targetOptional.transform.position); base.transform.Rotate(this.altRotation, -90f, 0f); } if (this.warpRandom <= 0f) { this.warpRandom = 0f; } if (this.size <= 2) { this.size = 2; } this.lrComp.positionCount = this.size; if (this.ampByFreq) { this.ampT = Mathf.Sin(this.freq * 3.1415927f); } else { this.ampT = 1f; } this.ampT *= this.amp; if (this.warp && this.warpInvert) { this.ampT /= 2f; } foreach (GameObject gameObject in this.colliders) { Object.Destroy(gameObject); } this.linePositions.Clear(); this.colliders.Clear(); for (int i = 0; i < this.size; i++) { this.angle = 6.2831855f / (float)this.size * (float)i * this.freq; if (this.centered) { this.angle -= this.freq * 3.1415927f; if (this.centCrest) { this.angle -= 1.5707964f; } } else { this.centCrest = false; } this.walkShift -= (double)(this.walkAuto / (float)this.size * Time.deltaTime); this.angle += (float)this.walkShift - this.walkManual; this.sinAngle = Mathf.Sin(this.angle); if (this.spiral) { this.sinAngleZ = Mathf.Cos(this.angle); } else { this.sinAngleZ = 0f; } if (this.origin == LineWaveCollider.Origins.Start) { this.start = 0f; } else { this.start = this.lengh / 2f; } if (this.warp) { this.warpT = (float)(this.size - i); this.warpT /= (float)this.size; this.warpT = Mathf.Sin(3.1415927f * this.warpT * (this.warpRandom + 1f)); if (this.warpInvert) { this.warpT = 1f / this.warpT; } this.linePositions.Add(new Vector3(this.lengh / (float)this.size * (float)i - this.start, this.sinAngle * this.ampT * this.warpT, this.sinAngleZ * this.ampT * this.warpT)); } else { this.linePositions.Add(new Vector3(this.lengh / (float)this.size * (float)i - this.start, this.sinAngle * this.ampT, this.sinAngleZ * this.ampT)); this.warpInvert = false; } if (i == 1) { this.posVtx2 = new Vector3(this.lengh / (float)this.size * (float)i - this.start, this.sinAngle * this.ampT * this.warpT, this.sinAngleZ * this.ampT * this.warpT); } if (i == this.size - 1) { this.posVtxSizeMinusOne = new Vector3(this.lengh / (float)this.size * (float)i - this.start, this.sinAngle * this.ampT * this.warpT, this.sinAngleZ * this.ampT * this.warpT); } } LineWaveCollider.WaveColliders waveColliders = this.waveCollider; if (waveColliders != LineWaveCollider.WaveColliders.Box) { if (waveColliders == LineWaveCollider.WaveColliders.Sphere) { this.colType = typeof(SphereCollider); } } else { this.colType = typeof(BoxCollider); } if (this.colliderGO.GetComponent(this.colType) == null) { Object.Destroy(this.colliderGO.GetComponent(typeof(Collider))); this.colliderGO.AddComponent(this.colType); } this.colliderGO.SetActive(true); this.colliderGO.transform.localScale = new Vector3(this.colliderSize, this.colliderSize, this.colliderSize); this.collidersGap = Mathf.Clamp(this.collidersGap, 1, 20); for (int j = 0; j < this.linePositions.Count; j++) { this.lrComp.SetPosition(j, this.linePositions[j]); if (j % this.collidersGap == 0) { GameObject gameObject2 = Object.Instantiate(this.colliderGO); gameObject2.transform.parent = this.Colliders.transform; if (this.targetOptional) { gameObject2.transform.position = Vector3.Lerp(base.gameObject.transform.position, this.targetOptional.transform.position, (float)j / (float)this.linePositions.Count); gameObject2.transform.Translate(0f, this.linePositions[j].y, this.linePositions[j].z, base.gameObject.transform); } else { gameObject2.transform.position = base.gameObject.transform.position; gameObject2.transform.Translate(this.linePositions[j].x, this.linePositions[j].y, this.linePositions[j].z, base.gameObject.transform); } gameObject2.transform.rotation = base.gameObject.transform.rotation; this.colliders.Add(gameObject2); } } this.colliderGO.SetActive(false); if (this.warpInvert) { this.lrComp.SetPosition(0, this.posVtx2); this.lrComp.SetPosition(this.size - 1, this.posVtxSizeMinusOne); } } // Token: 0x040024CA RID: 9418 private float ampT; // Token: 0x040024CB RID: 9419 public Material traceMaterial; // Token: 0x040024CC RID: 9420 public float traceWidth = 0.3f; // Token: 0x040024CD RID: 9421 public GameObject targetOptional; // Token: 0x040024CE RID: 9422 public float altRotation; // Token: 0x040024CF RID: 9423 public LineWaveCollider.Origins origin; // Token: 0x040024D0 RID: 9424 public int size = 300; // Token: 0x040024D1 RID: 9425 public float lengh = 10f; // Token: 0x040024D2 RID: 9426 public float freq = 2.5f; // Token: 0x040024D3 RID: 9427 public float amp = 1f; // Token: 0x040024D4 RID: 9428 public bool ampByFreq; // Token: 0x040024D5 RID: 9429 public bool centered = true; // Token: 0x040024D6 RID: 9430 public bool centCrest = true; // Token: 0x040024D7 RID: 9431 public bool warp = true; // Token: 0x040024D8 RID: 9432 public bool warpInvert; // Token: 0x040024D9 RID: 9433 public float warpRandom; // Token: 0x040024DA RID: 9434 public float walkManual; // Token: 0x040024DB RID: 9435 public float walkAuto; // Token: 0x040024DC RID: 9436 public bool spiral; // Token: 0x040024DD RID: 9437 private float start; // Token: 0x040024DE RID: 9438 private float warpT; // Token: 0x040024DF RID: 9439 private float angle; // Token: 0x040024E0 RID: 9440 private float sinAngle; // Token: 0x040024E1 RID: 9441 private float sinAngleZ; // Token: 0x040024E2 RID: 9442 private double walkShift; // Token: 0x040024E3 RID: 9443 private Vector3 posVtx2; // Token: 0x040024E4 RID: 9444 private Vector3 posVtxSizeMinusOne; // Token: 0x040024E5 RID: 9445 private LineRenderer lrComp; // Token: 0x040024E6 RID: 9446 private List linePositions; // Token: 0x040024E7 RID: 9447 public LineWaveCollider.WaveColliders waveCollider; // Token: 0x040024E8 RID: 9448 private List colliders; // Token: 0x040024E9 RID: 9449 private GameObject Colliders; // Token: 0x040024EA RID: 9450 private GameObject colliderGO; // Token: 0x040024EB RID: 9451 private Type colType; // Token: 0x040024EC RID: 9452 public float colliderSize = 0.2f; // Token: 0x040024ED RID: 9453 public int collidersGap = 5; // Token: 0x02000264 RID: 612 public enum Origins { // Token: 0x040034A6 RID: 13478 Start, // Token: 0x040034A7 RID: 13479 Middle } // Token: 0x02000265 RID: 613 public enum WaveColliders { // Token: 0x040034A9 RID: 13481 Box, // Token: 0x040034AA RID: 13482 Sphere } }