Beispiel #1
0
 public static void Load(World world, Type type)
 {
     ReflectLoader.LoadByParent <Behavior>(type, (dealer) =>
     {
         world.AddBehever(dealer);
     });
     ReflectLoader.LoadByAttribute <Component, GlobelAttribute>(type, (cmp, att) =>
     {
         world.Globel.AddComponent(cmp);
     });
     TupleTypeMgr.Load(type);
 }
Beispiel #2
0
        public static T GetTuple <T>(this World world, uint id) where T : ITuple, new()
        {
            string[] fileds = TupleTypeMgr.Get(typeof(T).Name);
            Entity   e      = world.Get <Entity>(id);

            if (e != null && e.HasComponents(fileds))
            {
                T s = new T();
                s.SetCmps(e);
                return(s);
            }
            return(default(T));
        }
Beispiel #3
0
        public static T[] GetTuples <T>(this World world) where T : ITuple, new ()
        {
            List <T> a = new List <T>();

            string[] fileds = TupleTypeMgr.Get(typeof(T).Name);
            foreach (var item in world.Entities())
            {
                if (item.HasComponents(fileds))
                {
                    T aaa = new T();
                    aaa.SetCmps(item);
                    a.Add(aaa);
                }
            }
            return(a.ToArray());
        }