4 using System.Collections.Generic;
5 using System.Collections.Specialized;
6 using SiliconStudio.Core.Collections;
7 using SiliconStudio.Paradox.EntityModel;
9 namespace SiliconStudio.
Paradox.Engine
17 private readonly TrackingHashSet<Entity> rootEntities;
20 : base(new[] { TransformationComponent.Key })
22 rootEntities =
new TrackingHashSet<Entity>();
23 rootEntities.CollectionChanged += rootEntities_CollectionChanged;
29 public ISet<Entity> RootEntities
31 get {
return rootEntities; }
37 return entity.Transformation;
41 protected internal override void OnSystemAdd()
48 foreach (var child
in entity.Transformation.Children)
50 EntitySystem.SetEnabled(child.Entity, enabled);
57 foreach (var child
in transformationComponent.Children)
59 InternalAddEntity(child.Entity);
62 if (transformationComponent.Parent == null)
63 rootEntities.Add(entity);
65 ((TrackingCollection<TransformationComponent>)transformationComponent.Children).CollectionChanged += Children_CollectionChanged;
71 var entityToRemove =
new List<Entity>();
72 foreach (var child
in transformationComponent.Children)
74 entityToRemove.Add(child.Entity);
77 foreach (var childEntity
in entityToRemove)
79 InternalRemoveEntity(childEntity,
false);
84 if (transformationComponent.Parent != null &&
EntitySystem.
Contains(transformationComponent.Parent.Entity))
85 transformationComponent.Parent = null;
87 rootEntities.Remove(entity);
89 ((TrackingCollection<TransformationComponent>)transformationComponent.Children).CollectionChanged -= Children_CollectionChanged;
96 case NotifyCollectionChangedAction.Add:
99 case NotifyCollectionChangedAction.Remove:
103 throw new NotSupportedException();
112 case NotifyCollectionChangedAction.Add:
113 InternalAddEntity(((TransformationComponent)e.
Item).Entity);
115 case NotifyCollectionChangedAction.Remove:
121 throw new NotSupportedException();
override void OnEntityRemoved(Entity entity, TransformationComponent transformationComponent)
Game entity. It usually aggregates multiple EntityComponent
Entity processor, triggered on various EntitySystem events such as Entity and Component additions and...
This processor will take care of adding/removing children of every Entity added/removed in the Entity...
object Item
Gets the added or removed item (if dictionary, value only).
Manage a collection of entities.
NotifyCollectionChangedAction Action
Gets the type of action performed. Allowed values are NotifyCollectionChangedAction.Add and NotifyCollectionChangedAction.Remove.
override TransformationComponent GenerateAssociatedData(Entity entity)
override void OnEntityAdding(Entity entity, TransformationComponent transformationComponent)
override void OnEnabledChanged(Entity entity, bool enabled)
bool Contains(Entity item)
Determines whether this instance contains the specified entity.