-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/achievements-engine
- Loading branch information
Showing
23 changed files
with
266 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
TowerForge/TowerForge/Networking/GameNetwork/RemoteEvents/RemoteKillEvent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// RemoteKillEvent.swift | ||
// TowerForge | ||
// | ||
// Created by Zheng Ze on 12/4/24. | ||
// | ||
|
||
import Foundation | ||
|
||
class RemoteKillEvent: TFRemoteEvent { | ||
let type: String | ||
let timeStamp: TimeInterval | ||
let source: UserPlayerId | ||
|
||
let id: UUID | ||
let targetIsSource: Bool | ||
|
||
init(id: UUID, player: Player, source: GamePlayer) { | ||
self.type = String(describing: RemoteKillEvent.self) | ||
self.timeStamp = Date().timeIntervalSince1970 | ||
self.source = source.userPlayerId | ||
|
||
self.id = id | ||
self.targetIsSource = player == .ownPlayer | ||
} | ||
|
||
func unpack(into eventManager: EventManager, for gamePlayer: UserPlayerId) { | ||
let player: Player = (gamePlayer == source) == targetIsSource ? .ownPlayer : .oppositePlayer // XOR | ||
let killEvent = KillEvent(on: id, at: timeStamp, player: player) | ||
eventManager.add(killEvent) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
TowerForge/TowerForge/Networking/GameNetwork/RemoteEvents/RemoteLifeEvent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// RemoteLifeEvent.swift | ||
// TowerForge | ||
// | ||
// Created by Zheng Ze on 12/4/24. | ||
// | ||
|
||
import Foundation | ||
|
||
class RemoteLifeEvent: TFRemoteEvent { | ||
let type: String | ||
let timeStamp: TimeInterval | ||
let source: UserPlayerId | ||
|
||
let reduceBy: Int | ||
let targetIsSource: Bool | ||
|
||
init(reduceBy: Int, player: Player, source: GamePlayer) { | ||
self.type = String(describing: RemoteLifeEvent.self) | ||
self.timeStamp = Date().timeIntervalSince1970 | ||
self.source = source.userPlayerId | ||
|
||
self.reduceBy = reduceBy | ||
self.targetIsSource = player == .ownPlayer | ||
} | ||
|
||
func unpack(into eventManager: EventManager, for gamePlayer: UserPlayerId) { | ||
let player: Player = (gamePlayer == source) == targetIsSource ? .ownPlayer : .oppositePlayer | ||
let lifeEvent = LifeEvent(at: timeStamp, reduceBy: reduceBy, player: player) | ||
eventManager.add(lifeEvent) | ||
} | ||
} |
Oops, something went wrong.