Ejemplo n.º 1
0
 public bool Add(GameObject entity, Component component)
 {
     if (entity != null && component != null)
     {
         bool componentSuccessfullyAttached = false;
         var  components = GetComponentsForEntity(entity);
         if (components == null)
         {
             components           = new Dictionary <Type, Component>();
             _gameObjects[entity] = components;
             _injector.OnObjectEntered(entity);
         }
         if (components.ContainsKey(component.GetType()) == false)
         {
             components.Add(component.GetType(), component);
             entity.Attach(component);
             _injector.OnComponentAdded(component);
             componentSuccessfullyAttached = true;
         }
         return(componentSuccessfullyAttached);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }