mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
refactor(gameplay): update systems per entity with chunk check
Refactor server entity update flow to process entities individually, skipping those whose chunk is not loaded. System update methods now accept a single entity instead of iterating the full registry view, and `ServerWorld::get_chunk_ref_count` is added to determine if an entity's chunk is active.
This commit is contained in:
@@ -44,9 +44,10 @@ private:
|
||||
void handle_entity_destory(EntityID id);
|
||||
void handle_task();
|
||||
void send_all_entities(std::shared_ptr<Session>& session);
|
||||
void update_ai();
|
||||
void update_move();
|
||||
void update_send();
|
||||
void update_ai(entt::entity e);
|
||||
void update_move(entt::entity e);
|
||||
void update_send(entt::entity e,
|
||||
std::span<std::shared_ptr<Session>> sessions);
|
||||
template <typename... Args>
|
||||
EntityID create_entity_in_factory(Args&&... args) {
|
||||
auto entity = m_registry.create();
|
||||
|
||||
@@ -94,6 +94,8 @@ public:
|
||||
|
||||
std::vector<std::shared_ptr<Session>> get_all_session() const;
|
||||
|
||||
uint32_t get_chunk_ref_count(const glm::vec3& pos) const;
|
||||
|
||||
int get_block(const glm::ivec3& block_pos) const override;
|
||||
bool is_solid(const glm::ivec3& block_pos) const override;
|
||||
bool can_pass_block(const glm::ivec3& block_pos) const override;
|
||||
|
||||
@@ -8,7 +8,8 @@ class PhysicalSystem {
|
||||
public:
|
||||
static glm::vec3 get_move_distance(const TickVelocity& v);
|
||||
|
||||
static void update(ServerWorld& world, entt::registry& registry);
|
||||
static void update(ServerWorld& world, entt::registry& registry,
|
||||
entt::entity e);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
namespace Cubed {
|
||||
class SpeedSystem {
|
||||
public:
|
||||
static void update(float dt, entt::registry& registry);
|
||||
static void update(float dt, entt::registry& registry, entt::entity e);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace Cubed {
|
||||
class WanderAISystem {
|
||||
public:
|
||||
static void update(entt::registry& registry);
|
||||
static void update(entt::registry& registry, entt::entity e);
|
||||
|
||||
private:
|
||||
static void do_ai(BaseServerCreature& creature, MoveBoost& move_boost);
|
||||
|
||||
Reference in New Issue
Block a user