#pragma once
#include <vector>
#include <string>

#include "Core/Models.h"
#include "Core/RuntimeSession.h"
#include "Memory/VmmAccessor.h"
#include "Readers/EntityTypeCache.h"

// -------------------------------------------------------------------------
// NearEntityListReader
// Reads the world's near-entity pointer table and builds a flat list of
// DayZNearEntityEntry values.  Entity type metadata is cached across calls
// via an internal EntityTypeCache.
// -------------------------------------------------------------------------

class NearEntityListReader {
public:
    /// Read the current near-entity list into @p entries.
    /// Replaces the contents of @p entries on each successful call.
    /// Returns false only when the initial table reads fail entirely.
    bool TryRead(VmmAccessor&                     mem,
                 const RuntimeSession&            session,
                 std::vector<DayZNearEntityEntry>& entries);

    /// Clear cached type metadata.  Call when the game session restarts.
    void Reset();

private:
    static constexpr int kMaxEntities = 4096;

    EntityTypeCache m_typeCache;
};
