예제 #1
0
        public void BuildEntityAndAddToList(ref ITypeSafeDictionary dictionary, EGID entityID, object[] implementors)
        {
            if (dictionary == null)
            {
                dictionary = new TypeSafeDictionary <T>();
            }

            var castedDic = dictionary as TypeSafeDictionary <T>;

            if (NEEDS_REFLECTION == true)
            {
                DBC.ECS.Check.Require(implementors != null, "Implementors not found while building an EntityView");
                DBC.ECS.Check.Require(castedDic.ContainsKey(entityID.entityID) == false,
                                      "building an entity with already used entity id! id".FastConcat(entityID).FastConcat(" ", ENTITY_VIEW_NAME));

                T entityView;
                EntityView <T> .BuildEntityView(entityID, out entityView);

                this.FillEntityView(ref entityView
                                    , entityViewBlazingFastReflection
                                    , implementors);

                castedDic.Add(entityID.entityID, ref entityView);
            }
            else
            {
                _initializer.ID = entityID;

                castedDic.Add(entityID.entityID, _initializer);
            }
        }
예제 #2
0
        public void BuildEntityViewAndAddToList(ref ITypeSafeDictionary dictionary, EGID entityID, object[] implementors)
        {
            if (dictionary == null)
            {
                dictionary = new TypeSafeDictionary <T>();
            }

            var castedDic = dictionary as TypeSafeDictionary <T>;

            if (needsReflection == true)
            {
                DBC.ECS.Check.Require(implementors != null, "Implementors not found while building an EntityView");

                T lentityView;
                EntityView <T> .BuildEntityView(entityID, out lentityView);

                this.FillEntityView(ref lentityView
                                    , entityViewBlazingFastReflection
                                    , implementors
                                    , DESCRIPTOR_NAME);

                castedDic.Add(entityID.entityID, ref lentityView);
            }
            else
            {
                _initializer.ID = entityID;

                castedDic.Add(entityID.entityID, _initializer);
            }
        }
예제 #3
0
        internal static NativeEGIDMapper <T> ToNativeEGIDMapper <T>(this TypeSafeDictionary <T> dic,
                                                                    ExclusiveGroupStruct groupStructId) where T : unmanaged, IEntityComponent
        {
            var mapper = new NativeEGIDMapper <T>(groupStructId, dic.implUnmgd);

            return(mapper);
        }
        internal static NativeEGIDMapper <T> ToNativeEGIDMapper <T>(this TypeSafeDictionary <T> dic,
                                                                    ExclusiveGroupStruct groupStructId) where T : unmanaged, IEntityStruct
        {
            var mapper = new NativeEGIDMapper <T>(groupStructId, dic.implementation.ToNative <uint, T>());

            return(mapper);
        }
예제 #5
0
        public static ITypeSafeDictionary Preallocate(ref ITypeSafeDictionary dictionary, int size)
        {
            if (dictionary == null)
            {
                dictionary = new TypeSafeDictionary <T>(size);
            }
            else
            {
                dictionary.AddCapacity(size);
            }

            return(dictionary);
        }