namespace NyxCS2.Core;

// ============================================================================
// CS2 offsets.
// BAKED VALUES = build 14183 (2026-09-23 23:13 UTC, source: sezzyaep/CS2-OFFSETS
// for module offsets + a2x/cs2-dumper for netvars).
// At runtime OffsetUpdater re-fetches the latest values (sezzyaep per-build
// module offsets + a2x netvars) and OVERWRITES these fields, so the app
// self-fixes after every CS2 update - same as the other modern external menus.
// Manual refresh: update-offsets.ps1 (patches this file) then build.bat.
// ============================================================================
public static class Offsets
{
    // --- provenance (shown in the menu / overlay status) ---
    public const string BakedDate = "2026-09-23";
    public static string Source = "Baked build 14183 (sezzyaep)";
    public static string Build  = "14183";   // baked build number

    // ---- client.dll (module base + offset). Build 14183 (sezzyaep) ----
    public static ulong EntityList            = 0x2711048; // dwEntityList
    public static ulong LocalPlayerPawn       = 0x255C5A8; // dwLocalPlayerPawn
    public static ulong LocalPlayerController = 0x25334D8; // dwLocalPlayerController
    public static ulong ViewMatrix            = 0x25618F0; // dwViewMatrix (4x4 float, direct read)
    public static ulong ViewAngles            = 0x2572118; // dwViewAngles (QAngle pitch/yaw/roll) - aimbot write target
    public static ulong GlobalVars            = 0x2227F08; // dwGlobalVars

    // ---- engine2.dll (unchanged across builds) ----
    public static ulong WindowWidth           = 0x91E4D8;  // dwWindowWidth
    public static ulong WindowHeight          = 0x91E4DC;  // dwWindowHeight

    // ---- netvars (from a2x/cs2-dumper client_dll.hpp) ----
    // C_BaseEntity
    public static uint Health     = 0x34C;   // m_iHealth (int32)
    public static uint MaxHealth  = 0x348;   // m_iMaxHealth
    public static uint TeamNum    = 0x3E7;   // m_iTeamNum (uint8, 2=CT 3=T)
    public static uint OldOrigin  = 0x14A4;  // m_vOldOrigin (Vector)
    public static uint GameSceneNode = 0x330;// m_pGameSceneNode (bone chain step 1)
    // CSkeletonInstance / CModelState (bone chain: scene->modelState->boneArray)
    public static uint ModelState = 0x140;   // m_modelState (ptr)
    public static uint BoneArray  = 0x80;    // m_boneArray inside CModelState (ptr)
    // C_BasePlayerPawn
    public static uint ViewOffset = 0xF60;   // m_vecViewOffset (Vector, eye height)
    public static uint EyeAngles  = 0x35F0;  // m_angEyeAngles (QAngle pitch/yaw/roll)
    public static uint WeaponServices = 0x12F0;// m_pWeaponServices (ptr)
    // CPlayer_WeaponServices
    public static uint ActiveWeapon = 0x60;  // m_hActiveWeapon (handle)
    // C_EconEntity -> C_AttributeContainer -> C_EconItemView (weapon id chain)
    public static uint AttributeManager    = 0x1290; // m_AttributeManager (ptr)
    public static uint Item                = 0x50;   // m_Item (ptr)
    public static uint ItemDefinitionIndex = 0x1BA;  // m_iItemDefinitionIndex (uint16)
    // C_CSPlayerPawn / C_CSPlayerPawnBase
    public static uint Armor         = 0x1ECC; // m_ArmorValue (int32)
    public static uint FlashDuration = 0x1510; // m_flFlashDuration (float32) - anti-flash write target
    public static uint IdEntIndex    = 0x36CC; // m_iIDEntIndex (int32, -1 = nothing) - triggerbot
    // CCSPlayerController - pawn handle. Two valid fields; Engine calibrates.
    public static uint PlayerPawn    = 0x92C; // m_hPlayerPawn (CHandle<C_CSPlayerPawn>)
    public static uint PlayerPawnAlt = 0x6BC; // m_hPawn (CHandle<C_BasePlayerPawn>) - used by reference menus
    public static uint SanitizedName = 0x878; // m_sSanitizedPlayerName (CUtlString)
    public static uint Ping          = 0x838; // m_iPing (uint32)

    // ---- entity list iteration (external scheme, 0x70 strides - current build) ----
    public const uint ListEntryBase    = 0x10;  // +0x10 per page; deref this to get page base
    public const uint ControllerStride = 0x70;  // controller stride
    public static uint PawnStride      = 0x70;  // pawn stride (was 0x78 before 2026 build)

    public const int  MaxPlayers = 64;

    // player model height (units) used to build the top of the box
    public const float PlayerHeight = 72f;
}