//copy pasta is bad, but I'm trying to do this quickly. private BaseEntity FindClosest(BaseEntity actor, string targetTag) { int count = _entities.Count; BaseEntity closest = null; float closestDist = -1; for (int i = 0; i < count; ++i) { BaseEntity target = _entities[i]; if (!target.HasTag(targetTag)) { continue; } float dist = BootStrap.DistSqrd(actor.transform.position, target.transform.position); if (closestDist == -1 || dist < closestDist) { closest = target; closestDist = dist; } } return(closest); }
public bool IsInRange(Transform other) { if (other == null) { return(false); } float dist = BootStrap.DistSqrd(transform.position, other.position); return((_attackRange * _attackRange) >= dist); }