/// <summary>Creates a new breaker</summary> /// <param name="car">The car</param> public Breaker(AbstractCar car) { Resumed = false; Car = car; Resume = new CarSound(); ResumeOrInterrupt = new CarSound(); }
private void getVehicleComponents() { vehicleController = GetComponent <CarControl>(); vehicleController.readUserInput = true; vehicleAudio = GetComponent <CarSound>(); vehicleSettings = GetComponent <CarSettings>(); }
/// <summary>Loads the sound set for a BVE2 based train</summary> /// <param name="trainFolder">The absolute on-disk path to the train's folder</param> /// <param name="car">The car</param> internal static void Parse(string trainFolder, TrainManager.Car car) { // set sound positions and radii Vector3 center = Vector3.Zero; // load sounds for all cars car.Sounds.Run = SoundCfgParser.TryLoadSoundArray(trainFolder, "Run", ".wav", center, SoundCfgParser.mediumRadius); car.Sounds.RunVolume = new double[car.Sounds.Run.Length]; // motor sound CultureInfo Culture = CultureInfo.InvariantCulture; car.Sounds.Motor.Position = center; for (int j = 0; j < car.Sounds.Motor.Tables.Length; j++) { for (int k = 0; k < car.Sounds.Motor.Tables[j].Entries.Length; k++) { int idx = car.Sounds.Motor.Tables[j].Entries[k].SoundIndex; if (idx >= 0) { CarSound snd = new CarSound(Program.Sounds.RegisterBuffer(OpenBveApi.Path.CombineFile(trainFolder, "Motor" + idx.ToString(Culture) + ".wav"), SoundCfgParser.mediumRadius), center); car.Sounds.Motor.Tables[j].Entries[k].Buffer = snd.Buffer; } } } }
internal ReverserHandle() { Driver = ReverserPosition.Neutral; Actual = ReverserPosition.Neutral; EngageSound = new CarSound(); ReleaseSound = new CarSound(); }
public PassAlarm(PassAlarmType type, AbstractCar Car) { this.baseCar = Car; this.Type = type; this.Sound = new CarSound(); this.Lit = false; }
public PilotLamp(AbstractCar car) { baseCar = car; oldState = DoorStates.None; OnSound = new CarSound(); OffSound = new CarSound(); }
public ReverserHandle(TrainBase train) { Driver = ReverserPosition.Neutral; Actual = ReverserPosition.Neutral; EngageSound = new CarSound(); ReleaseSound = new CarSound(); baseTrain = train; }
void Start() { _carSound = GetComponent<CarSound>(); I = this; camera = GameObject.Find("Main Camera").GetComponent<Camera>(); WaterPump = GameObject.Find("Water"); WaterPump.SetActive(false); }
/// <summary>Creates a new door</summary> /// <param name="direction">The direction in which the door is to open</param> /// <param name="width">The width of the door in millimeters</param> /// <param name="tolerance">The maximum tolerance for the door to be considered closed</param> public Door(int direction, double width, double tolerance) { Direction = direction; Width = width; MaxTolerance = tolerance; OpenSound = new CarSound(); CloseSound = new CarSound(); State = 0.0; }
public AbstractHandle() { Increase = new CarSound(); IncreaseFast = new CarSound(); Decrease = new CarSound(); DecreaseFast = new CarSound(); Min = new CarSound(); Max = new CarSound(); }
protected AbstractHandle(TrainBase Train) { baseTrain = Train; Increase = new CarSound(); IncreaseFast = new CarSound(); Decrease = new CarSound(); DecreaseFast = new CarSound(); Min = new CarSound(); Max = new CarSound(); }
public Compressor(double rate, MainReservoir reservoir, AbstractCar car) { Rate = rate; Enabled = false; StartSound = new CarSound(); LoopSound = new CarSound(); EndSound = new CarSound(); mainReservoir = reservoir; baseCar = car; }
/// <summary>Attempts to load an array of sound files into a car-sound array</summary> /// <param name="Folder">The folder the sound files are located in</param> /// <param name="FileStart">The first sound file</param> /// <param name="FileEnd">The last sound file</param> /// <param name="Position">The position the sound is to be emitted from within the car</param> /// <param name="Radius">The sound radius</param> /// <returns>The new car sound array</returns> internal static CarSound[] TryLoadSoundArray(string Folder, string FileStart, string FileEnd, Vector3 Position, double Radius) { CultureInfo Culture = CultureInfo.InvariantCulture; CarSound[] Sounds = { }; if (!Directory.Exists(Folder)) { //Detect whether the given folder exists before attempting to load from it return(Sounds); } string[] Files = Directory.GetFiles(Folder); foreach (string file in Files) { string a = System.IO.Path.GetFileName(file); if (string.IsNullOrEmpty(a)) { return(Sounds); } if (a.Length > FileStart.Length + FileEnd.Length) { if (a.StartsWith(FileStart, StringComparison.OrdinalIgnoreCase) & a.EndsWith(FileEnd, StringComparison.OrdinalIgnoreCase)) { string b = a.Substring(FileStart.Length, a.Length - FileEnd.Length - FileStart.Length); int n; if (int.TryParse(b, NumberStyles.Integer, Culture, out n)) { if (n >= 0) { int m = Sounds.Length; if (n >= m) { Array.Resize(ref Sounds, n + 1); for (int j = m; j < n; j++) { Sounds[j] = new CarSound(); } } Sounds[n] = new CarSound(Program.Sounds.RegisterBuffer(file, Radius), Position); } } } } } return(Sounds); }
private void Start() { alcoholMeter = FindObjectOfType <AlcoholMeter>(); spawnAlcohol = FindObjectOfType <SpawnObject>(); scoreCalculator = FindObjectOfType <ScoreCalculator>(); playerCollisions = FindObjectOfType <PlayerCollisions>(); objectives = FindObjectOfType <Objectives>(); blink = FindObjectOfType <BlinkingEffect>(); carSound = FindObjectOfType <CarSound>(); audioSource = FindObjectOfType <AudioSource>(); }
/// <summary>Plays a car sound.</summary> /// <param name="sound">The car sound.</param> /// <param name="pitch">The pitch change factor.</param> /// <param name="volume">The volume change factor.</param> /// <param name="car">The train car sound is attached to.</param> /// <param name="looped">Whether to play the sound in a loop.</param> /// <returns>The sound source.</returns> internal void PlayCarSound(CarSound sound, double pitch, double volume, AbstractCar car, bool looped) { if (sound.Buffer == null) { return; } if (car == null) { throw new InvalidDataException("A valid car must be specified"); } sound.Source = PlaySound(sound.Buffer, pitch, volume, sound.Position, car, looped); }
/// <summary>Attempts to load an array of sound files into a car-sound dictionary</summary> /// <param name="Folder">The folder the sound files are located in</param> /// <param name="FileStart">The first sound file</param> /// <param name="FileEnd">The last sound file</param> /// <param name="Position">The position the sound is to be emitted from within the car</param> /// <param name="Radius">The sound radius</param> /// <returns>The new car sound dictionary</returns> internal static Dictionary <int, CarSound> TryLoadSoundDictionary(string Folder, string FileStart, string FileEnd, Vector3 Position, double Radius) { System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; Dictionary <int, CarSound> Sounds = new Dictionary <int, CarSound>(); if (!System.IO.Directory.Exists(Folder)) { //Detect whether the given folder exists before attempting to load from it return(Sounds); } string[] Files = System.IO.Directory.GetFiles(Folder); for (int i = 0; i < Files.Length; i++) { string a = System.IO.Path.GetFileName(Files[i]); if (a == null) { return(Sounds); } if (a.Length > FileStart.Length + FileEnd.Length) { if (a.StartsWith(FileStart, StringComparison.OrdinalIgnoreCase) & a.EndsWith(FileEnd, StringComparison.OrdinalIgnoreCase)) { string b = a.Substring(FileStart.Length, a.Length - FileEnd.Length - FileStart.Length); int n; if (int.TryParse(b, System.Globalization.NumberStyles.Integer, Culture, out n)) { if (Sounds.ContainsKey(n)) { SoundHandle snd; Plugin.currentHost.RegisterSound(Files[i], Radius, out snd); Sounds[n] = new CarSound(snd, Position); } else { SoundHandle snd; Plugin.currentHost.RegisterSound(Files[i], Radius, out snd); Sounds.Add(n, new CarSound(snd, Position)); } } } } } return(Sounds); }
void LoadCar() { if (m_Car) { _Pool.Save(m_Car.gameObject); } string path = cop ? "police" : owner.carSet.carName; Spawn spawnPos = GetSpawnStartPos(); m_Car = _Pool.Load2(Resources.Load(path), spawnPos.pos, spawnPos.rot).GetComponent <CarControl>(); if (m_Car.m_CarDamage.meshTest) { m_Car.m_CarDamage.meshTest.Reset(this == _Player); m_Car.rigidbody.velocity = m_Car.rigidbody.angularVelocity = Vector3.zero; } //m_Car = ((GameObject)Instantiate(Resources.Load(path), spawnPos.pos, spawnPos.rot)).GetComponent<CarControl>(); m_Car.name = "Player Car " + pv.playerName; transformCar = m_Car.tr; rigidbody = m_Car.rigidbody; rigidbody.solverIterationCount = 6; m_CarSettings = m_Car.GetComponent <CarSettings>() as CarSettings; m_CarSound = m_Car.GetComponent <CarSound>() as CarSound; m_CarSettings.bypassABS = false; m_Car.pl = this; OnQualityChanged(); var priority = this == _Player ? 100 : 130; foreach (var a in GetComponents <AudioSource>()) { a.priority = priority; } foreach (var a in m_Car.audioSources) { a.priority = priority; } if (IsMine && !bot2) { _Game.MainCamera.Target = m_Car.tr; } AmplifyMotionEffect.RegisterRecursivelyS(m_Car.gameObject); }
/// <summary>Parses an XML node containing a list of sounds into a car sound array</summary> /// <param name="node">The node to parse</param> /// <param name="Sounds">The car sound array</param> /// <param name="Position">The default position of the sound (May be overriden by any node)</param> /// <param name="Radius">The default radius of the sound (May be overriden by any node)</param> private void ParseArrayNode(XmlNode node, out CarSound[] Sounds, Vector3 Position, double Radius) { Sounds = new CarSound[0]; foreach (XmlNode c in node.ChildNodes) { int idx = -1; if (c.Name.ToLowerInvariant() != "sound") { Plugin.currentHost.AddMessage(MessageType.Error, false, "Invalid array node " + c.Name + " in XML node " + node.Name); } else { for (int i = 0; i < c.ChildNodes.Count; i++) { if (c.ChildNodes[i].Name.ToLowerInvariant() == "index") { if (!NumberFormats.TryParseIntVb6(c.ChildNodes[i].InnerText.ToLowerInvariant(), out idx)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Invalid array index " + c.Name + " in XML node " + node.Name); return; } break; } } if (idx >= 0) { int l = Sounds.Length; Array.Resize(ref Sounds, idx + 1); while (l < Sounds.Length) { Sounds[l] = new CarSound(); l++; } ParseNode(c, out Sounds[idx], Position, Radius); } else { Plugin.currentHost.AddMessage(MessageType.Error, false, "Invalid array index " + c.Name + " in XML node " + node.Name); } } } }
/// <summary>Parses an XML node containing a list of sounds into a car sound array</summary> /// <param name="node">The node to parse</param> /// <param name="Sounds">The car sound array</param> /// <param name="Position">The default position of the sound (May be overriden by any node)</param> /// <param name="Radius">The default radius of the sound (May be overriden by any node)</param> private static void ParseArrayNode(XmlNode node, out CarSound[] Sounds, Vector3 Position, double Radius) { Sounds = new CarSound[0]; foreach (XmlNode c in node.ChildNodes) { int idx = -1; if (c.Name.ToLowerInvariant() == "sound") { for (int i = 0; i < c.ChildNodes.Count; i++) { if (c.ChildNodes[i].Name.ToLowerInvariant() == "index") { if (!NumberFormats.TryParseIntVb6(c.ChildNodes[i].InnerText.ToLowerInvariant(), out idx)) { return; } break; } } if (idx >= 0) { int l = Sounds.Length; Array.Resize(ref Sounds, idx + 1); while (l < Sounds.Length) { Sounds[l] = new CarSound(); l++; } ParseNode(c, out Sounds[idx], Position, Radius); } } } }
internal StationAdjustAlarm(TrainManager.Train train) { this.baseTrain = train; this.AdjustAlarm = new CarSound(); this.Lit = false; }
internal EmergencyHandle() { ApplicationSound = new CarSound(); }
public override void OnInspectorGUI() { CarSound carSound = target as CarSound; if (carSound.ExtCoasterSnd == null) { carSound.ExtCoasterSnd = new CarSoundItem[1]; } if (carSound.IntCoasterSnd == null) { carSound.IntCoasterSnd = new CarSoundItem[1]; } if (carSound.ExtPowerSnd == null) { carSound.ExtPowerSnd = new CarSoundItem[1]; } if (carSound.IntPowerSnd == null) { carSound.IntPowerSnd = new CarSoundItem[1]; } EditorGUILayout.TextField("rpm", carSound.rpm.ToString()); EditorGUILayout.TextField("throttleVolume", carSound.throttleVolume.ToString()); EditorGUILayout.TextField("coasterVolume", carSound.coasterVolume.ToString()); EditorGUILayout.TextField("throttle", carSound.DebugPower); EditorGUILayout.TextField("coaster", carSound.DebugCoaster); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Test Sounds:"); carSound.debugSound = EditorGUILayout.Toggle(carSound.debugSound); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Test Rpm:"); carSound.fakeRpm = EditorGUILayout.IntSlider(carSound.fakeRpm, 0, Convert.ToInt32(FindObjectOfType <GR_PhEngine>().RpmLimit)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Test Throttle:"); carSound.ThrottleValue = EditorGUILayout.Slider(carSound.ThrottleValue, 0.0f, 1.0f); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Shift Engage Sound:"); carSound.ShiftEngageAudio = (AudioClip)EditorGUILayout.ObjectField(carSound.ShiftEngageAudio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Shift Up Sound:"); carSound.ShiftUpAudio = (AudioClip)EditorGUILayout.ObjectField(carSound.ShiftUpAudio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Shift Dn Sound:"); carSound.ShiftDnAudio = (AudioClip)EditorGUILayout.ObjectField(carSound.ShiftDnAudio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Brake Sound:"); carSound.BrakeAudio = (AudioClip)EditorGUILayout.ObjectField(carSound.BrakeAudio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch correction:"); carSound.pitchCorrection = EditorGUILayout.Slider(carSound.pitchCorrection, 0.1f, 2.0f); EditorGUILayout.EndHorizontal(); #region EXTERNAL GUILayout.Space(10); EditorGUILayout.LabelField("External sound", EditorStyles.boldLabel); // POWER ------------------------------------------------------------------------------------------------------------------------------------ EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Power:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, false, false, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); for (int i = 0; i < carSound.ExtPowerSnd.Length; i++) { if (carSound.ExtPowerSnd[i].Volume == null) { carSound.ExtPowerSnd[i].Volume = new AnimationCurve(); } if (carSound.ExtPowerSnd[i].Pitch == null) { carSound.ExtPowerSnd[i].Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtPowerSnd[i].Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtPowerSnd[i].Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, false, false, false, false, i); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtPowerSnd[i].Volume = EditorGUILayout.CurveField(carSound.ExtPowerSnd[i].Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtPowerSnd[i].Pitch = EditorGUILayout.CurveField(carSound.ExtPowerSnd[i].Pitch); EditorGUILayout.EndHorizontal(); } // COASTER ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Coaster:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(true, false, false, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); for (int i = 0; i < carSound.ExtCoasterSnd.Length; i++) { if (carSound.ExtCoasterSnd[i].Volume == null) { carSound.ExtCoasterSnd[i].Volume = new AnimationCurve(); } if (carSound.ExtCoasterSnd[i].Pitch == null) { carSound.ExtCoasterSnd[i].Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtCoasterSnd[i].Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtCoasterSnd[i].Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(true, false, false, false, false, i); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtCoasterSnd[i].Volume = EditorGUILayout.CurveField(carSound.ExtCoasterSnd[i].Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtCoasterSnd[i].Pitch = EditorGUILayout.CurveField(carSound.ExtCoasterSnd[i].Pitch); EditorGUILayout.EndHorizontal(); } // REVERSE ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Reverse:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, false, true, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.ExtReverseSnd.Volume == null) { carSound.ExtReverseSnd.Volume = new AnimationCurve(); } if (carSound.ExtReverseSnd.Pitch == null) { carSound.ExtReverseSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtReverseSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtReverseSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, false, true, false, false, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtReverseSnd.Volume = EditorGUILayout.CurveField(carSound.ExtReverseSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtReverseSnd.Pitch = EditorGUILayout.CurveField(carSound.ExtReverseSnd.Pitch); EditorGUILayout.EndHorizontal(); // IDLE ------------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Idle:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, false, false, true, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.ExtIdleSnd.Volume == null) { carSound.ExtIdleSnd.Volume = new AnimationCurve(); } if (carSound.ExtIdleSnd.Pitch == null) { carSound.ExtIdleSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtIdleSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtIdleSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, false, false, true, false, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtIdleSnd.Volume = EditorGUILayout.CurveField(carSound.ExtIdleSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtIdleSnd.Pitch = EditorGUILayout.CurveField(carSound.ExtIdleSnd.Pitch); EditorGUILayout.EndHorizontal(); // MAX RPM ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("MaxRpm:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, false, false, false, true); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.ExtLimiterSnd.Volume == null) { carSound.ExtLimiterSnd.Volume = new AnimationCurve(); } if (carSound.ExtLimiterSnd.Pitch == null) { carSound.ExtLimiterSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtLimiterSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtLimiterSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, false, false, false, true, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtLimiterSnd.Volume = EditorGUILayout.CurveField(carSound.ExtLimiterSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtLimiterSnd.Pitch = EditorGUILayout.CurveField(carSound.ExtLimiterSnd.Pitch); EditorGUILayout.EndHorizontal(); // TURBO ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Turbo:"); EditorGUILayout.EndHorizontal(); if (carSound.ExtTurboSnd.Volume == null) { carSound.ExtTurboSnd.Volume = new AnimationCurve(); } if (carSound.ExtTurboSnd.Pitch == null) { carSound.ExtTurboSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.ExtTurboSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.ExtTurboSnd.Audio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.ExtTurboSnd.Volume = EditorGUILayout.CurveField(carSound.ExtTurboSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.ExtTurboSnd.Pitch = EditorGUILayout.CurveField(carSound.ExtTurboSnd.Pitch); EditorGUILayout.EndHorizontal(); #endregion EXTERNAL GUI.color = new Color32(44, 203, 220, 255); if (GUILayout.Button("Copy curves Ext -> Int")) { if (EditorUtility.DisplayDialogComplex("Warning", "Are you sure to copy the Ext curves value to the Int?\r\nAll the old data are owerwritten", "Ok", "Cancel", "No") == 0) { // power for (int i = 0; i < carSound.ExtPowerSnd.Length; i++) { carSound.IntPowerSnd[i].Volume = carSound.ExtPowerSnd[i].Volume; carSound.IntPowerSnd[i].Pitch = carSound.ExtPowerSnd[i].Pitch; } // coaster for (int i = 0; i < carSound.ExtCoasterSnd.Length; i++) { carSound.IntCoasterSnd[i].Volume = carSound.ExtCoasterSnd[i].Volume; carSound.IntCoasterSnd[i].Pitch = carSound.ExtCoasterSnd[i].Pitch; } carSound.IntReverseSnd.Volume = carSound.ExtReverseSnd.Volume; carSound.IntReverseSnd.Pitch = carSound.ExtReverseSnd.Pitch; carSound.IntIdleSnd.Volume = carSound.ExtIdleSnd.Volume; carSound.IntIdleSnd.Pitch = carSound.ExtIdleSnd.Pitch; carSound.IntLimiterSnd.Volume = carSound.ExtLimiterSnd.Volume; carSound.IntLimiterSnd.Pitch = carSound.ExtLimiterSnd.Pitch; } } GUI.color = Color.white; #region INTERNAL GUILayout.Space(10); EditorGUILayout.LabelField("Internal sound", EditorStyles.boldLabel); // POWER ------------------------------------------------------------------------------------------------------------------------------------ EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Power:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, true, false, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); for (int i = 0; i < carSound.IntPowerSnd.Length; i++) { if (carSound.IntPowerSnd[i].Volume == null) { carSound.IntPowerSnd[i].Volume = new AnimationCurve(); } if (carSound.IntPowerSnd[i].Pitch == null) { carSound.IntPowerSnd[i].Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntPowerSnd[i].Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntPowerSnd[i].Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, true, false, false, false, i); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntPowerSnd[i].Volume = EditorGUILayout.CurveField(carSound.IntPowerSnd[i].Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntPowerSnd[i].Pitch = EditorGUILayout.CurveField(carSound.IntPowerSnd[i].Pitch); EditorGUILayout.EndHorizontal(); } // COASTER ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Coaster:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(true, true, false, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); for (int i = 0; i < carSound.IntCoasterSnd.Length; i++) { if (carSound.IntCoasterSnd[i].Volume == null) { carSound.IntCoasterSnd[i].Volume = new AnimationCurve(); } if (carSound.IntCoasterSnd[i].Pitch == null) { carSound.IntCoasterSnd[i].Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntCoasterSnd[i].Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntCoasterSnd[i].Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(true, true, false, false, false, i); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntCoasterSnd[i].Volume = EditorGUILayout.CurveField(carSound.IntCoasterSnd[i].Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntCoasterSnd[i].Pitch = EditorGUILayout.CurveField(carSound.IntCoasterSnd[i].Pitch); EditorGUILayout.EndHorizontal(); } // REVERSE ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Reverse:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, true, true, false, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.IntReverseSnd.Volume == null) { carSound.IntReverseSnd.Volume = new AnimationCurve(); } if (carSound.IntReverseSnd.Pitch == null) { carSound.IntReverseSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntReverseSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntReverseSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, true, true, false, false, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntReverseSnd.Volume = EditorGUILayout.CurveField(carSound.IntReverseSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntReverseSnd.Pitch = EditorGUILayout.CurveField(carSound.IntReverseSnd.Pitch); EditorGUILayout.EndHorizontal(); // IDLE ------------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Idle:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, true, false, true, false); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.IntIdleSnd.Volume == null) { carSound.IntIdleSnd.Volume = new AnimationCurve(); } if (carSound.IntIdleSnd.Pitch == null) { carSound.IntIdleSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntIdleSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntIdleSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, true, false, true, false, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntIdleSnd.Volume = EditorGUILayout.CurveField(carSound.IntIdleSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntIdleSnd.Pitch = EditorGUILayout.CurveField(carSound.IntIdleSnd.Pitch); EditorGUILayout.EndHorizontal(); // MAX RPM ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("MaxRpm:"); GUI.color = new Color32(125, 255, 123, 255); if (GUILayout.Button("+")) { carSound.addSound(false, true, false, false, true); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (carSound.IntLimiterSnd.Volume == null) { carSound.IntLimiterSnd.Volume = new AnimationCurve(); } if (carSound.IntLimiterSnd.Pitch == null) { carSound.IntLimiterSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntLimiterSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntLimiterSnd.Audio, typeof(AudioClip), true); GUI.color = new Color32(199, 0, 2, 255); if (GUILayout.Button("x")) { carSound.removeSound(false, true, false, false, true, 0); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntLimiterSnd.Volume = EditorGUILayout.CurveField(carSound.IntLimiterSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntLimiterSnd.Pitch = EditorGUILayout.CurveField(carSound.IntLimiterSnd.Pitch); EditorGUILayout.EndHorizontal(); // TURBO ---------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Turbo:"); EditorGUILayout.EndHorizontal(); if (carSound.IntTurboSnd.Volume == null) { carSound.IntTurboSnd.Volume = new AnimationCurve(); } if (carSound.IntTurboSnd.Pitch == null) { carSound.IntTurboSnd.Pitch = new AnimationCurve(); } EditorGUILayout.BeginHorizontal(); carSound.IntTurboSnd.Audio = (AudioClip)EditorGUILayout.ObjectField(carSound.IntTurboSnd.Audio, typeof(AudioClip), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Volume:"); carSound.IntTurboSnd.Volume = EditorGUILayout.CurveField(carSound.IntTurboSnd.Volume); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Pitch:"); carSound.IntTurboSnd.Pitch = EditorGUILayout.CurveField(carSound.IntTurboSnd.Pitch); EditorGUILayout.EndHorizontal(); #endregion INTERNAL if (GUI.changed) { EditorUtility.SetDirty(carSound); if (!Application.isPlaying) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } }
/// <summary>Loads the sound set for a BVE2 based train</summary> /// <param name="train">The train</param> internal void Parse(TrainBase train) { // set sound positions and radii Vector3 front = new Vector3(0.0, 0.0, 0.5 * train.Cars[train.DriverCar].Length); Vector3 center = Vector3.Zero; Vector3 left = new Vector3(-1.3, 0.0, 0.0); Vector3 right = new Vector3(1.3, 0.0, 0.0); Vector3 cab = new Vector3(-train.Cars[train.DriverCar].Driver.X, train.Cars[train.DriverCar].Driver.Y, train.Cars[train.DriverCar].Driver.Z - 0.5); Vector3 panel = new Vector3(train.Cars[train.DriverCar].Driver.X, train.Cars[train.DriverCar].Driver.Y, train.Cars[train.DriverCar].Driver.Z + 1.0); // load sounds for driver's car train.SafetySystems.StationAdjust.AdjustAlarm = new CarSound(Plugin.currentHost, train.TrainFolder, "Adjust.wav", SoundCfgParser.tinyRadius, panel); train.Cars[train.DriverCar].CarBrake.Release = new CarSound(Plugin.currentHost, train.TrainFolder, "Brake.wav", SoundCfgParser.smallRadius, center); train.SafetySystems.PassAlarm.Sound = new CarSound(Plugin.currentHost, train.TrainFolder, "Halt.wav", SoundCfgParser.tinyRadius, cab); Plugin.currentHost.RegisterSound(Path.CombineFile(train.TrainFolder, "Klaxon0.wav"), SoundCfgParser.smallRadius, out var loopSound); train.Cars[train.DriverCar].Horns[0].LoopSound = loopSound as SoundBuffer; train.Cars[train.DriverCar].Horns[0].Loop = false; train.Cars[train.DriverCar].Horns[0].SoundPosition = front; if (train.Cars[train.DriverCar].Horns[0].LoopSound == null) { Plugin.currentHost.RegisterSound(Path.CombineFile(train.TrainFolder, "Klaxon.wav"), SoundCfgParser.smallRadius, out var loopSound1); train.Cars[train.DriverCar].Horns[0].LoopSound = loopSound1 as SoundBuffer; } Plugin.currentHost.RegisterSound(Path.CombineFile(train.TrainFolder, "Klaxon1.wav"), SoundCfgParser.smallRadius, out var loopSound2); train.Cars[train.DriverCar].Horns[1].LoopSound = loopSound2 as SoundBuffer; train.Cars[train.DriverCar].Horns[1].Loop = false; train.Cars[train.DriverCar].Horns[1].SoundPosition = front; Plugin.currentHost.RegisterSound(Path.CombineFile(train.TrainFolder, "Klaxon2.wav"), SoundCfgParser.smallRadius, out var loopSound3); train.Cars[train.DriverCar].Horns[2].LoopSound = loopSound3 as SoundBuffer; train.Cars[train.DriverCar].Horns[2].Loop = true; train.Cars[train.DriverCar].Horns[2].SoundPosition = front; train.SafetySystems.PilotLamp.OnSound = new CarSound(Plugin.currentHost, train.TrainFolder, "Leave.wav", SoundCfgParser.tinyRadius, cab); // load sounds for all cars for (int i = 0; i < train.Cars.Length; i++) { Vector3 frontaxle = new Vector3(0.0, 0.0, train.Cars[i].FrontAxle.Position); Vector3 rearaxle = new Vector3(0.0, 0.0, train.Cars[i].RearAxle.Position); train.Cars[i].CarBrake.Air = new CarSound(Plugin.currentHost, train.TrainFolder, "Air.wav", SoundCfgParser.smallRadius, center); train.Cars[i].CarBrake.AirHigh = new CarSound(Plugin.currentHost, train.TrainFolder, "AirHigh.wav", SoundCfgParser.smallRadius, center); train.Cars[i].CarBrake.AirZero = new CarSound(Plugin.currentHost, train.TrainFolder, "AirZero.wav", SoundCfgParser.smallRadius, center); if (train.Cars[i].CarBrake.brakeType == BrakeType.Main) { train.Cars[i].CarBrake.airCompressor.EndSound = new CarSound(Plugin.currentHost, train.TrainFolder, "CpEnd.wav", SoundCfgParser.mediumRadius, center); train.Cars[i].CarBrake.airCompressor.LoopSound = new CarSound(Plugin.currentHost, train.TrainFolder, "CpLoop.wav", SoundCfgParser.mediumRadius, center); train.Cars[i].CarBrake.airCompressor.StartSound = new CarSound(Plugin.currentHost, train.TrainFolder, "CpStart.wav", SoundCfgParser.mediumRadius, center); } train.Cars[i].Doors[0].CloseSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorClsL.wav", SoundCfgParser.smallRadius, left); train.Cars[i].Doors[1].CloseSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorClsR.wav", SoundCfgParser.smallRadius, right); if (train.Cars[i].Doors[0].CloseSound.Buffer == null) { train.Cars[i].Doors[0].CloseSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorCls.wav", SoundCfgParser.smallRadius, left); } if (train.Cars[i].Doors[1].CloseSound.Buffer == null) { train.Cars[i].Doors[1].CloseSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorCls.wav", SoundCfgParser.smallRadius, right); } train.Cars[i].Doors[0].OpenSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorOpnL.wav", SoundCfgParser.smallRadius, left); train.Cars[i].Doors[1].OpenSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorOpnR.wav", SoundCfgParser.smallRadius, right); if (train.Cars[i].Doors[0].OpenSound.Buffer == null) { train.Cars[i].Doors[0].OpenSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorOpn.wav", SoundCfgParser.smallRadius, left); } if (train.Cars[i].Doors[1].OpenSound.Buffer == null) { train.Cars[i].Doors[1].OpenSound = new CarSound(Plugin.currentHost, train.TrainFolder, "DoorOpn.wav", SoundCfgParser.smallRadius, right); } train.Handles.EmergencyBrake.ApplicationSound = new CarSound(Plugin.currentHost, train.TrainFolder, "EmrBrake.wav", SoundCfgParser.mediumRadius, center); train.Cars[i].Sounds.Flange = SoundCfgParser.TryLoadSoundDictionary(train.TrainFolder, "Flange", ".wav", center, SoundCfgParser.mediumRadius); train.Cars[i].Sounds.Loop = new CarSound(Plugin.currentHost, train.TrainFolder, "Loop.wav", SoundCfgParser.mediumRadius, center); train.Cars[i].FrontAxle.PointSounds = new[] { new CarSound(Plugin.currentHost, train.TrainFolder, "Point.wav", SoundCfgParser.smallRadius, frontaxle) }; train.Cars[i].RearAxle.PointSounds = new[] { new CarSound(Plugin.currentHost, train.TrainFolder, "Point.wav", SoundCfgParser.smallRadius, rearaxle) }; train.Cars[i].CarBrake.Rub = new CarSound(Plugin.currentHost, train.TrainFolder, "Rub.wav", SoundCfgParser.mediumRadius, center); train.Cars[i].Sounds.Run = SoundCfgParser.TryLoadSoundDictionary(train.TrainFolder, "Run", ".wav", center, SoundCfgParser.mediumRadius); train.Cars[i].Sounds.SpringL = new CarSound(Plugin.currentHost, train.TrainFolder, "SpringL.wav", SoundCfgParser.smallRadius, left); train.Cars[i].Sounds.SpringR = new CarSound(Plugin.currentHost, train.TrainFolder, "SpringR.wav", SoundCfgParser.smallRadius, right); // motor sound if (train.Cars[i].Specs.IsMotorCar) { System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; train.Cars[i].Sounds.Motor.Position = center; for (int j = 0; j < train.Cars[i].Sounds.Motor.Tables.Length; j++) { for (int k = 0; k < train.Cars[i].Sounds.Motor.Tables[j].Entries.Length; k++) { int idx = train.Cars[i].Sounds.Motor.Tables[j].Entries[k].SoundIndex; if (idx >= 0) { CarSound snd = new CarSound(Plugin.currentHost, train.TrainFolder, "Motor" + idx.ToString(Culture) + ".wav", SoundCfgParser.mediumRadius, center); train.Cars[i].Sounds.Motor.Tables[j].Entries[k].Buffer = snd.Buffer; } } } } } }
/// <inheritdoc/> public override void Update(double TimeElapsed) { if (State == TrainState.Pending) { // pending train bool forceIntroduction = !IsPlayerTrain && TrainManagerBase.currentHost.SimulationState != SimulationState.MinimalisticSimulation; double time = 0.0; if (!forceIntroduction) { for (int i = 0; i < TrainManagerBase.CurrentRoute.Stations.Length; i++) { if (TrainManagerBase.CurrentRoute.Stations[i].StopMode == StationStopMode.AllStop | TrainManagerBase.CurrentRoute.Stations[i].StopMode == StationStopMode.PlayerPass) { if (TrainManagerBase.CurrentRoute.Stations[i].ArrivalTime >= 0.0) { time = TrainManagerBase.CurrentRoute.Stations[i].ArrivalTime; } else if (TrainManagerBase.CurrentRoute.Stations[i].DepartureTime >= 0.0) { time = TrainManagerBase.CurrentRoute.Stations[i].DepartureTime - TrainManagerBase.CurrentRoute.Stations[i].StopTime; } break; } } time -= TimetableDelta; } if (TrainManagerBase.CurrentRoute.SecondsSinceMidnight >= time | forceIntroduction) { bool introduce = true; if (!forceIntroduction) { if (CurrentSectionIndex >= 0 && TrainManagerBase.CurrentRoute.Sections.Length > CurrentSectionIndex) { if (!TrainManagerBase.CurrentRoute.Sections[CurrentSectionIndex].IsFree()) { introduce = false; } } } if (this == TrainManagerBase.PlayerTrain && TrainManagerBase.currentHost.SimulationState != SimulationState.Loading) { /* Loading has finished, but we still have an AI train in the current section * This may be caused by an iffy RunInterval value, or simply by having no sections * * * We must introduce the player's train as otherwise the cab and loop sounds are missing * NOTE: In this case, the signalling cannot prevent the player from colliding with * the AI train */ introduce = true; } if (introduce) { // train is introduced State = TrainState.Available; for (int j = 0; j < Cars.Length; j++) { if (Cars[j].CarSections.Length != 0) { if (j == DriverCar && IsPlayerTrain && TrainManagerBase.CurrentOptions.InitialViewpoint == 0) { Cars[j].ChangeCarSection(CarSectionType.Interior); } else { /* * HACK: Load in exterior mode first to ensure everything is cached * before switching immediately to not visible * https://github.com/leezer3/OpenBVE/issues/226 * Stuff like the R142A really needs to downsize the textures supplied, * but we have no control over external factors.... */ Cars[j].ChangeCarSection(CarSectionType.Exterior); if (IsPlayerTrain && TrainManagerBase.CurrentOptions.InitialViewpoint == 0) { Cars[j].ChangeCarSection(CarSectionType.NotVisible, true); } } } Cars[j].FrontBogie.ChangeSection(!IsPlayerTrain ? 0 : -1); Cars[j].RearBogie.ChangeSection(!IsPlayerTrain ? 0 : -1); Cars[j].Coupler.ChangeSection(!IsPlayerTrain ? 0 : -1); if (Cars[j].Specs.IsMotorCar && Cars[j].Sounds.Loop != null) { Cars[j].Sounds.Loop.Play(Cars[j], true); } } } } } else if (State == TrainState.Available) { // available train UpdatePhysicsAndControls(TimeElapsed); if (CurrentSpeed > CurrentRouteLimit) { if (previousRouteLimit != CurrentRouteLimit || TrainManagerBase.CurrentOptions.GameMode == GameMode.Arcade) { /* * HACK: If the limit has changed, or we are in arcade mode, notify the player * This conforms to the original behaviour, but doesn't need to raise the message from the event. */ TrainManagerBase.currentHost.AddMessage(Translations.GetInterfaceString("message_route_overspeed"), MessageDependency.RouteLimit, GameMode.Normal, MessageColor.Orange, double.PositiveInfinity, null); } } if (TrainManagerBase.CurrentOptions.Accessibility) { if (previousRouteLimit != CurrentRouteLimit) { //Show for 10s and announce the current speed limit if screen reader present TrainManagerBase.currentHost.AddMessage(Translations.GetInterfaceString("message_route_newlimit"), MessageDependency.AccessibilityHelper, GameMode.Normal, MessageColor.White, TrainManagerBase.currentHost.InGameTime + 10.0, null); } Section nextSection = TrainManagerBase.CurrentRoute.NextSection(FrontCarTrackPosition()); if (nextSection != null) { //If we find an appropriate signal, and the distance to it is less than 500m, announce if screen reader is present //Aspect announce to be triggered via a separate keybind double tPos = nextSection.TrackPosition - FrontCarTrackPosition(); if (!nextSection.AccessibilityAnnounced && tPos < 500) { string s = Translations.GetInterfaceString("message_route_nextsection").Replace("[distance]", $"{tPos:0.0}") + "m"; TrainManagerBase.currentHost.AddMessage(s, MessageDependency.AccessibilityHelper, GameMode.Normal, MessageColor.White, TrainManagerBase.currentHost.InGameTime + 10.0, null); nextSection.AccessibilityAnnounced = true; } } RouteStation nextStation = TrainManagerBase.CurrentRoute.NextStation(FrontCarTrackPosition()); if (nextStation != null) { //If we find an appropriate signal, and the distance to it is less than 500m, announce if screen reader is present //Aspect announce to be triggered via a separate keybind double tPos = nextStation.DefaultTrackPosition - FrontCarTrackPosition(); if (!nextStation.AccessibilityAnnounced && tPos < 500) { string s = Translations.GetInterfaceString("message_route_nextstation").Replace("[distance]", $"{tPos:0.0}") + "m".Replace("[name]", nextStation.Name); TrainManagerBase.currentHost.AddMessage(s, MessageDependency.AccessibilityHelper, GameMode.Normal, MessageColor.White, TrainManagerBase.currentHost.InGameTime + 10.0, null); nextStation.AccessibilityAnnounced = true; } } } previousRouteLimit = CurrentRouteLimit; if (TrainManagerBase.CurrentOptions.GameMode == GameMode.Arcade) { if (CurrentSectionLimit == 0.0) { TrainManagerBase.currentHost.AddMessage(Translations.GetInterfaceString("message_signal_stop"), MessageDependency.PassedRedSignal, GameMode.Normal, MessageColor.Red, double.PositiveInfinity, null); } else if (CurrentSpeed > CurrentSectionLimit) { TrainManagerBase.currentHost.AddMessage(Translations.GetInterfaceString("message_signal_overspeed"), MessageDependency.SectionLimit, GameMode.Normal, MessageColor.Orange, double.PositiveInfinity, null); } } if (AI != null) { AI.Trigger(TimeElapsed); } } else if (State == TrainState.Bogus) { // bogus train if (AI != null) { AI.Trigger(TimeElapsed); } } //Trigger point sounds if appropriate for (int i = 0; i < Cars.Length; i++) { CarSound c = null; if (Cars[i].FrontAxle.PointSoundTriggered) { Cars[i].FrontAxle.PointSoundTriggered = false; int bufferIndex = Cars[i].FrontAxle.RunIndex; if (bufferIndex > Cars[i].FrontAxle.PointSounds.Length - 1) { //If the switch sound does not exist, return zero //Required to handle legacy trains which don't have idx specific run sounds defined bufferIndex = 0; } if (Cars[i].FrontAxle.PointSounds == null || Cars[i].FrontAxle.PointSounds.Length == 0) { //No point sounds defined at all continue; } c = (CarSound)Cars[i].FrontAxle.PointSounds[bufferIndex]; if (c.Buffer == null) { c = (CarSound)Cars[i].FrontAxle.PointSounds[0]; } } if (c != null) { double spd = Math.Abs(CurrentSpeed); double pitch = spd / 12.5; double gain = pitch < 0.5 ? 2.0 * pitch : 1.0; if (pitch > 0.2 && gain > 0.2) { c.Play(pitch, gain, Cars[i], false); } } } }
private void getVehicleComponents() { vehicleController = GetComponent<CarControl>(); vehicleController.readUserInput = true; vehicleAudio = GetComponent<CarSound>(); vehicleSettings = GetComponent<CarSettings>(); }
/// <summary>Parses a single XML node into a car sound</summary> /// <param name="node">The node to parse</param> /// <param name="Sound">The car sound</param> /// <param name="Position">The default position of this sound (May be overriden by the node)</param> /// <param name="Radius">The default radius of this sound (May be overriden by the node)</param> private void ParseNode(XmlNode node, out CarSound Sound, Vector3 Position, double Radius) { string fileName = null; foreach (XmlNode c in node.ChildNodes) { switch (c.Name.ToLowerInvariant()) { case "filename": try { fileName = OpenBveApi.Path.CombineFile(currentPath, c.InnerText); if (!System.IO.File.Exists(fileName)) { //Valid path, but the file does not exist Plugin.currentHost.AddMessage(MessageType.Error, false, "The sound path " + c.InnerText + " in XML node " + node.Name + " does not exist."); Sound = new CarSound(); return; } } catch { //Probably invalid filename characters Plugin.currentHost.AddMessage(MessageType.Error, false, "The sound path " + c.InnerText + " in XML node " + node.Name + " is invalid."); Sound = new CarSound(); return; } break; case "position": string[] Arguments = c.InnerText.Split(','); double x = 0.0, y = 0.0, z = 0.0; if (Arguments.Length >= 1 && Arguments[0].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[0], out x)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Sound radius X " + Arguments[0] + " in XML node " + node.Name + " is invalid."); x = 0.0; } if (Arguments.Length >= 2 && Arguments[1].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[1], out y)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Sound radius Y " + Arguments[1] + " in XML node " + node.Name + " is invalid."); y = 0.0; } if (Arguments.Length >= 3 && Arguments[2].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[2], out z)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Sound radius Z " + Arguments[2] + " in XML node " + node.Name + " is invalid."); z = 0.0; } Position = new Vector3(x, y, z); break; case "radius": if (!NumberFormats.TryParseDoubleVb6(c.InnerText, out Radius)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "The sound radius " + c.InnerText + " in XML node " + node.Name + " is invalid."); } break; } } if (fileName == null) { //No valid filename node specified Plugin.currentHost.AddMessage(MessageType.Error, false, "XML node " + node.Name + " does not point to a valid sound file."); Sound = new CarSound(); return; } Sound = new CarSound(Plugin.currentHost, fileName, Radius, Position); }
public void Start() { CarSound carSound = target as CarSound; }
void LoadCar() { if (m_Car) _Pool.Save(m_Car.gameObject); string path = cop ? "police" : owner.carSet.carName; Spawn spawnPos = GetSpawnStartPos(); m_Car = _Pool.Load2(Resources.Load(path), spawnPos.pos, spawnPos.rot).GetComponent<CarControl>(); if (m_Car.m_CarDamage.meshTest) { m_Car.m_CarDamage.meshTest.Reset(this == _Player); m_Car.rigidbody.velocity = m_Car.rigidbody.angularVelocity = Vector3.zero; } //m_Car = ((GameObject)Instantiate(Resources.Load(path), spawnPos.pos, spawnPos.rot)).GetComponent<CarControl>(); m_Car.name = "Player Car " + pv.playerName; transformCar = m_Car.tr; rigidbody = m_Car.rigidbody; rigidbody.solverIterationCount = 6; m_CarSettings = m_Car.GetComponent<CarSettings>() as CarSettings; m_CarSound = m_Car.GetComponent<CarSound>() as CarSound; m_CarSettings.bypassABS = false; m_Car.pl = this; OnQualityChanged(); var priority = this == _Player ? 100 : 130; foreach (var a in GetComponents<AudioSource>()) a.priority = priority; foreach (var a in m_Car.audioSources) a.priority = priority; if (IsMine && !bot2) _Game.MainCamera.Target = m_Car.tr; AmplifyMotionEffect.RegisterRecursivelyS(m_Car.gameObject); }
public StationAdjustAlarm(TrainBase train) { this.baseTrain = train; this.AdjustAlarm = new CarSound(); this.Lit = false; }
/// <summary>Parses a single XML node into a car sound</summary> /// <param name="node">The node to parse</param> /// <param name="Sound">The car sound</param> /// <param name="Position">The default position of this sound (May be overriden by the node)</param> /// <param name="Radius">The default radius of this sound (May be overriden by the node)</param> private static void ParseNode(XmlNode node, out CarSound Sound, Vector3 Position, double Radius) { string fileName = null; foreach (XmlNode c in node.ChildNodes) { switch (c.Name.ToLowerInvariant()) { case "filename": try { fileName = OpenBveApi.Path.CombineFile(currentPath, c.InnerText); if (!File.Exists(fileName)) { //Valid path, but the file does not exist Sound = new CarSound(); return; } } catch { //Probably invalid filename characters Sound = new CarSound(); return; } break; case "position": string[] Arguments = c.InnerText.Split(','); double x = 0.0, y = 0.0, z = 0.0; if (Arguments.Length >= 1 && Arguments[0].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[0], out x)) { x = 0.0; } if (Arguments.Length >= 2 && Arguments[1].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[1], out y)) { y = 0.0; } if (Arguments.Length >= 3 && Arguments[2].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[2], out z)) { z = 0.0; } Position = new Vector3(x, y, z); break; case "radius": if (!NumberFormats.TryParseDoubleVb6(c.InnerText, out Radius)) { } break; } } if (fileName == null) { //No valid filename node specified Sound = new CarSound(); return; } Sound = new CarSound(Program.Sounds.RegisterBuffer(fileName, Radius), Position); }
private Horn(CarSound sound, bool loop) { this.Sound = sound; this.Loop = loop; }
// Start is called before the first frame update void Start() { Instance = this; }
public EmergencyHandle() { ApplicationSound = new CarSound(); ApplicationTime = Double.MaxValue; }
public EmergencyHandle(TrainBase train) { ApplicationSound = new CarSound(); ApplicationTime = Double.MaxValue; baseTrain = train; }