public T Add <T>() where T : Component { ComponentHelper.Assert <T>(); /*if (!ComponentHelper.AllowMultiple<T>() && Handle.Has<T>()) { * throw new Exception($"Already has a component of type {typeof(T).Name}"); * } * T component = Activator.CreateInstance<T>(); * component.AppendTo(this); * Events.RaiseAddedComponent(component); * var registerAs = ComponentHelper.GetRegisterAs<T>(); * if (registerAs != null) { * registerAs.CallSet(Handle, component); * } else { * Handle.Set(component); * } * return component;*/ T component = Activator.CreateInstance <T>(); ComponentHelper.CallSet(Handle, component); component.AppendTo(this); Events.RaiseAddedComponent(component); return(component); }
public bool Has <T>() where T : Component { ComponentHelper.Assert <T>(); return(ComponentHelper.CallHas <T>(Handle)); /*var registerAs = ComponentHelper.GetRegisterAs<T>(); * if (registerAs != null) { * return registerAs.CallHas(Handle); * } * return Handle.Has<T>();*/ }
public bool Has <T>(out T component) where T : Component { ComponentHelper.Assert <T>(); try { component = ComponentHelper.CallGet <T>(Handle); return(true); } catch (Exception) { component = default; return(false); } }
public void Disable <T>() where T : Component { ComponentHelper.Assert <T>(); Handle.Disable <T>(); }
public bool IsEnabled <T>() where T : Component { ComponentHelper.Assert <T>(); return(Handle.IsEnabled <T>()); }