Entity and component

Outcome simulations are based on an approach where the system consists of a set of entities to each of which multiple components are attached.

Result is a flexible arrangement of objects that can be used to accomplish many different tasks.

Exact arrangement of the entities and their components can be dynamic, entities can be created and destroyed, components can be attached and removed. It can also stay pretty static. Both approaches can be used, either alone or complementing each other. All depends on how the user decides to design their mods.

Entity

Entity is the fundamental object in the system. It's most important feature for us right now is that it can hold components.

We can create many entities, or only a few. There are no built-in entities.

Entity type

When it comes to entities, a type helps define what components can be attached to an entity. Component definition includes the ability to specify entity type with which that component is compatible.

Components will use entity-local addresses to get variables, and we need this compatibility notion to be able to make some assumptions about what entity our component is attached to.

Each entity type introduces a new namespace for entities of that type. This means we can have entities /yellow/banana and /green/banana and they won't collide namespace-wise.

Component

Component lies at the core of computation. Each component instance is assigned to a single entity.

Each component defines a set of it's own variables and contains a single state machine (see next sub-chapter).

Component type

We can use component type to create sets of components that will have common characteristics.

Declaration of a new component type can contain things that we would normally declare for components themselves. What we define here will act as default for any new component of that type we might declare elsewhere. This default can be overriden for any of the entries by just declaring that entry on the component.

Component type can be also used as a way of organizing components, and/or expanding the component namespace (like with entity type).

# declare a new component type
component_type:
- id: decision
  vars:
  - id: template_var
  ...
  states:
  - id: template_state_1
  ...

# use the new component type
component:
- id: choice_213
  type: decision

# component `choice_213` has a var `template_var`
# /region/e_01001/decision/