Test crash bugfix
This commit is contained in:
parent
5d8df46361
commit
f4cd97cac7
@ -13,6 +13,7 @@ class RoundTimer: Timer {
|
|||||||
var timer: Timer?
|
var timer: Timer?
|
||||||
var timeLeft: Int = 0
|
var timeLeft: Int = 0
|
||||||
var isHeartbeatLocked = false
|
var isHeartbeatLocked = false
|
||||||
|
var isTimerStopped = false
|
||||||
var calculate = false
|
var calculate = false
|
||||||
var roundEnded = "Syncing"
|
var roundEnded = "Syncing"
|
||||||
|
|
||||||
@ -31,23 +32,16 @@ class RoundTimer: Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func stopTimer() {
|
func stopTimer() {
|
||||||
guard timer != nil else { return }
|
isTimerStopped = true
|
||||||
timer?.invalidate()
|
|
||||||
timer = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resumeTimer() {
|
func resumeTimer() {
|
||||||
timer = Timer.scheduledTimer(
|
isTimerStopped = false
|
||||||
timeInterval: 1.0,
|
|
||||||
target: self,
|
|
||||||
selector: #selector(onTimerFires),
|
|
||||||
userInfo: nil,
|
|
||||||
repeats: true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func onTimerFires()
|
@objc func onTimerFires()
|
||||||
{
|
{
|
||||||
|
if !isTimerStopped {
|
||||||
timeLeft -= 1
|
timeLeft -= 1
|
||||||
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
|
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
|
||||||
|
|
||||||
@ -76,3 +70,4 @@ class RoundTimer: Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user