Fix ComponentAdded event emission for multi-component assigns (gh issue #36)
This commit is contained in:
parent
f8915f1080
commit
e3d416a3e2
|
|
@ -24,7 +24,6 @@ extension Nexus {
|
|||
@discardableResult
|
||||
public final func assign(component: Component, to entity: Entity) -> Bool {
|
||||
let entityId: EntityIdentifier = entity.identifier
|
||||
defer { delegate?.nexusEvent(ComponentAdded(component: component.identifier, toEntity: entity.identifier)) }
|
||||
return assign(component: component, entityId: entityId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@ extension Nexus {
|
|||
|
||||
@usableFromInline
|
||||
func assign(_ componentId: ComponentIdentifier, _ entityId: EntityIdentifier) {
|
||||
componentIdsByEntity[entityId]!.insert(componentId)
|
||||
let (inserted, _) = componentIdsByEntity[entityId]!.insert(componentId)
|
||||
if inserted {
|
||||
delegate?.nexusEvent(ComponentAdded(component: componentId, toEntity: entityId))
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
|
|
|
|||
Loading…
Reference in New Issue