16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 05:29:18 +02:00

ECS System WIP

This commit is contained in:
2026-04-07 23:40:03 +02:00
parent f6db9978d2
commit 8e9fd9225f
30 changed files with 1133 additions and 242 deletions

View File

@@ -0,0 +1,29 @@
//
// Created by Daniu
//
#include "MovementSystem.h"
#include "entitysystem/ECWorld.h"
#include "entitysystem/components/BasicComponents.h"
#include "utilities/Logs.h"
void MovementSystem::Update(ECWorld& world, float dt)
{
constexpr double damping = 0.90; // 0.0 = instant stop, 1.0 = without damping
world.Each<ECSComponent::Transform, ECSComponent::Velocity>(
[dt](auto entity, auto& transform, auto& velocity)
{
transform.Position += velocity.Value * dt;
velocity.Value *= damping;
if (glm::length(velocity.Value) < 0.001)
{
velocity.Value = glm::dvec3(0.0);
}
}
);
}