public static void Initialize <T>(out ComponentId <T> componentId, string name)
        {
            int uniqueId = _uniqueId;

            componentId = new ComponentId <T>(uniqueId, name);
            _uniqueId++;
        }
Exemplo n.º 2
0
        protected void Initialize <T1>(
            SystemProcessorCallback <T1> callback,
            ComponentId <T1> componentId1)
        {
            _processCallback = delegate(Entity entity)
            {
                ComponentReference <T1> component1 = entity.GetComponentReference(componentId1);

                callback.Invoke(entity, ref component1.Value);
            };
        }
Exemplo n.º 3
0
        /// <summary> Gets a reference to the component for the current entity. </summary>
        public ComponentReference <T> GetComponentReference <T>(ComponentId <T> id)
        {
            IComponentReference untypedComponent;

            if (_components.TryGetValue(id, out untypedComponent))
            {
                return((ComponentReference <T>)untypedComponent);
            }

            return(null);
        }
        public static void Initialize <T>(Expression <Func <ComponentId <T> > > propName)
        {
            var fieldInfo = (FieldInfo)((MemberExpression)propName.Body).Member;
            var name      = fieldInfo.Name;

            int uniqueId    = _uniqueId;
            var componentId = new ComponentId <T>(uniqueId, name);

            _uniqueId++;

            // assign it
            fieldInfo.SetValue(null, componentId);
        }
Exemplo n.º 5
0
        protected void Initialize <T1, T2, T3>(
            SystemProcessorCallback <T1, T2, T3> callback,
            ComponentId <T1> componentId1,
            ComponentId <T2> componentId2,
            ComponentId <T3> componentId3)
        {
            _processCallback = delegate(Entity entity)
            {
                ComponentReference <T1> component1 = entity.GetComponentReference(componentId1);
                ComponentReference <T2> component2 = entity.GetComponentReference(componentId2);
                ComponentReference <T3> component3 = entity.GetComponentReference(componentId3);

                callback.Invoke(entity, ref component1.Value, ref component2.Value, ref component3.Value);
            };
        }
Exemplo n.º 6
0
        protected void Initialize <T1, T2, T3, T4, T5, T6>(
            SystemProcessorCallback <T1, T2, T3, T4, T5, T6> callback,
            ComponentId <T1> componentId1,
            ComponentId <T2> componentId2,
            ComponentId <T3> componentId3,
            ComponentId <T4> componentId4,
            ComponentId <T5> componentId5,
            ComponentId <T6> componentId6)
        {
            _processCallback = delegate(Entity entity)
            {
                ComponentReference <T1> component1 = entity.GetComponentReference(componentId1);
                ComponentReference <T2> component2 = entity.GetComponentReference(componentId2);
                ComponentReference <T3> component3 = entity.GetComponentReference(componentId3);
                ComponentReference <T4> component4 = entity.GetComponentReference(componentId4);
                ComponentReference <T5> component5 = entity.GetComponentReference(componentId5);
                ComponentReference <T6> component6 = entity.GetComponentReference(componentId6);

                callback.Invoke(entity, ref component1.Value, ref component2.Value, ref component3.Value, ref component4.Value, ref component5.Value, ref component6.Value);
            };
        }
Exemplo n.º 7
0
 /// <summary> Adds a component to the entity. </summary>
 /// <typeparam name="T"> Generic type parameter. </typeparam>
 public void AddComponent <T>(ComponentId <T> id, T value)
 {
     _components.Add(id, new ComponentReference <T>());
     _componentMask.Include(id);
 }
Exemplo n.º 8
0
 /// <summary> Gets a reference to the component for the current entity. </summary>
 public ComponentReference <T> GetComponentReference <T>(ComponentId <T> id)
 {
     return(_components.GetComponentReference(id));
 }
Exemplo n.º 9
0
 /// <summary> Adds a component to the entity. </summary>
 /// <typeparam name="T"> Generic type parameter. </typeparam>
 public void Add <T>(ComponentId <T> id, T value)
 {
     _components.AddComponent(id, value);
 }
Exemplo n.º 10
0
 public void Exclude(ComponentId componentId)
 {
     _mask &= ~(1L << componentId.Id);
 }
Exemplo n.º 11
0
 public void Include(ComponentId componentId)
 {
     _mask |= (1L << componentId.Id);
 }
 public static void Initialize <T>(out ComponentId <T> componentId, Expression <Func <ComponentId <T> > > propName)
 {
     Initialize(out componentId, propName.ToString());
 }