public void Init(ZACommons commons, EventDriver eventDriver) { var stateValue = commons.GetValue(StateKey); if (stateValue != null) { int state; if (int.TryParse(stateValue, out state)) { // Use remembered state CurrentState = state; // Should really validate, but eh... } } else { CurrentState = STATE_ACTIVE; } if (PRODUCTION_MANAGER_SETUP) { Setup(LIMIT_PRODUCTION_MANAGER_SAME_GRID ? commons.Blocks : commons.AllBlocks); } else if (CurrentState != STATE_INACTIVE) { eventDriver.Schedule(0.0, Run); } }
public void Init(ZACommons commons, EventDriver eventDriver) { var previous = commons.GetValue(LOSMinerKey); if (previous != null) { var parts = previous.Split(';'); if (parts.Length == 13) { // Resume original mode and line-of-sight vector var newMode = int.Parse(parts[0]); StartPoint = new Vector3D(); StartDirection = new Vector3D(); StartUp = new Vector3D(); StartLeft = new Vector3D(); for (int i = 0; i < 3; i++) { StartPoint.SetDim(i, double.Parse(parts[i+1])); StartDirection.SetDim(i, double.Parse(parts[i+4])); StartUp.SetDim(i, double.Parse(parts[i+7])); StartLeft.SetDim(i, double.Parse(parts[i+10])); } if (newMode == MINING) { Start((ShipControlCommons)commons, eventDriver); } else if (newMode == REVERSING) { StartReverse((ShipControlCommons)commons, eventDriver); } } } }
public void Init(ZACommons commons, EventDriver eventDriver) { var previous = commons.GetValue(LOSMinerKey); if (previous != null) { var parts = previous.Split(';'); if (parts.Length == 13) { // Resume original mode and line-of-sight vector var newMode = int.Parse(parts[0]); StartPoint = new Vector3D(); StartDirection = new Vector3D(); StartUp = new Vector3D(); StartLeft = new Vector3D(); for (int i = 0; i < 3; i++) { StartPoint.SetDim(i, double.Parse(parts[i + 1])); StartDirection.SetDim(i, double.Parse(parts[i + 4])); StartUp.SetDim(i, double.Parse(parts[i + 7])); StartLeft.SetDim(i, double.Parse(parts[i + 10])); } if (newMode == MINING) { Start((ShipControlCommons)commons, eventDriver); } else if (newMode == REVERSING) { StartReverse((ShipControlCommons)commons, eventDriver); } } } }
public void Init(ZACommons commons, EventDriver eventDriver, Func<ZACommons, EventDriver, bool> livenessCheck = null) { LivenessCheck = livenessCheck; var lastCommand = commons.GetValue(LastCommandKey); if (lastCommand != null) { HandleCommand(commons, eventDriver, lastCommand); } }
public void Init(ZACommons commons, EventDriver eventDriver, Func <ZACommons, EventDriver, bool> livenessCheck = null) { LivenessCheck = livenessCheck; var lastCommand = commons.GetValue(LastCommandKey); if (lastCommand != null) { HandleCommand(commons, eventDriver, lastCommand); } }
public void Init(ZACommons commons, EventDriver eventDriver, Func<ZACommons, EventDriver, bool> livenessCheck = null) { LivenessCheck = livenessCheck; var lastCommand = commons.GetValue(LastCommandKey); if (lastCommand != null) { HandleCommand(commons, eventDriver, lastCommand); // Can't trust current state, force a reset on "cruise stop" ThrusterStates.Clear(); FirstStop = true; } }
public void Init(ZACommons commons, EventDriver eventDriver, Func <ZACommons, EventDriver, bool> livenessCheck = null) { LivenessCheck = livenessCheck; var lastCommand = commons.GetValue(LastCommandKey); if (lastCommand != null) { HandleCommand(commons, eventDriver, lastCommand); // Can't trust current state, force a reset on "cruise stop" ThrusterStates.Clear(); FirstStop = true; } }
public void ConditionalInit(ZACommons commons, EventDriver eventDriver, bool defaultActive = false) { var activeValue = commons.GetValue(ActiveKey); if (activeValue != null) { bool active; if (Boolean.TryParse(activeValue, out active)) { if (active) Init(commons, eventDriver); return; } } if (defaultActive) Init(commons, eventDriver); }
public void Init(ZACommons commons, EventDriver eventDriver, ZACustomData customData, Func <ZACommons, EventDriver, bool> livenessCheck = null) { BurnDirection = customData.GetDirection("burnDirection", VTVLHELPER_BURN_DIRECTION); BrakeDirection = customData.GetDirection("brakeDirection", VTVLHELPER_BRAKE_DIRECTION); LaunchDirection = customData.GetDirection("launchDirection", VTVLHELPER_LAUNCH_DIRECTION); LivenessCheck = livenessCheck; var lastCommand = commons.GetValue(LastCommandKey); if (lastCommand != null) { HandleCommand(commons, eventDriver, lastCommand); } }
public void Init(ZACommons commons, EventDriver eventDriver) { Mode = IDLE; var modeString = commons.GetValue(ModeKey); if (modeString != null) { var newMode = int.Parse(modeString); switch (newMode) { case IDLE: break; case ACTIVE: Start(commons, eventDriver, false); break; case AUTO: Start(commons, eventDriver, true); break; } } }
public void ConditionalInit(ZACommons commons, EventDriver eventDriver, bool defaultActive = false) { var activeValue = commons.GetValue(ActiveKey); if (activeValue != null) { bool active; if (Boolean.TryParse(activeValue, out active)) { if (active) { Init(commons, eventDriver); } return; } } if (defaultActive) { Init(commons, eventDriver); } }
public void Init(ZACommons commons, EventDriver eventDriver) { Mode = Modes.Idle; var modeString = commons.GetValue(ModeKey); if (modeString != null) { var newMode = int.Parse(modeString); switch ((Modes)newMode) { case Modes.Idle: break; case Modes.Active: Start(commons, eventDriver, false); break; case Modes.Auto: Start(commons, eventDriver, true); break; } } }
public void Init(ZACommons commons, EventDriver eventDriver) { Mode = IDLE; var modeString = commons.GetValue(ModeKey); if (modeString != null) { var newMode = int.Parse(modeString); switch (newMode) { case IDLE: break; case ACTIVE: Start(commons, eventDriver, false); break; case AUTO: Start(commons, eventDriver, true); break; } } }
public void Init(ZACommons commons, EventDriver eventDriver) { var stateValue = commons.GetValue(StateKey); if (stateValue != null) { int state; if (int.TryParse(stateValue, out state)) { // Use remembered state CurrentState = state; // Should really validate, but eh... } } else { CurrentState = STATE_ACTIVE; } if (PRODUCTION_MANAGER_SETUP) { Setup(LIMIT_PRODUCTION_MANAGER_SAME_GRID ? commons.Blocks : commons.AllBlocks); } else if (CurrentState != STATE_INACTIVE) { eventDriver.Schedule(0.0, Run); } }
public void Init(ZACommons commons, EventDriver eventDriver) { UndockTarget = null; var previousTarget = commons.GetValue(UndockTargetKey); if (previousTarget != null) { var parts = previousTarget.Split(';'); if (parts.Length == 7) { UndockTarget = new Vector3D(double.Parse(parts[0]), double.Parse(parts[1]), double.Parse(parts[2])); var orientation = new QuaternionD(double.Parse(parts[3]), double.Parse(parts[4]), double.Parse(parts[5]), double.Parse(parts[6])); UndockForward = Transform(Vector3D.Forward, orientation); UndockUp = Transform(Vector3D.Up, orientation); } } UndockBackward = null; var backwardString = commons.GetValue(BackwardKey); if (backwardString != null) { // Enum.Parse apparently works, but I don't trust Keen // not breaking it in the future (by making typeof() illegal) //UndockBackward = (Base6Directions.Direction)Enum.Parse(typeof(Base6Directions.Direction), backwardString); UndockBackward = (Base6Directions.Direction) byte.Parse(backwardString); } Mode = Modes.Idle; var modeString = commons.GetValue(ModeKey); if (modeString != null) { Mode = (Modes)int.Parse(modeString); switch (Mode) { case Modes.Idle: break; case Modes.Undocking: if (UndockTarget != null && UndockBackward != null) { BeginUndock(commons, eventDriver); } else { ResetMode(commons); } break; case Modes.Returning: if (UndockTarget != null) { BeginReturn(commons, eventDriver); } else { ResetMode(commons); } break; case Modes.Orienting: if (UndockTarget != null) { ReorientStart(commons, eventDriver); } else { ResetMode(commons); } break; } } }
public void Init(ZACommons commons, EventDriver eventDriver) { UndockTarget = null; var previousTarget = commons.GetValue(UndockTargetKey); if (previousTarget != null) { var parts = previousTarget.Split(';'); if (parts.Length == 9) { var newTarget = new Vector3D(); UndockForward = new Vector3D(); UndockUp = new Vector3D(); for (int i = 0; i < 3; i++) { newTarget.SetDim(i, double.Parse(parts[i])); UndockForward.SetDim(i, double.Parse(parts[3 + i])); UndockUp.SetDim(i, double.Parse(parts[6 + i])); } UndockTarget = newTarget; // Set only if all successfully parsed } } UndockBackward = null; var backwardString = commons.GetValue(BackwardKey); if (backwardString != null) { // Enum.Parse apparently works, but I don't trust Keen // not breaking it in the future (by making typeof() illegal) //UndockBackward = (Base6Directions.Direction)Enum.Parse(typeof(Base6Directions.Direction), backwardString); UndockBackward = (Base6Directions.Direction) byte.Parse(backwardString); } Mode = IDLE; var modeString = commons.GetValue(ModeKey); if (modeString != null) { Mode = int.Parse(modeString); switch (Mode) { case IDLE: break; case UNDOCKING: if (UndockTarget != null && UndockBackward != null) { BeginUndock(commons, eventDriver); } else { ResetMode(commons); } break; case RETURNING: if (UndockTarget != null) { BeginReturn(commons, eventDriver); } else { ResetMode(commons); } break; case ORIENTING: if (UndockTarget != null) { ReorientStart(commons, eventDriver); } else { ResetMode(commons); } break; } } }
public void Init(ZACommons commons, EventDriver eventDriver) { UndockTarget = null; var previousTarget = commons.GetValue(UndockTargetKey); if (previousTarget != null) { var parts = previousTarget.Split(';'); if (parts.Length == 9) { var newTarget = new Vector3D(); UndockForward = new Vector3D(); UndockUp = new Vector3D(); for (int i = 0; i < 3; i++) { newTarget.SetDim(i, double.Parse(parts[i])); UndockForward.SetDim(i, double.Parse(parts[3+i])); UndockUp.SetDim(i, double.Parse(parts[6+i])); } UndockTarget = newTarget; // Set only if all successfully parsed } } UndockBackward = null; var backwardString = commons.GetValue(BackwardKey); if (backwardString != null) { // Enum.Parse apparently works, but I don't trust Keen // not breaking it in the future (by making typeof() illegal) //UndockBackward = (Base6Directions.Direction)Enum.Parse(typeof(Base6Directions.Direction), backwardString); UndockBackward = (Base6Directions.Direction)byte.Parse(backwardString); } Mode = IDLE; var modeString = commons.GetValue(ModeKey); if (modeString != null) { Mode = int.Parse(modeString); switch (Mode) { case IDLE: break; case UNDOCKING: if (UndockTarget != null && UndockBackward != null) { BeginUndock(commons, eventDriver); } else ResetMode(commons); break; case RETURNING: if (UndockTarget != null) { BeginReturn(commons, eventDriver); } else ResetMode(commons); break; case ORIENTING: if (UndockTarget != null) { ReorientStart(commons, eventDriver); } else ResetMode(commons); break; } } }