Example #1
0
        public override void Initialize()
        {
            this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);

            this.Paddle = new FloatRect(this.transform.Component.Position.X, this.transform.Component.Position.Y, 15, 100);
            this.PaddleColor = Color.White;
        }
Example #2
0
    protected override void Awake()
    {
        base.Awake();

        Worlds = new Dictionary <int, IWorld>();
        ComponentLookup.Init();
    }
Example #3
0
        public override void Initialize()
        {
            this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);

            this.BallColor = Color.White;
            this.Size = 25f;
        }
Example #4
0
        public override void Initialize()
        {
            this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);
            this.paddle = new ComponentLookup<PaddleComponent>(this.ParentEntity);

            this.Speed = 300f;
        }
Example #5
0
        public override void Initialize()
        {
            this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);
            this.paddle = new ComponentLookup<PaddleComponent>(this.ParentEntity);

            this.Speed = 315f;
            this.transform.Component.SetX(GameEngine.Instance.Window.Size.X - this.paddle.Component.Paddle.Width);
        }
Example #6
0
        public IComponent Get(int id)
        {
            Type compType = ComponentLookup.Get(id);

            if (!Components.ContainsKey(compType))
            {
                Debug.LogWarning($"Tried to access component {compType} but the entity didn't have it!");
                return(default);
        public int Add <T>(int entityId, T component) where T : class, IComponent
        {
            var underlyingType  = component.GetType();
            var componentTypeId = ComponentLookup.GetComponentType(underlyingType);

            Database.Add(componentTypeId, entityId, component);
            return(componentTypeId);
        }
Example #8
0
        /// <summary>
        /// Add component by id
        /// </summary>
        /// <param name="componentId"></param>
        public IComponent Add(int componentId)
        {
            IComponent component = (IComponent)Activator.CreateInstance(ComponentLookup.Get(componentId));

            Components.Add(component.GetType(), component);

            OnComponentAdded?.Invoke(this, component);
            return(component);
        }
        public override void Initialize()
        {
            this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);
            this.ball = new ComponentLookup<BallComponent>(this.ParentEntity);

            this.Angle = (float)(random.Next(25, 70) * (Math.PI / 180));
            this.Speed = 400f;
            this.SpeedIncrease = 20f;

            this.transform.Component.SetPosition(300, 300);
        }
Example #10
0
        public static IEntity Add <T>(this IEntity entity, T component) where T : IComponent
        {
            var componentTypeId = ComponentLookup <T> .Id;

            if (entity.HasComponent(componentTypeId))
            {
                throw new Exception(string.Format("Entity already has a component of type {0}", typeof(T).Name));
            }

            var componentPoolIndex = ComponentLookup <T> .New();

            ComponentLookup <T> .Array[componentPoolIndex] = component;
            entity.AddComponent(componentTypeId, componentPoolIndex, ComponentLookup <T> .UnusedIndices);

            return(entity);
        }
Example #11
0
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 public override void Initialize()
 {
     this.transform = new ComponentLookup<TransformComponent>(this.ParentEntity);
 }
        public void Remove(int entityId, Type componentType)
        {
            var componentTypeId = ComponentLookup.GetComponentType(componentType);

            Remove(entityId, componentTypeId);
        }
        public bool Has(int entityId, Type componentType)
        {
            var componentTypeId = ComponentLookup.GetComponentType(componentType);

            return(Has(entityId, componentTypeId));
        }
        public IComponent Get(int entityId, Type componentType)
        {
            var componentTypeId = ComponentLookup.GetComponentType(componentType);

            return(Get(entityId, componentTypeId));
        }
 public int[] GetTypesFor(params Type[] componentTypeIds)
 {
     return(ComponentLookup.GetComponentTypes(componentTypeIds));
 }