feat: add Activateable in Lightkeeper
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#ifndef LIGHTKEEPER_DOOR_H
|
||||
#define LIGHTKEEPER_DOOR_H
|
||||
|
||||
#include <components/Activatable.h>
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class Door final : public Activatable {
|
||||
public:
|
||||
explicit Door(GameObject& parent);
|
||||
|
||||
std::string GetTypeName() const override { return "Door"; }
|
||||
|
||||
void Start() override;
|
||||
void Update(float dt) override;
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void Open() { m_IsOpen = true; }
|
||||
void Close() { m_IsOpen = false; }
|
||||
void Toggle() { m_IsOpen = !m_IsOpen; }
|
||||
|
||||
[[nodiscard]] bool IsOpen() const { return m_IsOpen; }
|
||||
[[nodiscard]] float GetOpenAmount() const { return m_OpenAmount; }
|
||||
|
||||
void SetOpenOffset(const glm::vec3& offset) { m_OpenOffset = offset; }
|
||||
void SetOpenDuration(float seconds) { m_OpenDuration = seconds; }
|
||||
void SetToggleable(bool toggleable) { m_Toggleable = toggleable; }
|
||||
|
||||
protected:
|
||||
void OnActivate(GameObject& instigator) override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] glm::vec3 GetOffsetFor(float openAmount) const;
|
||||
void ApplyPosition();
|
||||
|
||||
glm::vec3 m_OpenOffset{0.0f, -2.4f, 0.0f};
|
||||
float m_OpenDuration{1.0f};
|
||||
bool m_Toggleable{true};
|
||||
|
||||
bool m_IsOpen{false};
|
||||
float m_OpenAmount{0.0f};
|
||||
|
||||
glm::vec3 m_ClosedPosition{0.0f};
|
||||
bool m_Started{false};
|
||||
};
|
||||
|
||||
#endif // LIGHTKEEPER_DOOR_H
|
||||
Reference in New Issue
Block a user