Phase 7: netfox + godot-jolt stack upgrade

Stack installed:
- netfox v1.35.3 (core + extras + noray + internals)
- godot-jolt v0.16.0-stable

Architecture:
- Server: ENet transport (works headless, no netfox deps)
- Client/Editor: netfox rollback (RollbackSynchronizer, TickInterpolator)

New/modified:
- docs/migration-netfox-plan.md — migration architecture
- scripts/network/network_manager.gd — netfox-aware ENet fallback
- scripts/network/player.gd — clean base player
- client/characters/player_netfox.gd — rollback player w/ WeaponManager
- client/characters/input/player_net_input.gd — BaseNetInput subclass
- client/characters/character/fps_character_controller.gd — netfox input feed
- client/weapons/ — weapon data, registry, TacticalWeaponHitscan, WeaponManager
- client/scripts/round_replicator.gd — client-side round state bridge
- server/scripts/round_manager.gd — improved state machine
- server/scripts/plugin_api/plugin_manager.gd — refined plugin system
- config: enemy_tag, ally_tag for meatball targeting

Removed: old C++ SimulationServer GDExtension (replaced by netfox rollback)
This commit is contained in:
2026-07-02 17:38:50 -04:00
parent e2dc429caa
commit e7299b17e9
3237 changed files with 523530 additions and 18 deletions
@@ -0,0 +1,89 @@
## TacticalWeaponHitscan — rollback-aware hitscan weapon for the tactical shooter.
##
## Extends NetworkWeaponHitscan3D with per-limb damage, team checks,
## and headshot detection.
##
## This script is ONLY loaded from client scenes where netfox is active.
## The server handles damage authority directly.
extends "res://addons/netfox.extras/weapon/network-weapon-hitscan-3d.gd"
class_name TacticalWeaponHitscan
## Weapon data resource (stats) — set on spawn
var weapon_data: WeaponData = null
## Weapon owner's peer ID — set on spawn
var owner_peer_id: int = -1
## Cooldown tick for rate-of-fire limiting
var _last_fire_tick: int = -1
func _can_fire() -> bool:
if weapon_data == null:
return false
if weapon_data.fire_mode == WeaponData.FireMode.MELEE:
return true # Melee always "can fire"
# Rate-of-fire check using network tick
var nt = Engine.get_singleton(&"NetworkTime")
if nt == null:
return true
var current_tick := nt.tick if nt.has_method(&"get_tick") else 0
if _last_fire_tick >= 0:
var tick_interval := maxi(1, int(weapon_data.fire_rate / 64.0))
if current_tick - _last_fire_tick < tick_interval:
return false
return true
func _can_peer_use(peer_id: int) -> bool:
return peer_id == owner_peer_id
func _after_fire():
# Track fire tick for cooldown
var nt = Engine.get_singleton(&"NetworkTime")
if nt != null:
_last_fire_tick = nt.tick if nt.has_method(&"get_tick") else 0
## Handle a raycast hit — called on ALL peers with rollback reconciliation.
func _on_hit(result: Dictionary):
if weapon_data == null:
return
if not multiplayer.is_server() and not is_multiplayer_authority():
return # Only server/authority applies damage
var collider := result.get("collider")
if collider == null:
return
# Determine limb hit via collision groups
var damage_multiplier: float = weapon_data.chest_multiplier
var is_headshot := false
if collider is Node:
if collider.is_in_group(&"head"):
damage_multiplier = weapon_data.headshot_multiplier
is_headshot = true
elif collider.is_in_group(&"chest"):
damage_multiplier = weapon_data.chest_multiplier
elif collider.is_in_group(&"waist"):
damage_multiplier = weapon_data.waist_multiplier
elif collider.is_in_group(&"legs"):
damage_multiplier = weapon_data.leg_multiplier
var final_damage := int(weapon_data.damage * damage_multiplier)
# Find the player node from the collider
var player := _find_player(collider)
if player != null and player.has_method(&"apply_damage"):
if is_headshot:
print("[TacticalWeapon] HEADSHOT on %s for %d" % [player.name, final_damage])
player.apply_damage(final_damage, owner_peer_id, weapon_data.weapon_id)
## Find a player node walking up the scene tree.
func _find_player(node: Node) -> Node:
var current = node
while current != null:
if current.has_method(&"apply_damage") or current.is_in_group(&"players"):
return current
current = current.get_parent()
return null
+200
View File
@@ -0,0 +1,200 @@
## WeaponManager — client-side weapon inventory with rollback-safe firing.
##
## Manages weapon switching, ammo tracking. Firing is handled by the
## RollbackHitscanManager (in _rollback_tick) for lag compensation.
##
## This script is ONLY loaded from client scenes where netfox is active.
extends Node
class_name WeaponManager
signal weapon_switched(old_slot: int, new_slot: int, weapon_data: WeaponData)
signal ammo_changed(weapon_id: int, magazine: int, reserve: int)
# Preload the weapon scripts (only works when netfox is active)
const _HitscanWeapon := preload("res://client/weapons/scripts/tactical_weapon_hitscan.gd")
## Reference to the player's weapon anchor node.
@export var weapon_anchor: Node3D
## Reference to the RollbackHitscanManager (set by player).
var rollback_hitscan_mgr: Node = null
## Current weapon data.
var current_weapon: WeaponData = null
var current_weapon_node: Node3D = null
var current_slot: int = 1
## Inventory: slot → { data, node, magazine, reserve }
var _inventory: Dictionary = {}
var _last_fire_time: float = 0.0
func add_weapon(data: WeaponData) -> void:
var slot: int = data.slot
if _inventory.has(slot):
_remove_weapon(slot)
var weapon_node: Node3D = _create_weapon(data)
if weapon_node == null:
return
weapon_node.visible = false
add_child(weapon_node)
_inventory[slot] = {
"data": data,
"node": weapon_node,
"magazine": data.magazine_size,
"reserve": data.reserve_size,
}
if current_weapon == null:
switch_to_slot(slot)
func remove_weapon(slot: int) -> void:
_remove_weapon(slot)
if current_slot == slot:
_switch_to_next_available()
func switch_to_slot(slot: int) -> bool:
if not _inventory.has(slot):
return false
var entry = _inventory[slot]
var old_slot := current_slot
current_slot = slot
current_weapon = entry["data"] as WeaponData
current_weapon_node = entry["node"] as Node3D
_update_visibility()
weapon_switched.emit(old_slot, slot, current_weapon)
# Update the RollbackHitscanManager with the new weapon data
_notify_hitscan_mgr_of_weapon_change(current_weapon)
return true
func switch_next() -> void:
var slots := _inventory.keys()
slots.sort()
var idx := slots.find(current_slot)
if idx >= 0 and idx + 1 < slots.size():
switch_to_slot(slots[idx + 1])
func switch_prev() -> void:
var slots := _inventory.keys()
slots.sort()
var idx := slots.find(current_slot)
if idx > 0:
switch_to_slot(slots[idx - 1])
# ---------------------------------------------------------------------------
# Firing (rollback-safe — delegates to RollbackHitscanManager)
# ---------------------------------------------------------------------------
## Called by the client to attempt firing through the rollback system.
## Returns true if ammo was consumed.
func fire() -> bool:
if current_weapon_node == null or current_weapon == null:
return false
if current_weapon.magazine_size > 0 and _get_magazine() <= 0:
return false
if not _check_fire_rate():
return false
# Consume ammo immediately for client prediction
var entry = _inventory[current_slot]
entry["magazine"] -= 1
ammo_changed.emit(current_weapon.weapon_id, entry["magazine"], entry["reserve"])
_last_fire_time = Time.get_ticks_msec() / 1000.0
# The actual raycast and damage happen in the RollbackHitscanManager's
# process_fire() during _rollback_tick(), triggered by the shoot input.
# This method just handles the client-side ammo tracking.
return true
func reload() -> void:
if current_weapon == null or current_weapon.magazine_size <= 0:
return
var entry = _inventory[current_slot]
if entry["magazine"] >= current_weapon.magazine_size or entry["reserve"] <= 0:
return
var needed := current_weapon.magazine_size - entry["magazine"]
var available := min(needed, entry["reserve"])
entry["magazine"] += available
entry["reserve"] -= available
ammo_changed.emit(current_weapon.weapon_id, entry["magazine"], entry["reserve"])
func get_ammo() -> Vector2i:
if current_weapon == null or not _inventory.has(current_slot):
return Vector2i.ZERO
var e = _inventory[current_slot]
return Vector2i(e["magazine"], e["reserve"])
## Get the current weapon's maximum distance for raycasting.
func get_max_distance() -> float:
if current_weapon != null:
return current_weapon.max_distance
return 1000.0
## Get the current weapon ID.
func get_weapon_id() -> int:
if current_weapon != null:
return current_weapon.weapon_id
return 0
func get_current_weapon_data() -> WeaponData:
return current_weapon
# ---------------------------------------------------------------------------
# Rollback integration
# ---------------------------------------------------------------------------
## Notify the RollbackHitscanManager when the weapon changes.
func _notify_hitscan_mgr_of_weapon_change(wd: WeaponData) -> void:
if rollback_hitscan_mgr != null and rollback_hitscan_mgr.has_method(&"set_weapon_data"):
rollback_hitscan_mgr.set_weapon_data(wd)
# ---------------------------------------------------------------------------
# Internal
# ---------------------------------------------------------------------------
func _create_weapon(data: WeaponData) -> Node3D:
var weapon := Node3D.new()
weapon.name = data.weapon_name
if data.fire_mode != WeaponData.FireMode.MELEE:
var hs: TacticalWeaponHitscan = _HitscanWeapon.new()
hs.name = "Hitscan"
hs.weapon_data = data
hs.max_distance = data.max_distance
weapon.add_child(hs, true)
return weapon
func _get_magazine() -> int:
var e = _inventory.get(current_slot)
return e["magazine"] if e else 0
func _check_fire_rate() -> bool:
if current_weapon.fire_rate <= 0:
return false
var now := Time.get_ticks_msec() / 1000.0
return (now - _last_fire_time) >= (1.0 / current_weapon.fire_rate)
func _remove_weapon(slot: int) -> void:
var e = _inventory.get(slot)
if e and e["node"]:
e["node"].queue_free()
_inventory.erase(slot)
func _switch_to_next_available() -> void:
var slots := _inventory.keys()
slots.sort()
if slots.size() > 0:
switch_to_slot(slots[0])
else:
current_weapon = null
current_weapon_node = null
_update_visibility()
func _update_visibility() -> void:
for slot in _inventory:
_inventory[slot]["node"].visible = (slot == current_slot)