public virtual void ChangeOwner(CEntity newOwner) { Debug.Assert(m_owner != null); m_owner.UnregisterComponent(this); newOwner.RegisterComponent(this); m_owner = newOwner; }
public override void ChangeOwner(CEntity newOwner) { base.ChangeOwner(newOwner); foreach (CSceneComponent child in m_children) { child.ChangeOwner(newOwner); } }
public bool AttachToComponent(CSceneComponent parentComponent, bool bTransferOwnership = false) { if (parentComponent == this) { LogUtility.Log("[Components] Tried to attach to self, aborting"); return(false); } if (parentComponent == null) { Detach(); return(false); } if (parentComponent == m_parentComponent) { LogUtility.Log("[Components] Tried attaching component to the same parent again, aborting"); return(false); } if (parentComponent.IsChildOf(this)) { LogUtility.Log("[Components] Tried to attach to a component which is already a child, this would create a loop, aborting"); return(false); } Detach(); CSceneComponent oldParent = m_parentComponent; m_parentComponent = parentComponent; m_transform.Parent = m_parentComponent.m_transform; m_parentComponent.m_children.Add(this); // todo henning handle different transform modes (Keep WorldTransform, Snap To etc.) if (m_parentComponent.Owner != Owner) { if (bTransferOwnership) { ChangeOwner(m_parentComponent.Owner); } else { CEntity currentParent = Owner.Parent; if (currentParent != null) { currentParent.UnregisterChildEntity(Owner); } parentComponent.Owner.RegisterChildEntity(Owner); World.TriggerHierarchyChanged(this, oldParent, parentComponent); } } return(true); }
internal void RegisterComponent(CEntity owner) { m_owner = owner; m_owner.RegisterComponent(this); Name = GetComponentName(this); Id = m_owner.ComponentCounter; if (ComponentGuid == Guid.Empty) { ComponentGuid = Guid.NewGuid(); } }
public SEntityId(CEntity entity, bool bOverrideEntity = false) { if (bOverrideEntity) { OverrideEntity = entity; EntityId = 0; } else { EntityId = entity.Id; OverrideEntity = null; } }
public virtual void Shutdown() { foreach (CEntityComponent component in m_components) { component.Shutdown(); } m_bIsAlive = false; IsPhysicsEnabled = false; CEntity parent = Parent; if (parent != null) { parent.UnregisterChildEntity(this); } Input.UnregisterListener(OnInputEvent); m_updateScope?.Disconnect(); }