QuestWeaver
A procedural quest generator
|
Holds information about all entities relevant for quests and quest generation. More...
#include <WorldModel.h>
Public Member Functions | |
WorldModel () noexcept | |
Creates a new empty world model. More... | |
virtual | ~WorldModel ()=default |
void | AddListener (std::shared_ptr< WorldListener > listener) const noexcept |
Adds a listener to the world model. More... | |
void | Execute (std::vector< WorldModelAction > modelActions) |
Commits the given changes to the world model and informs the attached WorldLister. More... | |
std::vector< std::shared_ptr< WorldEntity > > | GetEntities () const noexcept |
Returns a list of all entities known to this world model. More... | |
std::vector< std::shared_ptr< WorldEntity > > | GetEntitiesWithType (std::string type) const noexcept |
Returns all entities with a given type. More... | |
std::shared_ptr< WorldEntity > | GetEntityById (ID id) const noexcept |
Returns the entity for a given ID, or a nullptr if no such entity is known. More... | |
std::vector< WorldModelAction > | GetHistory () const noexcept |
Returns the action history of all actions executed by this world model. More... | |
MetaData | GetMetaData (ID entityId) const noexcept |
Returns the metadata for the entity with the given ID. More... | |
std::vector< WorldModelAction > | GetMetaDataHistoryForId (ID id) const noexcept |
Returns a list of all actions that changed the metadata of the entity with the given ID. More... | |
virtual const NameGenerator & | GetNameGenerator () const =0 |
The name generator used to create the names of world entities and story elements. More... | |
Protected Attributes | |
std::shared_ptr< RandomStream > | rs |
The random stream can be used by subclasses to create randomized entities. More... | |
Holds information about all entities relevant for quests and quest generation.
The WorldModel is provided by the caller of the API, so it can create game-specific quest entities (e.g cowboys for a wild-west game and aliens for a sci-fi game).
WorldEntity instances are immutable and stateless, so the world model also manages the entities MetaData. In addition, the world model keeps track of all changes ever made to any entities or meta data to create richer quests and back-stories.
Definition at line 28 of file WorldModel.h.
|
noexcept |
Creates a new empty world model.
|
virtualdefault |
|
noexcept |
Adds a listener to the world model.
The listener will receive all updates of the world model's Execute method.
void weave::WorldModel::Execute | ( | std::vector< WorldModelAction > | modelActions | ) |
Commits the given changes to the world model and informs the attached WorldLister.
This method is the only way to change the data of the world model and subclasses should not break that contract.
If one of the given actions is illegal (e.g. unknown entity ID), a ContractFailedException will be thrown. The actions executed up until that point will stay executed, the rest of the actions will not be executed.
modelActions | The actions to be executed. The actions are executed in order. |
|
noexcept |
Returns a list of all entities known to this world model.
|
noexcept |
Returns all entities with a given type.
|
noexcept |
Returns the entity for a given ID, or a nullptr if no such entity is known.
|
noexcept |
Returns the action history of all actions executed by this world model.
If this history is executed on an empty world model, it should result in a copy of the current model.
Returns the metadata for the entity with the given ID.
If no entity with that ID is known, an empty metadata object is returned.
|
noexcept |
Returns a list of all actions that changed the metadata of the entity with the given ID.
If an action changed the entity itself (e.g. delete it), but not the metadata, it will not be returned.
|
pure virtual |
The name generator used to create the names of world entities and story elements.
|
protected |
The random stream can be used by subclasses to create randomized entities.
Definition at line 101 of file WorldModel.h.