Jump to content

The Pyrogenesis Engine/Simulation

From Wikibooks, open books for an open world

The most important aspect of any game is its gameplay. In Pyrogenesis, the simulation can be thought of as the place where gameplay is executed. The simulation is the part of the engine that takes commands from the players (including the AI) and turns them into actions in the game world.

The simulation subsystem is defined in simulation2/Simulation2.cpp. Its central class, CSimulation2Impl is instantiated by ???, constructed from a unit manager (CUnitManager) and a terrain (CTerrain). From this alone, we can deduce that the simulation deals with how units interact with each other and with the terrain of a map.

When CSimulation2Impl is instantiated, it also initializes a component manager (CComponentManager?). Components are one of the most crucial concepts to grasp in order to understand how the simulation works. Programatically, components are merely subsystems accessed via the component manager. For instance, there is a pathfinder component for deriving the shortest path across a terrain, a sound manager component for outputting music and sound effects, and a projectile manager component for driving ballistic calculations of things like arrows and spears.

However, though each of these subsystems (components) are instantiated only once by the component manager (I think), they can be associated with any entity in the game world (I think) and will only ever be used in relation to one such entity at a time (I think). Thus, as a user of the simulation, it may be easier to think of the simulation as consisting of a set of entities, each "having" (being associated with) one or more components. For instance, a soldier unit may have a Pathfinder component, so it can find its way over the map, and an Attack component, so it can fight any enemies it comes across, and an Armour component, so it can handle damage dealt by other units.


Clipboard

To do:
Everything else.


Regarding how to load a single instance of a component for one whole session: For a single component you need to attach it to the system entity which unfortunately requires a C++ change. The location is: source/simulation2/Simulation2.cpp:128