Пример #1
0
        internal static object CloneAndPatchManagedComponent(object obj, EntityRemapUtility.EntityRemapInfo *remapping)
        {
            var clone = CloneManagedComponent(obj);

            EntityRemapUtility.PatchEntityInBoxedType(clone, remapping);
            return(clone);
        }
Пример #2
0
        /// <summary>
        /// Remaps all entity references within the given object using the specified <see cref="EntityRemapUtility.EntityRemapInfo"/>.
        /// </summary>
        /// <param name="obj">The object to remap references for.</param>
        /// <param name="remapSrc">Array of entities that should be remapped.</param>
        /// <param name="remapDst">Array of entities that each entry in the remapSrc array should be remapped to.</param>
        /// <param name="remapInfoCount">Length of the entity arrays.</param>
        /// <exception cref="ArgumentNullException">The given object was null.</exception>
        /// <exception cref="MissingPropertyBagException">The given object has no property bag associated with it.</exception>
        public void RemapEntityReferencesForPrefab(ref object obj, Entity *remapSrc, Entity *remapDst, int remapInfoCount)
        {
            m_Info        = null;
            m_PrefabSrc   = remapSrc;
            m_PrefabDst   = remapDst;
            m_PrefabCount = remapInfoCount;

            m_References?.Clear();
            GetPropertyBag(obj).Accept(this, ref obj);
        }
Пример #3
0
        /// <summary>
        /// Remaps all entity references within the given object using the specified <see cref="EntityRemapUtility.EntityRemapInfo"/>.
        /// </summary>
        /// <param name="obj">The object to remap references for.</param>
        /// <param name="entityRemapInfo">The entity remap information.</param>
        /// <exception cref="ArgumentNullException">The given object was null.</exception>
        /// <exception cref="MissingPropertyBagException">The given object has no property bag associated with it.</exception>
        public void RemapEntityReferences(ref object obj, EntityRemapUtility.EntityRemapInfo *entityRemapInfo)
        {
            m_Info        = entityRemapInfo;
            m_PrefabSrc   = null;
            m_PrefabDst   = null;
            m_PrefabCount = 0;

            m_References?.Clear();
            GetPropertyBag(obj).Accept(this, ref obj);
        }
Пример #4
0
        public void PatchEntities(ManagedComponentStore managedComponentStore, Archetype *archetype, Chunk *chunk, int entityCount,
                                  EntityRemapUtility.EntityRemapInfo *remapping)
        {
#if !NET_DOTS
            var managedPatches    = archetype->ManagedEntityPatches;
            var managedPatchCount = archetype->ManagedEntityPatchCount;

            // Patch managed components with entity references.
            for (int p = 0; p < managedPatchCount; p++)
            {
                var componentType = managedPatches[p].Type;

                for (int i = 0; i != entityCount; i++)
                {
                    var obj = managedComponentStore.GetManagedObject(chunk, componentType, i);
                    EntityRemapUtility.PatchEntityInBoxedType(obj, remapping);
                }
            }
#endif
        }
Пример #5
0
        public void PatchEntities(Archetype *archetype, Chunk *chunk, int entityCount,
                                  EntityRemapUtility.EntityRemapInfo *remapping)
        {
#if !NET_DOTS
            var firstManagedComponent = archetype->FirstManagedComponent;
            var numManagedComponents  = archetype->NumManagedComponents;
            for (int i = 0; i < numManagedComponents; ++i)
            {
                int type = i + firstManagedComponent;
                var a    = (int *)ChunkDataUtility.GetComponentDataRO(chunk, 0, type);
                for (int ei = 0; ei < entityCount; ++ei)
                {
                    if (a[ei] != 0)
                    {
                        var obj = m_ManagedComponentData[a[ei]];
                        EntityRemapUtility.PatchEntityInBoxedType(obj, remapping);
                    }
                }
            }
#endif
        }
 unsafe public EntityRemappingAdapter(EntityRemapUtility.EntityRemapInfo *remapInfo)
 {
     RemapInfo = remapInfo;
 }
 public EntityRemappingVisitor(EntityRemapUtility.EntityRemapInfo *remapInfo)
 {
     _EntityRemapAdapter = new EntityRemappingAdapter(remapInfo);
     AddAdapter(_EntityRemapAdapter);
 }
 public void RemapEntityReferences(object obj, EntityRemapUtility.EntityRemapInfo* entityRemapInfo)
 {
     // Not supported in DOTS Runtime.
 }