#include #include #include #include #include #include #include Checkpoint::Checkpoint(GameObject& parent) : Component(parent, "Checkpoint") { } glm::vec3 Checkpoint::GetSpawnPoint() const { return GetTransform().GetWorldPosition() + m_SpawnOffset; } void Checkpoint::OnTriggerEnter(GameObject* other) { if (other == nullptr) { return; } auto* respawn = other->GetComponent(); const glm::vec3 spawnPoint = GetSpawnPoint(); if (respawn == nullptr || respawn->GetRespawnPoint() == spawnPoint) { return; } respawn->SetRespawnPoint(spawnPoint); spdlog::info("{} reached checkpoint {}", other->GetName(), GetGameObject()->GetName()); } nlohmann::json Checkpoint::Serialize() const { return {{"spawnOffset", m_SpawnOffset}}; } void Checkpoint::Deserialize(const nlohmann::json& data) { m_SpawnOffset = data.value("spawnOffset", m_SpawnOffset); } void Checkpoint::ImGuiInspector() { ImGui::DragFloat3("Spawn offset", glm::value_ptr(m_SpawnOffset), 0.05f); }