Save workspace artifacts: character-controller, gdextension scaffold, network scripts, map-pipeline, server config
Includes code from task workspaces that was never pushed: - client/characters/ — fps_character_controller.gd (400 lines), fps_camera.gd, input_handler.gd - gdextension/simulation/ — C++ GDExtension scaffold: entity, movement, hit detection, simulation server, state serializer, bitstream (14 files) - scripts/network/ — ENet-based network_manager.gd, server/client_main.gd, player.gd - scripts/map_packaging/ — PCK pipeline: pack_map.gd, map_downloader.gd, map_registry_server.py, README - scripts/config/ — server_config.gd (480 lines) - scenes/ — client_main, server_main, player, test_range - project.godot, export_presets.cfg
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#ifndef TACTICAL_SHOOTER_MOVEMENT_COMPONENT_H
|
||||
#define TACTICAL_SHOOTER_MOVEMENT_COMPONENT_H
|
||||
|
||||
#include "entity.h"
|
||||
|
||||
namespace tactical_shooter {
|
||||
|
||||
/**
|
||||
* Physics-less movement simulation for networked FPS characters.
|
||||
*
|
||||
* Operates on Entity state directly — no Godot PhysicsServer3D involvement.
|
||||
* Uses semi-implicit Euler integration with configurable movement parameters.
|
||||
*
|
||||
* All values assume "Godot units" (1 unit ≈ 1 meter) with gravity in
|
||||
* units/s² and speeds in units/s.
|
||||
*/
|
||||
class MovementComponent {
|
||||
public:
|
||||
struct Parameters {
|
||||
float walk_speed = 4.0f; // units/s
|
||||
float sprint_speed = 6.5f; // units/s
|
||||
float crouch_speed = 2.0f; // units/s
|
||||
float acceleration = 20.0f; // units/s²
|
||||
float air_acceleration = 4.0f; // reduced control in air
|
||||
float friction = 8.0f; // ground deceleration
|
||||
float air_friction = 1.0f; // air resistance
|
||||
float jump_velocity = 5.0f; // initial upward velocity
|
||||
float gravity = -20.0f; // units/s² (negative = downward)
|
||||
float max_velocity = 10.0f; // speed cap (all directions)
|
||||
float crouch_height = 0.75f; // multiplier on entity base height
|
||||
float stand_height = 1.0f;
|
||||
};
|
||||
|
||||
MovementComponent();
|
||||
explicit MovementComponent(const Parameters ¶ms);
|
||||
|
||||
/**
|
||||
* Main update. Called once per simulation tick (e.g. every 1/128s).
|
||||
*
|
||||
* @param entity Entity to update
|
||||
* @param delta Timestep in seconds (e.g. 0.0078125 for 128Hz)
|
||||
*/
|
||||
void update(Entity &entity, float delta);
|
||||
|
||||
/// Modify movement parameters at runtime
|
||||
void set_parameters(const Parameters ¶ms);
|
||||
const Parameters ¶meters() const { return params_; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* Apply ground movement with acceleration/friction.
|
||||
* Follows Quake/CS-style movement model (non-Strafe).
|
||||
*/
|
||||
void apply_ground_movement(Entity &entity, float delta);
|
||||
|
||||
/**
|
||||
* Apply air movement with reduced acceleration.
|
||||
*/
|
||||
void apply_air_movement(Entity &entity, float delta);
|
||||
|
||||
/**
|
||||
* Integrate velocity into position (semi-implicit Euler).
|
||||
*/
|
||||
void integrate_position(Entity &entity, float delta);
|
||||
|
||||
Parameters params_;
|
||||
};
|
||||
|
||||
} // namespace tactical_shooter
|
||||
|
||||
#endif // TACTICAL_SHOOTER_MOVEMENT_COMPONENT_H
|
||||
Reference in New Issue
Block a user