private BlacksmithResourceDeposit GetClosest() { var stacks = COMPONENT_DATABASE.RetrieveComponents <BlacksmithResourceDeposit>(); if (stacks.Count == 0) { return(null); } BlacksmithResourceDeposit closest = null; float closestDist = float.MaxValue; foreach (var s in stacks) { var stack = (BlacksmithResourceDeposit)s; if (stack.logs <= 0) { continue; } float dist = (stack.gameObject.transform.position - transform.position).magnitude; if (dist < closestDist) { closest = stack; closestDist = dist; } } return(closest); }
public override void SetTarget() { BlacksmithResourceDeposit closest = GetClosest(); if (closest != null) { m_TargetDeposit = closest; target = m_TargetDeposit.transform; } }
public override void SetTarget() { var closest = GetClosest(); if (closest != null) { m_TargetStack = closest; target = m_TargetStack.transform; } }
private BlacksmithResourceDeposit GetClosest() { var trees = COMPONENT_DATABASE.RetrieveComponents <BlacksmithResourceDeposit>(); BlacksmithResourceDeposit closest = null; float closestDist = float.MaxValue; foreach (var tree in trees) { float dist = (tree.gameObject.transform.position - transform.position).magnitude; if (dist < closestDist) { closest = (BlacksmithResourceDeposit)tree; closestDist = dist; } } return(closest); }
protected override void DoReset() { m_DepositedWood = false; m_TargetDeposit = null; }