Skip to content

Commit 8ad5964

Browse files
committed
UI progress
1 parent 1236c0d commit 8ad5964

32 files changed

+519
-176
lines changed

Sources/GateEngine/ECS/2D Specific/Physics/Collision2DSystem.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77

88
public final class Collision2DSystem: System {
99
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
10-
for entity in game.entities {
10+
for entity in context.entities {
1111
guard entity.hasComponent(Collision2DComponent.self) else { continue }
1212
guard entity.hasComponent(Transform2Component.self) else { continue }
1313
entity[Collision2DComponent.self].updateColliders(entity.transform2)
1414
}
1515

1616
guard
17-
let quadtreeEntity = game.entities.first(where: {
17+
let quadtreeEntity = context.entities.first(where: {
1818
$0.hasComponent(QuadtreeComponent.self)
1919
})
2020
else {
2121
return
2222
}
2323
let quadtree = quadtreeEntity[QuadtreeComponent.self].quadtree!
2424

25-
for entity in game.entities {
25+
for entity in context.entities {
2626
guard entity.hasComponent(Collision2DComponent.self) else { continue }
2727
if let transformComponent = entity.component(ofType: Transform2Component.self) {
2828
let object = entity[Collision2DComponent.self]
@@ -69,9 +69,3 @@ public final class Collision2DSystem: System {
6969
public override class var phase: System.Phase { .simulation }
7070
public override class func sortOrder() -> SystemSortOrder? { .collision2DSystem }
7171
}
72-
73-
@MainActor extension Game {
74-
public var collision2DSystem: Collision2DSystem {
75-
return self.system(ofType: Collision2DSystem.self)
76-
}
77-
}

Sources/GateEngine/ECS/2D Specific/Physics/Physics2DSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class Physics2DSystem: System {
1212
// Skip Physics if we don't have at least 20 fps
1313
guard deltaTime < 1 / 20 else { return }
1414

15-
for entity in game.entities {
15+
for entity in context.entities {
1616
guard let physicsComponent = entity.component(ofType: Physics2DComponent.self) else {
1717
continue
1818
}

Sources/GateEngine/ECS/2D Specific/Sprite/SpriteSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public final class SpriteSystem: System {
99
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
10-
for entity in game.entities {
10+
for entity in context.entities {
1111
if let spriteComponent = entity.component(ofType: SpriteComponent.self) {
1212
if spriteComponent.moveToNextAnimationIfNeeded {
1313
spriteComponent.moveToNextAnimationIfNeeded = false

Sources/GateEngine/ECS/2D Specific/TileMap/TileMapSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public final class TileMapSystem: System {
99
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
10-
for entity in game.entities {
10+
for entity in context.entities {
1111
if let component = entity.component(ofType: TileMapComponent.self) {
1212
if component.needsSetup {
1313
self.setup(component)

Sources/GateEngine/ECS/3D Specific/Billboard/BillboardSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
public final class BillboardSystem: System {
99
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
10-
guard let camera = game.cameraEntity else {return}
10+
guard let camera = context.cameraEntity else {return}
1111
let cameraTransform = camera.transform3
1212

13-
for entity in game.entities {
13+
for entity in context.entities {
1414
guard let billboardComponent = entity.component(ofType: BillboardComponent.self) else {continue}
1515
guard let transformComponent = entity.component(ofType: Transform3Component.self) else {continue}
1616

Sources/GateEngine/ECS/3D Specific/CameraComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class CameraComponent: Component {
1919
public static let componentID: ComponentID = ComponentID()
2020
}
2121

22-
@MainActor extension Game {
22+
@MainActor extension ECSContext {
2323
public var cameraEntity: Entity? {
2424
return self.entities.first(where: {
2525
return $0.component(ofType: CameraComponent.self)?.isActive == true

Sources/GateEngine/ECS/3D Specific/ObjectAnimation/ObjectAnimation3DSystem.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public final class ObjectAnimation3DSystem: System {
99
var checkedIDs: Set<ObjectIdentifier> = []
10-
func getFarAway(from entities: ContiguousArray<Entity>) -> Entity? {
10+
func getFarAway(from entities: Set<Entity>) -> Entity? {
1111
func filter(_ entity: Entity) -> Bool {
1212
if let objectAnimation = entity.component(ofType: ObjectAnimation3DComponent.self) {
1313
return objectAnimation.disabled == false && objectAnimation.deltaAccumulator > 0
@@ -30,7 +30,7 @@ public final class ObjectAnimation3DSystem: System {
3030
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
3131
func shouldAccumulate(entity: Entity) -> Bool {
3232
guard
33-
let cameraTransform = game.cameraEntity?.component(ofType: Transform3Component.self)
33+
let cameraTransform = context.cameraEntity?.component(ofType: Transform3Component.self)
3434
else {
3535
return false
3636
}
@@ -64,11 +64,11 @@ public final class ObjectAnimation3DSystem: System {
6464
}
6565
}
6666

67-
let slowEntity = getFarAway(from: game.entities)
67+
let slowEntity = getFarAway(from: context.entities)
6868
if let entity = slowEntity {
6969
updateAnimation(for: entity)
7070
}
71-
for entity in game.entities {
71+
for entity in context.entities {
7272
guard entity != slowEntity else { continue }
7373
if let component = entity.component(ofType: ObjectAnimation3DComponent.self),
7474
component.disabled == false

Sources/GateEngine/ECS/3D Specific/Physics/Collision3DSystem.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public final class Collision3DSystem: System {
99
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
10-
let staticEntities = game.entities.filter({
10+
let staticEntities = context.entities.filter({
1111
guard let collisionComponenet = $0.component(ofType: Collision3DComponent.self) else {return false}
1212
if case .static = collisionComponenet.kind {
1313
return true
@@ -17,7 +17,7 @@ public final class Collision3DSystem: System {
1717
for entity in staticEntities {
1818
entity.collision3DComponent.updateColliders(entity.transform3)
1919
}
20-
let dynamicEntities = game.entities.filter({
20+
let dynamicEntities = context.entities.filter({
2121
guard let collisionComponenet = $0.component(ofType: Collision3DComponent.self) else {return false}
2222
if case .dynamic(_) = collisionComponenet.kind {
2323
return true
@@ -526,9 +526,8 @@ extension Collision3DSystem {
526526
}
527527

528528
extension Collision3DSystem {
529-
@_transparent
530529
private var octrees: [OctreeComponent] {
531-
return game.entities.compactMap({ $0.component(ofType: OctreeComponent.self) })
530+
return context.entities.compactMap({ $0.component(ofType: OctreeComponent.self) })
532531
}
533532

534533
@inline(__always)
@@ -594,7 +593,7 @@ extension Collision3DSystem {
594593
) -> [Entity] {
595594
var entities: [Entity] = []
596595

597-
for entity in game.entities {
596+
for entity in context.entities {
598597
if
599598
let collisionComponent = entity.component(ofType: Collision3DComponent.self),
600599
filter?(entity) ?? true
@@ -616,7 +615,7 @@ extension Collision3DSystem {
616615
) -> [Entity] {
617616
var entities: [Entity] = []
618617

619-
for entity in game.entities {
618+
for entity in context.entities {
620619
if
621620
let collisionComponent = entity.component(ofType: Collision3DComponent.self),
622621
filter?(entity) ?? true,
@@ -694,7 +693,7 @@ extension Collision3DSystem {
694693
}
695694
}
696695

697-
@MainActor extension Game {
696+
@MainActor extension ECSContext {
698697
@_transparent
699698
public var collision3DSystem: Collision3DSystem {
700699
return self.system(ofType: Collision3DSystem.self)

Sources/GateEngine/ECS/3D Specific/Physics/Physics3DSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class Physics3DSystem: System {
1212
// Skip Physics if we don't have at least 20 fps
1313
guard deltaTime < 1 / 20 else { return }
1414

15-
for entity in game.entities {
15+
for entity in context.entities {
1616
var deltaTime = deltaTime
1717
if let scale = entity.component(ofType: TimeScaleComponent.self)?.scale {
1818
deltaTime *= scale

Sources/GateEngine/ECS/3D Specific/Rig/Rig3DSystem.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public final class RigSystem {}
1010

1111
public final class Rig3DSystem: System {
1212
var checkedIDs: Set<ObjectIdentifier> = []
13-
func getFarAway(from entities: ContiguousArray<Entity>) -> Entity? {
13+
func getFarAway(from entities: Set<Entity>) -> Entity? {
1414
func filter(_ entity: Entity) -> Bool {
1515
if let rig = entity.component(ofType: Rig3DComponent.self) {
1616
return rig.disabled == false && rig.deltaAccumulator > 0
@@ -33,7 +33,7 @@ public final class Rig3DSystem: System {
3333
public override func update(context: ECSContext, input: HID, withTimePassed deltaTime: Float) async {
3434
func shouldAccumulate(entity: Entity) -> Bool {
3535
guard
36-
let cameraTransform = game.cameraEntity?.component(ofType: Transform3Component.self)
36+
let cameraTransform = context.cameraEntity?.component(ofType: Transform3Component.self)
3737
else {
3838
return false
3939
}
@@ -81,11 +81,11 @@ public final class Rig3DSystem: System {
8181
}
8282
}
8383

84-
let slowEntity = getFarAway(from: game.entities)
84+
let slowEntity = getFarAway(from: context.entities)
8585
if let entity = slowEntity {
8686
updateAnimation(for: entity)
8787
}
88-
for entity in game.entities {
88+
for entity in context.entities {
8989
guard entity != slowEntity else { continue }
9090
if let component = entity.component(ofType: Rig3DComponent.self),
9191
component.disabled == false
@@ -98,7 +98,7 @@ public final class Rig3DSystem: System {
9898
}
9999
}
100100

101-
for entity in game.entities {
101+
for entity in context.entities {
102102
if let rigAttachmentComponent = entity.component(ofType: RigAttachmentComponent.self) {
103103
updateRigAttachmentTransform(
104104
game,
@@ -127,12 +127,12 @@ public final class Rig3DSystem: System {
127127
rigAttachmentComponent: RigAttachmentComponent
128128
) {
129129
guard
130-
let parent = game.entities.first(where: {
130+
let parent = context.entities.first(where: {
131131
$0.id == rigAttachmentComponent.parentEntityID
132132
})
133133
else {
134134
//If the parent is gone trash the attachment
135-
game.removeEntity(entity)
135+
context.removeEntity(entity)
136136
return
137137
}
138138
guard let parentTransform = parent.component(ofType: Transform3Component.self) else {

0 commit comments

Comments
 (0)