public void SpawnOnRay(Ray ray, int mask, float length = 0.5f, Vector3 forward = null, float speed = 0f) { RaycastHit raycastHit; if (!GamePhysics.Trace(ray, 0f, out raycastHit, length, mask, QueryTriggerInteraction.UseGlobal)) { Effect.client.Run(this.DefaultEffect.resourcePath, ray.origin, ray.direction * -1f, forward); if (this.DefaultSoundDefinition != null) { this.PlaySound(this.DefaultSoundDefinition, raycastHit.point, speed); } return; } WaterLevel.WaterInfo waterInfo = WaterLevel.GetWaterInfo(ray.origin); if (waterInfo.isValid) { Vector3 vector3 = new Vector3(ray.origin.x, WaterSystem.GetHeight(ray.origin), ray.origin.z); MaterialEffect.Entry waterEntry = this.GetWaterEntry(); if (this.submergedWaterDepth > 0f && waterInfo.currentDepth >= this.submergedWaterDepth) { waterEntry = this.submergedWaterEntry; } else if (this.deepWaterDepth > 0f && waterInfo.currentDepth >= this.deepWaterDepth) { waterEntry = this.deepWaterEntry; } if (waterEntry == null) { return; } Effect.client.Run(waterEntry.Effect.resourcePath, vector3, Vector3.up, new Vector3()); if (waterEntry.SoundDefinition != null) { this.PlaySound(waterEntry.SoundDefinition, vector3, speed); } return; } PhysicMaterial materialAt = raycastHit.collider.GetMaterialAt(raycastHit.point); MaterialEffect.Entry entryFromMaterial = this.GetEntryFromMaterial(materialAt); if (entryFromMaterial != null) { Effect.client.Run(entryFromMaterial.Effect.resourcePath, raycastHit.point, raycastHit.normal, forward); if (entryFromMaterial.SoundDefinition != null) { this.PlaySound(entryFromMaterial.SoundDefinition, raycastHit.point, speed); } } else { Effect.client.Run(this.DefaultEffect.resourcePath, raycastHit.point, raycastHit.normal, forward); if (this.DefaultSoundDefinition != null) { this.PlaySound(this.DefaultSoundDefinition, raycastHit.point, speed); return; } } }
public void SpawnOnRay(Ray ray, int mask, float length = 0.5f, Vector3 forward = default(Vector3), float speed = 0f) { RaycastHit hitInfo; if (!GamePhysics.Trace(ray, 0f, out hitInfo, length, mask)) { Effect.client.Run(DefaultEffect.resourcePath, ray.origin, ray.direction * -1f, forward); if (DefaultSoundDefinition != null) { PlaySound(DefaultSoundDefinition, hitInfo.point, speed); } return; } WaterLevel.WaterInfo waterInfo = WaterLevel.GetWaterInfo(ray.origin); if (waterInfo.isValid) { Vector3 vector = new Vector3(ray.origin.x, WaterSystem.GetHeight(ray.origin), ray.origin.z); Entry waterEntry = GetWaterEntry(); if (submergedWaterDepth > 0f && waterInfo.currentDepth >= submergedWaterDepth) { waterEntry = submergedWaterEntry; } else if (deepWaterDepth > 0f && waterInfo.currentDepth >= deepWaterDepth) { waterEntry = deepWaterEntry; } if (waterEntry != null) { Effect.client.Run(waterEntry.Effect.resourcePath, vector, Vector3.up); if (waterEntry.SoundDefinition != null) { PlaySound(waterEntry.SoundDefinition, vector, speed); } } return; } PhysicMaterial materialAt = ColliderEx.GetMaterialAt(hitInfo.collider, hitInfo.point); Entry entryFromMaterial = GetEntryFromMaterial(materialAt); if (entryFromMaterial == null) { Effect.client.Run(DefaultEffect.resourcePath, hitInfo.point, hitInfo.normal, forward); if (DefaultSoundDefinition != null) { PlaySound(DefaultSoundDefinition, hitInfo.point, speed); } } else { Effect.client.Run(entryFromMaterial.Effect.resourcePath, hitInfo.point, hitInfo.normal, forward); if (entryFromMaterial.SoundDefinition != null) { PlaySound(entryFromMaterial.SoundDefinition, hitInfo.point, speed); } } }
public static float GetWaterDepth(Vector3 pos) { float waterInfo; using (TimeWarning timeWarning = TimeWarning.New("WaterLevel.GetWaterDepth", 0.1f)) { waterInfo = WaterLevel.GetWaterInfo(pos).currentDepth; } return(waterInfo); }
public static bool Test(Vector3 pos) { bool waterInfo; using (TimeWarning timeWarning = TimeWarning.New("WaterLevel.Test", 0.1f)) { waterInfo = WaterLevel.GetWaterInfo(pos).isValid; } return(waterInfo); }
public static float Factor(Bounds bounds) { using (TimeWarning.New("WaterLevel.Factor", 0.1f)) { if (Vector3.op_Equality(((Bounds) ref bounds).get_size(), Vector3.get_zero())) { ((Bounds) ref bounds).set_size(new Vector3(0.1f, 0.1f, 0.1f)); } WaterLevel.WaterInfo waterInfo = WaterLevel.GetWaterInfo(bounds); return(waterInfo.isValid ? Mathf.InverseLerp((float)((Bounds) ref bounds).get_min().y, (float)((Bounds) ref bounds).get_max().y, waterInfo.surfaceLevel) : 0.0f); } }
public static float Factor(Bounds bounds) { float single; using (TimeWarning timeWarning = TimeWarning.New("WaterLevel.Factor", 0.1f)) { if (bounds.size == Vector3.zero) { bounds.size = new Vector3(0.1f, 0.1f, 0.1f); } WaterLevel.WaterInfo waterInfo = WaterLevel.GetWaterInfo(bounds); single = (waterInfo.isValid ? Mathf.InverseLerp(bounds.min.y, bounds.max.y, waterInfo.surfaceLevel) : 0f); } return(single); }
public static float GetOverallWaterDepth(Vector3 pos) { using (TimeWarning.New("WaterLevel.GetOverallWaterDepth", 0.1f)) return(WaterLevel.GetWaterInfo(pos).overallDepth); }
public static bool Test(Vector3 pos) { using (TimeWarning.New("WaterLevel.Test", 0.1f)) return(WaterLevel.GetWaterInfo(pos).isValid); }