Files
tactical-shooter/server/scripts/combat/lag_compensation.gd
T
shawn e70ce76207 P7.9: fix headless export — resolve Resource class_name ordering + duplicate RoundManager + simulation stub API
- Fix dead code in server_main.gd (unreachable lag compensation print)
- Remove WeaponData type hints from weapon_server.gd (Resource class_name in Node scripts = headless fail)
- Use preload() instead of WeaponData class_name in weapon_definitions.gd for const refs
- Lazy-init WEAPONS dict (const can't reference preload members)
- Remove duplicate class_name RoundManager from server/scripts/round/round_manager.gd
- Remove DamageProcessor type hints from round/round_manager.gd and bomb_objective.gd
- Add start()/stop()/can_tick()/tick()/spawn_entity()/despawn_entity() to simulation_server_stub.gd
- Fix get_world_3d() → get_tree().root.world_3d in weapon_server.gd Node context
- Fix var data := → var data = for untyped WeaponDefinitions.get_weapon() returns
- Clean export cache and verify server starts with zero parse errors
2026-07-02 17:57:09 -04:00

36 lines
1.4 KiB
GDScript

## LagCompensation — records player position history for hit-scan rewinding.
## Minimal stub for server startup compatibility.
## Full implementation to be built when hitscan system is wired.
extends Node
## class_name LagCompensation — commented out for headless compatibility
var physics_world = null
var _history: Dictionary = {} # tick → { entity_id: position }
## Record the start of a new tick for lag compensation.
## Called by GameServer each tick before processing inputs.
## Individual player positions are recorded by the game server loop.
func record_tick(tick: int) -> void:
_history[tick] = {}
## Record a player's position at a given tick (used during per-entity processing).
func record_position(tick: int, entity_id: int, position: Vector3) -> void:
if not _history.has(tick):
_history[tick] = {}
_history[tick][entity_id] = position
if _history.size() > 128:
var oldest = _history.keys().min()
if oldest != null:
_history.erase(oldest)
func rewind_and_raycast(tick: int, origin: Vector3, direction: Vector3, max_range: float, exclude: Array = []) -> Dictionary:
# Stub: fall back to current-frame raycast
if physics_world == null:
return {}
var space_state = physics_world.direct_space_state
if space_state == null:
return {}
var query = PhysicsRayQueryParameters3D.create(origin, origin + direction * max_range)
query.exclude = exclude
return space_state.intersect_ray(query)