feat: add basic canvas / improve inspector

This commit is contained in:
2026-10-18 20:42:04 +02:00
parent 7df65f52b5
commit ad16daea7c
47 changed files with 3142 additions and 405 deletions
+51
View File
@@ -0,0 +1,51 @@
#include <components/Checkpoint.h>
#include <destrum/ObjectModel/GameObject.h>
#include <destrum/Serialization/GlmJson.h>
#include <components/PlayerRespawn.h>
#include <imgui.h>
#include <glm/gtc/type_ptr.hpp>
#include <spdlog/spdlog.h>
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<PlayerRespawn>();
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);
}