1 using System.Collections.Generic;
2 using System.Runtime.Serialization;
3 
4 namespace OpenBveApi.Runtime
5 {
6 	/// <summary>Represents data given to the plugin in the Elapse call.</summary>
7 	[DataContract]
8 	public class ElapseData
9 	{
10 		/// <summary>The state of the train.</summary>
11 		[DataMember]
12 		private readonly VehicleState MyVehicle;
13 
14 		/// <summary>The state of the preceding train, or a null reference if there is no preceding train.</summary>
15 		[DataMember]
16 		private readonly PrecedingVehicleState MyPrecedingVehicle;
17 
18 		/// <summary>The virtual handles.</summary>
19 		[DataMember]
20 		private Handles MyHandles;
21 
22 		/// <summary>The state of the door interlock.</summary>
23 		[DataMember]
24 		private DoorInterlockStates MyDoorInterlockState;
25 
26 		/// <summary>The current absolute time.</summary>
27 		[DataMember]
28 		private readonly Time MyTotalTime;
29 
30 		/// <summary>The elapsed time since the last call to Elapse.</summary>
31 		[DataMember]
32 		private readonly Time MyElapsedTime;
33 
34 		/// <summary>The debug message the plugin wants the host application to display.</summary>
35 		[DataMember]
36 		private string MyDebugMessage;
37 
38 		/// <summary>Whether the plugin requests that time acceleration is disabled.</summary>
39 		[DataMember]
40 		private bool MyDisableTimeAcceleration;
41 
42 		/// <summary>Stores the list of current stations.</summary>
43 		[DataMember]
44 		private readonly List<Station> MyStations;
45 
46 		/// <summary>The current camera view mode.</summary>
47 		[DataMember]
48 		private readonly CameraViewMode MyCameraViewMode;
49 
50 		/// <summary>The current interface language code.</summary>
51 		[DataMember]
52 		private readonly string MyLanguageCode;
53 
54 		/// <summary>The current destination code</summary>
55 		[DataMember]
56 		private readonly int CurrentDestination;
57 
58 		/// <summary>Creates a new instance of this class.</summary>
59 		/// <param name="vehicle">The state of the train.</param>
60 		/// <param name="precedingVehicle">The state of the preceding train, or a null reference if there is no preceding train.</param>
61 		/// <param name="handles">The virtual handles.</param>
62 		/// <param name="doorinterlock">Whether the door interlock is currently enabled</param>
63 		/// <param name="totalTime">The current absolute time.</param>
64 		/// <param name="elapsedTime">The elapsed time since the last call to Elapse.</param>
65 		/// <param name="stations">The current route's list of stations.</param>
66 		/// <param name="cameraView">The current camera view mode</param>
67 		/// <param name="languageCode">The current language code</param>
68 		/// <param name="destination">The current destination</param>
ElapseData(VehicleState vehicle, PrecedingVehicleState precedingVehicle, Handles handles, DoorInterlockStates doorinterlock, Time totalTime, Time elapsedTime, List<Station> stations, CameraViewMode cameraView, string languageCode, int destination)69 		public ElapseData(VehicleState vehicle, PrecedingVehicleState precedingVehicle, Handles handles, DoorInterlockStates doorinterlock, Time totalTime, Time elapsedTime, List<Station> stations, CameraViewMode cameraView, string languageCode, int destination)
70 		{
71 			this.MyVehicle = vehicle;
72 			this.MyPrecedingVehicle = precedingVehicle;
73 			this.MyHandles = handles;
74 			this.MyDoorInterlockState = doorinterlock;
75 			this.MyTotalTime = totalTime;
76 			this.MyElapsedTime = elapsedTime;
77 			this.MyDebugMessage = null;
78 			this.MyStations = stations;
79 			this.MyCameraViewMode = cameraView;
80 			this.MyLanguageCode = languageCode;
81 			this.CurrentDestination = destination;
82 		}
83 
84 
85 		/// <summary>Gets the state of the train.</summary>
86 		public VehicleState Vehicle
87 		{
88 			get
89 			{
90 				return this.MyVehicle;
91 			}
92 		}
93 
94 		/// <summary>Gets the state of the preceding train, or a null reference if there is no preceding train.</summary>
95 		public PrecedingVehicleState PrecedingVehicle
96 		{
97 			get
98 			{
99 				return this.MyPrecedingVehicle;
100 			}
101 		}
102 
103 		/// <summary>Gets or sets the virtual handles.</summary>
104 		public Handles Handles
105 		{
106 			get
107 			{
108 				return this.MyHandles;
109 			}
110 			set
111 			{
112 				this.MyHandles = value;
113 			}
114 		}
115 
116 		/// <summary>Gets or sets the state of the door lock.</summary>
117 		public DoorInterlockStates DoorInterlockState
118 		{
119 			get
120 			{
121 				return this.MyDoorInterlockState;
122 			}
123 			set
124 			{
125 				this.MyDoorInterlockState = value;
126 			}
127 		}
128 
129 		/// <summary>Gets the absolute in-game time.</summary>
130 		public Time TotalTime
131 		{
132 			get
133 			{
134 				return this.MyTotalTime;
135 			}
136 		}
137 
138 		/// <summary>Gets the time that elapsed since the last call to Elapse.</summary>
139 		public Time ElapsedTime
140 		{
141 			get
142 			{
143 				return this.MyElapsedTime;
144 			}
145 		}
146 
147 		/// <summary>Gets or sets the debug message the plugin wants the host application to display.</summary>
148 		public string DebugMessage
149 		{
150 			get
151 			{
152 				return this.MyDebugMessage;
153 			}
154 			set
155 			{
156 				this.MyDebugMessage = value;
157 			}
158 		}
159 
160 		/// <summary>Gets or sets the disable time acceleration bool.</summary>
161 		public bool DisableTimeAcceleration
162 		{
163 			get
164 			{
165 				return this.MyDisableTimeAcceleration;
166 			}
167 			set
168 			{
169 				this.MyDisableTimeAcceleration = value;
170 			}
171 		}
172 
173 		/// <summary>Returns the list of stations in the current route.</summary>
174 		public List<Station> Stations
175 		{
176 			get
177 			{
178 				return this.MyStations;
179 			}
180 		}
181 
182 		/// <summary>Gets the current camera view mode.</summary>
183 		public CameraViewMode CameraViewMode
184 		{
185 			get
186 			{
187 				return this.MyCameraViewMode;
188 			}
189 		}
190 
191 		/// <summary>Gets the current user interface language code.</summary>
192 		public string CurrentLanguageCode
193 		{
194 			get
195 			{
196 				return this.MyLanguageCode;
197 			}
198 		}
199 
200 		/// <summary>Gets the destination variable as set by the plugin</summary>
201 		public int Destination
202 		{
203 			get
204 			{
205 				return this.CurrentDestination;
206 			}
207 		}
208 	}
209 }
210