void CopyComponent(ref TComponent result, ref TComponent value)
        {
            var visitor = new CopyVisitor <TComponent>(ref value);

            PropertyContainer.Visit(ref value, visitor);
            result = visitor.Result;
        }
        TComponent CopyComponent(TComponent value)
        {
            var visitor = new CopyVisitor <TComponent>(ref value);

            PropertyContainer.Visit(ref value, visitor);
            return(visitor.Result);
        }
        protected override ISceneGraphNode CreateNode(ISceneGraphNode source, ISceneGraphNode parent)
        {
            if (source is EntityNode sourceNode)
            {
                var targetEntity = m_EntityManager.CreateEntity(m_EntityManager.GetChunk(sourceNode.Entity).Archetype);
                var sourceEntity = sourceNode.Entity;
                var visitor      = new CopyVisitor(m_EntityManager, sourceEntity, targetEntity);
                PropertyContainer.Visit(new EntityContainer(m_EntityManager, sourceEntity), visitor);
                m_WorldManager.SetEntityGuid(targetEntity, Guid.NewGuid());
                var entityNode = new EntityNode(this, m_Session, targetEntity);

                var newEntityName = EntityNameHelper.GetUniqueEntityName(m_WorldManager.GetEntityName(targetEntity), m_WorldManager, parent?.Children ?? Roots);
                m_WorldManager.SetEntityName(targetEntity, newEntityName);

                Add(entityNode, parent);
                return(entityNode);
            }

            return(null);
        }
Exemple #4
0
 public static PooledObject <CopyVisitor> Get(out CopyVisitor visitor) => s_Pool.Get(out visitor);