Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class SPWireState
- {
- // State < 0: ошибка (несколько контроллеров)
- // State == 0: нейтральное состояние (такой ControllerState игнорируется)
- // State > 0: активное состояние (ControllerState распространяется по всему проводу)
- public int State;
- public float Voltage; // Current = Voltage * InvResistance
- public int ControllerState;
- public float ControllerVoltage;
- public int ActiveCount = 0;
- public float TotalInvResistance = 0.0f;
- public bool Active = false;
- public float InvResistance = 0.0f;
- public SPIntMap ControlWires;
- };
- final class SPVehicle
- {
- /* ... */
- public SPIntMap GetControlWires(string name)
- {
- AssertNotDisposed();
- SPWireState wire = GetWire(name);
- if (wire)
- return wire.ControlWires;
- return null;
- }
- public SPIntMap GetControlWires(string name, bool neighbourDir)
- {
- AssertNotDisposed();
- int index = GetConnectionIndex(name);
- if (GetWireState(index, neighbourDir) == SPConnector.StateConnected)
- return GetNeighbour(neighbourDir).GetWire(name).ControlWires;
- return null;
- }
- public int GetCWState(string name, string wireName)
- {
- AssertNotDisposed();
- SPWireState wire = GetWire(name);
- if (wire and wire.ControlWires)
- return wire.ControlWires.Get(wireName, 0);
- return 0;
- }
- public void SetCWState(string name, string wireName, int value)
- {
- AssertNotDisposed();
- SPWireState wire = GetWire(name);
- if (wire and wire.ControlWires)
- wire.ControlWires.Set(wireName, value);
- }
- public SPIntMap GetNeighbourCWState(string wireName, bool neighbourDir, string wireName)
- {
- AssertNotDisposed();
- int index = GetConnectionIndex(name);
- if (GetWireState(index, neighbourDir) == SPConnector.StateConnected) {
- SPIntMap controlWires = GetNeighbour(neighbourDir).GetWire(name).ControlWires;
- if (controlWires)
- return controlWires.Get(wireName, 0);
- }
- return 0;
- }
- /* ... */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement