コード例 #1
0
ファイル: ShipItem.cs プロジェクト: Maxii/CodeEnv.Master
 /// <summary>
 /// Returns<c>true</c> if the current FormationStation doesn't meet the needs implied by the provided <c>purpose</c>, 
 /// <c>false</c> if the current station already meets those needs.    
 /// </summary>
 /// <param name="purpose">The purpose of the station change.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 private bool IsThereNeedForAFormationStationChangeTo(WithdrawPurpose purpose) {
     var currentStationInfo = FormationStation.StationInfo;
     switch (purpose) {
         case WithdrawPurpose.Disengage:
             D.Assert(!IsHQ, purpose.GetValueName());
             if (currentStationInfo.IsReserve) {
                 // current station already meets desired needs
                 return false;
             }
             return true;
         case WithdrawPurpose.Repair:
             if (IsHQ || currentStationInfo.IsReserve) {
                 return false;
             }
             return true;
         case WithdrawPurpose.None:
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(purpose));
     }
 }
コード例 #2
0
ファイル: ShipItem.cs プロジェクト: Maxii/CodeEnv.Master
    private void InitiateRepair(bool retainSuperiorsOrderOnRepairCompletion) {
        D.AssertNotEqual(ShipState.Repairing, CurrentState);
        D.Assert(!_debugSettings.DisableRepair);
        D.Assert(Data.Health < Constants.OneHundredPercent);

        //D.Log(ShowDebugLog, "{0} is investigating whether to Disengage or AssumeStation before Repairing.", DebugName);
        ShipOrder goToStationAndRepairOrder;
        if (IsThereNeedForAFormationStationChangeTo(WithdrawPurpose.Repair)) {
            // there is a need for a station change to repair
            D.AssertDefault((int)_fsmDisengagePurpose);
            _fsmDisengagePurpose = WithdrawPurpose.Repair;
            goToStationAndRepairOrder = new ShipOrder(ShipDirective.Disengage, OrderSource.Captain) {
                FollowonOrder = new ShipOrder(ShipDirective.Repair, OrderSource.Captain)
            };
        }
        else {
            // there is no need to change FormationStation because either ship is HQ or it is already assigned a reserve station
            goToStationAndRepairOrder = new ShipOrder(ShipDirective.AssumeStation, OrderSource.Captain) {
                FollowonOrder = new ShipOrder(ShipDirective.Repair, OrderSource.Captain)
            };
        }
        OverrideCurrentOrder(goToStationAndRepairOrder, retainSuperiorsOrderOnRepairCompletion);
    }
コード例 #3
0
ファイル: ShipItem.cs プロジェクト: Maxii/CodeEnv.Master
 /// <summary>
 /// Returns <c>true</c> and provides valid <c>stationSelectionCriteria</c> if the current FormationStation doesn't meet the needs
 /// implied by the provided <c>purpose</c>, <c>false</c> if the current station already meets those needs. If valid, the
 /// stationSelectionCritera will allow Command to determine whether a FormationStation is available that meets those needs.
 /// </summary>
 /// <param name="purpose">The purpose of the station change.</param>
 /// <param name="stationSelectionCriteria">The resulting station selection criteria needed by Cmd to determine station availability.</param>
 /// <returns></returns>
 private bool TryDetermineNeedForFormationStationChange(WithdrawPurpose purpose, out AFormationManager.FormationStationSelectionCriteria stationSelectionCriteria) {
     if (IsThereNeedForAFormationStationChangeTo(purpose)) {
         stationSelectionCriteria = new AFormationManager.FormationStationSelectionCriteria() { IsReserveReqd = true };
         return true;
     }
     stationSelectionCriteria = default(AFormationManager.FormationStationSelectionCriteria);
     return false;
 }
コード例 #4
0
ファイル: ShipItem.cs プロジェクト: Maxii/CodeEnv.Master
 void ExecuteDisengageOrder_ExitState() {
     LogEvent();
     _fsmDisengagePurpose = WithdrawPurpose.None;
 }