Swiftlint
This commit is contained in:
parent
51a08a0c51
commit
1ed0e24585
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Component+Access.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 25.06.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ public protocol Component: class {
|
|||
}
|
||||
|
||||
public extension Component {
|
||||
static var identifier: ComponentIdentifier { return ComponentIdentifier(Self.self) }
|
||||
static var identifier: ComponentIdentifier { return ComponentIdentifier(Self.self) }
|
||||
@inlinable var identifier: ComponentIdentifier { return Self.identifier }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// ComponentIdentifier.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 20.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -7,28 +7,28 @@
|
|||
|
||||
public extension Entity {
|
||||
@inlinable
|
||||
func get<C>() -> C? where C: Component {
|
||||
return nexus.get(for: identifier)
|
||||
}
|
||||
func get<C>() -> C? where C: Component {
|
||||
return nexus.get(for: identifier)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
func get<A>(component compType: A.Type = A.self) -> A? where A: Component {
|
||||
return nexus.get(for: identifier)
|
||||
}
|
||||
func get<A>(component compType: A.Type = A.self) -> A? where A: Component {
|
||||
return nexus.get(for: identifier)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
func get<A, B>(components _: A.Type, _: B.Type) -> (A?, B?) where A: Component, B: Component {
|
||||
let compA: A? = get(component: A.self)
|
||||
let compB: B? = get(component: B.self)
|
||||
return (compA, compB)
|
||||
}
|
||||
func get<A, B>(components _: A.Type, _: B.Type) -> (A?, B?) where A: Component, B: Component {
|
||||
let compA: A? = get(component: A.self)
|
||||
let compB: B? = get(component: B.self)
|
||||
return (compA, compB)
|
||||
}
|
||||
|
||||
// swiftlint:disable large_tuple
|
||||
@inlinable
|
||||
@inlinable
|
||||
func get<A, B, C>(components _: A.Type, _: B.Type, _: C.Type) -> (A?, B?, C?) where A: Component, B: Component, C: Component {
|
||||
let compA: A? = get(component: A.self)
|
||||
let compB: B? = get(component: B.self)
|
||||
let compC: C? = get(component: C.self)
|
||||
return (compA, compB, compC)
|
||||
}
|
||||
let compA: A? = get(component: A.self)
|
||||
let compB: B? = get(component: B.self)
|
||||
let compC: C? = get(component: C.self)
|
||||
return (compA, compB, compC)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,6 @@ public struct Entity {
|
|||
extension Entity: Equatable {
|
||||
public static func == (lhs: Entity, rhs: Entity) -> Bool {
|
||||
return lhs.nexus == rhs.nexus &&
|
||||
lhs.identifier == rhs.identifier
|
||||
lhs.identifier == rhs.identifier
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
@ -127,6 +127,6 @@ extension Family.EntityComponentIterator: LazySequenceProtocol { }
|
|||
extension Family: Equatable {
|
||||
public static func == (lhs: Family<R>, rhs: Family<R>) -> Bool {
|
||||
return lhs.nexus == rhs.nexus &&
|
||||
lhs.traits == rhs.traits
|
||||
lhs.traits == rhs.traits
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family1.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
@ -32,7 +32,7 @@ extension Nexus {
|
|||
excludesAll excludedComponents: Component.Type...
|
||||
) -> Family1<A> where A: Component {
|
||||
return Family1<A>(nexus: self,
|
||||
requiresAll: componentA,
|
||||
excludesAll: excludedComponents)
|
||||
requiresAll: componentA,
|
||||
excludesAll: excludedComponents)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family2.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family3.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family4.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
@ -38,7 +38,7 @@ extension Nexus {
|
|||
_ componentC: C.Type,
|
||||
_ componentD: D.Type,
|
||||
excludesAll excludedComponents: Component.Type...
|
||||
) -> Family4<A, B, C, D> where A: Component, B: Component, C: Component, D: Component {
|
||||
) -> Family4<A, B, C, D> where A: Component, B: Component, C: Component, D: Component {
|
||||
return Family4(
|
||||
nexus: self,
|
||||
requiresAll: (componentA, componentB, componentC, componentD),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Family5.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// FamilyRequirementsManaging.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 21.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -10,27 +10,27 @@ public extension Nexus {
|
|||
return familyMembersByTraits.keys.count
|
||||
}
|
||||
|
||||
func canBecomeMember(_ entity: Entity, in traits: FamilyTraitSet) -> Bool {
|
||||
guard let componentIds = componentIdsByEntity[entity.identifier] else {
|
||||
assertionFailure("no component set defined for entity: \(entity)")
|
||||
return false
|
||||
}
|
||||
return traits.isMatch(components: componentIds)
|
||||
}
|
||||
func canBecomeMember(_ entity: Entity, in traits: FamilyTraitSet) -> Bool {
|
||||
guard let componentIds = componentIdsByEntity[entity.identifier] else {
|
||||
assertionFailure("no component set defined for entity: \(entity)")
|
||||
return false
|
||||
}
|
||||
return traits.isMatch(components: componentIds)
|
||||
}
|
||||
|
||||
func members(withFamilyTraits traits: FamilyTraitSet) -> UnorderedSparseSet<EntityIdentifier> {
|
||||
return familyMembersByTraits[traits] ?? UnorderedSparseSet<EntityIdentifier>()
|
||||
}
|
||||
func members(withFamilyTraits traits: FamilyTraitSet) -> UnorderedSparseSet<EntityIdentifier> {
|
||||
return familyMembersByTraits[traits] ?? UnorderedSparseSet<EntityIdentifier>()
|
||||
}
|
||||
|
||||
func isMember(_ entity: Entity, in family: FamilyTraitSet) -> Bool {
|
||||
return isMember(entity.identifier, in: family)
|
||||
}
|
||||
func isMember(_ entity: Entity, in family: FamilyTraitSet) -> Bool {
|
||||
return isMember(entity.identifier, in: family)
|
||||
}
|
||||
|
||||
func isMember(_ entityId: EntityIdentifier, in family: FamilyTraitSet) -> Bool {
|
||||
return isMember(entity: entityId, inFamilyWithTraits: family)
|
||||
}
|
||||
|
||||
func isMember(entity entityId: EntityIdentifier, inFamilyWithTraits traits: FamilyTraitSet) -> Bool {
|
||||
return members(withFamilyTraits: traits).contains(entityId.index)
|
||||
}
|
||||
func isMember(entity entityId: EntityIdentifier, inFamilyWithTraits traits: FamilyTraitSet) -> Bool {
|
||||
return members(withFamilyTraits: traits).contains(entityId.index)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// NexusEventDelegate.swift
|
||||
//
|
||||
//
|
||||
//
|
||||
// Created by Christian Treffs on 20.08.19.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -8,41 +8,41 @@
|
|||
public protocol NexusEvent {}
|
||||
|
||||
public struct EntityCreated: NexusEvent {
|
||||
public let entityId: EntityIdentifier
|
||||
public let entityId: EntityIdentifier
|
||||
}
|
||||
|
||||
public struct EntityDestroyed: NexusEvent {
|
||||
public let entityId: EntityIdentifier
|
||||
public let entityId: EntityIdentifier
|
||||
}
|
||||
|
||||
public struct ComponentAdded: NexusEvent {
|
||||
public let component: ComponentIdentifier
|
||||
public let toEntity: EntityIdentifier
|
||||
public let component: ComponentIdentifier
|
||||
public let toEntity: EntityIdentifier
|
||||
}
|
||||
|
||||
public struct ComponentUpdated: NexusEvent {
|
||||
public let atEnity: EntityIdentifier
|
||||
public let atEnity: EntityIdentifier
|
||||
}
|
||||
|
||||
public struct ComponentRemoved: NexusEvent {
|
||||
public let component: ComponentIdentifier
|
||||
public let from: EntityIdentifier
|
||||
public let component: ComponentIdentifier
|
||||
public let from: EntityIdentifier
|
||||
}
|
||||
|
||||
public struct FamilyMemberAdded: NexusEvent {
|
||||
public let member: EntityIdentifier
|
||||
public let toFamily: FamilyTraitSet
|
||||
public let member: EntityIdentifier
|
||||
public let toFamily: FamilyTraitSet
|
||||
}
|
||||
|
||||
public struct FamilyMemberRemoved: NexusEvent {
|
||||
public let member: EntityIdentifier
|
||||
public let from: FamilyTraitSet
|
||||
public let member: EntityIdentifier
|
||||
public let from: FamilyTraitSet
|
||||
}
|
||||
|
||||
public struct FamilyCreated: NexusEvent {
|
||||
public let family: FamilyTraitSet
|
||||
public let family: FamilyTraitSet
|
||||
}
|
||||
|
||||
public struct FamilyDestroyed: NexusEvent {
|
||||
public let family: FamilyTraitSet
|
||||
public let family: FamilyTraitSet
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue