Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
TrailSystem.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
12#pragma once
13
14#include "../core/Types.hpp"
15#include "../math/Math.hpp"
16#include "../ecs/Registry.hpp"
19
20#include <deque>
21#include <unordered_map>
22
23namespace esengine::trail {
24
26struct TrailPoint {
27 glm::vec3 position{0.0f, 0.0f, 0.0f};
28 f32 birth_time = 0.0f;
29};
30
32struct TrailState {
33 std::deque<TrailPoint> points;
34};
35
37public:
38 TrailSystem() = default;
39
41 void update(ecs::Registry& registry, f32 dt);
42
44 void clear(Entity entity);
45
47 f32 now() const { return time_; }
48
49 const TrailState* getState(Entity entity) const;
50
51private:
52 f32 time_ = 0.0f;
53 std::unordered_map<Entity, TrailState> states_;
54 // RAII: auto-unregisters from the registry's onDestroy when this system is torn
55 // down, so a dead system never leaves a dangling `this` behind.
56 Connection destroyConn_;
57};
58
59} // namespace esengine::trail
Math utilities and GLM configuration for ESEngine.
Central ECS registry for entity and component management.
World-space motion trail renderable (sword swipes, projectile/dash streaks, ribbon effects).
Unified Transform component with local and world-space data.
Core type definitions and utilities for ESEngine.
RAII handle for signal connections.
Central container for all entities and components.
Definition Registry.hpp:73
void update(ecs::Registry &registry, f32 dt)
const TrailState * getState(Entity entity) const
void clear(Entity entity)
float f32
32-bit floating point
Definition Types.hpp:59
Entity identifier with packed index + generation.
Definition Types.hpp:135
One recorded trail sample: a world position stamped with the sim clock.
f32 birth_time
Value of TrailSystem::now() when recorded.
Per-entity point history. Front = oldest (tail), back = newest (near head).
std::deque< TrailPoint > points