Skip to content

Commit

Permalink
[tank-race-game] chore: add terminate game event
Browse files Browse the repository at this point in the history
  • Loading branch information
didymental committed Apr 14, 2024
1 parent 302480d commit c54470d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ArkGameExample/games/TankRaceGame/TankRaceGame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,16 @@ class TankRaceGame {
.on(TankRaceSteeringEvent.self) { event, context in
self.handlerManager?.handleTankSteer(event, in: context)
}
.on(TankWinEvent.self) { event, _ in
.on(TankWinEvent.self) { event, context in
self.handlerManager?.handleWin(event, view: self.rootView)
guard let stopwatchEntity = context.ecs.getEntities(with: [StopWatchComponent.self]).first,
let stopwatchComp = context.ecs
.getComponent(ofType: StopWatchComponent.self, for: stopwatchEntity) else {
return
}
context.events.emit(TerminateGameLoopEvent(
eventData: TerminateGameLoopEventData(timeInGame: stopwatchComp.currentTime))
)
}
}

Expand Down

0 comments on commit c54470d

Please sign in to comment.