Exemple #1
0
        /// <inheritdoc/>
        protected override void OnEntityRemoved(Entity entity, TransformationComponent transformationComponent)
        {
            var entityToRemove = new List <Entity>();

            foreach (var child in transformationComponent.Children)
            {
                entityToRemove.Add(child.Entity);
            }

            foreach (var childEntity in entityToRemove)
            {
                InternalRemoveEntity(childEntity, false);
            }

            // If sub entity is removed but its parent is still there, it needs to be detached.
            // Note that this behavior is still not totally fixed yet, it might change.
            if (transformationComponent.Parent != null && EntitySystem.Contains(transformationComponent.Parent.Entity))
            {
                transformationComponent.Parent = null;
            }

            rootEntities.Remove(entity);

            ((TrackingCollection <TransformationComponent>)transformationComponent.Children).CollectionChanged -= Children_CollectionChanged;
        }