// // Family1.swift // // // Created by Christian Treffs on 21.08.19. // public typealias Family1 = Family> public struct Requires1: FamilyRequirementsManaging where A: Component { public let componentTypes: [Component.Type] public init(_ components: A.Type) { componentTypes = [A.self] } public static func components(nexus: Nexus, entityId: EntityIdentifier) -> A { let compA: A = nexus.get(unsafeComponentFor: entityId) return (compA) } public static func entityAndComponents(nexus: Nexus, entityId: EntityIdentifier) -> (Entity, A) { let entity: Entity = nexus.get(unsafeEntity: entityId) let compA: A = nexus.get(unsafeComponentFor: entityId) return (entity, compA) } public static func relativesDescending(nexus: Nexus, parentId: EntityIdentifier, childId: EntityIdentifier) -> (parent: A, child: A) { let parentCompA: A = nexus.get(unsafeComponentFor: parentId) let childCompA: A = nexus.get(unsafeComponentFor: childId) return (parent: parentCompA, child: childCompA) } } extension Nexus { public func family( requires componentA: A.Type, excludesAll excludedComponents: Component.Type... ) -> Family1 where A: Component { Family1(nexus: self, requiresAll: componentA, excludesAll: excludedComponents) } }