EventSpawner class
#include <Jazz2/Events/EventSpawner.h>
Spawns objects in a level.
Maps each EventType to a registered factory and preload delegate, and uses them to create actor instances (or preload their assets) from an event type and its spawn parameters. The known spawnable actors are registered on construction.
Public types
-
using CreateDelegate = std::
shared_ptr<Actors:: ActorBase>(*)(const Actors:: ActorActivationDetails& details) - Delegate to create an object.
-
using PreloadDelegate = void(*)(const Actors::
ActorActivationDetails& details) - Delegate to preload assets for an object.
Constructors, destructors, conversion operators
- EventSpawner(ILevelHandler* levelHandler)
- Creates a new instance owned by the specified level handler.
Public functions
-
void PreloadEvent(EventType type,
std::
uint8_t* spawnParams) - Preloads assets for a given event.
-
auto SpawnEvent(EventType type,
const std::
uint8_t* spawnParams, Actors:: ActorState flags, std:: int32_t x, std:: int32_t y, std:: int32_t z) -> std:: shared_ptr<Actors:: ActorBase> - Spawns an object for a given event.
-
auto SpawnEvent(EventType type,
const std::
uint8_t* spawnParams, Actors:: ActorState flags, const Vector3i& pos) -> std:: shared_ptr<Actors:: ActorBase> - void RegisterSpawnable(EventType type, CreateDelegate create, PreloadDelegate preload = nullptr)
- Registers a delegate to create an object from an event.
Constants
-
static std::
int32_t SpawnParamsSize constexpr - Size of event parameters.
Function documentation
std:: shared_ptr<Actors:: ActorBase> Jazz2:: Events:: EventSpawner:: SpawnEvent(EventType type,
const std:: uint8_t* spawnParams,
Actors:: ActorState flags,
const Vector3i& pos)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.