Esempio n. 1
0
        public static NativeEGIDMultiMapper <T> QueryNativeMappedEntities <T>(this EntitiesDB entitiesDb,
                                                                              LocalFasterReadOnlyList <ExclusiveGroupStruct> groups)
            where T : unmanaged, IEntityComponent
        {
            var dictionary =
                new SveltoDictionary <ExclusiveGroupStruct, SveltoDictionary <uint, T,
                                                                              NativeStrategy <FasterDictionaryNode <uint> >,
                                                                              NativeStrategy <T>,
                                                                              NativeStrategy <int> >,
                                      NativeStrategy <FasterDictionaryNode <ExclusiveGroupStruct> >,
                                      NativeStrategy <SveltoDictionary <uint, T,
                                                                        NativeStrategy <FasterDictionaryNode <uint> >,
                                                                        NativeStrategy <T>,
                                                                        NativeStrategy <int> > >,
                                      NativeStrategy <int> >
                    ((uint)groups.count, Allocator.TempJob);

            foreach (var group in groups)
            {
                if (entitiesDb.SafeQueryEntityDictionary <T>(group, out var typeSafeDictionary) == true)
                {
                    if (typeSafeDictionary.count > 0)
                    {
                        dictionary.Add(group, ((TypeSafeDictionary <T>)typeSafeDictionary).implUnmgd);
                    }
                }
            }

            return(new NativeEGIDMultiMapper <T>(dictionary));
        }
Esempio n. 2
0
        public static NativeEGIDMapper <T> QueryNativeMappedEntities <T>(this EntitiesDB entitiesDb, ExclusiveGroupStruct groupStructId)
            where T : unmanaged, IEntityComponent
        {
            if (entitiesDb.SafeQueryEntityDictionary <T>(groupStructId, out var typeSafeDictionary) == false)
            {
                throw new EntityGroupNotFoundException(typeof(T), groupStructId.ToName());
            }

            return((typeSafeDictionary as TypeSafeDictionary <T>).ToNativeEGIDMapper(groupStructId));
        }
Esempio n. 3
0
        public static bool TryQueryNativeMappedEntities <T>(this EntitiesDB entitiesDb, ExclusiveGroupStruct groupStructId,
                                                            out NativeEGIDMapper <T> mapper)
            where T : unmanaged, IEntityComponent
        {
            mapper = default;
            if (entitiesDb.SafeQueryEntityDictionary <T>(groupStructId, out var typeSafeDictionary) == false ||
                typeSafeDictionary.count == 0)
            {
                return(false);
            }

            mapper = (typeSafeDictionary as TypeSafeDictionary <T>).ToNativeEGIDMapper(groupStructId);

            return(true);
        }
Esempio n. 4
0
        static bool QueryEntitiesAndIndexInternal <T>(this EntitiesDB entitiesDb, EGID entityGID, out uint index, out NB <T> buffer) where T : unmanaged, IEntityComponent
        {
            index  = 0;
            buffer = default;
            if (entitiesDb.SafeQueryEntityDictionary <T>(entityGID.groupID, out var safeDictionary) == false)
            {
                return(false);
            }

            if (safeDictionary.TryFindIndex(entityGID.entityID, out index) == false)
            {
                return(false);
            }

            buffer = (NB <T>)(safeDictionary as ITypeSafeDictionary <T>).GetValues(out _);

            return(true);
        }