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); }
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); }
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); }
public bool DoesCurrentTargetMatch(IMatcher <GameEntity> matcher) { return(TargetingHelpers.DoesCurrentTargetMatch(m_contexts, m_entity, matcher)); }
public List <int> GetMatchingTargetsInSight(IMatcher <GameEntity> matcher) { return(TargetingHelpers.GetMatchingTargetsInSight(m_contexts, m_entity, matcher)); }
public GameEntity GetTarget() { return(TargetingHelpers.GetTarget(m_contexts, m_entity)); }
//Targeting public void SetTarget(GameEntity target) { TargetingHelpers.SetTarget(m_entity, target); }