feat(gameplay): add server-side entity movement and AI

Refactor LocalPlayer::update_physical to operate on a passed position, and run speed, physical, and wander AI systems in ServerEntityManager.
This commit is contained in:
2026-07-31 20:51:14 +08:00
parent c5ce91e653
commit 2e4a32fed7
4 changed files with 21 additions and 9 deletions

View File

@@ -6,6 +6,9 @@
#include "Cubed/gameplay/hitbox_manager.hpp"
#include "Cubed/gameplay/server_world.hpp"
#include "Cubed/gameplay/session.hpp"
#include "Cubed/gameplay/systems/physical_system.hpp"
#include "Cubed/gameplay/systems/speed_system.hpp"
#include "Cubed/gameplay/systems/wander_ai_system.hpp"
#include "Cubed/tools/cubed_assert.hpp"
#include "Cubed/tools/net_utils.hpp"
using namespace google::protobuf;
@@ -25,8 +28,15 @@ void ServerEntityManager::init() {
void ServerEntityManager::update() {
handle_task();
update_ai();
update_move();
}
void ServerEntityManager::update_ai() { WanderAISystem::update(m_registry); }
void ServerEntityManager::update_move() {
SpeedSystem::update(
static_cast<float>(m_world.get_per_tick_time()) / 1000.0f, m_registry);
PhysicalSystem::update(m_world, m_registry);
}
void ServerEntityManager::handle_task() {
TaskPair pair;
while (m_tasks.try_pop(pair)) {