Example #1
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypePlayerState)
            {
                ++matches;
            }
            if (components[i] == componentTypePlayerCharacterControlState)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
Example #2
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeBulletTagComponentData)
            {
                ++matches;
            }
            if (components[i] == componentTypePlayerIdComponentData)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
            if (components[i] == componentTypeVelocity)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
Example #3
0
        private static ArchetypeOffsetsFromChunk GetChunkOffsets(EntityManager em, EntityArchetype archetype, ComponentType metaType, ComponentType componentType, ComponentType bufferType = default, ComponentType linkType = default)
        {
            ArchetypeOffsetsFromChunk schema = default;

            var   tmpEntity = em.CreateEntity(archetype);
            var   chunk     = em.GetChunk(tmpEntity);
            byte *chunkPtr  = *(byte **)&chunk;
            var   tmp       = em.GetArchetypeChunkComponentType <ChunkHeader>(false);
            var   types     = archetype.GetComponentTypes();

            UnsafeUtility.CopyStructureToPtr(ref metaType.TypeIndex, UnsafeUtility.AddressOf(ref tmp));
            schema.MetaOffset = (byte *)chunk.GetNativeArray(tmp).GetUnsafeReadOnlyPtr() - chunkPtr;

            UnsafeUtility.CopyStructureToPtr(ref componentType.TypeIndex, UnsafeUtility.AddressOf(ref tmp));
            schema.ComponentOffset = (byte *)chunk.GetNativeArray(tmp).GetUnsafeReadOnlyPtr() - chunkPtr;

            if (bufferType != default)
            {
                UnsafeUtility.CopyStructureToPtr(ref linkType.TypeIndex, UnsafeUtility.AddressOf(ref tmp));
                schema.BufferLinkOffset = (byte *)chunk.GetNativeArray(tmp).GetUnsafeReadOnlyPtr() - chunkPtr;

                UnsafeUtility.CopyStructureToPtr(ref bufferType.TypeIndex, UnsafeUtility.AddressOf(ref tmp));
                schema.BufferOffset = (byte *)chunk.GetNativeArray(tmp).GetUnsafeReadOnlyPtr() - chunkPtr;
            }

            em.DestroyEntity(tmpEntity);
            return(schema);
        }
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeAsteroidTagComponentData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCollisionSphereComponent)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
            if (components[i] == componentTypeVelocity)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeMovableCubeComponent)
            {
                ++matches;
            }
            if (components[i] == componentTypeTestCommandData)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
Example #6
0
    public static void GatherAllVersionNumbers(EntityManager entityManager, Dictionary <ComponentType, uint> summedVersionNumbers)
    {
        summedVersionNumbers.Clear();

        using (NativeArray <ArchetypeChunk> chunks = entityManager.GetAllChunks(Allocator.TempJob)) // needs to be temp job to preven unity error :(
        {
            foreach (ArchetypeChunk chunk in chunks)
            {
                EntityArchetype archetype = chunk.Archetype;

                //StringBuilder s = new StringBuilder("archetype: ");

                using (NativeArray <ComponentType> componentTypes = archetype.GetComponentTypes(Allocator.Temp))
                {
                    foreach (ComponentType componentType in componentTypes)
                    {
                        //s.Append(componentType.GetManagedType());
                        //s.Append(" - ");
                        uint version = chunk.GetComponentVersion(componentType);
                        if (summedVersionNumbers.TryGetValue(componentType, out uint sum))
                        {
                            summedVersionNumbers[componentType] = sum + version;
                        }
                        else
                        {
                            summedVersionNumbers.Add(componentType, version);
                        }
                    }
                }

                //UnityEngine.Debug.Log(s.ToString());
            }
        }
    }
Example #7
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == shipTagType)
            {
                ++matches;
            }
            if (components[i] == positionType)
            {
                ++matches;
            }
            if (components[i] == rotationType)
            {
                ++matches;
            }
            if (components[i] == shipStateType)
            {
                ++matches;
            }
            if (components[i] == playerIdType)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
Example #8
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeQbitDataComponent)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeNonUniformScale)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
        }
        return(matches == 5);
    }
Example #9
0
        public static ComponentTypes ToComponentTypes(this EntityArchetype archetype)
        {
            var components = archetype.GetComponentTypes();
            var result     = new ComponentTypes(components.ToArray());

            components.Dispose();
            return(result);
        }
Example #10
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeAbilityCollectionAbilityEntry)
            {
                ++matches;
            }
            if (components[i] == componentTypeAbilityCollectionState)
            {
                ++matches;
            }
            if (components[i] == componentTypeItemInputState)
            {
                ++matches;
            }
            if (components[i] == componentTypePartOwnerInputState)
            {
                ++matches;
            }
            if (components[i] == componentTypePartOwnerRegistryAsset)
            {
                ++matches;
            }
            if (components[i] == componentTypeRigAttacherAttachBone)
            {
                ++matches;
            }
            if (components[i] == componentTypeRigAttacherState)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
            if (components[i] == componentTypeLinkedEntityGroup)
            {
                ++matches;
            }
        }
        return(matches == 11);
    }
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeGameModeData)
            {
                ++matches;
            }
        }
        return(matches == 1);
    }
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            #region __GHOST_COMPONENT_TYPE_CHECK__
            if (components[i] == componentType__GHOST_COMPONENT_TYPE_NAME__)
            {
                ++matches;
            }
            #endregion
        }
        return(matches == __GHOST_COMPONENT_COUNT__);
    }
Example #13
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeMovableCubeComponent)
            {
                ++matches;
            }
            if (components[i] == componentTypePhysicsCollider)
            {
                ++matches;
            }
            if (components[i] == componentTypePhysicsDamping)
            {
                ++matches;
            }
            if (components[i] == componentTypePhysicsMass)
            {
                ++matches;
            }
            if (components[i] == componentTypePhysicsVelocity)
            {
                ++matches;
            }
            if (components[i] == componentTypeRenderBounds)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
        }
        return(matches == 9);
    }
Example #14
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeRepGrenadeTagComponentData)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
        }
        return(matches == 2);
    }
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeTeleporterClientDataClass)
            {
                ++matches;
            }
            if (components[i] == componentTypeTeleporterPresentationData)
            {
                ++matches;
            }
            if (components[i] == componentTypeTeleporterServer)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
            if (components[i] == componentTypeLinkedEntityGroup)
            {
                ++matches;
            }
        }
        return(matches == 7);
    }
        protected override TreeViewItem BuildRoot()
        {
            foreach (var info in archetypeInfoById.Values)
            {
                info.Dispose();
            }
            archetypeInfoById.Clear();
            var currentNonChunkId = -1;
            var currentChunkIndex = 0;
            var root = new TreeViewItem {
                id = currentNonChunkId--, depth = -1, displayName = "Root"
            };

            if (!chunkArray.IsCreated)
            {
                root.children = new List <TreeViewItem>();
            }
            else
            {
                var          currentArchetype     = new EntityArchetype();
                TreeViewItem currentArchetypeItem = null;
                foreach (var chunk in chunkArray)
                {
                    if (chunk.Archetype != currentArchetype)
                    {
                        currentArchetype = chunk.Archetype;
                        var stats = new ArchetypeInfo()
                        {
                            archetype       = currentArchetype,
                            control         = new EntityQueryGUIControl(currentArchetype.GetComponentTypes(), true),
                            counts          = new int[currentArchetype.ChunkCapacity],
                            firstChunkIndex = currentChunkIndex
                        };
                        archetypeInfoById.Add(currentNonChunkId, stats);
                        currentArchetypeItem = new TreeViewItem()
                        {
                            id = currentNonChunkId--, depth = 0
                        };
                        root.AddChild(currentArchetypeItem);
                    }

                    archetypeInfoById[currentArchetypeItem.id].IncrementCount(chunk.Count);
                    archetypeInfoById[currentArchetypeItem.id].lastChunkIndex = currentChunkIndex;

                    if (Mode == ViewMode.Chunks)
                    {
                        var chunkItem = new TreeViewItem()
                        {
                            id = currentChunkIndex, depth = 1, displayName = chunk.Count.ToString()
                        };
                        currentArchetypeItem.AddChild(chunkItem);
                    }
                    ++currentChunkIndex;
                }
                if (!root.hasChildren)
                {
                    root.children = new List <TreeViewItem>();
                }
            }

            foreach (var info in archetypeInfoById.Values)
            {
                info.UpdateHistogram();
            }

            SetupDepthsFromParentsAndChildren(root);
            return(root);
        }
Example #17
0
    public bool CanSerialize(EntityArchetype arch)
    {
        var components = arch.GetComponentTypes();
        int matches    = 0;

        for (int i = 0; i < components.Length; ++i)
        {
            if (components[i] == componentTypeAbilityCollectionAbilityEntry)
            {
                ++matches;
            }
            if (components[i] == componentTypeAbilityCollectionState)
            {
                ++matches;
            }
            if (components[i] == componentTypeAbilityOwnerOwnedAbility)
            {
                ++matches;
            }
            if (components[i] == componentTypeAbilityOwnerOwnedCollection)
            {
                ++matches;
            }
            if (components[i] == componentTypeAbilityOwnerState)
            {
                ++matches;
            }
            if (components[i] == componentTypeAimDataData)
            {
                ++matches;
            }
            if (components[i] == componentTypeAnimSourceControllerRigData)
            {
                ++matches;
            }
            if (components[i] == componentTypeAnimSourceControllerSettings)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterInterpolatedData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterPredictedData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterReplicatedData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterSettings)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerComponentData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerGroundSupportData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerInitializationData)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerMoveQuery)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerMoveResult)
            {
                ++matches;
            }
            if (components[i] == componentTypeCharacterControllerVelocity)
            {
                ++matches;
            }
            if (components[i] == componentTypeDamageEvent)
            {
                ++matches;
            }
            if (components[i] == componentTypeDamageHistoryData)
            {
                ++matches;
            }
            if (components[i] == componentTypeHealthStateData)
            {
                ++matches;
            }
            if (components[i] == componentTypeHitColliderOwnerState)
            {
                ++matches;
            }
            if (components[i] == componentTypeInventoryInternalState)
            {
                ++matches;
            }
            if (components[i] == componentTypeInventoryItemEntry)
            {
                ++matches;
            }
            if (components[i] == componentTypeInventoryState)
            {
                ++matches;
            }
            if (components[i] == componentTypePartOwnerInputState)
            {
                ++matches;
            }
            if (components[i] == componentTypePartOwnerRegistryAsset)
            {
                ++matches;
            }
            if (components[i] == componentTypePlayerOwnerPlayerId)
            {
                ++matches;
            }
            if (components[i] == componentTypePlayerControlledState)
            {
                ++matches;
            }
            if (components[i] == componentTypeSkeletonRenderer)
            {
                ++matches;
            }
            if (components[i] == componentTypeLocalToWorld)
            {
                ++matches;
            }
            if (components[i] == componentTypeRotation)
            {
                ++matches;
            }
            if (components[i] == componentTypeTranslation)
            {
                ++matches;
            }
            if (components[i] == componentTypeLinkedEntityGroup)
            {
                ++matches;
            }
        }
        return(matches == 34);
    }