KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
KTech::Memory Class Reference

Engine component responsible for registering all world structures. More...

#include <memory.hpp>

Public Member Functions

void CallOnTicks ()
 Call the virtual OnTick() functions of all registered world structures.
 

Public Attributes

CachingRegistry< Objectobjects
 Objects registry.
 
CachingRegistry< Layerlayers
 Layers registry.
 
CachingRegistry< Cameracameras
 Cameras registry.
 
CachingRegistry< Mapmaps
 Maps registry.
 
CachingRegistry< Widgetwidgets
 Widgets registry.
 
CachingRegistry< UIuis
 UIs registry.
 

Friends

class Output
 

Detailed Description

Engine component responsible for registering all world structures.

This engine component contains a CachingRegistry for each world structure. World structures automatically add themselves to their corresponding CachingRegistry here. This way world structures can refer and get access to each other in a serializable way, using their IDs (in contrary to a memory addresses, which aren't serializable nor safe in terms of memory). This is why world structures need an Engine reference (and is indeed a non-optional parameter in all of their constructors); they must have access to this place to integrate with everything else.

See also
CachingRegistry to learn about accessing world structures using their ID.

Member Function Documentation

◆ CallOnTicks()

void KTech::Memory::CallOnTicks ( )

Call the virtual OnTick() functions of all registered world structures.

Normally placed at the start of tick, with the other callback-calling functions of engine components. For example:

// Game loop
while (engine.running)
{
// Call various callback-functions
engine.input.CallCallbacks();
engine.time.CallInvocations();
engine.memory.CallOnTicks(); // <- Call `OnTick()` functions of all world structures
// Graphics...
}

This function was placed in Memory, because this engine component has the most direct access to all of the world structures. Although, this function could have been technically placed easily anywhere else.


The documentation for this class was generated from the following files: