private void OnLookupAdd(EntityUid uid, EntityLookupComponent component, ComponentAdd args) { int capacity; if (EntityManager.TryGetComponent(uid, out TransformComponent? xform)) { capacity = (int)Math.Min(256, Math.Ceiling(xform.ChildCount / (float)GrowthRate) * GrowthRate); } else { capacity = 256; } component.Tree = new DynamicTree <EntityUid>( GetTreeAABB, capacity: capacity, growthFunc: x => x == GrowthRate ? GrowthRate * 8 : x * 2 ); }
private void OnLookupShutdown(EntityUid uid, EntityLookupComponent component, ComponentShutdown args) { component.Tree.Clear(); }