Exemplo n.º 1
0
        public override void OnRun(GoapState goalState)
        {
            if (m_agent.DoesCurrentTargetMatch(GameMatcher.OreBranch))
            {
                OnComplete();
                return;
            }

            if (HasValidTarget())
            {
                //TODO : Add wait time, executionTime > 60ms then Failed
                var branches = (m_agent.GetMatchingTargetsInSight(GameMatcher.OreBranch));
                foreach (var branchID in branches)
                {
                    var branch = m_agent.Contexts.game.GetEntityWithId(branchID);
                    if (TargetingHelpers.GetTargeters(m_agent.Contexts, branch).Count == 0)
                    {
                        m_agent.SetTarget(branchID);
                        OnComplete();
                        return;
                    }
                } //Wait till ore vein creates branch
            }

            if (m_agent.HasMatchingTargetInSight(GameMatcher.OreVein) == false)
            {
                OnFailed();
                return;
            }

            var oreVein = m_agent.GetMatchingTargetsInSight(GameMatcher.OreVein)[0];

            m_agent.SetTarget(oreVein);
        }
Exemplo n.º 2
0
        private int GetVeinAvailableBranches(GameEntity e)
        {
            if (e.hasBag == false)
            {
                return(0);
            }

            var branches          = e.bag.items;
            var availableBranches = branches.Count;

            foreach (var entityId in branches)
            {
                var branch    = m_context.game.GetEntityWithId(entityId);
                var targeters = TargetingHelpers.GetTargeters(m_context, branch);

//
//                var targetedByMiner = false;
//
//                foreach (var targeterID in targeters)
//                {
//                    var targeter = m_context.GetEntityWithId(targeterID);
//
//                    if (targeter.isMiner)
//                    {
//                        targetedByMiner = true;
//                        break;
//                    }
//                }

//                if (targetedByMiner == false) availableBranches++;


                if (targeters.Count > 0) //targeted
                {
                    availableBranches--;
                }
            }

            return(availableBranches);
        }
Exemplo n.º 3
0
        private bool HasValidTarget()
        {
            if (m_agent.HasMatchingTargetInSight(GameMatcher.OreBranch) == false)
            {
                return(false);
            }


            var targets = m_agent.GetMatchingTargetsInSight(GameMatcher.OreBranch);

            foreach (var branchID in targets)
            {
                //If branch targeted
                var branch = m_agent.Contexts.game.GetEntityWithId(branchID);
                if (TargetingHelpers.GetTargeters(m_agent.Contexts, branch).Count == 0)
                {
                    return(true);
                }
            }

            return(false);
        }