Start of rewind system

This commit is contained in:
Rendo 2025-12-21 02:22:41 +05:00
commit 42c95820d7
16 changed files with 55 additions and 33 deletions

17
systems/rewind.gd Normal file
View file

@ -0,0 +1,17 @@
extends Node
const timestamp_range:float = 200.0 #MSEC
const timestamps_amount: int = 200
var timestamp: float = 0
func _process(delta: float) -> void:
if not is_multiplayer_authority():
return
if Session.session_started_flag:
timestamp += delta
sync_time.rpc(timestamp)
@rpc
func sync_time(new_timestamp: float) -> void:
timestamp = new_timestamp

1
systems/rewind.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bafcih3g8gi2q

View file

@ -8,23 +8,23 @@ signal return_to_previous
var machine: WeaponSubStateMachine
func _use_begin() -> void:
func _use_begin(timestamp: float) -> void:
pass
@rpc("authority","call_remote","reliable")
func use_begin() -> void:
_use_begin()
func use_begin(timestamp: float) -> void:
_use_begin(timestamp)
if is_multiplayer_authority():
use_begin.rpc()
use_begin.rpc(timestamp)
func _use_end():
func _use_end(timestamp: float):
pass
@rpc("authority","call_remote","reliable")
func use_end() -> void:
_use_end()
func use_end(timestamp: float) -> void:
_use_end(timestamp)
if is_multiplayer_authority():
use_end.rpc()
use_end.rpc(timestamp)
func _alternate_state() -> void:
pass

View file

@ -70,12 +70,12 @@ func _enter() -> void:
func _exit() -> void:
super()
func use_begin() -> void:
func use_begin(timestamp: float) -> void:
if current_state != null:
current_state.use_begin()
func use_end() -> void:
current_state.use_begin(timestamp)
func use_end(timestamp: float) -> void:
if current_state != null:
current_state.use_end()
current_state.use_end(timestamp)
func alternate_state() -> void:
if current_state != null:
current_state.alternate_state()

View file

@ -218,17 +218,17 @@ func _physics_process(delta: float) -> void:
return
current_state.physics_update(delta)
func use_begin() -> void:
func use_begin(timestamp: float) -> void:
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
return
if current_state != null:
current_state.use_begin()
current_state.use_begin(timestamp)
func use_end() -> void:
func use_end(timestamp: float) -> void:
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
return
if current_state != null:
current_state.use_end()
current_state.use_end(timestamp)
func alternate_state() -> void:
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled: