Skip to content

Commit ecef10f

Browse files
committed
Sort relative to zero
1 parent e98a24f commit ecef10f

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

Sources/GateEngine/ECS/Base/ECSContext.swift

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@
131131
let rhs = type(of: rhs)
132132
let lhsSO = lhs.sortOrder()?.rawValue
133133
let rhsSO = rhs.sortOrder()?.rawValue
134-
if lhsSO != nil || rhsSO != nil {
135-
if let lhsSO = lhsSO, let rhsSO = rhsSO {
136-
return lhsSO < rhsSO
137-
}
138-
if lhsSO != nil {
139-
return true
140-
}
141-
if rhsSO != nil {
142-
return true
143-
}
134+
135+
if let lhsSO = lhsSO, let rhsSO = rhsSO {
136+
return lhsSO < rhsSO
137+
}
138+
if let lhsSO {
139+
return lhsSO <= 0
144140
}
141+
if let rhsSO {
142+
return rhsSO > 0
143+
}
144+
145145
return false
146146
})
147147
}
@@ -165,12 +165,17 @@
165165
_systems.sort(by: { (lhs, rhs) -> Bool in
166166
let lhsSO = type(of: lhs).sortOrder()?.rawValue
167167
let rhsSO = type(of: rhs).sortOrder()?.rawValue
168+
168169
if let lhsSO = lhsSO, let rhsSO = rhsSO {
169170
return lhsSO < rhsSO
170171
}
171-
if lhsSO == nil && rhsSO != nil {
172-
return true
172+
if let lhsSO {
173+
return lhsSO <= 0
174+
}
175+
if let rhsSO {
176+
return rhsSO > 0
173177
}
178+
174179
return false
175180
})
176181
}
@@ -189,12 +194,17 @@
189194
_renderingSystems.sort(by: { (lhs, rhs) -> Bool in
190195
let lhsSO = type(of: lhs).sortOrder()?.rawValue
191196
let rhsSO = type(of: rhs).sortOrder()?.rawValue
197+
192198
if let lhsSO = lhsSO, let rhsSO = rhsSO {
193199
return lhsSO < rhsSO
194200
}
195-
if lhsSO == nil && rhsSO != nil {
196-
return true
201+
if let lhsSO {
202+
return lhsSO <= 0
203+
}
204+
if let rhsSO {
205+
return rhsSO > 0
197206
}
207+
198208
return false
199209
})
200210
}

0 commit comments

Comments
 (0)