private void CreateDebugTextures() { LinearEmitter.lineTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); LinearEmitter.lineTexture.SetPixel(0, 0, Color.white); LinearEmitter.lineTexture.Apply(); LinearEmitter.occludedLineTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); LinearEmitter.occludedLineTexture.SetPixel(0, 0, Color.black); LinearEmitter.occludedLineTexture.Apply(); LinearEmitter.occluderBorderTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); LinearEmitter.occluderBorderTexture.SetPixel(0, 0, new Color(1f, 1f, 1f, 0.25f)); LinearEmitter.occluderBorderTexture.Apply(); LinearEmitter.occluderCentreTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false); LinearEmitter.occluderCentreTexture.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.25f)); LinearEmitter.occluderCentreTexture.Apply(); LinearEmitter.sourceTexture = new Texture2D(10, 10, TextureFormat.ARGB32, false); FMOD_Listener.Fill(LinearEmitter.sourceTexture, new Color(0f, 0f, 0f, 0f)); LinearEmitter.DrawCross(LinearEmitter.sourceTexture, new Color(1f, 1f, 1f, 0.5f)); LinearEmitter.sourceTexture.Apply(); LinearEmitter.pointTexture = new Texture2D(5, 5, TextureFormat.ARGB32, false); FMOD_Listener.Fill(LinearEmitter.pointTexture, new Color(1f, 1f, 1f, 0.5f)); Color color = new Color(1f, 1f, 1f, 0.25f); LinearEmitter.pointTexture.SetPixel(0, 0, color); LinearEmitter.pointTexture.SetPixel(0, 4, color); LinearEmitter.pointTexture.SetPixel(4, 0, color); LinearEmitter.pointTexture.SetPixel(4, 4, color); LinearEmitter.pointTexture.Apply(); LinearEmitter.occludedPointTexture = new Texture2D(5, 5, TextureFormat.ARGB32, false); FMOD_Listener.Fill(LinearEmitter.occludedPointTexture, new Color(0f, 0f, 0f, 0.5f)); color = new Color(0f, 0f, 0f, 0.25f); LinearEmitter.occludedPointTexture.SetPixel(0, 0, color); LinearEmitter.occludedPointTexture.SetPixel(0, 4, color); LinearEmitter.occludedPointTexture.SetPixel(4, 0, color); LinearEmitter.occludedPointTexture.SetPixel(4, 4, color); LinearEmitter.occludedPointTexture.Apply(); }
private void UpdateSource(LinearEmitter.Source source) { this.OccludeSegments(source); ATTRIBUTES_3D attributes; attributes.position = source.position.toFMODVector(); attributes.forward = base.transform.forward.toFMODVector(); attributes.up = base.transform.up.toFMODVector(); attributes.velocity = Vector3.zero.toFMODVector(); UnityUtil.ERRCHECK(source.eventInstance.set3DAttributes(attributes)); if (this.windParameterIndex >= 0 && TheForestAtmosphere.Instance != null) { UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.windParameterIndex, TheForestAtmosphere.Instance.WindIntensity)); } if (this.rainParameterIndex >= 0) { UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.rainParameterIndex, (!Scene.WeatherSystem.Raining) ? 0f : 1f)); } this.SetSourceParameterValues(source); }
private void SetSegmentFlag(int index, LinearEmitter.SegmentFlags flagToSet, bool value) { this.segmentFlags[index] = ((!value) ? (this.segmentFlags[index] & ~flagToSet) : (this.segmentFlags[index] | flagToSet)); }
private void SetSourceParameterValues(LinearEmitter.Source source) { if (this.parameters != null) { float closestT = this.segments[source.segment].closestT; int segment = source.segment; int index = (source.segment + 1) % this.points.Count; for (int i = 0; i < this.parameters.Count; i++) { if (this.parameters[i].index >= 0) { float num = this.parameters[i].values[segment]; float num2 = this.parameters[i].values[index]; float value = num + (num2 - num) * closestT; UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.parameters[i].index, value)); } } } }
private void OccludeSegments(LinearEmitter.Source occluder) { if (this.audibleSegments.Count == 0) { return; } Vector3 closestPoint = this.segments[occluder.segment].closestPoint; Vector3 v = closestPoint - LocalPlayer.Transform.position; float sqrMagnitude = v.sqrMagnitude; v.y = 0f; float num = -45f; Vector3 rhs = v.RotateY(num); Vector3 rhs2 = v.RotateY(-num); int i = 0; while (i < this.audibleSegments.Count) { int index = this.audibleSegments[i]; LinearEmitter.Segment segment = this.segments[index]; bool flag = false; if (segment.sqrDistance >= sqrMagnitude) { Vector3 lhs = segment.closestPoint - LocalPlayer.Transform.position; lhs.y = 0f; if (Vector3.Dot(lhs, rhs) >= 0f && Vector3.Dot(lhs, rhs2) >= 0f) { this.SetSegmentOccluded(index, true); int index2 = this.audibleSegments.Count - 1; this.audibleSegments[i] = this.audibleSegments[index2]; this.audibleSegments.RemoveAt(index2); flag = true; } } if (!flag) { i++; } } }