예제 #1
0
 private void SetJetcanDropoffState()
 {
     if (_jettisonContainer.CurrentContainer == null)
     {
         _jetcanDropOffState = JetcanDropOffStates.MarkCanFull;
     }
     else if (_jettisonContainer.CurrentContainer.Distance > (int)Ranges.LootActivate)
     {
         _jetcanDropOffState = JetcanDropOffStates.MarkCanFull;
     }
     else if (!_jettisonContainer.IsCurrentContainerWindowOpen)
     {
         _jetcanDropOffState = JetcanDropOffStates.OpenCan;
     }
     else if (_jettisonContainer.IsActiveCanFull())
     {
         _jetcanDropOffState = JetcanDropOffStates.MarkCanFull;
     }
     else
     {
         _jetcanDropOffState = JetcanDropOffStates.TransferCargo;
     }
 }
예제 #2
0
 public override void Reset()
 {
     _stationDropOffState = StationDropOffStates.Idle;
     _jetcanDropOffState  = JetcanDropOffStates.Idle;
     _corporateHangarArrayDropOffState = CorporateHangarArrayDropOffStates.Idle;
 }
예제 #3
0
        private BehaviorExecutionResults DropOffCargoToJetCan()
        {
            var methodName = "DropOffCargoToJetCan";

            LogTrace(methodName);

            if (_jetcanDropOffState == JetcanDropOffStates.Idle)
            {
                SetJetcanDropoffState();
            }

            //If the jetcan doesn't exist, override the state to 'create can'.
            if (_jettisonContainer.CurrentContainer == null)
            {
                _jetcanDropOffState = JetcanDropOffStates.CreateCan;
            }

            switch (_jetcanDropOffState)
            {
            case JetcanDropOffStates.MarkCanFull:
                _jetcanDropOffState = JetcanDropOffStates.CreateCan;

                if (_jettisonContainer.CurrentContainer != null)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Marking active can full.");
                    MarkJetcanFull();
                }
                else
                {
                    goto case JetcanDropOffStates.CreateCan;
                }

                break;

            case JetcanDropOffStates.CreateCan:
                _jettisonContainer.SetActiveCan();

                if (_jettisonContainer.CurrentContainer != null)
                {
                    _jettisonContainer.RenameActiveCan(false);

                    _jetcanDropOffState = JetcanDropOffStates.OpenCan;
                    goto case JetcanDropOffStates.OpenCan;
                }

                if (_meCache.Ship.Ship.HasOreHold)
                {
                    if (!_ship.IsOreHoldActive)
                    {
                        LogMessage(methodName, LogSeverityTypes.Standard, "Making ship ore hold active before creating a jetcan.");
                        _ship.MakeOreHoldActive();
                        return(BehaviorExecutionResults.Incomplete);
                    }
                }
                else if (!_ship.IsCargoHoldActive)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Making ship cargo hold active before creating a jetcan.");
                    _ship.MakeCargoHoldActive();
                    return(BehaviorExecutionResults.Incomplete);
                }

                var ore = CargoContainer.GetOreFromList(_meCache.Ship.Ship.HasOreHold ? _meCache.Ship.Ship.GetOreHoldCargo() : _meCache.Ship.Cargo.ToList());

                if (ore.Count == 0)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Error: We're above the cargo full threshold but have no ore to jetisson.");
                    return(BehaviorExecutionResults.Error);
                }

                var item = ore.First();

                LogMessage(methodName, LogSeverityTypes.Standard, "Creating new jetcan from item \"{0}\" ({1}).",
                           item.Name, item.ID);

                _jettisonContainer.CreateJetCan(item);
                break;

            case JetcanDropOffStates.OpenCan:
                if (!_jettisonContainer.IsCurrentContainerWindowOpen)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Opening cargo of active jetcan \"{0}\" ({1}).",
                               _jettisonContainer.CurrentContainer.Name, _jettisonContainer.CurrentContainerId);
                    _jettisonContainer.CurrentContainer.Open();
                }
                else
                {
                    _jetcanDropOffState = JetcanDropOffStates.TransferCargo;
                    goto case JetcanDropOffStates.TransferCargo;
                }
                break;

            case JetcanDropOffStates.TransferCargo:
                if (_meCache.Ship.Ship.HasOreHold)
                {
                    if (!_ship.IsOreHoldActive)
                    {
                        LogMessage(methodName, LogSeverityTypes.Standard, "Making ship ore hold active before transferring cargo to a jetcan.");
                        _ship.MakeOreHoldActive();
                        return(BehaviorExecutionResults.Incomplete);
                    }
                }
                else if (!_ship.IsCargoHoldActive)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Making ship cargo hold active before transferring cargo to a jetcan.");
                    _ship.MakeCargoHoldActive();
                    return(BehaviorExecutionResults.Incomplete);
                }

                LogMessage(methodName, LogSeverityTypes.Standard, "Transferring ore to the active jetcan.");

                if (_meCache.Ship.Ship.HasOreHold)
                {
                    _ship.TransferOreHoldToJetCan(_jettisonContainer.CurrentContainerId);
                }
                else
                {
                    _ship.TransferCargoHoldToJetCan(_jettisonContainer.CurrentContainerId);
                }

                _jetcanDropOffState = JetcanDropOffStates.Idle;
                return(BehaviorExecutionResults.Complete);
            }

            return(BehaviorExecutionResults.Incomplete);
        }