public ActionResult Tick(IAIController ai) { if (_internalState == OperationalState.CompleteAndWaitingToReset) { this.Reset(); _actionState = this.OnStart(ai); if (_actionState > ActionResult.Waiting) { return(_actionState); } } else if (_actionState == ActionResult.None) { _actionState = this.OnStart(ai); if (_actionState > ActionResult.Waiting) { return(_actionState); } } _internalState = OperationalState.Active; _actionState = this.OnTick(ai); if (_internalState == OperationalState.Inactive) { //Reset was called during tick, probably by a 'ChangeState' call on a parent state machine. //exit cleanly _actionState = ActionResult.None; return(_actionState); } if (_actionState > ActionResult.Waiting) { _internalState = OperationalState.CompleteAndWaitingToReset; this.OnComplete(ai); if (_repeat != RepeatMode.Never && (int)_repeat != (int)_actionState) { _actionState = ActionResult.Waiting; } if (_alwaysSucceed && _actionState == ActionResult.Failed) { _actionState = ActionResult.Success; } } return(_actionState); }
public Oxygen Run(Dictionary <Data, object> segments) { OperationalState state = (OperationalState)segments[Data.OperationalState]; Version version = (Version)segments[Data.ReplicantVersion]; var oxygen = new Oxygen(); switch (state) { case OperationalState.Idle: case OperationalState.Sleeping: oxygen.Amount = 10; break; case OperationalState.Normal: oxygen.Amount = 50; break; case OperationalState.Running: oxygen.Amount = 75; break; case OperationalState.Panic: oxygen.Amount = 100; break; } // The new models of replicants have an improved utilization of oxygen and need lower // levels returns for operation. if (version.Major > 2) { oxygen.Amount = oxygen.Amount * 0.8; } return(oxygen); }
public AssayState(OperationalState os) : base(os) { }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="OperationalState" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => OperationalState.CreateFrom(sourceValue);
public void Reset() { _actionState = ActionResult.None; _internalState = OperationalState.Inactive; this.OnReset(); }