feat: add Activateable in Lightkeeper

This commit is contained in:
2026-10-17 17:00:00 +02:00
parent 89a168f76d
commit 70c940c476
13 changed files with 354 additions and 5 deletions
+30 -3
View File
@@ -16,6 +16,7 @@
#include <destrum/Util/ModelDocUtils.h>
#include <components/FirstPersonController.h>
#include <components/Door.h>
#include <components/InteractableButton.h>
#include <components/TriggerLoggerComponent.h>
@@ -159,7 +160,32 @@ namespace {
}
}
void CreateButton(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
GameObject* CreateDoorway(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
{
const MaterialID frameMaterial = AddPrototypeMaterial(gfxDevice, resources, "Dark", 0.9f);
const MaterialID doorMaterial = AddPrototypeMaterial(gfxDevice, resources, "Purple", 0.5f);
constexpr float x = 4.0f;
constexpr float z = -4.5f;
constexpr float frameHeight = 2.8f;
constexpr float doorWidth = 1.6f;
constexpr float doorHeight = 2.4f;
for (const float side : {-1.0f, 1.0f}) {
CreateBox(scene, gfxDevice, resources, side < 0.0f ? "DoorFrame_Left" : "DoorFrame_Right",
{x, GroundHeight + frameHeight * 0.5f, z + side * (doorWidth * 0.5f + 0.2f)},
{0.4f, frameHeight, 0.4f}, frameMaterial, RigidbodyType::Static);
}
CreateBox(scene, gfxDevice, resources, "DoorFrame_Top", {x, GroundHeight + frameHeight + 0.2f, z},
{0.4f, 0.4f, doorWidth + 0.8f}, frameMaterial, RigidbodyType::Static);
GameObject* door = CreateBox(scene, gfxDevice, resources, "Door", {x, GroundHeight + doorHeight * 0.5f, z},
{0.3f, doorHeight, doorWidth}, doorMaterial, RigidbodyType::Kinematic);
door->AddComponent<Door>()->SetOpenOffset({0.0f, 0.0f, -doorWidth - 0.1f});
return door;
}
void CreateButton(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources, const GameObject& target)
{
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},
@@ -172,7 +198,7 @@ namespace {
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>();
button->AddComponent<InteractableButton>()->AddTarget(target);
}
void CreateFlightHelmet(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
@@ -299,7 +325,8 @@ MainSceneObjects BuildMainScene(Scene& scene, GfxDevice& gfxDevice, RenderResour
CreateTree(scene, gfxDevice, resources);
CreateCapybara(scene, gfxDevice, resources);
CreateTriggerZone(scene);
CreateButton(scene, gfxDevice, resources);
const GameObject* door = CreateDoorway(scene, gfxDevice, resources);
CreateButton(scene, gfxDevice, resources, *door);
CreatePlayer(scene, objects);
LoadSpawnBallResources(gfxDevice, resources, objects);