refactor: update death timer method to accept tick parameter
This commit is contained in:
parent
7a757df05c
commit
8586180dbc
2 changed files with 4 additions and 4 deletions
|
|
@ -38,7 +38,7 @@ func RespondToInput(lobbyState *MatchState, messages []runtime.MatchData, logger
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the input to the tick where it occurred
|
// Apply latest player input
|
||||||
lobbyState.presences[msg.GetSessionId()].stageState.BoundsCheckedMove(update.X, update.Y)
|
lobbyState.presences[msg.GetSessionId()].stageState.BoundsCheckedMove(update.X, update.Y)
|
||||||
|
|
||||||
// Check if the input is within the grace window
|
// Check if the input is within the grace window
|
||||||
|
|
@ -106,8 +106,6 @@ func BroadcastToPresences(tick int64, lobbyState *MatchState, logger *runtime.Lo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v.stageState.UpdateDeathTimer(tick)
|
|
||||||
|
|
||||||
var tickData = v.stageState.MakeServerTick(tick, newBulletsToBroadcast)
|
var tickData = v.stageState.MakeServerTick(tick, newBulletsToBroadcast)
|
||||||
|
|
||||||
data, err := json.Marshal(tickData)
|
data, err := json.Marshal(tickData)
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func (s *PlayerStageState) DeleteBulletsBeyondKillBoundary(tick int64) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PlayerStageState) UpdateDeathTimer() {
|
func (s *PlayerStageState) UpdateDeathTimer(tick int64) {
|
||||||
// If the player is dead, decrement the death timer
|
// If the player is dead, decrement the death timer
|
||||||
if s.deathTimer >= 0 {
|
if s.deathTimer >= 0 {
|
||||||
s.deathTimer -= 1
|
s.deathTimer -= 1
|
||||||
|
|
@ -100,6 +100,8 @@ func (s *PlayerStageState) AddBullet(b *ffi.Bullet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PlayerStageState) MakeServerTick(tick int64, serializedNewBullets []map[string]any) *ServerTickUpdate {
|
func (s *PlayerStageState) MakeServerTick(tick int64, serializedNewBullets []map[string]any) *ServerTickUpdate {
|
||||||
|
s.UpdateDeathTimer(tick)
|
||||||
|
|
||||||
hitPosX, hitPosY := s.hitCol.GetPos()
|
hitPosX, hitPosY := s.hitCol.GetPos()
|
||||||
grazePosX, grazePosY := s.hitCol.GetPos()
|
grazePosX, grazePosY := s.hitCol.GetPos()
|
||||||
var tickData = ServerTickUpdate{
|
var tickData = ServerTickUpdate{
|
||||||
|
|
|
||||||
Reference in a new issue