internal Instance(Transform parent, Vector3 offset, EngineSoundLoop loop) { this.parent = parent; this.loop = loop; Type[] components = new Type[] { typeof(EngineSoundLoopPlayer) }; GameObject go = new GameObject("_EnginePlayer", components); this.player = go.GetComponent <EngineSoundLoopPlayer>(); this.player.instance = this; Setup(go, ref this.D, ref this.flags, 1, loop._dUpper, 1f); Setup(go, ref this.F, ref this.flags, 2, loop._fMidHigh, 1f); Setup(go, ref this.E, ref this.flags, 4, loop._eMidLow, 1f); Setup(go, ref this.L, ref this.flags, 8, loop._lLower, 1f); Setup(go, ref this.K, ref this.flags, 0x10, loop._kPassing, 0f); this._lastVolumeFactor = this._lastClampedThrottle = this._lastSinerp = this._lastPitchFactor = float.NegativeInfinity; this._lastVolumeFactorClamp = -128; this._masterVolume = 1f; this._pitch = loop._idleShiftUp.lowVolume; this._shiftTime = -3000f; this._speedFactor = this._dVol = this._fVol = this._eVol = this._kVol = this._throttle = 0f; this._gear = 0; Transform transform = go.transform; transform.parent = parent; transform.localPosition = offset; transform.localRotation = Quaternion.identity; }
internal Instance(Transform parent, Vector3 offset, EngineSoundLoop loop) { this.parent = parent; this.loop = loop; GameObject gameObject = new GameObject("_EnginePlayer", new Type[] { typeof(EngineSoundLoopPlayer) }); this.player = gameObject.GetComponent <EngineSoundLoopPlayer>(); this.player.instance = this; EngineSoundLoop.Instance.Setup(gameObject, ref this.D, ref this.flags, 1, loop._dUpper, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.F, ref this.flags, 2, loop._fMidHigh, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.E, ref this.flags, 4, loop._eMidLow, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.L, ref this.flags, 8, loop._lLower, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.K, ref this.flags, 16, loop._kPassing, 0f); float single = Single.NegativeInfinity; float single1 = single; this._lastPitchFactor = single; float single2 = single1; single1 = single2; this._lastSinerp = single2; float single3 = single1; single1 = single3; this._lastClampedThrottle = single3; this._lastVolumeFactor = single1; this._lastVolumeFactorClamp = -128; this._masterVolume = 1f; this._pitch = loop._idleShiftUp.lowVolume; this._shiftTime = -3000f; float single4 = 0f; single1 = single4; this._throttle = single4; float single5 = single1; single1 = single5; this._kVol = single5; float single6 = single1; single1 = single6; this._eVol = single6; float single7 = single1; single1 = single7; this._fVol = single7; float single8 = single1; single1 = single8; this._dVol = single8; this._speedFactor = single1; this._gear = 0; Transform transforms = gameObject.transform; transforms.parent = parent; transforms.localPosition = offset; transforms.localRotation = Quaternion.identity; }
private void UPDATE(float speedFactor, float throttle) { bool flag; bool flag5; bool flag6; byte num4; bool flag7; float num8; if (throttle != this._throttle) { this._throttle = throttle; flag = true; } else { flag = false; } float num = this._pitch; float num2 = this._volume; float num3 = this._speedFactor; bool doPitchAdjust = false; bool doVolumeAdjust = false; bool flag4 = !(speedFactor == num3); if (flag4) { this._speedFactor = speedFactor; } if ((this.flags & 0x100) == 0x100) { flag5 = flag6 = this.UPDATE_SHIFTING(ref doPitchAdjust, ref doVolumeAdjust); } else { flag5 = true; flag6 = false; } if (!flag5) { goto Label_02FF; } Label_0085: if (flag4 || flag6) { int num5 = this.loop._topGear; this._lastSinerp = EngineSoundLoop.Sinerp(0f, (float)num5, speedFactor); int num6 = (int)this._lastSinerp; if (num6 == this._gear) { flag7 = false; num4 = (num6 != num5) ? this._gear : ((byte)(num5 - 1)); } else if (num6 < this._gear) { if (this._gear > 0) { if (this._gear == num5) { this._gear = (byte)(this._gear - 1); flag7 = false; num4 = this._gear; } else { flag7 = true; num4 = (byte)(this._gear - 1); } } else { flag7 = false; num4 = this._gear; } } else if ((this._gear < 0xff) && (this._gear < num5)) { if (this._gear < (num5 - 1)) { flag7 = true; num4 = (byte)(this._gear + 1); } else { flag7 = false; num4 = this._gear; this._gear = (byte)(this._gear + 1); } } else { flag7 = false; num4 = this._gear; } } else { flag7 = false; num4 = (this._gear != this.loop._topGear) ? this._gear : ((byte)(this._gear - 1)); } float num7 = this._lastSinerp - num4; if (num7 == 0f) { num8 = 0f; } else if (throttle >= 0.5f) { num8 = num7; } else if (throttle <= 0f) { num8 = num7 * 0.3f; } else { num8 = num7 * (0.3f + (throttle * 0.7f)); } if (flag7) { if (num4 > this._gear) { this.flags = (ushort)(this.flags | 0x300); } else { this.flags = (ushort)(this.flags | 0x100); } this._lastPitchFactor = num8; this._shiftTime = Time.time; if (!(flag6 = this.UPDATE_SHIFTING(ref doPitchAdjust, ref doVolumeAdjust))) { goto Label_02FF; } goto Label_0085; } if ((num8 != this._lastPitchFactor) || flag6) { this._lastPitchFactor = num8; this.loop.GearLerp(num4, num8, ref this._pitch, ref doPitchAdjust, ref this._volume, ref doVolumeAdjust); } Label_02FF: if (doVolumeAdjust && (this._volume != num2)) { this.UPDATE_PITCH_AND_OR_THROTTLE_VOLUME(); } else if (flag) { this.UPDATE_THROTTLE_VOLUME(); } if (flag4) { this.UPDATE_PASSING_VOLUME(); } if (doPitchAdjust && (this._pitch != num)) { this.UPDATE_RATES(); } }
private static void Setup(GameObject go, ref AudioSource source, ref ushort flags, ushort flag, EngineSoundLoop.Phrase phrase, float volumeScalar) { if (phrase == null || !phrase.clip) { return; } source = go.AddComponent<AudioSource>(); source.playOnAwake = false; source.loop = true; source.clip = phrase.clip; source.volume = phrase.volume * volumeScalar; source.dopplerLevel = 0f; flags = (ushort)(flags | flag); }
internal Instance(Transform parent, Vector3 offset, EngineSoundLoop loop) { this.parent = parent; this.loop = loop; GameObject gameObject = new GameObject("_EnginePlayer", new Type[] { typeof(EngineSoundLoopPlayer) }); this.player = gameObject.GetComponent<EngineSoundLoopPlayer>(); this.player.instance = this; EngineSoundLoop.Instance.Setup(gameObject, ref this.D, ref this.flags, 1, loop._dUpper, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.F, ref this.flags, 2, loop._fMidHigh, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.E, ref this.flags, 4, loop._eMidLow, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.L, ref this.flags, 8, loop._lLower, 1f); EngineSoundLoop.Instance.Setup(gameObject, ref this.K, ref this.flags, 16, loop._kPassing, 0f); float single = Single.NegativeInfinity; float single1 = single; this._lastPitchFactor = single; float single2 = single1; single1 = single2; this._lastSinerp = single2; float single3 = single1; single1 = single3; this._lastClampedThrottle = single3; this._lastVolumeFactor = single1; this._lastVolumeFactorClamp = -128; this._masterVolume = 1f; this._pitch = loop._idleShiftUp.lowVolume; this._shiftTime = -3000f; float single4 = 0f; single1 = single4; this._throttle = single4; float single5 = single1; single1 = single5; this._kVol = single5; float single6 = single1; single1 = single6; this._eVol = single6; float single7 = single1; single1 = single7; this._fVol = single7; float single8 = single1; single1 = single8; this._dVol = single8; this._speedFactor = single1; this._gear = 0; Transform transforms = gameObject.transform; transforms.parent = parent; transforms.localPosition = offset; transforms.localRotation = Quaternion.identity; }
private void UPDATE(float speedFactor, float throttle) { bool flag; bool flag1; bool flag2; byte num; bool flag3; float single; if (throttle == this._throttle) { flag = false; } else { this._throttle = throttle; flag = true; } float single1 = this._pitch; float single2 = this._volume; float single3 = this._speedFactor; bool flag4 = false; bool flag5 = false; bool flag6 = speedFactor != single3; if (flag6) { this._speedFactor = speedFactor; } if ((this.flags & 256) != 256) { flag1 = true; flag2 = false; } else { bool flag7 = this.UPDATE_SHIFTING(ref flag4, ref flag5); flag2 = flag7; flag1 = flag7; } if (flag1) { while (true) { if (flag6 || flag2) { int num1 = this.loop._topGear; this._lastSinerp = EngineSoundLoop.Sinerp(0f, (float)num1, speedFactor); int num2 = (int)this._lastSinerp; if (num2 == this._gear) { flag3 = false; num = (num2 != num1 ? this._gear : (byte)(num1 - 1)); } else if (num2 < this._gear) { if (this._gear <= 0) { flag3 = false; num = this._gear; } else if (this._gear != num1) { flag3 = true; num = (byte)(this._gear - 1); } else { EngineSoundLoop.Instance instance = this; instance._gear = (byte)(instance._gear - 1); flag3 = false; num = this._gear; } } else if (this._gear >= 255 || this._gear >= num1) { flag3 = false; num = this._gear; } else if (this._gear >= num1 - 1) { flag3 = false; num = this._gear; EngineSoundLoop.Instance instance1 = this; instance1._gear = (byte)(instance1._gear + 1); } else { flag3 = true; num = (byte)(this._gear + 1); } } else { flag3 = false; num = (this._gear != this.loop._topGear ? this._gear : (byte)(this._gear - 1)); } float single4 = this._lastSinerp - (float)num; if (single4 == 0f) { single = 0f; } else if (throttle < 0.5f) { single = (throttle > 0f ? single4 * (0.3f + throttle * 0.7f) : single4 * 0.3f); } else { single = single4; } if (!flag3) { break; } if (num <= this._gear) { EngineSoundLoop.Instance instance2 = this; instance2.flags = (ushort)(instance2.flags | 256); } else { EngineSoundLoop.Instance instance3 = this; instance3.flags = (ushort)(instance3.flags | 768); } this._lastPitchFactor = single; this._shiftTime = Time.time; bool flag8 = this.UPDATE_SHIFTING(ref flag4, ref flag5); flag2 = flag8; if (!flag8) { if (flag5 && this._volume != single2) { this.UPDATE_PITCH_AND_OR_THROTTLE_VOLUME(); } else if (flag) { this.UPDATE_THROTTLE_VOLUME(); } if (flag6) { this.UPDATE_PASSING_VOLUME(); } if (flag4 && this._pitch != single1) { this.UPDATE_RATES(); } return; } } if (single != this._lastPitchFactor || flag2) { this._lastPitchFactor = single; this.loop.GearLerp(num, single, ref this._pitch, ref flag4, ref this._volume, ref flag5); } } if (flag5 && this._volume != single2) { this.UPDATE_PITCH_AND_OR_THROTTLE_VOLUME(); } else if (flag) { this.UPDATE_THROTTLE_VOLUME(); } if (flag6) { this.UPDATE_PASSING_VOLUME(); } if (flag4 && this._pitch != single1) { this.UPDATE_RATES(); } }