commit
d8ce40b9c3
|
|
@ -35,7 +35,7 @@ import PackageDescription
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "YourPackageName",
|
name: "YourPackageName",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.16.0")
|
.package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.17.0")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ extension Entity {
|
||||||
public subscript<C: Component, Value>(_ componentKeyPath: WritableKeyPath<C, Value>) -> Value? {
|
public subscript<C: Component, Value>(_ componentKeyPath: WritableKeyPath<C, Value>) -> Value? {
|
||||||
nonmutating set {
|
nonmutating set {
|
||||||
guard var comp = self.get(component: C.self),
|
guard var comp = self.get(component: C.self),
|
||||||
let value = newValue else {
|
let value = newValue else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
comp[keyPath: componentKeyPath] = value
|
comp[keyPath: componentKeyPath] = value
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = entity
|
_ = entity
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -86,7 +86,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
.forEach { (position: Position) in
|
.forEach { (position: Position) in
|
||||||
_ = position
|
_ = position
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, numEntities * 10)
|
XCTAssertEqual(loopCount, numEntities * 10)
|
||||||
|
|
@ -110,7 +110,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = position
|
_ = position
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -136,7 +136,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = position
|
_ = position
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -161,7 +161,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = velocity
|
_ = velocity
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -187,7 +187,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = velocity
|
_ = velocity
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -212,7 +212,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = name
|
_ = name
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -239,7 +239,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = name
|
_ = name
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -265,7 +265,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = color
|
_ = color
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -293,7 +293,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = color
|
_ = color
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
@ -348,7 +348,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
||||||
_ = empty
|
_ = empty
|
||||||
|
|
||||||
loopCount += 1
|
loopCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(loopCount, family.count * 10)
|
XCTAssertEqual(loopCount, family.count * 10)
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class ColorSystem {
|
||||||
color.r = 1
|
color.r = 1
|
||||||
color.g = 2
|
color.g = 2
|
||||||
color.b = 3
|
color.b = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,6 +148,6 @@ class PositionSystem {
|
||||||
|
|
||||||
pos.x = x
|
pos.x = x
|
||||||
pos.y = y
|
pos.y = y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class FamilyTests: XCTestCase {
|
||||||
.forEach { (entity: Entity, _: Position) in
|
.forEach { (entity: Entity, _: Position) in
|
||||||
entity.assign(Velocity(a: 3.14))
|
entity.assign(Velocity(a: 3.14))
|
||||||
entity.remove(Position.self)
|
entity.remove(Position.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(familyA.count, 0)
|
XCTAssertEqual(familyA.count, 0)
|
||||||
XCTAssertEqual(familyB.count, 10)
|
XCTAssertEqual(familyB.count, 10)
|
||||||
|
|
@ -131,7 +131,7 @@ class FamilyTests: XCTestCase {
|
||||||
.forEach { (entity: Entity, velocity: Velocity) in
|
.forEach { (entity: Entity, velocity: Velocity) in
|
||||||
entity.assign(Position(x: 1, y: 2))
|
entity.assign(Position(x: 1, y: 2))
|
||||||
entity.remove(velocity)
|
entity.remove(velocity)
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(familyA.count, 10)
|
XCTAssertEqual(familyA.count, 10)
|
||||||
XCTAssertEqual(familyB.count, 0)
|
XCTAssertEqual(familyB.count, 0)
|
||||||
|
|
@ -176,7 +176,7 @@ class FamilyTests: XCTestCase {
|
||||||
.prefix(currentCount)
|
.prefix(currentCount)
|
||||||
.forEach { (entity: Entity) in
|
.forEach { (entity: Entity) in
|
||||||
entity.destroy()
|
entity.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(family.memberIds.count, (count / 2))
|
XCTAssertEqual(family.memberIds.count, (count / 2))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,6 @@ class SystemsTests: XCTestCase {
|
||||||
.prefix(count)
|
.prefix(count)
|
||||||
.forEach { (entity: Entity) in
|
.forEach { (entity: Entity) in
|
||||||
entity.destroy()
|
entity.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue