feat: add interactable component and test button

This commit is contained in:
2026-10-16 23:25:11 +02:00
parent faba4171ec
commit 7dd5ee7903
14 changed files with 236 additions and 6 deletions
+18
View File
@@ -16,6 +16,7 @@
#include <destrum/Util/ModelDocUtils.h>
#include <components/FirstPersonController.h>
#include <components/InteractableButton.h>
#include <components/TriggerLoggerComponent.h>
#include <glm/gtc/constants.hpp>
@@ -158,6 +159,22 @@ namespace {
}
}
void CreateButton(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
{
const MaterialID pedestalMaterial = AddPrototypeMaterial(gfxDevice, resources, "Dark", 0.9f);
CreateBox(scene, gfxDevice, resources, "ButtonPedestal", {1.5f, -0.45f, -4.5f}, {0.4f, 1.1f, 0.4f},
pedestalMaterial, RigidbodyType::Static);
// Every button needs its own material, pressing it recolors the material
Material buttonMaterial = Material::SimpleColor(glm::vec3{1.0f}, "ButtonMaterial");
buttonMaterial.roughnessFactor = 0.4f;
const MaterialID buttonMaterialID = resources.materials().addMaterial(std::move(buttonMaterial));
GameObject* button = CreateBox(scene, gfxDevice, resources, "Button", {1.5f, 0.15f, -4.5f}, {0.25f, 0.1f, 0.25f},
buttonMaterialID, RigidbodyType::Static);
button->AddComponent<InteractableButton>();
}
void CreateFlightHelmet(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
{
GameObject* helmetObj = ModelSpawner::SpawnStaticModel(
@@ -282,6 +299,7 @@ MainSceneObjects BuildMainScene(Scene& scene, GfxDevice& gfxDevice, RenderResour
CreateTree(scene, gfxDevice, resources);
CreateCapybara(scene, gfxDevice, resources);
CreateTriggerZone(scene);
CreateButton(scene, gfxDevice, resources);
CreatePlayer(scene, objects);
LoadSpawnBallResources(gfxDevice, resources, objects);