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)
    // C_CSPlayerPawnBase
    public static uint AimPunch    = 0x1E2C; // m_aimPunchAngle (Vector) - recoil control
    // C_CSPlayerPawn / C_CSPlayerPawnBase]]
    public static uint IsScoped    = 0x1EAC; // m_bIsScoped
    public static uint IsDefusing  = 0x1EA8; // m_bIsDefusing
    public static uint IsDefusingKit = 0x1EA9; // m_bIsDefusing with kit
    public static uint Reloading   = 0x1EA4; // m_bReloading (approx, guarded at runtime)
    public static uint HasC4       = 0x1EC4; // m_bHasC4 (CT w/ bomb) - flags ESP
    public static uint Spotted     = 0x1E9D; // m_bSpotted (C_BaseEntity)
    public static uint Flags       = 0x1EB4; // m_fFlags (bitmask: ON_GROUND 1, DUCKING 2)
    // 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)
    public static uint Account       = 0x2540;// m_iAccount (int32) - money
    // CPlayer_CameraServices (observer chain for the spectator list)
    public static uint ObserverServices = 0x1148; // m_pObserverServices (ptr)
    public static uint ObserverTarget   = 0x20;   // m_hObserverTarget (CHandle)
    public static uint ObserverMode     = 0x18;   // m_iObserverMode (int: 0=free 1=dead 2=1st 3=3rd 4=freecam)
    // C_CSWeaponBase (dropped-weapon ESP + ammo)
    public static uint Clip1             = 0x20A8; // m_iClip1
    public static uint ReserveAmmo       = 0x20B0; // m_iPrimaryReserveAmmoCount
    public static uint OwnerEntity       = 0x1C0;  // m_hOwnerEntity (CHandle<C_BaseEntity>)
    // planted bomb entity (C_PlantedC4 -> scan by class id, then read these)
    public static uint NextBombTime   = 0x1C40; // m_flNextBombTime (float global time)
    public static uint BombDefused    = 0x1C54; // m_bBombDefused
    public static byte PlantedC4ClassId = 194;  // CCSPlayerController 189 / CPlantedC4 194 (verify at runtime)

    // ---- 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;
}