108108}
109109
110110@MainActor public final class ECSContext {
111+ /**
112+ An immutable copy of the View this ECSContext will be drawn into.
113+ Use this copy for size and color information from witin your simulation
114+ */
115+ public internal( set) var gameView : GameViewSnapshot = . empty
116+
111117 private var previousFrameWasDropped : Bool = false
112118 private var platformSystemsNeedSorting = true
113119 private var _platformSystems : [ PlatformSystem ] = [ ]
@@ -378,8 +384,7 @@ extension ECSContext {
378384}
379385
380386//MARK: System Management
381- extension ECSContext {
382- @usableFromInline
387+ public extension ECSContext {
383388 func system( ofType systemType: System . Type ) -> System {
384389 for system in _systems {
385390 if type ( of: system) == systemType {
@@ -388,7 +393,6 @@ extension ECSContext {
388393 }
389394 return insertSystem ( systemType)
390395 }
391- @usableFromInline
392396 func hasSystem( ofType systemType: System . Type ) -> Bool {
393397 for system in _systems {
394398 if type ( of: system) == systemType {
@@ -397,7 +401,6 @@ extension ECSContext {
397401 }
398402 return false
399403 }
400- @usableFromInline
401404 func system( ofType systemType: RenderingSystem . Type ) -> RenderingSystem {
402405 for system in _renderingSystems {
403406 if type ( of: system) == systemType {
@@ -406,15 +409,14 @@ extension ECSContext {
406409 }
407410 return insertSystem ( systemType)
408411 }
409- func system( ofType systemType: PlatformSystem . Type ) -> PlatformSystem {
412+ internal func system( ofType systemType: PlatformSystem . Type ) -> PlatformSystem {
410413 for system in _platformSystems {
411414 if type ( of: system) == systemType {
412415 return system
413416 }
414417 }
415418 return insertSystem ( systemType)
416419 }
417- @usableFromInline
418420 func insertSystem( _ newSystem: System ) {
419421 let systemType = type ( of: newSystem)
420422 guard _systems. contains ( where: { type ( of: $0) == systemType } ) == false else { return }
@@ -423,7 +425,6 @@ extension ECSContext {
423425 _systems = systems
424426 systemsNeedSorting = true
425427 }
426- @usableFromInline
427428 func insertSystem( _ newSystem: RenderingSystem ) {
428429 let systemType = type ( of: newSystem)
429430 guard _renderingSystems. contains ( where: { type ( of: $0) == systemType } ) == false else {
@@ -434,7 +435,7 @@ extension ECSContext {
434435 _renderingSystems = renderingSystems
435436 renderingSystemsNeedSorting = true
436437 }
437- func insertSystem( _ newSystem: PlatformSystem ) {
438+ internal func insertSystem( _ newSystem: PlatformSystem ) {
438439 let systemType = type ( of: newSystem)
439440 guard _platformSystems. contains ( where: { type ( of: $0) == systemType } ) == false else {
440441 return
@@ -444,42 +445,40 @@ extension ECSContext {
444445 _platformSystems = platformSystems
445446 platformSystemsNeedSorting = true
446447 }
447- @usableFromInline @ discardableResult
448+ @discardableResult
448449 func insertSystem( _ system: System . Type ) -> System {
449450 let system = system. init ( )
450451 self . insertSystem ( system)
451452 return system
452453 }
453- @usableFromInline @ discardableResult
454+ @discardableResult
454455 func insertSystem( _ system: RenderingSystem . Type ) -> RenderingSystem {
455456 let system = system. init ( )
456457 self . insertSystem ( system)
457458 return system
458459 }
459460 @inline ( __always) @discardableResult
460- func insertSystem( _ system: PlatformSystem . Type ) -> PlatformSystem {
461+ internal func insertSystem( _ system: PlatformSystem . Type ) -> PlatformSystem {
461462 let system = system. init ( )
462463 self . insertSystem ( system)
463464 return system
464465 }
465- @usableFromInline
466466 func removeSystem( _ system: System ) {
467467 if let index = self . _systems. firstIndex ( where: { $0 === system } ) {
468468 self . _systems. remove ( at: index) . teardown ( context: self )
469469 }
470470 }
471- @usableFromInline
472471 func removeSystem( _ system: RenderingSystem ) {
473472 if let index = self . _renderingSystems. firstIndex ( where: { $0 === system } ) {
474473 self . _renderingSystems. remove ( at: index) . teardown ( context: self )
475474 }
476475 }
477- func removeSystem( _ system: PlatformSystem ) {
476+ internal func removeSystem( _ system: PlatformSystem ) {
478477 if let index = self . _platformSystems. firstIndex ( where: { $0 === system } ) {
479478 self . _platformSystems. remove ( at: index) . teardown ( context: self )
480479 }
481480 }
482- @usableFromInline @ discardableResult
481+ @discardableResult
483482 func removeSystem< T: System > ( _ system: T . Type ) -> System ? {
484483 if let index = self . _systems. firstIndex ( where: { type ( of: $0) == system } ) {
485484 let system = self . _systems. remove ( at: index)
@@ -488,7 +487,7 @@ extension ECSContext {
488487 }
489488 return nil
490489 }
491- @usableFromInline @ discardableResult
490+ @discardableResult
492491 func removeSystem< T: RenderingSystem > ( _ system: T . Type ) -> RenderingSystem ? {
493492 if let index = self . _renderingSystems. firstIndex ( where: { type ( of: $0) == system } ) {
494493 let system = self . _renderingSystems. remove ( at: index)
@@ -498,7 +497,7 @@ extension ECSContext {
498497 return nil
499498 }
500499 @discardableResult
501- func removeSystem< T: PlatformSystem > ( _ system: T . Type ) -> PlatformSystem ? {
500+ internal func removeSystem< T: PlatformSystem > ( _ system: T . Type ) -> PlatformSystem ? {
502501 if let index = self . _platformSystems. firstIndex ( where: { type ( of: $0) == system } ) {
503502 let system = self . _platformSystems. remove ( at: index)
504503 system. teardown ( context: self )
0 commit comments