vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ragdoll_system.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include "core/system.h"
7#include "debug/fault_latch.h"
8#include "ecs/entity.h"
9#include "ecs/scene_observer.h"
10
11namespace Vkm::Engine {
12
13class Scene;
14
26EntityId ragdollOwnerOf(const Scene& scene, EntityId body, int32_t* outBone = nullptr);
27
38class RagdollSystem : public System, public ISceneObserver {
39 public:
40 RagdollSystem() = default;
41 ~RagdollSystem() override = default;
42
43 RagdollSystem(const RagdollSystem& other) = delete;
44 RagdollSystem& operator=(const RagdollSystem& other) = delete;
45
46 RagdollSystem(RagdollSystem && other) = delete;
47 RagdollSystem& operator=(RagdollSystem && other) = delete;
48
49 public:
50 void init(FrameContext& ctx) override;
51 void fixedUpdate(FrameContext& ctx) override;
52
54 void shutdown() override;
55
64 void onEntityDestroyed(EntityId id) override;
65
66 private:
67 Scene* m_scene = nullptr;
68 FaultLatch m_scaled;
69};
70
81bool isPosedByAnimation(const Scene& scene, EntityId entity);
82
91void markPosedByAnimation(const Scene& scene, std::vector<bool>& bySlot);
92
93} // namespace Vkm::Engine
Names a recurring fault once per gap rather than once a frame.
Definition fault_latch.h:11
void init(FrameContext &ctx) override
Called once after all systems are registered, before the first update.
void fixedUpdate(FrameContext &ctx) override
Execute this system at the fixed simulation rate.
void onEntityDestroyed(EntityId id) override
Destroy a ragdoll's bones when the thing they belong to goes.
void shutdown() override
Drops the observer registration, so nothing calls a dead system.
Central registry managing entities and an open set of component types.
Definition scene.h:29
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
Per-frame state bundle passed to every system.
Definition system.h:55