User Tools

Site Tools


entities

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
entities [2018/09/10 12:13]
gobrosse [Definitions]
entities [2018/09/10 12:15]
gobrosse [Traits & Components]
Line 9: Line 9:
 Entities are actually a very complicated thing. Because they can have so many aspects to them and hold a good chunk of the gameplay code, they call for smart design patterns to keep their logic sane and somewhat readable. In Chunk Stories this is accomplished through the use of composition,​ entities delegate large aspects of themselves to smaller classes that are instanced once per entity and added to it at constructor time. Entities are actually a very complicated thing. Because they can have so many aspects to them and hold a good chunk of the gameplay code, they call for smart design patterns to keep their logic sane and somewhat readable. In Chunk Stories this is accomplished through the use of composition,​ entities delegate large aspects of themselves to smaller classes that are instanced once per entity and added to it at constructor time.
  
-These constitutive elements are of two classes: **Traits** or **EntityComponents**. Traits are as the name hints, an object that represent a specific *aspect* of an entity, a *property* it has. Traits are **not** replicated or saved with the entity, they cannot hold long-term state and information.+These constitutive elements are `Trait`s. Traits are as the name hints, an object that represent a specific *aspect* of an entity, a *property* it has. By default, ​Traits are **not** replicated or saved with the entity, they cannot hold long-term state and information.
  
-This is the responsibility of EntityComponents: these are just like traits with the difference being in that they are also **data containers**,​ with functions for reading and saving their data in a **byte stream**. ​EntityComponents ​are saved with entities ( actually they define almost everything about the entity ​but it'​s ​UUID and entity definition ​). They are also replicated to online players, ​with the ability ​to customize what player ​receives what information.+This is the responsibility of `SerializableTrait`s: these are just like normal ​traits with the difference being in that they are also **data containers**,​ with functions for reading and saving their data in a **byte stream**. ​`SerializableTrait`are saved with entities ( actually they define almost everything about the entity ​except ​it'​s ​type and UUID ).  
 + 
 +They are also replicated to online players, ​and you even get the chance ​to serialize the trait differently for each player, meaning you can decide to not send sensitive ​information ​such as inventory contents to players who shouldn'​t have knowledge of it ( to prevent cheating for example )
  
 ## Definitions ## Definitions
entities.txt · Last modified: 2018/09/10 12:16 by gobrosse