vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::BehaviorSystem Class Reference

Drives the lifecycle of every entity's ScriptComponent behaviors. More...

#include <behavior_system.h>

Inheritance diagram for Vkm::Engine::BehaviorSystem:
Vkm::Engine::System Vkm::Engine::ISceneObserver

Public Member Functions

void init (FrameContext &ctx) override
 Called once after all systems are registered, before the first update.
void update (FrameContext &ctx) override
 Execute this system for the current frame.
void fixedUpdate (FrameContext &ctx) override
 Execute this system at the fixed simulation rate.
bool isReplayed () const override
 Re-run during a replay: it moves the world from state and command, repeatably.
void shutdown () override
 Called once on engine shutdown.
void onEntityDestroyed (EntityId entity) override
 ISceneObserver: fire onDestroy on entity's behaviors before its ScriptComponent goes.
void endSession (Scene &scene)
 End the session: onDestroy on every started behavior, reset, and discard queued requests.

Static Public Member Functions

static void destroyEntityBehaviors (Scene &scene, EntityId entity)
 Fire onDestroy on entity's started behaviors, before its ScriptComponent goes.

Detailed Description

Drives the lifecycle of every entity's ScriptComponent behaviors.

Runs before PhysicsSystem in Simulation, so physics integrates script state the same frame. Destroy requests drain after each fixed tick and the frame pass; loadScene() after the frame pass only. Contacts are dispatched after onStart and before the destroy drain, so a handler may destroy its own entity. A throwing hook is reported through reportError() and the behavior disabled.

Member Function Documentation

◆ init()

void Vkm::Engine::BehaviorSystem::init ( FrameContext & ctx)
overridevirtual

Called once after all systems are registered, before the first update.

Parameters
ctxThe first frame's context; its products are all null.

Reimplemented from Vkm::Engine::System.

◆ update()

void Vkm::Engine::BehaviorSystem::update ( FrameContext & ctx)
overridevirtual

Execute this system for the current frame.

Parameters
ctxThis frame's services and the products published so far.

Reimplemented from Vkm::Engine::System.

◆ fixedUpdate()

void Vkm::Engine::BehaviorSystem::fixedUpdate ( FrameContext & ctx)
overridevirtual

Execute this system at the fixed simulation rate.

Called 0+ times per frame; the step is ctx.clock.getFixedStep().

Runs before any producer stage, so ctx.visibility and ctx.ui are null here. ctx.poses is set by SkeletalAnimationSystem's own fixedUpdate, so a later Simulation system reads this tick's pose.

Parameters
ctxThis frame's services; see above for which products are set.

Reimplemented from Vkm::Engine::System.

◆ isReplayed()

bool Vkm::Engine::BehaviorSystem::isReplayed ( ) const
inlineoverridevirtual

Re-run during a replay: it moves the world from state and command, repeatably.

Returns
Always true.

Reimplemented from Vkm::Engine::System.

◆ onEntityDestroyed()

void Vkm::Engine::BehaviorSystem::onEntityDestroyed ( EntityId entity)
overridevirtual

ISceneObserver: fire onDestroy on entity's behaviors before its ScriptComponent goes.

Runs inside Scene::destroyEntity, whatever called it.

Parameters
entityThe entity being destroyed.

Implements Vkm::Engine::ISceneObserver.

◆ endSession()

void Vkm::Engine::BehaviorSystem::endSession ( Scene & scene)

End the session: onDestroy on every started behavior, reset, and discard queued requests.

Drops subscriptions and the started/disabled flags. Call while the module is loaded and the EventBus alive. Queued destroy() / loadScene() requests named the world being torn down, so they go too.

Parameters
sceneScene whose session ends.

◆ destroyEntityBehaviors()

void Vkm::Engine::BehaviorSystem::destroyEntityBehaviors ( Scene & scene,
EntityId entity )
static

Fire onDestroy on entity's started behaviors, before its ScriptComponent goes.

Parameters
sceneScene holding the entity.
entityEntity whose behaviors are told.

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