public static void ApplyToAll(this IBlueprint blueprint, params IEntity[] entities)
 {
     for (var i = 0; i < entities.Length; i++)
     {
         blueprint.Apply(entities[i]);
     }
 }
Exemple #2
0
 public static void ApplyToAll(this IBlueprint blueprint, params IEntity[] entities)
 {
     foreach (var entity in entities)
     {
         blueprint.Apply(entity);
     }
 }
        public IEntity CreateEntity(IBlueprint blueprint = null)
        {
            var entity = EntityFactory.Create(null);

            EntityLookup.Add(entity);
            _onEntityAdded.OnNext(new CollectionEntityEvent(entity));
            SubscribeToEntity(entity);

            blueprint?.Apply(entity);

            return(entity);
        }
Exemple #4
0
        public IEntity CreateEntity(IBlueprint blueprint = null)
        {
            var entity = EntityFactory.Create(null);

            _entities.Add(entity.Id, entity);

            EventSystem.Publish(new EntityAddedEvent(entity, this));

            if (blueprint != null)
            {
                blueprint.Apply(entity);
            }

            return(entity);
        }
Exemple #5
0
        public IEntity CreateEntity(string id = null, IBlueprint blueprint = null)
        {
            id = !string.IsNullOrEmpty(id) ? id : Guid.NewGuid().ToString();
            var entity = new Entity(id, EventSystem);

            _entities.Add(entity);

            EventSystem.Publish(new EntityAddedEvent(entity, this));

            if (blueprint != null)
            {
                blueprint.Apply(entity);
            }

            return(entity);
        }
Exemple #6
0
        public IEntity CreateEntity(IBlueprint blueprint = null)
        {
            var newId  = IdentityGenerator.GenerateId();
            var entity = new Entity(newId, EventSystem);

            _entities.Add(entity);

            EventSystem.Publish(new EntityAddedEvent(entity, this));

            if (blueprint != null)
            {
                blueprint.Apply(entity);
            }

            return(entity);
        }
Exemple #7
0
        public IEntity CreateEntity(IBlueprint blueprint = null, int?id = null)
        {
            if (id.HasValue && EntityLookup.Contains(id.Value))
            {
                throw new InvalidOperationException("id already exists");
            }

            var entity = EntityFactory.Create(id);

            EntityLookup.Add(entity);
            _onEntityAdded.OnNext(new CollectionEntityEvent(entity));
            SubscribeToEntity(entity);

            blueprint?.Apply(entity);

            return(entity);
        }
//        public static bool MatchesGroup(this IEntity entity, IGroup group)
//        { return entity.HasComponents(group.TargettedComponents.ToArray()); }

        public static IEntity ApplyBlueprint(this IEntity entity, IBlueprint blueprint)
        {
            blueprint.Apply(entity);
            return(entity);
        }
Exemple #9
0
 public static TEntity Apply <TEntity>(this TEntity entity, IBlueprint <TEntity> blueprint)
     where TEntity : class, IEntity
 {
     blueprint.Apply(entity);
     return(entity);
 }