2.1 Entities
Every object in Spliced that has any interaction or requires more complex data than building tiles is an entity.
Entities serve as containers for components which control the behaviour.
Instantiating an entity only creates the entity on the current machine. To create an entity on the network, inform every involved party over an event.
Entity (ENTITY)
Implemented in Version a2.0
class Entity { }
Entity is the base class for all entities.
Entity implements following methods:
| Method | Description |
|---|---|
| Entity(int size, unsigned long id) | Instantiates a entity in the world with the ID passed in the second parameter. The first parameter is the maximum amount of components. |
| ~Entity() | Removes the entity. |
| void SetComponent(int index, Component* component) | Sets pointer to a component at the given index. |
| Component* GetComponent(int index) | Gets component pointer from the given index. |
| int GetSize() | Gets maximum amount of components that can be held by the given entity. |
| unsigned long GetID() | Gets entity id. |
Entity implements following private properties:
| Property | Description |
|---|---|
| int size | Maximum amount of components that can be held by the given entity. |
| unsigned long id | Entity id. |
| Components** components | Points to array of component pointers. |
Player (PLAYER)
Implemented in Version a2.0
class Player : public Entity { }
The player entity for clients has basic hitbox and model functionality while not containing any further components
Player additionally implements following methods:
| Method | Description |
|---|---|
| Player(unsigned long id) | Instantiates a player in the world with the ID passed in the parameter. This entity does not hold any components. |
PlayerClient (PLAYER_CLIENT)
Implemented in Version a2.0
class PlayerClient : public Entity { }
This entity is the player that the client is actively using. (Self-Player) It contains various components useful for the client-side.
PlayerClient additionally implements following methods:
| Method | Description |
|---|---|
| PlayerClient(unsigned long id) | Instantiates a player in the world with the ID passed in the parameter. PlayerClient automatically creates a PlayerStat-, Inventory- and PlayerItemComponent. |