Nebula
Loading...
Searching...
No Matches
Nebula.Game.Entity Class Reference

Detailed Description

Represents a game object that resides in a game world.

Contains properties and native components that make up the behaviour and logic of the entity. Entities can receive messages which are propagated to all properties that listen for the message.

Public Member Functions

bool IsValid ()
 Check if entity is valid (not destroyed)
 
bool HasComponent< T > ()
 Check if entity has some unmanaged component.
 
void SetComponent< T > (in T component)
 Set the value of a native, unmanaged component.
 
GetComponent< T > ()
 Gets a value copy of the native, unmanaged component.
 
bool HasProperty< T > ()
 Checks if the entity has a certain property.
 
void AddProperty (Property property)
 Adds a property to the entity.
 
GetProperty< T > ()
 Gets the property if it exists in the entity.
 
Vector3 GetPosition ()
 Gets the position of the entity.
 
void SetPosition (Vector3 position)
 Sets the position of the entity.
 
Quaternion GetOrientation ()
 Gets the orientation of the entity.
 
void SetOrientation (Quaternion orientation)
 Sets the orientation of the entity.
 
Vector3 GetScale ()
 Gets the scale of the entity.
 
void SetScale (Vector3 scale)
 Sets the scale of the entity.
 
void Send< T > (in T msg)
 Sends this entity a message.
 
override string ToString ()
 Constructs a string representation of this entity.
 

Static Public Member Functions

static void Destroy (Entity entity)
 Schedule the entity for destruction.
 

Package Functions

 Entity (World world, UInt64 entityId)
 

Properties

World World [get]
 The world that this entity belongs to.
 
UInt64 Id [get]
 Unique identifier for the entity.
 

Private Attributes

World world = null
 
UInt64 id = 0xFFFFFFFFFFFFFFFF
 
List< Propertyproperties
 
MsgDispatcher dispatcher = new MsgDispatcher()
 

Constructor & Destructor Documentation

◆ Entity()

Nebula.Game.Entity.Entity ( World world,
UInt64 entityId )
inlinepackage

Do not create new entities using this constructor, instead create them via World.CreateEntity.

Member Function Documentation

◆ AddProperty()

void Nebula.Game.Entity.AddProperty ( Property property)
inline

Adds a property to the entity.

◆ Destroy()

static void Nebula.Game.Entity.Destroy ( Entity entity)
inlinestatic

Schedule the entity for destruction.

Note that this does not immediately remove the entity from the native backend.

◆ GetComponent< T >()

T Nebula.Game.Entity.GetComponent< T > ( )
inline

Gets a value copy of the native, unmanaged component.

This method does allocate and copy memory, thus should be used sparringly in time-critical code.

Type Constraints
T :struct 
T :NativeComponent 

◆ GetOrientation()

Quaternion Nebula.Game.Entity.GetOrientation ( )
inline

Gets the orientation of the entity.

◆ GetPosition()

Vector3 Nebula.Game.Entity.GetPosition ( )
inline

Gets the position of the entity.

◆ GetProperty< T >()

T Nebula.Game.Entity.GetProperty< T > ( )
inline

Gets the property if it exists in the entity.

This is a linear search (O(N)) through all properties attached to this entity.

Returns
Null, or the property if entity has it.
Type Constraints
T :Property 

◆ GetScale()

Vector3 Nebula.Game.Entity.GetScale ( )
inline

Gets the scale of the entity.

◆ HasComponent< T >()

bool Nebula.Game.Entity.HasComponent< T > ( )
inline

Check if entity has some unmanaged component.

Type Constraints
T :struct 
T :NativeComponent 

◆ HasProperty< T >()

bool Nebula.Game.Entity.HasProperty< T > ( )
inline

Checks if the entity has a certain property.

This is a linear search (O(N)) through all properties attached to this entity.

Type Constraints
T :Property 

◆ IsValid()

bool Nebula.Game.Entity.IsValid ( )
inline

Check if entity is valid (not destroyed)

◆ Send< T >()

void Nebula.Game.Entity.Send< T > ( in T msg)
inline

Sends this entity a message.

The message will be propagated into all Properties that this entity has, that accepts the message.

Type Constraints
T :struct 
T :Msg 

◆ SetComponent< T >()

void Nebula.Game.Entity.SetComponent< T > ( in T component)
inline

Set the value of a native, unmanaged component.

This method does allocate and copy memory, thus should be used sparringly in time-critical code.

Type Constraints
T :struct 
T :NativeComponent 

◆ SetOrientation()

void Nebula.Game.Entity.SetOrientation ( Quaternion orientation)
inline

Sets the orientation of the entity.

◆ SetPosition()

void Nebula.Game.Entity.SetPosition ( Vector3 position)
inline

Sets the position of the entity.

◆ SetScale()

void Nebula.Game.Entity.SetScale ( Vector3 scale)
inline

Sets the scale of the entity.

◆ ToString()

override string Nebula.Game.Entity.ToString ( )
inline

Constructs a string representation of this entity.

Member Data Documentation

◆ dispatcher

MsgDispatcher Nebula.Game.Entity.dispatcher = new MsgDispatcher()
private

◆ id

UInt64 Nebula.Game.Entity.id = 0xFFFFFFFFFFFFFFFF
private

◆ properties

List<Property> Nebula.Game.Entity.properties
private

◆ world

World Nebula.Game.Entity.world = null
private

Property Documentation

◆ Id

UInt64 Nebula.Game.Entity.Id
get

Unique identifier for the entity.

◆ World

World Nebula.Game.Entity.World
get

The world that this entity belongs to.


The documentation for this class was generated from the following file: