@@ -8,7 +8,7 @@ namespace Funbit.Ets.Telemetry.Server.Data
8
8
class Ets2TelemetryData : IEts2TelemetryData
9
9
{
10
10
Box < Ets2TelemetryStructure > _rawData ;
11
-
11
+
12
12
public void Update ( Ets2TelemetryStructure rawData )
13
13
{
14
14
_rawData = new Box < Ets2TelemetryStructure > ( rawData ) ;
@@ -34,7 +34,6 @@ internal static string BytesToString(byte[] bytes)
34
34
35
35
public IEts2Game Game => new Ets2Game ( _rawData ) ;
36
36
public IEts2Truck Truck => new Ets2Truck ( _rawData ) ;
37
- public IEts2Trailer Trailer => new Ets2Trailer ( _rawData ) ;
38
37
public IEts2Job Job => new Ets2Job ( _rawData ) ;
39
38
public IEts2Navigation Navigation => new Ets2Navigation ( _rawData ) ;
40
39
}
@@ -59,6 +58,11 @@ public Ets2Game(Box<Ets2TelemetryStructure> rawData)
59
58
public DateTime NextRestStopTime => Ets2TelemetryData . MinutesToDate ( _rawData . Struct . nextRestStop ) ;
60
59
public string Version => $ "{ _rawData . Struct . ets2_version_major } .{ _rawData . Struct . ets2_version_minor } ";
61
60
public string TelemetryPluginVersion => _rawData . Struct . ets2_telemetry_plugin_revision . ToString ( ) ;
61
+
62
+ public string Everything =>
63
+ $ "Stats for game:\n Game: { GameName } \n Paused: { Paused } \n Time: { Time . ToString ( ) } \n " +
64
+ $ "Next Rest Stop Time: { NextRestStopTime } \n Time Scale: { TimeScale } \n Game Version: { Version } \n Telemetry Version: { TelemetryPluginVersion } " +
65
+ $ "{ ( TimeScale == 0 ? "\n \n (Game is " + ( Connected ? "closed)" : "starting up)" ) : "" ) } ";
62
66
}
63
67
64
68
class Ets2Vector : IEts2Vector
@@ -112,12 +116,12 @@ public Ets2Truck(Box<Ets2TelemetryStructure> rawData)
112
116
/// <summary>
113
117
/// Truck speed in km/h.
114
118
/// </summary>
115
- public float Speed => _rawData . Struct . speed * 3.6f ;
119
+ public int Speed => ( int ) ( _rawData . Struct . speed * 3.6f ) ;
116
120
117
121
/// <summary>
118
122
/// Cruise control speed in km/h.
119
123
/// </summary>
120
- public float CruiseControlSpeed => _rawData . Struct . cruiseControlSpeed * 3.6f ;
124
+ public int CruiseControlSpeed => ( int ) ( _rawData . Struct . cruiseControlSpeed * 3.6f ) ;
121
125
122
126
public bool CruiseControlOn => _rawData . Struct . cruiseControl != 0 ;
123
127
public float Odometer => _rawData . Struct . truckOdometer ;
@@ -126,7 +130,7 @@ public Ets2Truck(Box<Ets2TelemetryStructure> rawData)
126
130
public int ForwardGears => _rawData . Struct . gearsForward ;
127
131
public int ReverseGears => _rawData . Struct . gearsReverse ;
128
132
public string ShifterType => Ets2TelemetryData . BytesToString ( _rawData . Struct . shifterType ) ;
129
- public float EngineRpm => _rawData . Struct . engineRpm ;
133
+ public int EngineRpm => ( int ) _rawData . Struct . engineRpm ;
130
134
public float EngineRpmMax => _rawData . Struct . engineRpmMax ;
131
135
public float Fuel => _rawData . Struct . fuel ;
132
136
public float FuelCapacity => _rawData . Struct . fuelCapacity ;
@@ -246,46 +250,31 @@ public IEts2Wheel[] Wheels
246
250
}
247
251
}
248
252
*/
249
- }
250
-
251
- class Ets2Trailer : IEts2Trailer
252
- {
253
- readonly Box < Ets2TelemetryStructure > _rawData ;
254
253
255
- public Ets2Trailer ( Box < Ets2TelemetryStructure > rawData )
256
- {
257
- _rawData = rawData ;
258
- }
254
+ public string Everything =>
255
+ $ "Stats for truck:\n Name: { Make } { Model } \n Odometer: { Odometer } \n \n " +
256
+ $ "Speed: { Speed } KMH\n " +
257
+ ( Speed == 0 ? $ "Parking Brake Engaged: { ParkBrakeOn } \n " : $ "RPM: { EngineRpm } /{ EngineRpmMax } \n ") +
258
+ ( CruiseControlOn ? $ "Cruise Control Speed: { int . Parse ( CruiseControlSpeed . ToString ( ) ) } \n " : "" ) +
259
+ $ "Gear: { ( DisplayedGear == 0 ? "N" : DisplayedGear . ToString ( ) ) } /{ ForwardGears + ReverseGears } ({ ForwardGears } /{ ReverseGears } )\n Shift Type: { ShifterType } \n " +
260
+ $ "Fuel: { Fuel } /{ FuelCapacity } \n \n " +
259
261
260
- public bool Attached => _rawData . Struct . trailer_attached != 0 ;
261
- public string Id => Ets2TelemetryData . BytesToString ( _rawData . Struct . trailerId ) ;
262
- public string Name => Ets2TelemetryData . BytesToString ( _rawData . Struct . trailerName ) ;
262
+ $ "Damages:\n Cabin: { WearCabin } \n Chassis: { WearChassis } \n Engine: { WearEngine } \n Transmission: { WearTransmission } \n Wheels: { WearWheels } \n \n " +
263
263
264
- /// <summary>
265
- /// Trailer mass in kilograms.
266
- /// </summary>
267
- public float Mass => _rawData . Struct . trailerMass ;
268
-
269
- public float Wear => _rawData . Struct . wearTrailer ;
270
-
271
- public IEts2Placement Placement => new Ets2Placement (
272
- _rawData . Struct . trailerCoordinateX ,
273
- _rawData . Struct . trailerCoordinateY ,
274
- _rawData . Struct . trailerCoordinateZ ,
275
- _rawData . Struct . trailerRotationX ,
276
- _rawData . Struct . trailerRotationY ,
277
- _rawData . Struct . trailerRotationZ ) ;
264
+ $ "Lights: " + ( LightsBeamHighOn ? "On (High Beams)" : LightsBeamLowOn ? "On" : "Off" ) + "\n \n " +
265
+ ( BlinkerLeftOn ? "**Turning Left**" : "" ) +
266
+ ( BlinkerRightOn ? "**Turning Right**" : "" ) ;
278
267
}
279
268
280
269
class Ets2Navigation : IEts2Navigation
281
270
{
282
271
readonly Box < Ets2TelemetryStructure > _rawData ;
283
-
272
+
284
273
public Ets2Navigation ( Box < Ets2TelemetryStructure > rawData )
285
274
{
286
275
_rawData = rawData ;
287
276
}
288
-
277
+
289
278
public DateTime EstimatedTime => Ets2TelemetryData . SecondsToDate ( ( int ) _rawData . Struct . navigationTime ) ;
290
279
public int EstimatedDistance => ( int ) _rawData . Struct . navigationDistance ;
291
280
public int SpeedLimit => _rawData . Struct . navigationSpeedLimit > 0 ? ( int ) Math . Round ( _rawData . Struct . navigationSpeedLimit * 3.6f ) : 0 ;
@@ -300,9 +289,24 @@ public Ets2Job(Box<Ets2TelemetryStructure> rawData)
300
289
_rawData = rawData ;
301
290
}
302
291
292
+ public bool Attached => _rawData . Struct . trailer_attached != 0 ;
293
+ public string Id => Ets2TelemetryData . BytesToString ( _rawData . Struct . trailerId ) ;
294
+ public string Name => Ets2TelemetryData . BytesToString ( _rawData . Struct . trailerName ) ;
295
+ public float Mass => _rawData . Struct . trailerMass ;
296
+
297
+ public float Wear => _rawData . Struct . wearTrailer ;
298
+
299
+ public IEts2Placement Placement => new Ets2Placement (
300
+ _rawData . Struct . trailerCoordinateX ,
301
+ _rawData . Struct . trailerCoordinateY ,
302
+ _rawData . Struct . trailerCoordinateZ ,
303
+ _rawData . Struct . trailerRotationX ,
304
+ _rawData . Struct . trailerRotationY ,
305
+ _rawData . Struct . trailerRotationZ ) ;
306
+
303
307
public int Income => _rawData . Struct . jobIncome ;
304
308
public DateTime DeadlineTime => Ets2TelemetryData . MinutesToDate ( _rawData . Struct . jobDeadline ) ;
305
- public DateTime RemainingTime
309
+ public DateTime RemainingTime
306
310
{
307
311
get
308
312
{
@@ -311,11 +315,18 @@ public DateTime RemainingTime
311
315
return Ets2TelemetryData . MinutesToDate ( 0 ) ;
312
316
}
313
317
}
318
+ public DateTime EstimatedTime => Ets2TelemetryData . SecondsToDate ( ( int ) _rawData . Struct . navigationTime ) ;
319
+ public int EstimatedDistance => ( int ) _rawData . Struct . navigationDistance ;
314
320
315
321
public string SourceCity => Ets2TelemetryData . BytesToString ( _rawData . Struct . jobCitySource ) ;
316
322
public string SourceCompany => Ets2TelemetryData . BytesToString ( _rawData . Struct . jobCompanySource ) ;
317
323
public string DestinationCity => Ets2TelemetryData . BytesToString ( _rawData . Struct . jobCityDestination ) ;
318
324
public string DestinationCompany => Ets2TelemetryData . BytesToString ( _rawData . Struct . jobCompanyDestination ) ;
325
+
326
+ public string Everything =>
327
+ $ "Stats for job:\n Delivering { Name } (Internal Name: { Id } ) from { SourceCity } ({ SourceCompany } ) to { DestinationCity } ({ DestinationCompany } )\n Pay: { Income } \n \n " +
328
+ $ "Estimated Arrival: { EstimatedTime . Hour } :{ EstimatedTime . Minute } :{ EstimatedTime . Second } \n Time Left: { EstimatedTime . Hour } :{ EstimatedTime . Minute } :{ EstimatedTime . Second } \n \n " +
329
+ $ "Trailer:\n Attached: { Attached } \n Weight: { Mass } KG\n Damage: { Wear } ";
319
330
}
320
331
321
332
/*
@@ -357,7 +368,7 @@ public Ets2GearSlot(Box<Ets2TelemetryStructure> rawData, int slotIndex)
357
368
}
358
369
*/
359
370
360
- class Box < T > where T : struct
371
+ class Box < T > where T : struct
361
372
{
362
373
public T Struct { get ; set ; }
363
374
0 commit comments