Files
tactical-shooter/addons/netfox.extras/physics/network-rigid-body-2d.gd
T
shawn e7299b17e9 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)
2026-07-02 17:39:22 -04:00

45 lines
1.5 KiB
GDScript

@icon("res://addons/netfox.extras/icons/network-rigid-body-2d.svg")
extends RigidBody2D
class_name NetworkRigidBody2D
## A rollback / state synchronizer class for RigidBody2D.
## Set state property path to physics_state to synchronize the state of this body.
@onready var direct_state = PhysicsServer2D.body_get_direct_state(get_rid())
var physics_state: Array:
get: return get_state()
set(v): set_state(v)
enum {
ORIGIN,
ROT,
LIN_VEL,
ANG_VEL,
SLEEPING
}
func _notification(notification: int):
if notification == NOTIFICATION_READY:
add_to_group("network_rigid_body")
func get_state() -> Array:
var body_state: Array = [Vector3.ZERO, Quaternion.IDENTITY, Vector3.ZERO, Vector3.ZERO, false]
body_state[ORIGIN] = direct_state.transform.origin
body_state[ROT] = direct_state.transform.get_rotation()
body_state[LIN_VEL] = direct_state.linear_velocity
body_state[ANG_VEL] = direct_state.angular_velocity
body_state[SLEEPING] = direct_state.sleeping
return body_state
func set_state(remote_state: Array) -> void:
direct_state.transform = Transform2D(remote_state[ROT], remote_state[ORIGIN])
direct_state.linear_velocity = remote_state[LIN_VEL]
direct_state.angular_velocity = remote_state[ANG_VEL]
direct_state.sleeping = remote_state[SLEEPING]
## Override and apply any logic, forces or impulses to the rigid body as you would in physics_process
## The physics engine will run its simulation during rollback_tick with other nodes
func _physics_rollback_tick(_delta, _tick):
pass