Exemple #1
0
                public IComponent AddComponet(Type type)
                {
                    IComponent comp = GetComponent(type);

                    if (comp != null)
                    {
                        throw new Exception(string.Format("Have Exist Component Type : {0}", type));
                    }
                    comp = _moudle.CreateComponent(type);
                    _components.Add(type, comp);
                    return(comp);
                }
Exemple #2
0
 public IComponent AddComponent(IEntity entity, Type type)
 {
     using (new LockWait(ref _lock))
     {
         EntityContainer container;
         if (FindContainer(entity, out container))
         {
             IComponent ic    = _moudle.CreateComponent(type);
             int        index = AddComponent(ic, false);
             container.AddComponet(type, index);
             return(ic);
         }
         else
         {
             throw new Exception("Not Exist Entity");
         }
     }
 }