private EntityBag BuildEntityBag(Type type)
        {
            var entityBag = new EntityBag();

            var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                             .Where(x => x.GetCustomAttributes <AutoGeneratePropertyAttribute>(false).Any() &&
                                    x.GetCustomAttributes <AutoGeneratePropertyAttribute>(false)
                                    .Cast <AutoGeneratePropertyAttribute>()
                                    .Any(z => z.AutoGenerate == true));

            foreach (var property in properties)
            {
                var bag = default(PropertyBag);

                var tColl        = typeof(ICollection <>);
                var propertyType = property.PropertyType;
                if (!propertyType.Equals(typeof(int)) &&
                    !propertyType.Equals(typeof(string)) &&
                    !propertyType.Equals(typeof(float)) &&
                    !propertyType.Equals(typeof(double)) &&
                    !propertyType.Equals(typeof(decimal)) &&
                    !propertyType.Equals(typeof(int?)) &&
                    !propertyType.Equals(typeof(float?)) &&
                    !propertyType.Equals(typeof(decimal?)) &&
                    !propertyType.Equals(typeof(double?)) &&
                    !propertyType.Equals(typeof(DateTime)) &&
                    !propertyType.Equals(typeof(DateTime?)) &&
                    !propertyType.Equals(typeof(bool)) &&
                    !propertyType.Equals(typeof(bool?)) &&
                    !propertyType.Equals(typeof(TimeSpan)) &&
                    !propertyType.Equals(typeof(TimeSpan?)) &&
                    (propertyType.GetTypeInfo().IsGenericType&& tColl.IsAssignableFrom(propertyType.GetGenericTypeDefinition()) ||
                     propertyType.GetInterfaces().Any(x => x.GetTypeInfo().IsGenericType&& x.GetGenericTypeDefinition() == tColl)) == false)
                {
                    //List<PropertyInfo> props = new List<PropertyInfo>(propertyType
                    //                                                              .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                    //                                                              .Where(x => x.GetCustomAttributes<AutoGeneratePropertyAttribute>(false).Any() &&
                    //                                                                          x.GetCustomAttributes<AutoGeneratePropertyAttribute>(false)
                    //                                                                           .Cast<AutoGeneratePropertyAttribute>()
                    //                                                                           .Any(z => z.AutoGenerate == true))
                    //                                                              .ToList());

                    //var orderedprops1 = GetOrderedProperties(props);
                    //await GenerateForm(orderedprops1, property);
                }
                else
                {
                    bag = this.GetBagFromProperty(property, type);
                }
            }

            return(entityBag);
        }
        private static EntityConfiguration <T> TryAddEntity <T>() where T : new()
        {
            var type = typeof(T);

            if (_instance._entities.ContainsKey(type))
            {
                throw new ArgumentException($"Entity { type.Name } is already defined.");
            }
            var bag = new EntityBag();

            _instance._entities.Add(type, bag);

            return(new EntityConfiguration <T>(bag));
        }
        void RecycleEntities(EntityBag bag)
        {
            if (bag.Entities.Length > 0)
            {
                m_Manager.DestroyEntity(bag.Entities);
                bag.Entities.Dispose();
            }

            bag.ValidVersion++;

            // Sanity check all arrays.
            SanityCheckVersions();

            bag.Entities = new NativeArray <Entity>(kBatchCount, Allocator.Persistent);

            for (int i = 0; i < bag.Entities.Length; ++i)
            {
                bag.Entities[i] = m_Manager.CreateEntity(m_Archetype);
            }
        }
        public void TestIssue149()
        {
            m_OurTypes = new ComponentType[] { typeof(Issue149Data) };

            m_Archetype = m_Manager.CreateArchetype(typeof(Issue149Data));

            for (int i = 0; i < Bags.Length; ++i)
            {
                Bags[i] = new EntityBag();
            }

            var a = Bags[0];
            var b = Bags[1];
            var c = Bags[2];

            try
            {
                RecycleEntities(a);
                RecycleEntities(b);
                RecycleEntities(c);
                RecycleEntities(a);
                RecycleEntities(b);
                RecycleEntities(a);
                RecycleEntities(c);
                RecycleEntities(a);
                RecycleEntities(a);
                RecycleEntities(b);
                RecycleEntities(a);
                RecycleEntities(c);
                RecycleEntities(a);
            }
            finally
            {
                // To get rid of leak errors in the log when the test fails.
                a.Entities.Dispose();
                b.Entities.Dispose();
                c.Entities.Dispose();
            }
        }
예제 #5
0
 public UnitRenderSystem(SdlMainWindow sdlWindow, IGameEngineService gameEngineService)
 {
     _sdlWindow = sdlWindow;
     _unitBag   = EntityBag.Create <ITransform>(gameEngineService);
 }
 public static EntityBag CreateEntityBag(string name, string value, long entityId, long entityKindId, long protectionLevel, long ID, global::System.Guid tid, long createdById, long modifiedById, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     EntityBag entityBag = new EntityBag();
     entityBag.Name = name;
     entityBag.Value = value;
     entityBag.EntityId = entityId;
     entityBag.EntityKindId = entityKindId;
     entityBag.ProtectionLevel = protectionLevel;
     entityBag.Id = ID;
     entityBag.Tid = tid;
     entityBag.CreatedById = createdById;
     entityBag.ModifiedById = modifiedById;
     entityBag.Created = created;
     entityBag.Modified = modified;
     return entityBag;
 }
 public void AddToEntityBags(EntityBag entityBag)
 {
     base.AddObject("EntityBags", entityBag);
 }
예제 #8
0
 internal EntityConfiguration(EntityBag bag)
 {
     _entityBag = bag;
 }