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