void OnTriggerExit2D(Collider2D other) { IBoid otherBoid = other.GetComponentInParent <IBoid>(); if (otherBoid != null) { neighbors.Remove(otherBoid); } IStaticAvoidBoid otherStaticBoid = other.GetComponentInParent <IStaticAvoidBoid>(); if (otherStaticBoid != null) { staticAvoid.Remove(otherStaticBoid); UpdateStaticAvoidance(); } IMobileAvoidBoid otherMobileBoid = other.GetComponentInParent <IMobileAvoidBoid>(); if (otherMobileBoid != null) { mobileAvoid.Remove(otherMobileBoid); } }
void OnTriggerEnter2D(Collider2D other) { IBoid otherBoid = other.GetComponentInParent <IBoid>(); if (otherBoid != null && !neighbors.Contains(otherBoid) && otherBoid as Boid != this) { neighbors.Add(otherBoid); } IStaticAvoidBoid otherStaticAvoid = other.GetComponentInParent <IStaticAvoidBoid>(); if (otherStaticAvoid != null && !staticAvoid.Contains(otherStaticAvoid)) { staticAvoid.Add(otherStaticAvoid); UpdateStaticAvoidance(); } IMobileAvoidBoid otheMobileAvoid = other.GetComponentInParent <IMobileAvoidBoid>(); if (otheMobileAvoid != null && !mobileAvoid.Contains(otheMobileAvoid)) { mobileAvoid.Add(otheMobileAvoid); } }