-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocoShunter.cs
52 lines (45 loc) · 1.58 KB
/
LocoShunter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
namespace DvRemoteRemote
{
public class LocoShunter : Loco<ShunterLocoState, ShunterLocoActions>
{
private readonly LocoControllerShunter _inner;
private readonly LocoBase _base;
private readonly ShunterLocoSimulation _sim;
public LocoShunter(LocoControllerShunter inner)
{
_inner = inner;
_base = new LocoBase(inner);
_sim = inner.GetComponent<ShunterLocoSimulation>();
}
/// <inheritdoc />
public override void GetState(ShunterLocoState state)
{
_base.GetState(state);
state.LocoType = "shunter";
state.Sander = _inner.GetSandersOn() ? 1 : 0;
state.SanderFlow = _inner.GetSandersFlow() / _sim.sandFlow.max;
state.EngineTemp = _inner.GetEngineTemp();
state.EngineOn = _inner.EngineOn;
}
/// <inheritdoc />
public override void GetActions(ShunterLocoActions actions)
{
_base.GetActions(actions);
actions.SetSander = val => _inner.SetSandersOn(val >= 0.5f);
actions.SetEngineOn = on => _inner.EngineOn = on;
}
}
public class ShunterLocoState : BaseLocoState
{
public float Sander { get; set; }
public float SanderFlow { get; set; }
public float EngineTemp { get; set; }
public bool EngineOn { get; set; }
}
public class ShunterLocoActions : BaseLocoActions
{
public Action<float> SetSander { get; set; }
public Action<bool> SetEngineOn { get; set; }
}
}