From 788c6f75eacc57e485ce2706a111333ace5f2882 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Tue, 20 Oct 2020 14:39:15 +0200 Subject: [PATCH] Add entity creation convenience to Entity --- Sources/FirebladeECS/Entity.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/FirebladeECS/Entity.swift b/Sources/FirebladeECS/Entity.swift index d1c8395..729bdee 100644 --- a/Sources/FirebladeECS/Entity.swift +++ b/Sources/FirebladeECS/Entity.swift @@ -27,6 +27,21 @@ public struct Entity { nexus.count(components: identifier) } + @discardableResult + public func createEntity() -> Entity { + nexus.createEntity() + } + + @discardableResult + public func createEntity(with components: Component...) -> Entity { + createEntity(with: components) + } + + @discardableResult + public func createEntity(with components: C) -> Entity where C: Collection, C.Element == Component { + nexus.createEntity(with: components) + } + /// Checks if a component with given type is assigned to this entity. /// - Parameter type: the component type. public func has(_ type: C.Type) -> Bool where C: Component {