32 lines
871 B
C++
32 lines
871 B
C++
#include "components/ProbeStateComponent.hpp"
|
|
|
|
#include "Entity.hpp"
|
|
#include "components/TransformComponent.hpp"
|
|
|
|
#include "raylib.h"
|
|
|
|
void ProbeStateComponent::Setup() {}
|
|
|
|
void ProbeStateComponent::Update(float) {
|
|
if (!context || !context->probeEntity || entity != context->probeEntity) {
|
|
return;
|
|
}
|
|
|
|
auto transform = entity->GetComponent<TransformComponent>();
|
|
if (!transform) {
|
|
return;
|
|
}
|
|
|
|
if (transform->get().y < -20.0f ||
|
|
transform->get().y > static_cast<float>(GetScreenHeight() + 20) ||
|
|
transform->get().x < -20.0f ||
|
|
transform->get().x > static_cast<float>(GetScreenWidth() + 20)) {
|
|
if (context->onPlayerDeath) {
|
|
// leaving the viewport is treated as death to keep the probe bounded
|
|
context->onPlayerDeath();
|
|
}
|
|
}
|
|
}
|
|
|
|
void ProbeStateComponent::Cleanup() {}
|