Changes between Version 5 and Version 6 of SimulationArchitecture


Ignore:
Timestamp:
Nov 15, 2009, 5:16:55 PM (15 years ago)
Author:
Philip Taylor
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SimulationArchitecture

    v5 v6  
    3737An entity can only have (at most) one component that implements a particular interface (that is, it cannot have both `PositionInterpolated` and `PositionStatic`). Any code that interacts with the entity cannot tell what component types it uses - the code can only use `QueryInterface` to get a pointer to whatever component implements the `Position` interface, and call the common methods declared by that interface.
    3838
     39== Message passing ==
     40
     41Direct method calls between components are sometimes necessary, but they force component implementations to know details of other components. For example, a `Position` component may want to notify many other components when the entity moves (e.g. any components that want to detect when an entity is within a certain range, or set it on fire if it's walking on lava), and it would be bad (complex, inflexible) if the `Position` component type's code had to know about every other component type it should notify.
     42
     43The '''message passing''' system helps with this case. Component types can '''subscribe''' to a particular message type, and components can '''post''' or '''broadcast''' a message with a type and associated data, which will be received by all subscribed components. (''Post'' sends the message to the components with a specific entity ID, ''broadcast'' sends to component of all entities). For example, the burn-on-lava component can subscribe to the `PositionChanged` message type, and the `Position` component can then post a `PositionChanged` message to its own entity ID, and the burn component's message handler function will be called. The `Position` component only has to know about this message type, not about any of the components that use it.
     44
     45Messages are one-to-many communication (any number of components can receive a single posted message), and they are one-way (it is not possible to return a value in response to a message). Components are notified in a consistent but arbitrary order.
     46
     47(TODO: the post vs broadcast semantics are not very well designed currently.)
     48
    3949== TODO ==
    4050
    4151Things to talk about:
    42  * Message passing
    4352 * Serialization
    4453 * Entity templates and initialisation