private void RemoveAreaBodyFromActiveArea(BaseActiveArea activeArea, AreaBody areaBody)
        {
            // remove it from this AA.
            activeArea.RemoveBody(areaBody);

            // if it's not in any other AA at this point, hibernate it.
            var isActiveAreasContainingBody = this.ActiveAreas.Any(aa =>
                                                                   aa != activeArea && // is a different active area
                                                                   aa.AreaBodies.Select(aab => aab.Body).Contains(areaBody.Body)); // contains the body

            if (!isActiveAreasContainingBody)
            {
                // no other active area has this body in it, so go ahead and hibernate the body
                this.BodiesToHibernate.Add(areaBody.Body);
            }
        }
        private bool BodyOverlapsOtherBodiesInActiveArea(BaseActiveArea activeArea, AreaBody areaBody)
        {
            for (var i = 0; i < activeArea.AreaBodies.Count; i++)
            {
                var otherAreaBody = activeArea.AreaBodies[i];

                // it's the same AreaBody so skip it.
                if (areaBody == otherAreaBody)
                {
                    continue;
                }

                if (areaBody.AABB.Overlaps(ref otherAreaBody.AABB))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
 public void RemoveBody(AreaBody areaBody)
 {
     this.AreaBodies.Remove(areaBody);
     this.BodyIds.Remove(areaBody.Body.Id);
 }