Exemplo n.º 1
0
        public TType Get <TType>() where TType : class
        {
            var item = BlackBoards.Components.OfType <TType>().FirstOrDefault();

            //?? StartingBlackBoardComponents.OfType<TType>().FirstOrDefault();
            return(item ?? EcsComponent.CreateObject(typeof(TType)) as TType);
        }
        /*--------------------------------------
         * PUBLIC METHODS
         *------------------------------------*/

        /// <summary>Adds a component to the entity.</summary>
        /// <param name="component">The component to add to the entity.</param>
        public void AddComponent(EcsComponent component)
        {
            mComponents.Add(component.GetType(), component);

            var scene = mScene;

            if (scene != null)
            {
                scene.NotifyComponentsChanged(this);
            }
        }
Exemplo n.º 3
0
 public void AddComponent(int id, EcsComponent component, Type type)
 {
     Components[type].Add(id, component);
 }
Exemplo n.º 4
0
 public static void Translate(EcsComponent component, float x, float y, float z)
 {
     component.transform.position += new Vector3(x, y, z);
 }
Exemplo n.º 5
0
 public static void TranslateWithTime(EcsComponent component, Vector3 direction)
 {
     component.transform.position += Time.deltaTime * direction;
 }
Exemplo n.º 6
0
 public void AddComponent(EcsComponent component)
 {
     mComponents.Add(component.GetType(), component);
 }