1 using OpenBveApi.Colors;
2 
3 namespace OpenBveApi.Runtime {
4 
5 	/* ----------------------------------------------------
6 	 * This part of the API is stable as of openBVE 1.2.10.
7 	 * Any modification must retain backward compatibility.
8 	 * ---------------------------------------------------- */
9 
10 	/// <summary>Plays a sound.</summary>
11 	/// <param name="index">The index to the sound to be played.</param>
12 	/// <param name="volume">The initial volume of the sound. A value of 1.0 represents nominal volume.</param>
13 	/// <param name="pitch">The initial pitch of the sound. A value of 1.0 represents nominal pitch.</param>
14 	/// <param name="looped">Whether the sound should be played in an indefinate loop.</param>
15 	/// <returns>The handle to the sound, or a null reference if the sound could not be played.</returns>
16 	/// <exception cref="System.InvalidOperationException">Raised when the host application does not allow the function to be called.</exception>
PlaySoundDelegate(int index, double volume, double pitch, bool looped)17 	public delegate SoundHandle PlaySoundDelegate(int index, double volume, double pitch, bool looped);
18 
19     /// <summary>Plays a sound.</summary>
20     /// <param name="index">The index to the sound to be played.</param>
21     /// <param name="volume">The initial volume of the sound. A value of 1.0 represents nominal volume.</param>
22     /// <param name="pitch">The initial pitch of the sound. A value of 1.0 represents nominal pitch.</param>
23     /// <param name="looped">Whether the sound should be played in an indefinate loop.</param>
24     /// <param name="carIndex">The index of the car this sound is to be attached to</param>
25     /// <returns>The handle to the sound, or a null reference if the sound could not be played.</returns>
26     /// <exception cref="System.InvalidOperationException">Raised when the host application does not allow the function to be called.</exception>
PlayCarSoundDelegate(int index, double volume, double pitch, bool looped, int carIndex)27     public delegate SoundHandle PlayCarSoundDelegate(int index, double volume, double pitch, bool looped, int carIndex);
28 
29 	/// <summary>Adds a message to the in-game display</summary>
30 	/// <param name="Message">The message to display</param>
31 	/// <param name="Color">The color in which to display the message</param>
32 	/// <param name="Time">The time in seconds for which to display the message</param>
AddInterfaceMessageDelegate(string Message, MessageColor Color, double Time)33 	public delegate void AddInterfaceMessageDelegate(string Message, MessageColor Color, double Time);
34 
35 	/// <summary>Adds a score to the after game log</summary>
36 	/// <param name="Score">The score to add or subtract</param>
37 	/// <param name="Message">The message to be displayed in the post-game log</param>
38 	/// /// <param name="Color">The color in which to display the message</param>
39 	/// <param name="Time">The time in seconds for which to display the message</param>
AddScoreDelegate(int Score, string Message, MessageColor Color, double Time)40 	public delegate void AddScoreDelegate(int Score, string Message, MessageColor Color, double Time);
41 
42 	/// <summary>Represents the interface for performing runtime train services.</summary>
43 	public interface IRuntime
44 	{
45 		/// <summary>Is called when the plugin is loaded.</summary>
46 		/// <param name="properties">The properties supplied to the plugin on loading.</param>
47 		/// <returns>Whether the plugin was loaded successfully.</returns>
48 		/// <remarks>If the plugin was not loaded successfully, the plugin should set the Reason property to supply the reason of failure.</remarks>
Load(LoadProperties properties)49 		bool Load(LoadProperties properties);
50 
51 		/// <summary>Is called when the plugin is unloaded.</summary>
Unload()52 		void Unload();
53 
54 		/// <summary>Is called after loading to inform the plugin about the specifications of the train.</summary>
55 		/// <param name="specs">The specifications of the train.</param>
SetVehicleSpecs(VehicleSpecs specs)56 		void SetVehicleSpecs(VehicleSpecs specs);
57 
58 		/// <summary>Is called when the plugin should initialize or reinitialize.</summary>
59 		/// <param name="mode">The mode of initialization.</param>
Initialize(InitializationModes mode)60 		void Initialize(InitializationModes mode);
61 
62 		/// <summary>Is called every frame.</summary>
63 		/// <param name="data">The data passed to the plugin.</param>
Elapse(ElapseData data)64 		void Elapse(ElapseData data);
65 
66 		/// <summary>Is called when the driver changes the reverser.</summary>
67 		/// <param name="reverser">The new reverser position.</param>
SetReverser(int reverser)68 		void SetReverser(int reverser);
69 
70 		/// <summary>Is called when the driver changes the power notch.</summary>
71 		/// <param name="powerNotch">The new power notch.</param>
SetPower(int powerNotch)72 		void SetPower(int powerNotch);
73 
74 		/// <summary>Is called when the driver changes the brake notch.</summary>
75 		/// <param name="brakeNotch">The new brake notch.</param>
SetBrake(int brakeNotch)76 		void SetBrake(int brakeNotch);
77 
78 		/// <summary>Is called when a virtual key is pressed.</summary>
79 		/// <param name="key">The virtual key that was pressed.</param>
KeyDown(VirtualKeys key)80 		void KeyDown(VirtualKeys key);
81 
82 		/// <summary>Is called when a virtual key is released.</summary>
83 		/// <param name="key">The virtual key that was released.</param>
KeyUp(VirtualKeys key)84 		void KeyUp(VirtualKeys key);
85 
86 		/// <summary>Is called when a horn is played or when the music horn is stopped.</summary>
87 		/// <param name="type">The type of horn.</param>
HornBlow(HornTypes type)88 		void HornBlow(HornTypes type);
89 
90 		/// <summary>Is called when the state of the doors changes.</summary>
91 		/// <param name="oldState">The old state of the doors.</param>
92 		/// <param name="newState">The new state of the doors.</param>
DoorChange(DoorStates oldState, DoorStates newState)93 		void DoorChange(DoorStates oldState, DoorStates newState);
94 
95 		/// <summary>Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.</summary>
96 		/// <param name="data">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
97 		/// <remarks>The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.</remarks>
SetSignal(SignalData[] data)98 		void SetSignal(SignalData[] data);
99 
100 		/// <summary>Is called when the train passes a beacon.</summary>
101 		/// <param name="data">The beacon data.</param>
SetBeacon(BeaconData data)102 		void SetBeacon(BeaconData data);
103 
104 		/// <summary>Is called when the plugin should perform the AI.</summary>
105 		/// <param name="data">The AI data.</param>
PerformAI(AIData data)106 		void PerformAI(AIData data);
107 
108 	}
109 
110 }
111