#pragma once #include "core/Common.hpp" #include namespace dnr { struct TumblerPin { float currentHeight = 0.0f; // 0.0 to 1.0 float targetHeight = 0.5f; // sweet spot float tolerance = 0.12f; bool locked = false; bool isInSweetSpot() const { return std::abs(currentHeight - targetHeight) <= tolerance; } }; class TumblerLock { public: TumblerLock(); void init(int pinCount = 4, float difficulty = 1.0f); void update(float dt); void moveLeft(); void moveRight(); void adjustHeight(float delta); bool tryLockCurrentPin(); bool isAllPinsLocked() const; int getSelectedPin() const { return m_selectedPin; } int getPinCount() const { return static_cast(m_pins.size()); } const TumblerPin& getPin(int index) const { return m_pins[index]; } float getDecayRate() const { return m_decayRate; } private: std::vector m_pins; int m_selectedPin = 0; float m_decayRate = 0.25f; }; } // namespace dnr