Example #1
0
 private Activity Mining(Actor self, out MiningState state)
 {
     // Let the harvester become idle so it can shoot enemies.
     // Tick in SpawnerHarvester trait will kick activity back to KickTick.
     state = MiningState.Packaging;
     return(ChildActivity);
 }
Example #2
0
        Activity TryDeployTick(Actor self, out MiningState state)
        {
            // Wait for child wait activity to be done.
            // Could be wait or could be move to.
            if (ChildActivity != null)
            {
                ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
                state         = MiningState.TryDeploy;
                return(this);
            }

            if (!deploy.IsValidTerrain(self.Location))
            {
                // If we can't deploy, go back to scan state so that we scan try deploy again.
                state = MiningState.Scan;
                return(this);
            }

            // Issue deploy order and enter deploying state.
            //if (deploy. == DeployState.Undeployed)
            //{
            IsInterruptible = false;

            tranforms.DeployTransform(true);
            //}

            state = MiningState.Deploying;
            return(this);
        }
        void HandleSpawnerHarvest(Actor self, Order order)
        {
            allowKicks = true;

            // state == Deploying implies order string of SpawnerHarvestDeploying
            // and must not cancel deploy activity!
            if (MiningState != MiningState.Deploying)
            {
                self.CancelActivity();
            }

            MiningState = MiningState.Scan;

            LastOrderLocation = ResolveHarvestLocation(self, order);
            self.QueueActivity(new SlaveMinerHarvesterHarvest(self));
            //self.SetTargetLine(Target.FromCell(self.World, LastOrderLocation.Value), Color.Red);

            // Assign new targets for slaves too.
            foreach (var se in SlaveEntries)
            {
                if (se.IsValid && se.Actor.IsInWorld)
                {
                    AssignTargetForSpawned(se.Actor, LastOrderLocation.Value);
                }
            }
        }
Example #4
0
        private void StartMiningButton_Click(object sender, RoutedEventArgs e)
        {
            if (Settings.Server == null || Settings.Wallet == null || Settings.Worker == null)
            {
                Setup setupWindow = new Setup();
                setupWindow.ShowDialog();
            }

            if (!System.IO.File.Exists(exeName))
            {
                MessageBox.Show(Application.Current.MainWindow, "You must add t-rex.exe to this folder before mining.", "You Suck", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            string args = "-a ethash -o stratum+tcp://" + Settings.Server + ":4444 -u " + Settings.Wallet + " -p x -w " + Settings.Worker;

            if (state == MiningState.MINING)
            {
                myConsole.WriteOutput("Stopping Mining", Color.FromRgb(255, 255, 255));
                StopTimer();
                myConsole.StopProcess();
                state = MiningState.STOPPED;
            }
            else
            {
                myConsole.WriteOutput("Starting Mining", Color.FromRgb(255, 255, 255));
                myConsole.StartProcess(exeName, args);
                state = MiningState.MINING;
                StartTimer();
            }
            ReloadUI();
        }
Example #5
0
        public void ResetState()
        {
            miningState   = new MiningState();
            _stateMachine = new StateMachine <State, Trigger>(State.Neutral);

            // Neutral
            _stateMachine.Configure(State.Neutral)
            .Permit(Trigger.StartMining, State.Mining)
            .Permit(Trigger.ThrowBobbler, State.ThrowingBobbler);

            // Mining
            _stateMachine.Configure(State.Mining)
            .Permit(Trigger.EndMining, State.Neutral)
            .Permit(Trigger.AbortMining, State.Neutral);

            // Fishing
            _stateMachine.Configure(State.Fishing)
            .Permit(Trigger.AbortFishing, State.Neutral);
            _stateMachine.Configure(State.ThrowingBobbler)
            .SubstateOf(State.Fishing)
            .Permit(Trigger.BobblerInWater, State.BobblerInWater);
            _stateMachine.Configure(State.BobblerInWater)
            .SubstateOf(State.Fishing)
            .Permit(Trigger.FishBite, State.FishBiting);
            _stateMachine.Configure(State.FishBiting)
            .SubstateOf(State.Fishing)
            .Permit(Trigger.FishSuccessfulCatch, State.Neutral)
            .Permit(Trigger.FishUnsuccessfulCatch, State.Neutral);
        }
        Activity Kick(Actor self, out MiningState state)
        {
            var closestHarvestablePosition = ClosestHarvestablePos(self, harvInfo.KickScanRadius);

            if (closestHarvestablePosition.HasValue)
            {
                // I may stay mining.
                state = MiningState.Mining;
                return(ChildActivity);
            }

            // get going
            harv.LastOrderLocation     = null;
            closestHarvestablePosition = ClosestHarvestablePos(self, lastScanRange);
            if (closestHarvestablePosition != null)
            {
                state = MiningState.Undeploy;
                harv.ForceMove(closestHarvestablePosition.Value);
            }
            else
            {
                state          = MiningState.Kick;
                lastScanRange *= 2; // larger search range
            }

            return(this);
        }
        public void UpdateTags(int methodNumber, MiningState miningState = null)
        {
            var list = new List <int>()
            {
                methodNumber
            };

            UpdateTags(list, miningState);
        }
Example #8
0
 public void AbortMining(string id)
 {
     if (miningState.miningId != id)
     {
         Console.WriteLine(String.Format("Player {0} tried to AbortMining on Object {1}, but they were mining object {2}", _userName, id, miningState.miningId));
     }
     miningState = new MiningState();
     _stateMachine.Fire(Trigger.AbortMining);
 }
Example #9
0
        //NOTE! this is blocking method
        public void stop()
        {
            MiningState state = MiningState.MINING_IN_PROGRESS;

            if (m_state.compare_exchange_weak(state, MiningState.MINING_STOPPED))
            {
                m_miningStopped.wait();
                m_miningStopped.clear();
            }
        }
Example #10
0
    void MakeFSM()
    {
        SleepingState sleeping = new SleepingState();

        sleeping.AddTransition("wake_up", "walk_to_mine");

        WalkToMineState walkToMine = new WalkToMineState(mines);

        walkToMine.AddTransition("reached_mine", "mining");
        walkToMine.AddTransition("all_empty_mines", "idle");

        IdleState idle = new IdleState(mines);

        idle.AddTransition("money_in_pocket", "walk_to_bank");
        idle.AddTransition("available_mines", "walk_to_mine");
        idle.AddTransition("nothing_to_do", "walk_to_bar");
        idle.AddTransition("no_energy", "walk_to_house");

        WalkToHouseState walkToHouse = new WalkToHouseState(house);

        walkToHouse.AddTransition("reached_house", "sleeping");

        WalkToBarState walkToBar = new WalkToBarState(bar);

        walkToBar.AddTransition("reached_bar", "drinking");

        DrinkingState drinking = new DrinkingState();

        drinking.AddTransition("finished_drink", "idle");

        MiningState mining = new MiningState();

        mining.AddTransition("empty_mine", "walk_to_mine");
        mining.AddTransition("no_energy", "walk_to_house");

        WalkToBankState walkToBank = new WalkToBankState(bank);

        walkToBank.AddTransition("reached_bank", "depositing");

        DepositingState depositing = new DepositingState();

        depositing.AddTransition("finished_deposit", "idle");

        fsm = new FSM();
        fsm.AddState(walkToHouse);
        fsm.AddState(sleeping);
        fsm.AddState(walkToMine);
        fsm.AddState(mining);
        fsm.AddState(walkToBank);
        fsm.AddState(idle);
        fsm.AddState(walkToBar);
        fsm.AddState(depositing);
        fsm.AddState(drinking);
    }
Example #11
0
 private void CheckIfReachedBestLocation(Actor self, out MiningState state)
 {
     if ((self.Location - deployDestPosition).LengthSquared <= cellRange * cellRange)
     {
         ChildActivity.Cancel(self);
         state = MiningState.TryDeploy;
     }
     else
     {
         state = MiningState.Moving;
     }
 }
Example #12
0
 public void ResolveOrder(Actor self, Order order)
 {
     if (order.OrderString == "SpawnerRefineryHarvest")
     {
         HandleSpawnerHarvest(self, order);
     }
     else if (order.OrderString == "Stop" || order.OrderString == "Move")
     {
         // Disable "smart idle"
         MiningState = MiningState.Scan;
     }
 }
 public void ResolveOrder(Actor self, Order order)
 {
     if (order.OrderString == orderID)
     {
         HandleSpawnerHarvest(self, order);
     }
     else if (order.OrderString == "Stop" || order.OrderString == "Move")
     {
         // Disable "smart idle"
         allowKicks  = false;
         MiningState = MiningState.Scan;
     }
 }
Example #14
0
        void ScanAndMove(Actor self, out MiningState state)
        {
            var closestHarvestablePosition = ClosestHarvestablePos(self, harvInfo.LongScanRadius);

            // No suitable resource field found.
            // We only have to wait for resource to regen.
            if (!closestHarvestablePosition.HasValue)
            {
                var randFrames = self.World.SharedRandom.Next(100, 175);

                // Avoid creating an activity cycle
                QueueChild(new Wait(randFrames));
                state = MiningState.Scan;
            }

            // ... Don't claim resource layer here. Slaves will claim by themselves.

            // If not given a direct order, assume ordered to the first resource location we find:
            if (!harv.LastOrderLocation.HasValue)
            {
                harv.LastOrderLocation = closestHarvestablePosition;
            }

            // Calculate best depoly position.
            var deployPosition = CalcTransformPosition(self, closestHarvestablePosition.Value);

            // Just sit there until we can. Won't happen unless the map is filled with units.
            if (deployPosition == null)
            {
                QueueChild(new Wait(harvInfo.KickDelay));
                state = MiningState.Scan;
            }

            // TODO: The harvest-deliver-return sequence is a horrible mess of duplicated code and edge-cases
            var notify = self.TraitsImplementing <INotifyHarvesterAction>();

            foreach (var n in notify)
            {
                n.MovingToResources(self, deployPosition.Value);
            }

            state = MiningState.Moving;

            //When it reached the best position, we will let it do this activity again
            deployDestPosition = deployPosition.Value;
            cellRange          = 2;
            var moveActivity = mobile.MoveTo(deployPosition.Value, cellRange);

            moveActivity.Queue(this);
            QueueChild(moveActivity);
        }
Example #15
0
        Activity KickTick(Actor self, out MiningState state)
        {
            var closestHarvestablePosition = ClosestHarvestablePos(self, harvInfo.KickScanRadius);

            if (closestHarvestablePosition.HasValue)
            {
                // I may stay mining.
                state = MiningState.Mining;
                return(NextActivity);
            }

            // get going
            harv.LastOrderLocation = null;
            return(UndeployAndGo(self, out state));
        }
Example #16
0
        private void SetLabelState(Label label, MiningState state = MiningState.None, params object[] values)
        {
            switch (state)
            {
            case MiningState.Mining:
                label.Text      = string.Format(Resources.MainForm_SetLabelState_Mining, values);
                label.ForeColor = _goodColor;
                break;

            default:
                label.Text      = Resources.MainForm_SetLabelState_Not_mining;
                label.ForeColor = _inactiveColor;
                break;
            }
        }
Example #17
0
 private void Deploying(Actor self, out MiningState state)
 {
     // deploy failure.
     if (!tranforms.CanDeploy())
     {
         //Wait 15 seconds and return state to Scan
         Activity act = new Wait(15);
         QueueChild(act);
         state = MiningState.Scan;
     }
     else
     {
         state = MiningState.Mining;
     }
 }
Example #18
0
        private void UndeployingCheck(Actor self, out MiningState state)
        {
            var closestHarvestablePosition = ClosestHarvestablePos(self, harvInfo.KickScanRadius);

            if (closestHarvestablePosition.HasValue)
            {
                // I may stay mining.
                state = MiningState.Mining;
            }
            else
            {
                // get going
                harv.LastOrderLocation = null;
                CheckWheteherNeedUndeployAndGo(self, out state);
            }
        }
        /// <summary>
        /// Generalized mining method, used from mining proxy and cmd miner
        /// </summary>
        /// <param name="methodsList">Which functions should execute</param>
        /// <param name="miningState">Link to mining proxy monitoring instance</param>
        public void UpdateTags(List <int> methodsList, MiningState miningState = null)
        {
            this.miningState = miningState;

            if (methodsList == null || methodsList.Count == 0)
            {
                throw new NotImplementedException();
            }
            if (methodsList.Contains(0))
            {
                DownloadAndTrimPagesAsync().Wait();
            }
            if (methodsList.Contains(1))
            {
                CalculateAndSaveBookTagsToDb();
            }
        }
Example #20
0
        private void TryDeploy(Actor self, out MiningState state)
        {
            if (!deploy.IsValidTerrain(self.Location))
            {
                // If we can't deploy, go back to scan state so that we scan try deploy again.
                state = MiningState.Scan;
            }
            else
            {
                IsInterruptible = false;

                Activity transformsActivity = tranforms.GetTransformActivity(self);
                QueueChild(transformsActivity);

                state = MiningState.Deploying;
            }
        }
        public void TickIdle(Actor self)
        {
            // wake up on idle for long (to find new resource patch. i.e., kick)
            if (allowKicks && self.IsIdle)
            {
                kickTicks--;
            }
            else
            {
                kickTicks = info.KickDelay;
            }

            if (kickTicks <= 0)
            {
                kickTicks   = info.KickDelay;
                MiningState = MiningState.Packaging;
                self.QueueActivity(new SlaveMinerHarvesterHarvest(self));
            }
        }
 void InitFSM()
 {
     _FSMSystemManager = new FSMSystemManager(gameObject, _navMeshAgent);
     if (IsPlayerCamp)
     {
         CenterPos = GameMapManager.Instance.PlayerCenter.transform.position;
     }
     else
     {
         CenterPos = GameMapManager.Instance.AICenter.transform.position;
     }
     miningState = new MiningState(CenterPos, Object_Camp, IsPlayerCamp);;
     idleState   = new IdleState();
     moveState   = new MoveState();
     _FSMSystemManager.AddState(miningState);
     _FSMSystemManager.AddState(idleState);
     _FSMSystemManager.AddState(moveState);
     _FSMSystemManager.CurrentState = idleState;
     harvesterState = HarvesterState.idle;
 }
        void INotifyDeployComplete.FinishedDeploy(Actor self)
        {
            allowKicks = true;

            // rescan from where we are
            MiningState = MiningState.Scan;

            // Tell harvesters to unload and restart mining.
            foreach (var se in SlaveEntries)
            {
                if (!se.IsValid || !se.Actor.IsInWorld)
                {
                    continue;
                }

                var s = se.Actor;
                se.SpawnerSlave.Stop(s);
                AssignTargetForSpawned(s, self.Location);
                s.QueueActivity(new FindAndDeliverResources(s));
            }
        }
Example #24
0
        Activity DeployingTick(Actor self, out MiningState state)
        {
            // Deploying in progress
            if (ChildActivity != null)
            {
                ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
                state         = MiningState.Deploying;
                return(this);
            }

            // deploy failure.
            if (!tranforms.CanDeploy())
            {
                QueueChild(new Wait(15));
                state = MiningState.Scan;
                return(this);
            }

            state = MiningState.Mining;
            return(this);
        }
Example #25
0
 public void backupstates()
 {
     backuptravel = _States.TravelerState;
         backupmining = _States.MiningState;
         backupdrone = _States.DroneState;
         backupfitting = _States.fittingstate;
         backuplogin = _States.LoginState;
         backupskill = _States.SkillState;
         backuptut = _States.tutstates;
 }
Example #26
0
 Activity UndeployAndGo(Actor self, out MiningState state)
 {
     state = MiningState.Scan;
     QueueChild(new UndeployForGrantedCondition(self, deploy));
     return(this);
 }
Example #27
0
 private Activity CheckWheteherNeedUndeployAndGo(Actor self, out MiningState state)
 {
     QueueChild(new DeployForGrantedCondition(self, deploy));
     state = MiningState.Scan;
     return(this);
 }
Example #28
0
        Activity ScanTick(Actor self, out MiningState state)
        {
            if (ChildActivity != null)
            {
                ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
                state         = MiningState.Scan;
                return(this);
            }

            var closestHarvestablePosition = ClosestHarvestablePos(self, harvInfo.LongScanRadius);

            // No suitable resource field found.
            // We only have to wait for resource to regen.
            if (!closestHarvestablePosition.HasValue)
            {
                var randFrames = self.World.SharedRandom.Next(100, 175);

                // Avoid creating an activity cycle
                QueueChild(new Wait(randFrames));
                state = MiningState.Scan;
                return(this);
            }

            //// ... Don't claim resource layer here. Slaves will claim by themselves.

            // If not given a direct order, assume ordered to the first resource location we find:
            if (!harv.LastOrderLocation.HasValue)
            {
                harv.LastOrderLocation = closestHarvestablePosition;
            }

            self.SetTargetLine(Target.FromCell(self.World, closestHarvestablePosition.Value), Color.Red, false);

            // Calculate best depoly position.
            var deployPosition = CalcTransformPosition(self, closestHarvestablePosition.Value);

            // Just sit there until we can. Won't happen unless the map is filled with units.
            if (deployPosition == null)
            {
                QueueChild(new Wait(harvInfo.KickDelay));
                state = MiningState.Scan;
                return(this);
            }
            //}

            // TODO: The harvest-deliver-return sequence is a horrible mess of duplicated code and edge-cases
            var notify = self.TraitsImplementing <INotifyHarvesterAction>();

            foreach (var n in notify)
            {
                n.MovingToResources(self, deployPosition.Value, this);
            }

            state = MiningState.TryDeploy;

            // This gives glitch. If you repeatedly on an ore target then
            // the child Move() will glitch out and the harvester will be positioned in illegal places.
            // QueueChild(mobile.MoveTo(deployPosition.Value, 2));
            // Instead of queing, we RETURN MOVE.
            // This doesn't break the graph and will work fine (as "bad" codes did in older ORA engine).
            var move = mobile.MoveTo(deployPosition.Value, 2);

            move.Queue(this);
            return(move);
        }