#include "adapters/eft/aimbot/AimbotTargetState.h"

#include <utility>

namespace ta::adapters::eft::aimbot
{
    TargetStateStore& TargetStateStore::instance()
    {
        static TargetStateStore state;
        return state;
    }

    TargetState TargetStateStore::snapshot() const
    {
        std::lock_guard<std::mutex> lock(mutex_);
        return state_;
    }

    void TargetStateStore::set_local_nickname(std::string nickname)
    {
        std::lock_guard<std::mutex> lock(mutex_);
        state_.local_nickname = std::move(nickname);
    }

    void TargetStateStore::set_target(ta::adapters::unity::vector3 target)
    {
        std::lock_guard<std::mutex> lock(mutex_);
        state_.target = target;
        state_.has_target = true;
    }

    void TargetStateStore::clear_target()
    {
        std::lock_guard<std::mutex> lock(mutex_);
        state_.target = {};
        state_.has_target = false;
    }

    void TargetStateStore::reset()
    {
        std::lock_guard<std::mutex> lock(mutex_);
        state_ = {};
    }
}
