46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
#ifndef LIGHTKEEPER_INTERACTABLEBUTTON_H
|
|
#define LIGHTKEEPER_INTERACTABLEBUTTON_H
|
|
|
|
#include <components/Interactable.h>
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include <destrum/ObjectModel/ObjectId.h>
|
|
|
|
class InteractableButton final : public Interactable {
|
|
public:
|
|
explicit InteractableButton(GameObject& parent);
|
|
|
|
std::string GetTypeName() const override { return "InteractableButton"; }
|
|
|
|
void Start() override;
|
|
void Interact(GameObject& interactor) override;
|
|
|
|
nlohmann::json Serialize() const override;
|
|
void Deserialize(const nlohmann::json& data) override;
|
|
void ImGuiInspector() override;
|
|
|
|
[[nodiscard]] std::size_t GetColorIndex() const { return m_ColorIndex; }
|
|
[[nodiscard]] int GetPressCount() const { return m_PressCount; }
|
|
|
|
void SetCycleColors(bool cycleColors) { m_CycleColors = cycleColors; }
|
|
|
|
// Every Activatable on a target object is activated when the button is pressed
|
|
void AddTarget(const GameObject& target);
|
|
void RemoveTarget(ObjectId target);
|
|
[[nodiscard]] const std::vector<ObjectId>& GetTargets() const { return m_Targets; }
|
|
|
|
private:
|
|
void ApplyColor();
|
|
void ActivateTargets(GameObject& interactor);
|
|
void DrawTargetsInspector();
|
|
|
|
std::size_t m_ColorIndex{0};
|
|
int m_PressCount{0};
|
|
bool m_CycleColors{true};
|
|
std::vector<ObjectId> m_Targets;
|
|
};
|
|
|
|
#endif // LIGHTKEEPER_INTERACTABLEBUTTON_H
|