Simplify some stuff

Remove render component in startup
This commit is contained in:
Aaron Kimbre 2022-04-17 12:38:12 -05:00
parent 5b0f917485
commit 23677b4bd3

View File

@ -7,22 +7,13 @@ void WhFans::OnStartup(Entity* self) {
self->SetVar<bool>(u"on", false); self->SetVar<bool>(u"on", false);
ToggleFX(self, false); ToggleFX(self, false);
auto* renderComponent = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
if (renderComponent == nullptr) {
return;
}
renderComponent->PlayEffect(495, u"fanOn", "fanOn");
} }
void WhFans::ToggleFX(Entity* self, bool hit) { void WhFans::ToggleFX(Entity* self, bool hit) {
std::string fanGroup = self->GetGroups()[0]; std::string fanGroup = self->GetGroups()[0];
std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup);
auto* renderComponent = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER)); auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent == nullptr) { if (renderComponent == nullptr) {
return; return;
} }
@ -36,7 +27,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
self->SetVar<bool>(u"on", false); self->SetVar<bool>(u"on", false);
for (Entity* volume : fanVolumes) { for (Entity* volume : fanVolumes) {
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); auto phantomPhysicsComponent = volume->GetComponent<PhantomPhysicsComponent>();
if (!volumePhys) continue; if (!volumePhys) continue;
volumePhys->SetPhysicsEffectActive(false); volumePhys->SetPhysicsEffectActive(false);
EntityManager::Instance()->SerializeEntity(volume); EntityManager::Instance()->SerializeEntity(volume);
@ -48,7 +39,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
self->SetVar<bool>(u"on", true); self->SetVar<bool>(u"on", true);
for (Entity* volume : fanVolumes) { for (Entity* volume : fanVolumes) {
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); auto phantomPhysicsComponent = volume->GetComponent<PhantomPhysicsComponent>();
if (!volumePhys) continue; if (!volumePhys) continue;
volumePhys->SetPhysicsEffectActive(true); volumePhys->SetPhysicsEffectActive(true);
EntityManager::Instance()->SerializeEntity(volume); EntityManager::Instance()->SerializeEntity(volume);