示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LudumEngine.Entity"/> class from a
        /// entity blueprint and assigns it to a scene.
        /// </summary>
        /// <param name="blueprint">A blueprint to instantiate from.</param>
        /// <param name="scene">A scene to add the entity to.</param>
        internal Entity(EntityBlueprint blueprint, Scene scene)
        {
            this.Scene = scene;

            _componentCollection = new ComponentCollection(blueprint.ComponentCollection);

            foreach (Component component in _componentCollection.GetAllComponents())
            {
                component.Entity = this;
                component.Reset();
                component.Initialize();
            }
        }
示例#2
0
        /// <summary>
        /// Delete all components in this entity.
        /// </summary>
        internal void Delete()
        {
            // Get all current components
            var allComponents = ComponentCollection.GetAllComponents();

            // Remove all component references
            ComponentCollection = new ComponentCollection();

            // Make sure all components destroy themselfs
            foreach (Component component in allComponents)
            {
                component.Delete();
            }
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LudumEngine.ComponentCollection"/> class
 /// as a copy of another collection.
 /// </summary>
 /// <param name="parent">the collection to copy.</param>
 internal ComponentCollection(ComponentCollection parent)
 {
     _components = parent.CloneDictionary();
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LudumEngine.EntityBlueprint"/> class as
 /// a copy of another blueprint.
 /// </summary>
 /// <param name="parent">The blueprint to copy.</param>
 internal EntityBlueprint(EntityBlueprint parent)
 {
     this.ComponentCollection = new ComponentCollection(parent.ComponentCollection);
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LudumEngine.EntityBlueprint"/> class.
 /// </summary>
 internal EntityBlueprint()
 {
     this.ComponentCollection = new ComponentCollection();
 }