Deprecate relatives API
This commit is contained in:
parent
d0db124960
commit
0d79dc1d13
|
|
@ -203,7 +203,7 @@ class GameLogicSystem {
|
|||
|
||||
```
|
||||
|
||||
### 👫 Relatives
|
||||
### 👫 Relatives (deprecated)
|
||||
|
||||
This ECS implementation provides an integrated way of creating a [directed acyclic graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph) hierarchy of entities by forming parent-child relationships. Entities can become children of a parent entity. In family terms they become **relatives**. Families provide iteration over these relationships.
|
||||
The entity hierarchy implementation does not use an additional component therefore keeping the hierarchy intact over different component-families.
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ public struct Entity {
|
|||
/// Add an entity as child.
|
||||
/// - Parameter entity: The child entity.
|
||||
@discardableResult
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public func addChild(_ entity: Entity) -> Bool {
|
||||
nexus.addChild(entity, to: self)
|
||||
}
|
||||
|
|
@ -112,16 +113,19 @@ public struct Entity {
|
|||
/// Remove entity as child.
|
||||
/// - Parameter entity: The child entity.
|
||||
@discardableResult
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public func removeChild(_ entity: Entity) -> Bool {
|
||||
nexus.removeChild(entity, from: self)
|
||||
}
|
||||
|
||||
/// Removes all children from this entity.
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public func removeAllChildren() {
|
||||
nexus.removeAllChildren(from: self)
|
||||
}
|
||||
|
||||
/// Returns the number of children for this entity.
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public var numChildren: Int {
|
||||
nexus.numChildren(for: self)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
extension Nexus {
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public final func addChild(_ child: Entity, to parent: Entity) -> Bool {
|
||||
let inserted: Bool
|
||||
if childrenByParentEntity[parent.identifier] == nil {
|
||||
|
|
@ -21,10 +22,12 @@ extension Nexus {
|
|||
return inserted
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public final func removeChild(_ child: Entity, from parent: Entity) -> Bool {
|
||||
removeChild(child.identifier, from: parent.identifier)
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
@discardableResult
|
||||
public final func removeChild(_ child: EntityIdentifier, from parent: EntityIdentifier) -> Bool {
|
||||
let removed: Bool = childrenByParentEntity[parent]?.remove(child) != nil
|
||||
|
|
@ -34,15 +37,18 @@ extension Nexus {
|
|||
return removed
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public final func removeAllChildren(from parent: Entity) {
|
||||
self.removeAllChildren(from: parent.identifier)
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public final func removeAllChildren(from parentId: EntityIdentifier) {
|
||||
childrenByParentEntity[parentId]?.forEach { removeChild($0, from: parentId) }
|
||||
return childrenByParentEntity[parentId] = nil
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
public final func numChildren(for entity: Entity) -> Int {
|
||||
childrenByParentEntity[entity.identifier]?.count ?? 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
import XCTest
|
||||
import FirebladeECS
|
||||
|
||||
@available(*, deprecated, message: "This will be removed in the next minor update.")
|
||||
class SceneGraphTests: XCTestCase {
|
||||
|
||||
var nexus: Nexus!
|
||||
|
|
|
|||
Loading…
Reference in New Issue