-
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 pull request #25 from zheng-ze/main
Add ContactSystem, HomeSystem and Cost Checking for spawns
- Loading branch information
Showing
19 changed files
with
290 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,6 @@ struct RemoveEvent: TFEvent { | |
} | ||
|
||
removeSystem.handleRemove(for: entityId) | ||
return EventOutput() | ||
return nil | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
TowerForge/TowerForge/LevelManager/Events/Implemented Events/RequestSpawnEvent.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,35 @@ | ||
// | ||
// RequestSpawnEvent.swift | ||
// TowerForge | ||
// | ||
// Created by Zheng Ze on 23/3/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct RequestSpawnEvent: TFEvent { | ||
let timestamp: TimeInterval | ||
let position: CGPoint | ||
let entityType: (PlayerSpawnable & TFEntity).Type | ||
let player: Player | ||
|
||
var entityId: UUID { | ||
fatalError("entityId is not to be used here") | ||
} | ||
|
||
init<T: TFEntity & PlayerSpawnable>(ofType type: T.Type, timestamp: TimeInterval, | ||
position: CGPoint, player: Player) { | ||
self.timestamp = timestamp | ||
self.position = position | ||
self.entityType = type | ||
self.player = player | ||
} | ||
|
||
func execute(in target: any EventTarget) -> EventOutput? { | ||
guard let homeSystem = target.system(ofType: HomeSystem.self) else { | ||
return nil | ||
} | ||
homeSystem.attemptSpawn(at: position, ofType: entityType, for: player) | ||
return nil | ||
} | ||
} |
Oops, something went wrong.