PositionComponent

Namespace: Murder.Components
Assembly: Murder.dll

public sealed struct PositionComponent : IMurderTransformComponent, ITransformComponent, IParentRelativeComponent, IComponent, IEquatable<T>

Position component used to track entities positions within a grid.

Implements: IMurderTransformComponent, ITransformComponent, IParentRelativeComponent, IComponent, IEquatable<T>

⭐ Constructors

public PositionComponent(Point p)

Create a new PositionComponent.

Parameters
p Point

public PositionComponent(float x, float y, IMurderTransformComponent parent)

Parameters
x float
y float
parent IMurderTransformComponent

public PositionComponent(float x, float y)

Create a new PositionComponent.

Parameters
x float
y float

public PositionComponent(Vector2 v)

Create a new PositionComponent.

Parameters
v Vector2

⭐ Properties

Angle

public virtual float Angle { get; }

Returns
float

HasParent

public virtual bool HasParent { get; }

Whether this position is tracking a parent entity.

Returns
bool

Scale

public virtual Vector2 Scale { get; }

Returns
Vector2

X

public virtual float X { get; }

Relative X position of the component.

Returns
float

Y

public virtual float Y { get; }

Relative Y position of the component.

Returns
float

⭐ Methods

Equals(PositionComponent)

public virtual bool Equals(PositionComponent other)

Compares two position components. This will take their parents into account.

Parameters
other PositionComponent

Returns
bool

Equals(Object)

public virtual bool Equals(Object obj)

Parameters
obj Object

Returns
bool

Add(IMurderTransformComponent)

public virtual IMurderTransformComponent Add(IMurderTransformComponent r)

Parameters
r IMurderTransformComponent

Returns
IMurderTransformComponent

Add(Vector2)

public virtual IMurderTransformComponent Add(Vector2 r)

Parameters
r Vector2

Returns
IMurderTransformComponent

GetGlobal()

public virtual IMurderTransformComponent GetGlobal()

Return the global position of the component within the world.

Returns
IMurderTransformComponent

Subtract(IMurderTransformComponent)

public virtual IMurderTransformComponent Subtract(IMurderTransformComponent r)

Parameters
r IMurderTransformComponent

Returns
IMurderTransformComponent

Subtract(Vector2)

public virtual IMurderTransformComponent Subtract(Vector2 r)

Parameters
r Vector2

Returns
IMurderTransformComponent

With(float, float)

public virtual IMurderTransformComponent With(float x, float y)

Parameters
x float
y float

Returns
IMurderTransformComponent

GetHashCode()

public virtual int GetHashCode()

Returns
int

WithoutParent()

public virtual IParentRelativeComponent WithoutParent()

Creates a copy of component with the relative coordinates without its parent.

Returns
IParentRelativeComponent

OnParentModified(IComponent, Entity)

public virtual void OnParentModified(IComponent parentComponent, Entity childEntity)

This tracks whenever a parent position has been modified.

Parameters
parentComponent IComponent

childEntity Entity