summaryrefslogtreecommitdiffstats
path: root/game/shared
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-21 18:16:40 +0500
committeruntodesu <kirill@untode.su>2025-03-21 18:16:40 +0500
commit9f80a278a6f188c8e9131df0684bad14a07491ee (patch)
tree067c6ad4b892a34c3c03e3ecdbe312453bd46ea4 /game/shared
parentfddd7f761176bb45cfdd41eeccaeadac22d33ddf (diff)
downloadvoxelius-9f80a278a6f188c8e9131df0684bad14a07491ee.tar.bz2
voxelius-9f80a278a6f188c8e9131df0684bad14a07491ee.zip
Toggles system rework, added flight pmove mode
- Reworked toggles to use a constant-styled enumerations - Added TOGGLE_PM_FLIGHT and an according movement mode. Now server-side just doesn't simulate gravity altogether for players, instead relying on whatever the client provides which works fine for now. Closes #12
Diffstat (limited to 'game/shared')
-rw-r--r--game/shared/collision.cc11
-rw-r--r--game/shared/factory.cc2
2 files changed, 8 insertions, 5 deletions
diff --git a/game/shared/collision.cc b/game/shared/collision.cc
index 126d3bb..0593fbb 100644
--- a/game/shared/collision.cc
+++ b/game/shared/collision.cc
@@ -6,6 +6,7 @@
#include "shared/coord.hh"
#include "shared/dimension.hh"
#include "shared/globals.hh"
+#include "shared/gravity.hh"
#include "shared/grounded.hh"
#include "shared/transform.hh"
#include "shared/velocity.hh"
@@ -146,11 +147,15 @@ void CollisionComponent::fixed_update(Dimension *dimension)
auto surface = voxel_surface::UNKNOWN;
auto vertical_move = vgrid_collide(dimension, 1, collision, transform, velocity, surface);
- if(vertical_move == cxpr::sign<int>(dimension->get_gravity())) {
- auto &component = dimension->entities.get_or_emplace<GroundedComponent>(entity);
- component.surface = surface;
+ if(dimension->entities.any_of<GravityComponent>(entity)) {
+ if(vertical_move == cxpr::sign<int>(dimension->get_gravity()))
+ dimension->entities.emplace_or_replace<GroundedComponent>(entity, GroundedComponent{surface});
+ else dimension->entities.remove<GroundedComponent>(entity);
}
else {
+ // The entity cannot be grounded because the component
+ // setup of said entity should not let it comprehend the
+ // concept of resting on the ground (it flies around)
dimension->entities.remove<GroundedComponent>(entity);
}
diff --git a/game/shared/factory.cc b/game/shared/factory.cc
index ee09a24..34cc55c 100644
--- a/game/shared/factory.cc
+++ b/game/shared/factory.cc
@@ -18,8 +18,6 @@ void shared_factory::create_player(Dimension *dimension, entt::entity entity)
collision.aabb.min = glm::fvec3(-0.4f, -1.6f, -0.4f);
collision.aabb.max = glm::fvec3(+0.4f, +0.2f, +0.4f);
- dimension->entities.emplace_or_replace<GravityComponent>(entity);
-
auto &head = dimension->entities.emplace_or_replace<HeadComponent>(entity);
head.angles = glm::fvec3(0.0f, 0.0f, 0.0f);
head.offset = glm::fvec3(0.0f, 0.0f, 0.0f);