public void TargetNearestTypedPickable(Vector3 selfPosition, PickableCategory type) { PickableController nearestPickable = null; foreach (var pickable in pickablesInSight) { if (pickable != null) { if (pickable.Category == type) { if (nearestPickable == null) { nearestPickable = pickable; } else if (IsVectorCloserThanOtherVector( selfPosition, pickable.transform.root.position, nearestPickable.transform.root.position)) { nearestPickable = pickable; } } } } target = nearestPickable; }
protected void LookingForTypedPickable(PickableCategory pickableType) { if (pickableMemory.GetPickableTarget() == null && pickableMemory.IsTypePickableInSight(pickableType)) { pickableMemory.TargetNearestTypedPickable(mover.transform.root.position, pickableType); } }
public bool IsTypePickableInSight(PickableCategory type) { foreach (var pickable in pickablesInSight) { if (pickable.Category == type) { return(true); } } return(false); }