HierarchyEntity2D ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    DeltaEngine.Entities DrawableEntity
      DeltaEngine.Rendering2D Entity2D
        DeltaEngine.Rendering2D HierarchyEntity2D
          DeltaEngine.Physics2D PhysicalEntity2D
          DeltaEngine.Rendering2D Sprite

Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class HierarchyEntity2D : Entity2D, 
	HierarchyObject2D

The HierarchyEntity2D type exposes the following members.

Constructors

  NameDescription
Protected methodHierarchyEntity2D 
Initializes a new instance of the HierarchyEntity2D class
Public methodHierarchyEntity2D(Vector2D)
Initializes a new instance of the HierarchyEntity2D class
Public methodHierarchyEntity2D(Rectangle, Single)
Initializes a new instance of the HierarchyEntity2D class
Top
Methods

  NameDescription
Public methodAdd(HierarchyObject2D)
Public methodAdd T (T) (Inherited from Entity2D.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity2D.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Inherited from Entity.)
Public methodGet T  (Inherited from Entity2D.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Public methodGetComponentsForEditing (Inherited from Entity2D.)
Protected methodGetComponentsForSaving (Inherited from Entity2D.)
Protected methodGetDrawBehaviors (Inherited from DrawableEntity.)
Public methodGetFirstChildOfType T 
Public methodGetInterpolatedArray T  (Inherited from DrawableEntity.)
Public methodGetInterpolatedList T  (Inherited from DrawableEntity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Protected methodNextUpdateStarted (Inherited from Entity2D.)
Public methodOnDraw T  (Inherited from DrawableEntity.)
Protected methodOnPositionChanged (Overrides Entity2D OnPositionChanged .)
Protected methodOnRotationChanged (Overrides Entity2D OnRotationChanged .)
Public methodRemove(HierarchyObject2D)
Public methodRemove T   (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodRotatedDrawAreaContains (Inherited from Entity2D.)
Public methodSet (Inherited from Entity2D.)
Public methodSetComponents (Inherited from Entity.)
Public methodSetWithoutInterpolation T  (Inherited from Entity2D.)
Public methodStart T  (Inherited from Entity.)
Public methodStop T  (Inherited from Entity.)
Public methodToggleVisibility (Inherited from DrawableEntity.)
Public methodToString (Inherited from Entity.)
Public methodUpdateGlobalsFromParent
Top
Extension Methods

  NameDescription
Public Extension MethodAffixToPhysics (Defined by Entity2DPhysicsExtensions.)
Public Extension MethodStartBouncingOffScreenEdges (Defined by Entity2DExtensions.)
Public Extension MethodStartFalling (Defined by Entity2DExtensions.)
Public Extension MethodStartMoving (Defined by Entity2DExtensions.)
Public Extension MethodStartRotating (Defined by Entity2DExtensions.)
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Protected fieldlastTickLerpComponents
Each element can either be a Lerp, a Lerp List or an array of Lerp objects. View code on GitHub
(Inherited from DrawableEntity.)
Top
Properties

  NameDescription
Public propertyAlpha (Inherited from Entity2D.)
Public propertyCenter (Inherited from Entity2D.)
Public propertyChildren
Public propertyColor (Inherited from Entity2D.)
Public propertyDidFootprintChange (Inherited from Entity2D.)
Public propertyDrawArea (Inherited from Entity2D.)
Public propertyIsActive (Overrides DrawableEntity IsActive.)
Public propertyIsPauseable (Inherited from Entity.)
Public propertyIsVisible (Inherited from DrawableEntity.)
Public propertyLastColor (Inherited from Entity2D.)
Public propertyLastDrawArea (Inherited from Entity2D.)
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyParent
Public propertyRelativePosition
Public propertyRelativeRotation
Public propertyRenderLayer (Inherited from DrawableEntity.)
Public propertyRotation (Inherited from Entity2D.)
Public propertyRotationCenter (Inherited from Entity2D.)
Public propertySize (Inherited from Entity2D.)
Public propertyTopLeft (Inherited from Entity2D.)
Public propertyUpdatePriority (Inherited from Entity.)
Top
Remarks

Tests: DeltaEngine.Rendering2D.Tests.HierarchyEntity2DTests
Examples

7 unit tests call DeltaEngine.Rendering2D.HierarchyEntity2D
[Test]
public void PositionOfChildUpdatedRelativeToParentOnParentPositionChange()
{
    var parentEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(Vector2D.Half, Size.Zero));
    var childEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(0.4f, 0.4f, 0.1f, 0.1f));
    var grandChildEntity =
        new MockHierarchyEntity2D(Rectangle.FromCenter(new Vector2D(0.2f, 0.0f), Size.Zero));
    parentEntity.Add(childEntity);
    childEntity.Add(grandChildEntity);
    Assert.AreEqual(new Vector2D(0.4f, 0.4f), childEntity.Center);
    Assert.AreEqual(new Vector2D(0.2f, 0.0f), grandChildEntity.Center);
    parentEntity.Center += new Vector2D(0.1f, 0.1f);
    Assert.IsTrue(new Vector2D(0.5f, 0.5f).IsNearlyEqual(childEntity.Center),
        childEntity.Center.ToString());
    Assert.IsTrue(new Vector2D(-0.1f, -0.1f).IsNearlyEqual(childEntity.RelativePosition),
        childEntity.RelativePosition.ToString());
    Assert.IsTrue(new Vector2D(0.3f, 0.1f).IsNearlyEqual(grandChildEntity.Center),
        grandChildEntity.Center.ToString());
    Assert.IsTrue(new Vector2D(-0.2f, -0.4f).IsNearlyEqual(grandChildEntity.RelativePosition),
        grandChildEntity.RelativePosition.ToString());
}
[Test]
public void SetLocalsUpdatesGlobals()
{
    var parentEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(Vector2D.Half, Size.Zero));
    var childEntity = new MockHierarchyEntity2D(Rectangle.Zero);
    parentEntity.Add(childEntity);
    var childRelativePosition = new Vector2D(0.2f, 0.0f);
    childEntity.RelativePosition = childRelativePosition;
    childEntity.RelativeRotation = 10;
    Assert.AreEqual(parentEntity.Center + childRelativePosition, childEntity.Center);
    Assert.AreEqual(10, childEntity.Rotation);
}
[Test]
public void BuildHierarchyOfDifferentEntities()
{
    var parentEntity = new MockHierarchyEntity2D();
    var entityGivenPosition = new MockHierarchyEntity2D(new Vector2D(0.3f, 0.4f));
    var entityGivenRect = new MockHierarchyEntity2D(new Rectangle(0.1f, 0.0f, 0.5f, 0.4f), 20);
    parentEntity.Add(entityGivenPosition);
    parentEntity.Add(entityGivenRect);
    Assert.AreEqual(parentEntity, entityGivenPosition.Parent);
    Assert.AreEqual(new Vector2D(0.3f, 0.4f), entityGivenPosition.RelativePosition);
    Assert.AreEqual(parentEntity, entityGivenRect.Parent);
    Assert.AreEqual(20, entityGivenRect.RelativeRotation);
}
See Also