Entity.HasComponent<T> method
template<typename T>
bool HasComponent();
Description
Returns true when the entity has a component of type T
attached. Use as a guard before GetComponent
when presence isn't guaranteed.
Returns
| bool | presence | True if attached, false otherwise (and for default-constructed entities). |
Example
if (e.HasComponent<Thread::AudioComponent>()) {
auto& ac = e.GetComponent<Thread::AudioComponent>();
ac.Volume = 0.5f;
}
Entity.HasComponent<T> metoda
template<typename T>
bool HasComponent();
Opis
Zwraca true, gdy encja ma podpięty komponent typu T. Używaj jako
zabezpieczenia przed GetComponent, gdy obecność
komponentu nie jest pewna.
Zwraca
| bool | obecność | True, jeśli podpięty; false w przeciwnym razie (oraz dla encji utworzonych domyślnie). |
Przykład
if (e.HasComponent<Thread::AudioComponent>()) {
auto& ac = e.GetComponent<Thread::AudioComponent>();
ac.Volume = 0.5f;
}