| 
 | 1 | +Entities & Components  | 
 | 2 | +=====================  | 
 | 3 | + | 
 | 4 | +.. epigraph::  | 
 | 5 | + | 
 | 6 | +	.. image:: /_static/ecs.svg  | 
 | 7 | +		:alt: ECS Diagram from Wikipedia  | 
 | 8 | +		:height: 100pt  | 
 | 9 | +		:align: right  | 
 | 10 | + | 
 | 11 | +	"Entity–component–system (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed from components of data, with systems which operate on the components.  | 
 | 12 | + | 
 | 13 | +	ECS follows the principle of composition over inheritance, meaning that every entity is defined not by a type hierarchy, but by the components that are associated with it. Systems act globally over all entities which have the required components."  | 
 | 14 | + | 
 | 15 | +	— `Wikipedia - Entity Component System <https://en.wikipedia.org/wiki/Entity_component_system>`_  | 
 | 16 | + | 
 | 17 | +Entity  | 
 | 18 | +------  | 
 | 19 | +In Unnatural Worlds specifically, each entity is identified by its unique 32-bit integer.  | 
 | 20 | +These ids are assigned by the server, and client cannot predict the values.  | 
 | 21 | + | 
 | 22 | +.. note::  | 
 | 23 | +	In a very long game, it is possible that an id is reused.  | 
 | 24 | + | 
 | 25 | +.. note::  | 
 | 26 | +	Some entities and/or components are synchronized only with the owner of the entity.  | 
 | 27 | + | 
 | 28 | +Proto  | 
 | 29 | +-----  | 
 | 30 | +Defines the prototype of the entity.  | 
 | 31 | + | 
 | 32 | +It is allowed to change from construction to unit, or from unit to another unit.  | 
 | 33 | +It is forbidden to change eg. from unit to resource.  | 
 | 34 | + | 
 | 35 | +Owner  | 
 | 36 | +-----  | 
 | 37 | +Defines which force owns this entity.  | 
 | 38 | + | 
 | 39 | +Immutable.  | 
 | 40 | + | 
 | 41 | +Controller  | 
 | 42 | +----------  | 
 | 43 | +In case that multiple players belong to the same force, the last player to give any orders to this entity will become the controller of the entity.  | 
 | 44 | + | 
 | 45 | +.. warning::  | 
 | 46 | +	Controllers are not yet implemented.  | 
 | 47 | + | 
 | 48 | +Position  | 
 | 49 | +--------  | 
 | 50 | +Index of the tile this entity is placed on.  | 
 | 51 | +In case the entity has large radius, this component defines the center tile.  | 
 | 52 | + | 
 | 53 | +The yaw defines the orientation (a rotation along the local vertical axis) of this entity on the tile.  | 
 | 54 | +The actual direction of 0 degrees yaw is different for each tile.  | 
 | 55 | + | 
 | 56 | +Unit  | 
 | 57 | +----  | 
 | 58 | +Contains additional state for a unit (or building).  | 
 | 59 | + | 
 | 60 | +- ``Shooting`` - waiting for the cannon to cool down.  | 
 | 61 | +- ``Processing`` - the unit has processed a recipe and is waiting for it to complete.  | 
 | 62 | +- ``Rebuilding`` - recipe for the unit has changed, and the unit is waiting for the changes to complete.  | 
 | 63 | +- ``Stalling`` - the unit's recipe cannot be executed, usually because a limit for the outputs has been reached.  | 
 | 64 | + | 
 | 65 | +Life  | 
 | 66 | +----  | 
 | 67 | +Amount of life of the unit (or building).  | 
 | 68 | + | 
 | 69 | +Move  | 
 | 70 | +----  | 
 | 71 | +Contains information about current movement of the unit.  | 
 | 72 | +Information is available for the next neighboring tile only.  | 
 | 73 | + | 
 | 74 | +Aim  | 
 | 75 | +---  | 
 | 76 | +Id of a target unit that this unit will automatically shoot at.  | 
 | 77 | + | 
 | 78 | +Recipe  | 
 | 79 | +------  | 
 | 80 | +Id of the prototype of the recipe that this unit will automatically process.  | 
 | 81 | + | 
 | 82 | +UpdateTimestamp  | 
 | 83 | +---------------  | 
 | 84 | +Contains a timestamp (tick) of when this construction started, or when this unit's recipe was last processed.  | 
 | 85 | +It is used for planning logistics deliveries.  | 
 | 86 | + | 
 | 87 | +RecipeStatistics  | 
 | 88 | +----------------  | 
 | 89 | +Used for calculating this unit's processing efficiency.  | 
 | 90 | + | 
 | 91 | +It is reset when the recipe changes.  | 
 | 92 | + | 
 | 93 | +Priority  | 
 | 94 | +--------  | 
 | 95 | +Contains the priority assigned by the player.  | 
 | 96 | +The priority applies to both constructions and recipe processing.  | 
 | 97 | +It is used by the logistics planning.  | 
 | 98 | + | 
 | 99 | +Amount  | 
 | 100 | +------  | 
 | 101 | +Contains the count of the resource in this entity.  | 
 | 102 | + | 
 | 103 | +Attachment  | 
 | 104 | +----------  | 
 | 105 | +Defines that this entity is attached to another entity.  | 
 | 106 | +This entity is automatically moved to the position (and orientation) of the target.  | 
 | 107 | +This is commonly used by a resource carried by a truck.  | 
 | 108 | + | 
 | 109 | +Player  | 
 | 110 | +------  | 
 | 111 | +This entity represents a client - a player or an observer.  | 
 | 112 | + | 
 | 113 | +Force  | 
 | 114 | +-----  | 
 | 115 | +This entity represents a force.  | 
 | 116 | +The component contains public information about the force.  | 
 | 117 | + | 
 | 118 | +ForceDetails  | 
 | 119 | +------------  | 
 | 120 | +This component contains private information about the force.  | 
 | 121 | + | 
 | 122 | +ForeignPolicy  | 
 | 123 | +-------------  | 
 | 124 | +This entity declares the policy between two forces.  | 
 | 125 | + | 
 | 126 | +DiplomacyProposal  | 
 | 127 | +-----------------  | 
 | 128 | +This entity contains a proposal of a policy to another force.  | 
 | 129 | + | 
 | 130 | +.. warning::  | 
 | 131 | +	Diplomacy is not yet implemented.  | 
0 commit comments