├── .gitattributes ├── .gitignore ├── README.md ├── common.hpp ├── dependencies ├── controller │ ├── controller.hpp │ ├── driver.hpp │ └── memory.hpp ├── encryption │ └── xor.hpp ├── rendering │ ├── imgui │ │ ├── imconfig.h │ │ ├── imgui.cpp │ │ ├── imgui.h │ │ ├── imgui_demo.cpp │ │ ├── imgui_draw.cpp │ │ ├── imgui_impl_dx9.cpp │ │ ├── imgui_impl_dx9.h │ │ ├── imgui_impl_win32.cpp │ │ ├── imgui_impl_win32.h │ │ ├── imgui_internal.h │ │ ├── imgui_tables.cpp │ │ ├── imgui_widgets.cpp │ │ ├── imstb_rectpack.h │ │ ├── imstb_textedit.h │ │ └── imstb_truetype.h │ └── ui │ │ └── ui.hpp └── utils │ ├── math.hpp │ └── utils.hpp ├── globals.hpp ├── main.cpp ├── rust.sln ├── rust.vcxproj ├── rust.vcxproj.filters ├── rust.vcxproj.user └── sdk ├── classes ├── basemounted.hpp ├── baseplayer.hpp ├── baseprojectile.hpp ├── bone.hpp ├── camera.hpp ├── item.hpp ├── itemdefinition.hpp ├── modelstate.hpp ├── playereyes.hpp ├── playerinput.hpp ├── playermodel.hpp ├── playerwalkmovement.hpp ├── prefab.hpp └── projectile.hpp ├── game ├── aimbot.hpp ├── entity_list.hpp ├── features.hpp └── players.hpp └── offsets.hpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Rust Base 2 | A simple OOP cheat base for the video game Rust made by me a while ago, code is old and could be improved a lot, this is also outdated. 3 | -------------------------------------------------------------------------------- /common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* libraries */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | /* encryption */ 20 | #include "dependencies/encryption/xor.hpp" 21 | 22 | /* bypass */ 23 | #include "dependencies/controller/controller.hpp" 24 | 25 | /* utils */ 26 | #include "dependencies/utils/utils.hpp" 27 | #include "dependencies/utils/math.hpp" 28 | 29 | /* global */ 30 | #include "globals.hpp" 31 | 32 | /* imgui, fonts, images */ 33 | #include "dependencies/rendering/imgui/imgui.h" 34 | 35 | /* sdk */ 36 | #include "sdk/offsets.hpp" 37 | #include "sdk/classes/camera.hpp" 38 | #include "sdk/classes/prefab.hpp" 39 | #include "sdk/classes/basemounted.hpp" 40 | #include "sdk/classes/itemdefinition.hpp" 41 | #include "sdk/classes/projectile.hpp" 42 | #include "sdk/classes/baseprojectile.hpp" 43 | #include "sdk/classes/item.hpp" 44 | #include "sdk/classes/bone.hpp" 45 | #include "sdk/classes/playereyes.hpp" 46 | #include "sdk/classes/modelstate.hpp" 47 | #include "sdk/classes/playerinput.hpp" 48 | #include "sdk/classes/playermodel.hpp" 49 | #include "sdk/classes/playerwalkmovement.hpp" 50 | #include "sdk/classes/baseplayer.hpp" 51 | #include "sdk/game/players.hpp" 52 | #include "sdk/game/entity_list.hpp" 53 | #include "sdk/game/features.hpp" 54 | #include "sdk/game/aimbot.hpp" -------------------------------------------------------------------------------- /dependencies/controller/controller.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "driver.hpp" 4 | #include "memory.hpp" -------------------------------------------------------------------------------- /dependencies/controller/driver.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "controller.hpp" 3 | 4 | class driver_t 5 | { 6 | public: 7 | uintptr_t send_cmd() 8 | { 9 | return NULL; 10 | } 11 | } driver; -------------------------------------------------------------------------------- /dependencies/controller/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "controller.hpp" 3 | 4 | /* 5 | * replace with your functions 6 | */ 7 | 8 | #define STR_BUFFER_SIZE 64 9 | #define WSTR_BUFFER_SIZE 1024 10 | 11 | class memory_t 12 | { 13 | private: 14 | public: 15 | uintptr_t module_base(const char* module_name) 16 | { 17 | return NULL; 18 | } 19 | 20 | void read(uintptr_t address, void* buffer, size_t size) 21 | { 22 | return; 23 | } 24 | 25 | template 26 | t read(uintptr_t address) 27 | { 28 | t cum{}; 29 | return cum; 30 | } 31 | 32 | std::string read_str(uintptr_t address, int size = STR_BUFFER_SIZE) 33 | { 34 | std::unique_ptr buffer(new char[size]); 35 | read(address, buffer.get(), size); 36 | return std::string(buffer.get()); 37 | } 38 | 39 | std::wstring read_wstr(uintptr_t address) 40 | { 41 | wchar_t buffer[WSTR_BUFFER_SIZE * sizeof(wchar_t)]; 42 | read(address, &buffer, WSTR_BUFFER_SIZE * sizeof(wchar_t)); 43 | return std::wstring(buffer); 44 | } 45 | 46 | 47 | template 48 | t read_chain(uintptr_t address, std::vector chain) 49 | { 50 | uintptr_t cur_read = address; 51 | 52 | for (int i = 0; i < chain.size() - 1; ++i) 53 | cur_read = read(cur_read + chain[i]); 54 | 55 | return read(cur_read + chain[chain.size() - 1]); 56 | } 57 | 58 | template 59 | bool write(uintptr_t address, const v& value) 60 | { 61 | return true; 62 | } 63 | 64 | } memory; -------------------------------------------------------------------------------- /dependencies/encryption/xor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef JM_XORSTR_HPP 2 | #define JM_XORSTR_HPP 3 | 4 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 5 | #include 6 | #elif defined(_M_X64) || defined(__amd64__) || defined(_M_IX86) || defined(__i386__) 7 | #include 8 | #else 9 | #error Unsupported platform 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define __(str) ::jm::xor_string([]() { return str; }, std::integral_constant{}, std::make_index_sequence<::jm::detail::_buffer_size()>{}) 18 | 19 | // me when da xor doesnt work in da debug :( 20 | #ifndef _DEBUG 21 | #define _(str) __(str).crypt_get() 22 | #else 23 | #define _ 24 | #endif 25 | 26 | #ifdef _MSC_VER 27 | #define XORSTR_FORCEINLINE __forceinline 28 | #else 29 | #define XORSTR_FORCEINLINE __attribute__((always_inline)) inline 30 | #endif 31 | 32 | #if defined(__clang__) || defined(__GNUC__) 33 | #define JM_XORSTR_LOAD_FROM_REG(x) ::jm::detail::load_from_reg(x) 34 | #else 35 | #define JM_XORSTR_LOAD_FROM_REG(x) (x) 36 | #endif 37 | 38 | namespace jm { 39 | 40 | namespace detail { 41 | 42 | template 43 | XORSTR_FORCEINLINE constexpr std::size_t _buffer_size() 44 | { 45 | return ((Size / 16) + (Size % 16 != 0)) * 2; 46 | } 47 | 48 | template 49 | XORSTR_FORCEINLINE constexpr std::uint32_t key4() noexcept 50 | { 51 | std::uint32_t value = Seed; 52 | for (char c : __TIME__) 53 | value = static_cast((value ^ c) * 16777619ull); 54 | return value; 55 | } 56 | 57 | template 58 | XORSTR_FORCEINLINE constexpr std::uint64_t key8() 59 | { 60 | constexpr auto first_part = key4<2166136261 + S>(); 61 | constexpr auto second_part = key4(); 62 | return (static_cast(first_part) << 32) | second_part; 63 | } 64 | 65 | // loads up to 8 characters of string into uint64 and xors it with the key 66 | template 67 | XORSTR_FORCEINLINE constexpr std::uint64_t 68 | load_xored_str8(std::uint64_t key, std::size_t idx, const CharT* str) noexcept 69 | { 70 | using cast_type = typename std::make_unsigned::type; 71 | constexpr auto value_size = sizeof(CharT); 72 | constexpr auto idx_offset = 8 / value_size; 73 | 74 | std::uint64_t value = key; 75 | for (std::size_t i = 0; i < idx_offset && i + idx * idx_offset < N; ++i) 76 | value ^= 77 | (std::uint64_t{ static_cast(str[i + idx * idx_offset]) } 78 | << ((i % idx_offset) * 8 * value_size)); 79 | 80 | return value; 81 | } 82 | 83 | // forces compiler to use registers instead of stuffing constants in rdata 84 | XORSTR_FORCEINLINE std::uint64_t load_from_reg(std::uint64_t value) noexcept 85 | { 86 | #if defined(__clang__) || defined(__GNUC__) 87 | asm("" : "=r"(value) : "0"(value) : ); 88 | #endif 89 | return value; 90 | } 91 | 92 | template 93 | struct uint64_v { 94 | constexpr static std::uint64_t value = V; 95 | }; 96 | 97 | } // namespace detail 98 | 99 | template 100 | class xor_string; 101 | 102 | template 103 | class xor_string, std::index_sequence> { 104 | #ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS 105 | constexpr static inline std::uint64_t alignment = ((Size > 16) ? 32 : 16); 106 | #else 107 | constexpr static inline std::uint64_t alignment = 16; 108 | #endif 109 | 110 | alignas(alignment) std::uint64_t _storage[sizeof...(Keys)]; 111 | 112 | public: 113 | using value_type = CharT; 114 | using size_type = std::size_t; 115 | using pointer = CharT*; 116 | using const_pointer = const CharT*; 117 | 118 | template 119 | XORSTR_FORCEINLINE xor_string(L l, std::integral_constant, std::index_sequence) noexcept 120 | : _storage{ JM_XORSTR_LOAD_FROM_REG(detail::uint64_v(Keys, Indices, l())>::value)... } 121 | {} 122 | 123 | XORSTR_FORCEINLINE constexpr size_type size() const noexcept 124 | { 125 | return Size - 1; 126 | } 127 | 128 | XORSTR_FORCEINLINE void crypt() noexcept 129 | { 130 | // everything is inlined by hand because a certain compiler with a certain linker is _very_ slow 131 | #if defined(__clang__) 132 | alignas(alignment) 133 | std::uint64_t arr[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... }; 134 | std::uint64_t* keys = 135 | (std::uint64_t*)JM_XORSTR_LOAD_FROM_REG((std::uint64_t)arr); 136 | #else 137 | alignas(alignment) std::uint64_t keys[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... }; 138 | #endif 139 | 140 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 141 | #if defined(__clang__) 142 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v( 143 | reinterpret_cast(_storage) + Indices * 2, 144 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51), 145 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)), 146 | 51)), ...); 147 | #else // GCC, MSVC 148 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64( 149 | reinterpret_cast(_storage) + Indices * 2, 150 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2), 151 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...); 152 | #endif 153 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS) 154 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256( 155 | reinterpret_cast<__m256i*>(_storage) + Indices, 156 | _mm256_xor_si256( 157 | _mm256_load_si256(reinterpret_cast(_storage) + Indices), 158 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...); 159 | 160 | if constexpr (sizeof(_storage) % 32 != 0) 161 | _mm_store_si128( 162 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2), 163 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)), 164 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2)))); 165 | #else 166 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128( 167 | reinterpret_cast<__m128i*>(_storage) + Indices, 168 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices), 169 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...); 170 | #endif 171 | } 172 | 173 | XORSTR_FORCEINLINE const_pointer get() const noexcept 174 | { 175 | return reinterpret_cast(_storage); 176 | } 177 | 178 | XORSTR_FORCEINLINE pointer get() noexcept 179 | { 180 | return reinterpret_cast(_storage); 181 | } 182 | 183 | XORSTR_FORCEINLINE pointer crypt_get() noexcept 184 | { 185 | // crypt() is inlined by hand because a certain compiler with a certain linker is _very_ slow 186 | #if defined(__clang__) 187 | alignas(alignment) 188 | std::uint64_t arr[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... }; 189 | std::uint64_t* keys = 190 | (std::uint64_t*)JM_XORSTR_LOAD_FROM_REG((std::uint64_t)arr); 191 | #else 192 | alignas(alignment) std::uint64_t keys[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... }; 193 | #endif 194 | 195 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 196 | #if defined(__clang__) 197 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v( 198 | reinterpret_cast(_storage) + Indices * 2, 199 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51), 200 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)), 201 | 51)), ...); 202 | #else // GCC, MSVC 203 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64( 204 | reinterpret_cast(_storage) + Indices * 2, 205 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2), 206 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...); 207 | #endif 208 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS) 209 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256( 210 | reinterpret_cast<__m256i*>(_storage) + Indices, 211 | _mm256_xor_si256( 212 | _mm256_load_si256(reinterpret_cast(_storage) + Indices), 213 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...); 214 | 215 | if constexpr (sizeof(_storage) % 32 != 0) 216 | _mm_store_si128( 217 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2), 218 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)), 219 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2)))); 220 | #else 221 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128( 222 | reinterpret_cast<__m128i*>(_storage) + Indices, 223 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices), 224 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...); 225 | #endif 226 | 227 | return (pointer)(_storage); 228 | } 229 | }; 230 | 231 | #ifndef _DEBUG 232 | template 233 | xor_string(L l, std::integral_constant, std::index_sequence)->xor_string< 234 | std::remove_const_t>, 235 | Size, 236 | std::integer_sequence()...>, 237 | std::index_sequence>; 238 | #endif 239 | 240 | } // namespace jm 241 | 242 | #endif // include guard 243 | 244 | 245 | /* credits github.com/obama-gaming */ 246 | #define _f(n) xor_float::convert(n) 247 | namespace xor_float 248 | { 249 | constexpr uint32_t gen_key() 250 | { 251 | return (~(__TIME__[0] * 0xa24a7c) ^ 252 | 0xcfc9 ^ 253 | (__TIME__[4] * 0x5a99) ^ 254 | 0x57f3aaa9 ^ 255 | ~(__TIME__[6] * 0x84575a) ^ 256 | 0x51f6 ^ 257 | (__TIME__[3] * 0x1cd2) ^ 258 | 0x7dee4b90 ^ 259 | ~(__TIME__[7] * 0x38ab64) ^ 260 | 0x661198b); 261 | } 262 | 263 | constexpr uint32_t xor_key = gen_key(); 264 | __forceinline float convert_back(const uint32_t val) 265 | { 266 | const auto xor_key_m128 = _mm_castsi128_ps(_mm_cvtsi32_si128(xor_key)); 267 | const auto val_m128 = _mm_castsi128_ps(_mm_cvtsi32_si128(val)); 268 | const auto xored_val_m128 = _mm_xor_ps(val_m128, xor_key_m128); 269 | return _mm_cvtss_f32(xored_val_m128); 270 | } 271 | __forceinline float convert(float val) 272 | { 273 | uint32_t cache; 274 | reinterpret_cast(cache) = val; 275 | cache ^= xor_key; 276 | return xor_float::convert_back(cache); 277 | } 278 | } -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | 32 | //---- Disable all of Dear ImGui or don't implement standard windows. 33 | // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. 34 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 35 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. 36 | //#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty. 37 | 38 | //---- Don't implement some functions to reduce linkage requirements. 39 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a) 41 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 42 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 43 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 44 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 45 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 46 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 47 | 48 | //---- Include imgui_user.h at the end of imgui.h as a convenience 49 | //#define IMGUI_INCLUDE_IMGUI_USER_H 50 | 51 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 52 | //#define IMGUI_USE_BGRA_PACKED_COLOR 53 | 54 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 55 | //#define IMGUI_USE_WCHAR32 56 | 57 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 58 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 59 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 60 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 61 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 62 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 63 | 64 | //---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 65 | // Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. 66 | // #define IMGUI_USE_STB_SPRINTF 67 | 68 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 69 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 70 | // On Windows you may use vcpkg with 'vcpkg install freetype' + 'vcpkg integrate install'. 71 | //#define IMGUI_ENABLE_FREETYPE 72 | 73 | //---- Use stb_truetype to build and rasterize the font atlas (default) 74 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 75 | //#define IMGUI_ENABLE_STB_TRUETYPE 76 | 77 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 78 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 79 | /* 80 | #define IM_VEC2_CLASS_EXTRA \ 81 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 82 | operator MyVec2() const { return MyVec2(x,y); } 83 | 84 | #define IM_VEC4_CLASS_EXTRA \ 85 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 86 | operator MyVec4() const { return MyVec4(x,y,z,w); } 87 | */ 88 | 89 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 90 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 91 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 92 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 93 | //#define ImDrawIdx unsigned int 94 | 95 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 96 | //struct ImDrawList; 97 | //struct ImDrawCmd; 98 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 99 | //#define ImDrawCallback MyImDrawCallback 100 | 101 | //---- Debug Tools: Macro to break in Debugger 102 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 103 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 104 | //#define IM_DEBUG_BREAK __debugbreak() 105 | 106 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), 107 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) 108 | // This adds a small runtime cost which is why it is not enabled by default. 109 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX 110 | 111 | //---- Debug Tools: Enable slower asserts 112 | //#define IMGUI_DEBUG_PARANOID 113 | 114 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 115 | /* 116 | namespace ImGui 117 | { 118 | void MyFunction(const char* name, const MyMatrix44& v); 119 | } 120 | */ 121 | -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imgui_demo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krispybyte/Simple-Rust-Base/aa05115b0614cfaef73afe1022c77ecc3860ebc5/dependencies/rendering/imgui/imgui_demo.cpp -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imgui_impl_dx9.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | // CHANGELOG 13 | // (minor and older changes stripped away, please see git history for details) 14 | // 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857). 15 | // 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file. 16 | // 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer. 17 | // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. 18 | // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. 19 | // 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). 20 | // 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. 21 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 22 | // 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. 23 | // 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 24 | // 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. 25 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. 26 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 27 | 28 | #include "imgui.h" 29 | #include "imgui_impl_dx9.h" 30 | 31 | // DirectX 32 | #include 33 | 34 | // DirectX data 35 | static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; 36 | static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; 37 | static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; 38 | static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; 39 | static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; 40 | 41 | struct CUSTOMVERTEX 42 | { 43 | float pos[3]; 44 | D3DCOLOR col; 45 | float uv[2]; 46 | }; 47 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) 48 | 49 | #ifdef IMGUI_USE_BGRA_PACKED_COLOR 50 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (_COL) 51 | #else 52 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16)) 53 | #endif 54 | 55 | static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) 56 | { 57 | // Setup viewport 58 | D3DVIEWPORT9 vp; 59 | vp.X = vp.Y = 0; 60 | vp.Width = (DWORD)draw_data->DisplaySize.x; 61 | vp.Height = (DWORD)draw_data->DisplaySize.y; 62 | vp.MinZ = 0.0f; 63 | vp.MaxZ = 1.0f; 64 | g_pd3dDevice->SetViewport(&vp); 65 | 66 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) 67 | g_pd3dDevice->SetPixelShader(NULL); 68 | g_pd3dDevice->SetVertexShader(NULL); 69 | g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 70 | g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 71 | g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); 72 | g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); 73 | g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); 74 | g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); 75 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); 76 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 77 | g_pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); 78 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); 79 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); 80 | g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); 81 | g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 82 | g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 83 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); 84 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); 85 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); 86 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); 87 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); 88 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); 89 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); 90 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); 91 | 92 | // Setup orthographic projection matrix 93 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. 94 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() 95 | { 96 | float L = draw_data->DisplayPos.x + 0.5f; 97 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; 98 | float T = draw_data->DisplayPos.y + 0.5f; 99 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; 100 | D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; 101 | D3DMATRIX mat_projection = 102 | { { { 103 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f, 104 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f, 105 | 0.0f, 0.0f, 0.5f, 0.0f, 106 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f 107 | } } }; 108 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); 109 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); 110 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); 111 | } 112 | } 113 | 114 | // Render function. 115 | void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) 116 | { 117 | // Avoid rendering when minimized 118 | if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) 119 | return; 120 | 121 | // Create and grow buffers if needed 122 | if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) 123 | { 124 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 125 | g_VertexBufferSize = draw_data->TotalVtxCount + 5000; 126 | if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) 127 | return; 128 | } 129 | if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) 130 | { 131 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 132 | g_IndexBufferSize = draw_data->TotalIdxCount + 10000; 133 | if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) 134 | return; 135 | } 136 | 137 | // Backup the DX9 state 138 | IDirect3DStateBlock9* d3d9_state_block = NULL; 139 | if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) 140 | return; 141 | if (d3d9_state_block->Capture() < 0) 142 | { 143 | d3d9_state_block->Release(); 144 | return; 145 | } 146 | 147 | // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) 148 | D3DMATRIX last_world, last_view, last_projection; 149 | g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); 150 | g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); 151 | g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); 152 | 153 | // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. 154 | // FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and 155 | // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR 156 | // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } 157 | CUSTOMVERTEX* vtx_dst; 158 | ImDrawIdx* idx_dst; 159 | if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) 160 | return; 161 | if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) 162 | return; 163 | for (int n = 0; n < draw_data->CmdListsCount; n++) 164 | { 165 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 166 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; 167 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) 168 | { 169 | vtx_dst->pos[0] = vtx_src->pos.x; 170 | vtx_dst->pos[1] = vtx_src->pos.y; 171 | vtx_dst->pos[2] = 0.0f; 172 | vtx_dst->col = IMGUI_COL_TO_DX9_ARGB(vtx_src->col); 173 | vtx_dst->uv[0] = vtx_src->uv.x; 174 | vtx_dst->uv[1] = vtx_src->uv.y; 175 | vtx_dst++; 176 | vtx_src++; 177 | } 178 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); 179 | idx_dst += cmd_list->IdxBuffer.Size; 180 | } 181 | g_pVB->Unlock(); 182 | g_pIB->Unlock(); 183 | g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); 184 | g_pd3dDevice->SetIndices(g_pIB); 185 | g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); 186 | 187 | // Setup desired DX state 188 | ImGui_ImplDX9_SetupRenderState(draw_data); 189 | 190 | // Render command lists 191 | // (Because we merged all buffers into a single one, we maintain our own offset into them) 192 | int global_vtx_offset = 0; 193 | int global_idx_offset = 0; 194 | ImVec2 clip_off = draw_data->DisplayPos; 195 | for (int n = 0; n < draw_data->CmdListsCount; n++) 196 | { 197 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 198 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 199 | { 200 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 201 | if (pcmd->UserCallback != NULL) 202 | { 203 | // User callback, registered via ImDrawList::AddCallback() 204 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) 205 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) 206 | ImGui_ImplDX9_SetupRenderState(draw_data); 207 | else 208 | pcmd->UserCallback(cmd_list, pcmd); 209 | } 210 | else 211 | { 212 | const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; 213 | const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId; 214 | g_pd3dDevice->SetTexture(0, texture); 215 | g_pd3dDevice->SetScissorRect(&r); 216 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); 217 | } 218 | } 219 | global_idx_offset += cmd_list->IdxBuffer.Size; 220 | global_vtx_offset += cmd_list->VtxBuffer.Size; 221 | } 222 | 223 | // Restore the DX9 transform 224 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); 225 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); 226 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); 227 | 228 | // Restore the DX9 state 229 | d3d9_state_block->Apply(); 230 | d3d9_state_block->Release(); 231 | } 232 | 233 | bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) 234 | { 235 | // Setup backend capabilities flags 236 | ImGuiIO& io = ImGui::GetIO(); 237 | io.BackendRendererName = "imgui_impl_dx9"; 238 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. 239 | 240 | g_pd3dDevice = device; 241 | g_pd3dDevice->AddRef(); 242 | return true; 243 | } 244 | 245 | void ImGui_ImplDX9_Shutdown() 246 | { 247 | ImGui_ImplDX9_InvalidateDeviceObjects(); 248 | if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } 249 | } 250 | 251 | static bool ImGui_ImplDX9_CreateFontsTexture() 252 | { 253 | // Build texture atlas 254 | ImGuiIO& io = ImGui::GetIO(); 255 | unsigned char* pixels; 256 | int width, height, bytes_per_pixel; 257 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); 258 | 259 | // Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices) 260 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 261 | if (io.Fonts->TexPixelsUseColors) 262 | { 263 | ImU32* dst_start = (ImU32*)ImGui::MemAlloc(width * height * bytes_per_pixel); 264 | for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + width * height; dst < dst_end; src++, dst++) 265 | *dst = IMGUI_COL_TO_DX9_ARGB(*src); 266 | pixels = (unsigned char*)dst_start; 267 | } 268 | #endif 269 | 270 | // Upload texture to graphics system 271 | g_FontTexture = NULL; 272 | if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) 273 | return false; 274 | D3DLOCKED_RECT tex_locked_rect; 275 | if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) 276 | return false; 277 | for (int y = 0; y < height; y++) 278 | memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); 279 | g_FontTexture->UnlockRect(0); 280 | 281 | // Store our identifier 282 | io.Fonts->SetTexID((ImTextureID)g_FontTexture); 283 | 284 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 285 | if (io.Fonts->TexPixelsUseColors) 286 | ImGui::MemFree(pixels); 287 | #endif 288 | 289 | return true; 290 | } 291 | 292 | bool ImGui_ImplDX9_CreateDeviceObjects() 293 | { 294 | if (!g_pd3dDevice) 295 | return false; 296 | if (!ImGui_ImplDX9_CreateFontsTexture()) 297 | return false; 298 | return true; 299 | } 300 | 301 | void ImGui_ImplDX9_InvalidateDeviceObjects() 302 | { 303 | if (!g_pd3dDevice) 304 | return; 305 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 306 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 307 | if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. 308 | } 309 | 310 | void ImGui_ImplDX9_NewFrame() 311 | { 312 | if (!g_FontTexture) 313 | ImGui_ImplDX9_CreateDeviceObjects(); 314 | } 315 | -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct IDirect3DDevice9; 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 18 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 21 | 22 | // Use if you want to reset your rendering device without losing Dear ImGui state. 23 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 24 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 25 | -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imgui_impl_win32.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #include "imgui.h" 15 | #include "imgui_impl_win32.h" 16 | #ifndef WIN32_LEAN_AND_MEAN 17 | #define WIN32_LEAN_AND_MEAN 18 | #endif 19 | #include 20 | #include 21 | #include 22 | 23 | // Configuration flags to add in your imconfig.h file: 24 | //#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support (this used to be meaningful before <1.81) but we know load XInput dynamically so the option is less relevant now. 25 | 26 | // Using XInput for gamepad (will load DLL dynamically) 27 | #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 28 | #include 29 | typedef DWORD (WINAPI *PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*); 30 | typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*); 31 | #endif 32 | 33 | // CHANGELOG 34 | // (minor and older changes stripped away, please see git history for details) 35 | // 2021-02-18: Added ImGui_ImplWin32_EnableAlphaCompositing(). Non Visual Studio users will need to link with dwmapi.lib (MinGW/gcc: use -ldwmapi). 36 | // 2021-02-17: Fixed ImGui_ImplWin32_EnableDpiAwareness() attempting to get SetProcessDpiAwareness from shcore.dll on Windows 8 whereas it is only supported on Windows 8.1. 37 | // 2021-01-25: Inputs: Dynamically loading XInput DLL. 38 | // 2020-12-04: Misc: Fixed setting of io.DisplaySize to invalid/uninitialized data when after hwnd has been closed. 39 | // 2020-03-03: Inputs: Calling AddInputCharacterUTF16() to support surrogate pairs leading to codepoint >= 0x10000 (for more complete CJK inputs) 40 | // 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions. 41 | // 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT. 42 | // 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. 43 | // 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter(). 44 | // 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. 45 | // 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. 46 | // 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application). 47 | // 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. 48 | // 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. 49 | // 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads). 50 | // 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples. 51 | // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag. 52 | // 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). 53 | // 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. 54 | // 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set). 55 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 56 | // 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. 57 | // 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert. 58 | // 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag. 59 | // 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read. 60 | // 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging. 61 | // 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set. 62 | 63 | // Win32 Data 64 | static HWND g_hWnd = NULL; 65 | static INT64 g_Time = 0; 66 | static INT64 g_TicksPerSecond = 0; 67 | static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT; 68 | static bool g_HasGamepad = false; 69 | static bool g_WantUpdateHasGamepad = true; 70 | 71 | // XInput DLL and functions 72 | #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 73 | static HMODULE g_XInputDLL = NULL; 74 | static PFN_XInputGetCapabilities g_XInputGetCapabilities = NULL; 75 | static PFN_XInputGetState g_XInputGetState = NULL; 76 | #endif 77 | 78 | // Functions 79 | bool ImGui_ImplWin32_Init(void* hwnd) 80 | { 81 | if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&g_TicksPerSecond)) 82 | return false; 83 | if (!::QueryPerformanceCounter((LARGE_INTEGER*)&g_Time)) 84 | return false; 85 | 86 | // Setup backend capabilities flags 87 | g_hWnd = (HWND)hwnd; 88 | ImGuiIO& io = ImGui::GetIO(); 89 | io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) 90 | io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) 91 | io.BackendPlatformName = "imgui_impl_win32"; 92 | io.ImeWindowHandle = hwnd; 93 | 94 | // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime. 95 | io.KeyMap[ImGuiKey_Tab] = VK_TAB; 96 | io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; 97 | io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; 98 | io.KeyMap[ImGuiKey_UpArrow] = VK_UP; 99 | io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; 100 | io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR; 101 | io.KeyMap[ImGuiKey_PageDown] = VK_NEXT; 102 | io.KeyMap[ImGuiKey_Home] = VK_HOME; 103 | io.KeyMap[ImGuiKey_End] = VK_END; 104 | io.KeyMap[ImGuiKey_Insert] = VK_INSERT; 105 | io.KeyMap[ImGuiKey_Delete] = VK_DELETE; 106 | io.KeyMap[ImGuiKey_Backspace] = VK_BACK; 107 | io.KeyMap[ImGuiKey_Space] = VK_SPACE; 108 | io.KeyMap[ImGuiKey_Enter] = VK_RETURN; 109 | io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; 110 | io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN; 111 | io.KeyMap[ImGuiKey_A] = 'A'; 112 | io.KeyMap[ImGuiKey_C] = 'C'; 113 | io.KeyMap[ImGuiKey_V] = 'V'; 114 | io.KeyMap[ImGuiKey_X] = 'X'; 115 | io.KeyMap[ImGuiKey_Y] = 'Y'; 116 | io.KeyMap[ImGuiKey_Z] = 'Z'; 117 | 118 | // Dynamically load XInput library 119 | #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 120 | const char* xinput_dll_names[] = 121 | { 122 | "xinput1_4.dll", // Windows 8+ 123 | "xinput1_3.dll", // DirectX SDK 124 | "xinput9_1_0.dll", // Windows Vista, Windows 7 125 | "xinput1_2.dll", // DirectX SDK 126 | "xinput1_1.dll" // DirectX SDK 127 | }; 128 | for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++) 129 | if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n])) 130 | { 131 | g_XInputDLL = dll; 132 | g_XInputGetCapabilities = (PFN_XInputGetCapabilities)::GetProcAddress(dll, "XInputGetCapabilities"); 133 | g_XInputGetState = (PFN_XInputGetState)::GetProcAddress(dll, "XInputGetState"); 134 | break; 135 | } 136 | #endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 137 | 138 | return true; 139 | } 140 | 141 | void ImGui_ImplWin32_Shutdown() 142 | { 143 | // Unload XInput library 144 | #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 145 | if (g_XInputDLL) 146 | ::FreeLibrary(g_XInputDLL); 147 | g_XInputDLL = NULL; 148 | g_XInputGetCapabilities = NULL; 149 | g_XInputGetState = NULL; 150 | #endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 151 | 152 | g_hWnd = NULL; 153 | g_Time = 0; 154 | g_TicksPerSecond = 0; 155 | g_LastMouseCursor = ImGuiMouseCursor_COUNT; 156 | g_HasGamepad = false; 157 | g_WantUpdateHasGamepad = true; 158 | } 159 | 160 | static bool ImGui_ImplWin32_UpdateMouseCursor() 161 | { 162 | ImGuiIO& io = ImGui::GetIO(); 163 | if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) 164 | return false; 165 | 166 | ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); 167 | if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) 168 | { 169 | // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor 170 | ::SetCursor(NULL); 171 | } 172 | else 173 | { 174 | // Show OS mouse cursor 175 | LPTSTR win32_cursor = IDC_ARROW; 176 | switch (imgui_cursor) 177 | { 178 | case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break; 179 | case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break; 180 | case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break; 181 | case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break; 182 | case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break; 183 | case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break; 184 | case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break; 185 | case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break; 186 | case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break; 187 | } 188 | ::SetCursor(::LoadCursor(NULL, win32_cursor)); 189 | } 190 | return true; 191 | } 192 | 193 | static void ImGui_ImplWin32_UpdateMousePos() 194 | { 195 | ImGuiIO& io = ImGui::GetIO(); 196 | IM_ASSERT(g_hWnd != 0); 197 | 198 | // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) 199 | if (io.WantSetMousePos) 200 | { 201 | POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y }; 202 | if (::ClientToScreen(g_hWnd, &pos)) 203 | ::SetCursorPos(pos.x, pos.y); 204 | } 205 | 206 | // Set mouse position 207 | io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); 208 | POINT pos; 209 | if (HWND active_window = ::GetForegroundWindow()) 210 | if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd)) 211 | if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos)) 212 | io.MousePos = ImVec2((float)pos.x, (float)pos.y); 213 | } 214 | 215 | // Gamepad navigation mapping 216 | static void ImGui_ImplWin32_UpdateGamepads() 217 | { 218 | #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 219 | ImGuiIO& io = ImGui::GetIO(); 220 | memset(io.NavInputs, 0, sizeof(io.NavInputs)); 221 | if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) 222 | return; 223 | 224 | // Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow. 225 | // Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE. 226 | if (g_WantUpdateHasGamepad) 227 | { 228 | XINPUT_CAPABILITIES caps; 229 | g_HasGamepad = g_XInputGetCapabilities ? (g_XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false; 230 | g_WantUpdateHasGamepad = false; 231 | } 232 | 233 | io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; 234 | XINPUT_STATE xinput_state; 235 | if (g_HasGamepad && g_XInputGetState && g_XInputGetState(0, &xinput_state) == ERROR_SUCCESS) 236 | { 237 | const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad; 238 | io.BackendFlags |= ImGuiBackendFlags_HasGamepad; 239 | 240 | #define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; } 241 | #define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; } 242 | MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A 243 | MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B 244 | MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X 245 | MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y 246 | MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left 247 | MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right 248 | MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up 249 | MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down 250 | MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB 251 | MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB 252 | MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB 253 | MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB 254 | MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768); 255 | MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); 256 | MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); 257 | MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767); 258 | #undef MAP_BUTTON 259 | #undef MAP_ANALOG 260 | } 261 | #endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 262 | } 263 | 264 | void ImGui_ImplWin32_NewFrame() 265 | { 266 | ImGuiIO& io = ImGui::GetIO(); 267 | IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); 268 | 269 | // Setup display size (every frame to accommodate for window resizing) 270 | RECT rect = { 0, 0, 0, 0 }; 271 | ::GetClientRect(g_hWnd, &rect); 272 | io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); 273 | 274 | // Setup time step 275 | INT64 current_time = 0; 276 | ::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time); 277 | io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond; 278 | g_Time = current_time; 279 | 280 | // Read keyboard modifiers inputs 281 | io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; 282 | io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; 283 | io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0; 284 | io.KeySuper = false; 285 | // io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below. 286 | 287 | // Update OS mouse position 288 | ImGui_ImplWin32_UpdateMousePos(); 289 | 290 | // Update OS mouse cursor with the cursor requested by imgui 291 | ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); 292 | if (g_LastMouseCursor != mouse_cursor) 293 | { 294 | g_LastMouseCursor = mouse_cursor; 295 | ImGui_ImplWin32_UpdateMouseCursor(); 296 | } 297 | 298 | // Update game controllers (if enabled and available) 299 | ImGui_ImplWin32_UpdateGamepads(); 300 | } 301 | 302 | // Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions. 303 | #ifndef WM_MOUSEHWHEEL 304 | #define WM_MOUSEHWHEEL 0x020E 305 | #endif 306 | #ifndef DBT_DEVNODES_CHANGED 307 | #define DBT_DEVNODES_CHANGED 0x0007 308 | #endif 309 | 310 | // Win32 message handler (process Win32 mouse/keyboard inputs, etc.) 311 | // Call from your application's message handler. 312 | // When implementing your own backend, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs. 313 | // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. 314 | // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. 315 | // Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags. 316 | // PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds. 317 | // PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. 318 | #if 0 319 | // Copy this line into your .cpp file to forward declare the function. 320 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 321 | #endif 322 | IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 323 | { 324 | if (ImGui::GetCurrentContext() == NULL) 325 | return 0; 326 | 327 | ImGuiIO& io = ImGui::GetIO(); 328 | switch (msg) 329 | { 330 | case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: 331 | case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: 332 | case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: 333 | case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: 334 | { 335 | int button = 0; 336 | if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; } 337 | if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; } 338 | if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; } 339 | if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } 340 | if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL) 341 | ::SetCapture(hwnd); 342 | io.MouseDown[button] = true; 343 | return 0; 344 | } 345 | case WM_LBUTTONUP: 346 | case WM_RBUTTONUP: 347 | case WM_MBUTTONUP: 348 | case WM_XBUTTONUP: 349 | { 350 | int button = 0; 351 | if (msg == WM_LBUTTONUP) { button = 0; } 352 | if (msg == WM_RBUTTONUP) { button = 1; } 353 | if (msg == WM_MBUTTONUP) { button = 2; } 354 | if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } 355 | io.MouseDown[button] = false; 356 | if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd) 357 | ::ReleaseCapture(); 358 | return 0; 359 | } 360 | case WM_MOUSEWHEEL: 361 | io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; 362 | return 0; 363 | case WM_MOUSEHWHEEL: 364 | io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; 365 | return 0; 366 | case WM_KEYDOWN: 367 | case WM_SYSKEYDOWN: 368 | if (wParam < 256) 369 | io.KeysDown[wParam] = 1; 370 | return 0; 371 | case WM_KEYUP: 372 | case WM_SYSKEYUP: 373 | if (wParam < 256) 374 | io.KeysDown[wParam] = 0; 375 | return 0; 376 | case WM_CHAR: 377 | // You can also use ToAscii()+GetKeyboardState() to retrieve characters. 378 | if (wParam > 0 && wParam < 0x10000) 379 | io.AddInputCharacterUTF16((unsigned short)wParam); 380 | return 0; 381 | case WM_SETCURSOR: 382 | if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) 383 | return 1; 384 | return 0; 385 | case WM_DEVICECHANGE: 386 | if ((UINT)wParam == DBT_DEVNODES_CHANGED) 387 | g_WantUpdateHasGamepad = true; 388 | return 0; 389 | } 390 | return 0; 391 | } 392 | 393 | 394 | //-------------------------------------------------------------------------------------------------------- 395 | // DPI-related helpers (optional) 396 | //-------------------------------------------------------------------------------------------------------- 397 | // - Use to enable DPI awareness without having to create an application manifest. 398 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 399 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 400 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 401 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 402 | //--------------------------------------------------------------------------------------------------------- 403 | // This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable. 404 | // ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically. 405 | // If you are trying to implement your own backend for your own engine, you may ignore that noise. 406 | //--------------------------------------------------------------------------------------------------------- 407 | 408 | // Implement some of the functions and types normally declared in recent Windows SDK. 409 | #if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS) 410 | static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp) 411 | { 412 | OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp, 0, 0, 0, 0 }; 413 | DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR; 414 | ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL); 415 | cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); 416 | cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); 417 | return ::VerifyVersionInfoW(&osvi, mask, cond); 418 | } 419 | #define IsWindowsVistaOrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0600), LOBYTE(0x0600), 0) // _WIN32_WINNT_VISTA 420 | #define IsWindows8OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WIN8 421 | #define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0603), LOBYTE(0x0603), 0) // _WIN32_WINNT_WINBLUE 422 | #endif 423 | 424 | #ifndef DPI_ENUMS_DECLARED 425 | typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS; 426 | typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE; 427 | #endif 428 | #ifndef _DPI_AWARENESS_CONTEXTS_ 429 | DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); 430 | #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (DPI_AWARENESS_CONTEXT)-3 431 | #endif 432 | #ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 433 | #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4 434 | #endif 435 | typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+ 436 | typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+ 437 | typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update) 438 | 439 | // Helper function to enable DPI awareness without setting up a manifest 440 | void ImGui_ImplWin32_EnableDpiAwareness() 441 | { 442 | // if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer! 443 | { 444 | static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process 445 | if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext")) 446 | { 447 | SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); 448 | return; 449 | } 450 | } 451 | if (IsWindows8Point1OrGreater()) 452 | { 453 | static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process 454 | if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness")) 455 | { 456 | SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE); 457 | return; 458 | } 459 | } 460 | #if _WIN32_WINNT >= 0x0600 461 | ::SetProcessDPIAware(); 462 | #endif 463 | } 464 | 465 | #if defined(_MSC_VER) && !defined(NOGDI) 466 | #pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps(). MinGW will require linking with '-lgdi32' 467 | #endif 468 | 469 | float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor) 470 | { 471 | UINT xdpi = 96, ydpi = 96; 472 | static BOOL bIsWindows8Point1OrGreater = IsWindows8Point1OrGreater(); 473 | if (bIsWindows8Point1OrGreater) 474 | { 475 | static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process 476 | if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor")) 477 | GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); 478 | } 479 | #ifndef NOGDI 480 | else 481 | { 482 | const HDC dc = ::GetDC(NULL); 483 | xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); 484 | ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); 485 | ::ReleaseDC(NULL, dc); 486 | } 487 | #endif 488 | IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! 489 | return xdpi / 96.0f; 490 | } 491 | 492 | float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd) 493 | { 494 | HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST); 495 | return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor); 496 | } 497 | 498 | //--------------------------------------------------------------------------------------------------------- 499 | // Transparency related helpers (optional) 500 | //-------------------------------------------------------------------------------------------------------- 501 | 502 | #if defined(_MSC_VER) 503 | #pragma comment(lib, "dwmapi") // Link with dwmapi.lib. MinGW will require linking with '-ldwmapi' 504 | #endif 505 | 506 | // [experimental] 507 | // Borrowed from GLFW's function updateFramebufferTransparency() in src/win32_window.c 508 | // (the Dwm* functions are Vista era functions but we are borrowing logic from GLFW) 509 | void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd) 510 | { 511 | if (!IsWindowsVistaOrGreater()) 512 | return; 513 | 514 | BOOL composition; 515 | if (FAILED(::DwmIsCompositionEnabled(&composition)) || !composition) 516 | return; 517 | 518 | BOOL opaque; 519 | DWORD color; 520 | if (IsWindows8OrGreater() || (SUCCEEDED(::DwmGetColorizationColor(&color, &opaque)) && !opaque)) 521 | { 522 | HRGN region = ::CreateRectRgn(0, 0, -1, -1); 523 | DWM_BLURBEHIND bb = {}; 524 | bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; 525 | bb.hRgnBlur = region; 526 | bb.fEnable = TRUE; 527 | ::DwmEnableBlurBehindWindow((HWND)hwnd, &bb); 528 | ::DeleteObject(region); 529 | } 530 | else 531 | { 532 | DWM_BLURBEHIND bb = {}; 533 | bb.dwFlags = DWM_BB_ENABLE; 534 | ::DwmEnableBlurBehindWindow((HWND)hwnd, &bb); 535 | } 536 | } 537 | 538 | //--------------------------------------------------------------------------------------------------------- 539 | -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #pragma once 15 | #include "imgui.h" // IMGUI_IMPL_API 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 18 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 20 | 21 | // Win32 message handler your application need to call. 22 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 23 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 24 | #if 0 25 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 26 | #endif 27 | 28 | // DPI-related helpers (optional) 29 | // - Use to enable DPI awareness without having to create an application manifest. 30 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 31 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 32 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 33 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 34 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 35 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 36 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 37 | 38 | // Transparency related helpers (optional) [experimental] 39 | // - Use to enable alpha compositing transparency with the desktop. 40 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 41 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 42 | -------------------------------------------------------------------------------- /dependencies/rendering/imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.00. 3 | // Those changes would need to be pushed into nothings/stb: 4 | // - Added STBRP__CDECL 5 | // Grep for [DEAR IMGUI] to find the changes. 6 | 7 | // stb_rect_pack.h - v1.00 - public domain - rectangle packing 8 | // Sean Barrett 2014 9 | // 10 | // Useful for e.g. packing rectangular textures into an atlas. 11 | // Does not do rotation. 12 | // 13 | // Not necessarily the awesomest packing method, but better than 14 | // the totally naive one in stb_truetype (which is primarily what 15 | // this is meant to replace). 16 | // 17 | // Has only had a few tests run, may have issues. 18 | // 19 | // More docs to come. 20 | // 21 | // No memory allocations; uses qsort() and assert() from stdlib. 22 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 23 | // 24 | // This library currently uses the Skyline Bottom-Left algorithm. 25 | // 26 | // Please note: better rectangle packers are welcome! Please 27 | // implement them to the same API, but with a different init 28 | // function. 29 | // 30 | // Credits 31 | // 32 | // Library 33 | // Sean Barrett 34 | // Minor features 35 | // Martins Mozeiko 36 | // github:IntellectualKitty 37 | // 38 | // Bugfixes / warning fixes 39 | // Jeremy Jaussaud 40 | // Fabian Giesen 41 | // 42 | // Version history: 43 | // 44 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 45 | // 0.99 (2019-02-07) warning fixes 46 | // 0.11 (2017-03-03) return packing success/fail result 47 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 48 | // 0.09 (2016-08-27) fix compiler warnings 49 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 50 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 51 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 52 | // 0.05: added STBRP_ASSERT to allow replacing assert 53 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 54 | // 0.01: initial release 55 | // 56 | // LICENSE 57 | // 58 | // See end of file for license information. 59 | 60 | ////////////////////////////////////////////////////////////////////////////// 61 | // 62 | // INCLUDE SECTION 63 | // 64 | 65 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 66 | #define STB_INCLUDE_STB_RECT_PACK_H 67 | 68 | #define STB_RECT_PACK_VERSION 1 69 | 70 | #ifdef STBRP_STATIC 71 | #define STBRP_DEF static 72 | #else 73 | #define STBRP_DEF extern 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | 80 | typedef struct stbrp_context stbrp_context; 81 | typedef struct stbrp_node stbrp_node; 82 | typedef struct stbrp_rect stbrp_rect; 83 | 84 | #ifdef STBRP_LARGE_RECTS 85 | typedef int stbrp_coord; 86 | #else 87 | typedef unsigned short stbrp_coord; 88 | #endif 89 | 90 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 91 | // Assign packed locations to rectangles. The rectangles are of type 92 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 93 | // are 'num_rects' many of them. 94 | // 95 | // Rectangles which are successfully packed have the 'was_packed' flag 96 | // set to a non-zero value and 'x' and 'y' store the minimum location 97 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 98 | // if you imagine y increasing downwards). Rectangles which do not fit 99 | // have the 'was_packed' flag set to 0. 100 | // 101 | // You should not try to access the 'rects' array from another thread 102 | // while this function is running, as the function temporarily reorders 103 | // the array while it executes. 104 | // 105 | // To pack into another rectangle, you need to call stbrp_init_target 106 | // again. To continue packing into the same rectangle, you can call 107 | // this function again. Calling this multiple times with multiple rect 108 | // arrays will probably produce worse packing results than calling it 109 | // a single time with the full rectangle array, but the option is 110 | // available. 111 | // 112 | // The function returns 1 if all of the rectangles were successfully 113 | // packed and 0 otherwise. 114 | 115 | struct stbrp_rect 116 | { 117 | // reserved for your use: 118 | int id; 119 | 120 | // input: 121 | stbrp_coord w, h; 122 | 123 | // output: 124 | stbrp_coord x, y; 125 | int was_packed; // non-zero if valid packing 126 | 127 | }; // 16 bytes, nominally 128 | 129 | 130 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 131 | // Initialize a rectangle packer to: 132 | // pack a rectangle that is 'width' by 'height' in dimensions 133 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 134 | // 135 | // You must call this function every time you start packing into a new target. 136 | // 137 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 138 | // the following stbrp_pack_rects() call (or calls), but can be freed after 139 | // the call (or calls) finish. 140 | // 141 | // Note: to guarantee best results, either: 142 | // 1. make sure 'num_nodes' >= 'width' 143 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 144 | // 145 | // If you don't do either of the above things, widths will be quantized to multiples 146 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 147 | // 148 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 149 | // may run out of temporary storage and be unable to pack some rectangles. 150 | 151 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 152 | // Optionally call this function after init but before doing any packing to 153 | // change the handling of the out-of-temp-memory scenario, described above. 154 | // If you call init again, this will be reset to the default (false). 155 | 156 | 157 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 158 | // Optionally select which packing heuristic the library should use. Different 159 | // heuristics will produce better/worse results for different data sets. 160 | // If you call init again, this will be reset to the default. 161 | 162 | enum 163 | { 164 | STBRP_HEURISTIC_Skyline_default=0, 165 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 166 | STBRP_HEURISTIC_Skyline_BF_sortHeight 167 | }; 168 | 169 | 170 | ////////////////////////////////////////////////////////////////////////////// 171 | // 172 | // the details of the following structures don't matter to you, but they must 173 | // be visible so you can handle the memory allocations for them 174 | 175 | struct stbrp_node 176 | { 177 | stbrp_coord x,y; 178 | stbrp_node *next; 179 | }; 180 | 181 | struct stbrp_context 182 | { 183 | int width; 184 | int height; 185 | int align; 186 | int init_mode; 187 | int heuristic; 188 | int num_nodes; 189 | stbrp_node *active_head; 190 | stbrp_node *free_head; 191 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 192 | }; 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif 199 | 200 | ////////////////////////////////////////////////////////////////////////////// 201 | // 202 | // IMPLEMENTATION SECTION 203 | // 204 | 205 | #ifdef STB_RECT_PACK_IMPLEMENTATION 206 | #ifndef STBRP_SORT 207 | #include 208 | #define STBRP_SORT qsort 209 | #endif 210 | 211 | #ifndef STBRP_ASSERT 212 | #include 213 | #define STBRP_ASSERT assert 214 | #endif 215 | 216 | // [DEAR IMGUI] Added STBRP__CDECL 217 | #ifdef _MSC_VER 218 | #define STBRP__NOTUSED(v) (void)(v) 219 | #define STBRP__CDECL __cdecl 220 | #else 221 | #define STBRP__NOTUSED(v) (void)sizeof(v) 222 | #define STBRP__CDECL 223 | #endif 224 | 225 | enum 226 | { 227 | STBRP__INIT_skyline = 1 228 | }; 229 | 230 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 231 | { 232 | switch (context->init_mode) { 233 | case STBRP__INIT_skyline: 234 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 235 | context->heuristic = heuristic; 236 | break; 237 | default: 238 | STBRP_ASSERT(0); 239 | } 240 | } 241 | 242 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 243 | { 244 | if (allow_out_of_mem) 245 | // if it's ok to run out of memory, then don't bother aligning them; 246 | // this gives better packing, but may fail due to OOM (even though 247 | // the rectangles easily fit). @TODO a smarter approach would be to only 248 | // quantize once we've hit OOM, then we could get rid of this parameter. 249 | context->align = 1; 250 | else { 251 | // if it's not ok to run out of memory, then quantize the widths 252 | // so that num_nodes is always enough nodes. 253 | // 254 | // I.e. num_nodes * align >= width 255 | // align >= width / num_nodes 256 | // align = ceil(width/num_nodes) 257 | 258 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 259 | } 260 | } 261 | 262 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 263 | { 264 | int i; 265 | #ifndef STBRP_LARGE_RECTS 266 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff); 267 | #endif 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | #ifdef STBRP_LARGE_RECTS 287 | context->extra[1].y = (1<<30); 288 | #else 289 | context->extra[1].y = 65535; 290 | #endif 291 | context->extra[1].next = NULL; 292 | } 293 | 294 | // find minimum y position if it starts at x1 295 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 296 | { 297 | stbrp_node *node = first; 298 | int x1 = x0 + width; 299 | int min_y, visited_width, waste_area; 300 | 301 | STBRP__NOTUSED(c); 302 | 303 | STBRP_ASSERT(first->x <= x0); 304 | 305 | #if 0 306 | // skip in case we're past the node 307 | while (node->next->x <= x0) 308 | ++node; 309 | #else 310 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 311 | #endif 312 | 313 | STBRP_ASSERT(node->x <= x0); 314 | 315 | min_y = 0; 316 | waste_area = 0; 317 | visited_width = 0; 318 | while (node->x < x1) { 319 | if (node->y > min_y) { 320 | // raise min_y higher. 321 | // we've accounted for all waste up to min_y, 322 | // but we'll now add more waste for everything we've visted 323 | waste_area += visited_width * (node->y - min_y); 324 | min_y = node->y; 325 | // the first time through, visited_width might be reduced 326 | if (node->x < x0) 327 | visited_width += node->next->x - x0; 328 | else 329 | visited_width += node->next->x - node->x; 330 | } else { 331 | // add waste area 332 | int under_width = node->next->x - node->x; 333 | if (under_width + visited_width > width) 334 | under_width = width - visited_width; 335 | waste_area += under_width * (min_y - node->y); 336 | visited_width += under_width; 337 | } 338 | node = node->next; 339 | } 340 | 341 | *pwaste = waste_area; 342 | return min_y; 343 | } 344 | 345 | typedef struct 346 | { 347 | int x,y; 348 | stbrp_node **prev_link; 349 | } stbrp__findresult; 350 | 351 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 352 | { 353 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 354 | stbrp__findresult fr; 355 | stbrp_node **prev, *node, *tail, **best = NULL; 356 | 357 | // align to multiple of c->align 358 | width = (width + c->align - 1); 359 | width -= width % c->align; 360 | STBRP_ASSERT(width % c->align == 0); 361 | 362 | // if it can't possibly fit, bail immediately 363 | if (width > c->width || height > c->height) { 364 | fr.prev_link = NULL; 365 | fr.x = fr.y = 0; 366 | return fr; 367 | } 368 | 369 | node = c->active_head; 370 | prev = &c->active_head; 371 | while (node->x + width <= c->width) { 372 | int y,waste; 373 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 374 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 375 | // bottom left 376 | if (y < best_y) { 377 | best_y = y; 378 | best = prev; 379 | } 380 | } else { 381 | // best-fit 382 | if (y + height <= c->height) { 383 | // can only use it if it first vertically 384 | if (y < best_y || (y == best_y && waste < best_waste)) { 385 | best_y = y; 386 | best_waste = waste; 387 | best = prev; 388 | } 389 | } 390 | } 391 | prev = &node->next; 392 | node = node->next; 393 | } 394 | 395 | best_x = (best == NULL) ? 0 : (*best)->x; 396 | 397 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 398 | // 399 | // e.g, if fitting 400 | // 401 | // ____________________ 402 | // |____________________| 403 | // 404 | // into 405 | // 406 | // | | 407 | // | ____________| 408 | // |____________| 409 | // 410 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 411 | // 412 | // This makes BF take about 2x the time 413 | 414 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 415 | tail = c->active_head; 416 | node = c->active_head; 417 | prev = &c->active_head; 418 | // find first node that's admissible 419 | while (tail->x < width) 420 | tail = tail->next; 421 | while (tail) { 422 | int xpos = tail->x - width; 423 | int y,waste; 424 | STBRP_ASSERT(xpos >= 0); 425 | // find the left position that matches this 426 | while (node->next->x <= xpos) { 427 | prev = &node->next; 428 | node = node->next; 429 | } 430 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 431 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 432 | if (y + height <= c->height) { 433 | if (y <= best_y) { 434 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 435 | best_x = xpos; 436 | STBRP_ASSERT(y <= best_y); 437 | best_y = y; 438 | best_waste = waste; 439 | best = prev; 440 | } 441 | } 442 | } 443 | tail = tail->next; 444 | } 445 | } 446 | 447 | fr.prev_link = best; 448 | fr.x = best_x; 449 | fr.y = best_y; 450 | return fr; 451 | } 452 | 453 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 454 | { 455 | // find best position according to heuristic 456 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 457 | stbrp_node *node, *cur; 458 | 459 | // bail if: 460 | // 1. it failed 461 | // 2. the best node doesn't fit (we don't always check this) 462 | // 3. we're out of memory 463 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 464 | res.prev_link = NULL; 465 | return res; 466 | } 467 | 468 | // on success, create new node 469 | node = context->free_head; 470 | node->x = (stbrp_coord) res.x; 471 | node->y = (stbrp_coord) (res.y + height); 472 | 473 | context->free_head = node->next; 474 | 475 | // insert the new node into the right starting point, and 476 | // let 'cur' point to the remaining nodes needing to be 477 | // stiched back in 478 | 479 | cur = *res.prev_link; 480 | if (cur->x < res.x) { 481 | // preserve the existing one, so start testing with the next one 482 | stbrp_node *next = cur->next; 483 | cur->next = node; 484 | cur = next; 485 | } else { 486 | *res.prev_link = node; 487 | } 488 | 489 | // from here, traverse cur and free the nodes, until we get to one 490 | // that shouldn't be freed 491 | while (cur->next && cur->next->x <= res.x + width) { 492 | stbrp_node *next = cur->next; 493 | // move the current node to the free list 494 | cur->next = context->free_head; 495 | context->free_head = cur; 496 | cur = next; 497 | } 498 | 499 | // stitch the list back in 500 | node->next = cur; 501 | 502 | if (cur->x < res.x + width) 503 | cur->x = (stbrp_coord) (res.x + width); 504 | 505 | #ifdef _DEBUG 506 | cur = context->active_head; 507 | while (cur->x < context->width) { 508 | STBRP_ASSERT(cur->x < cur->next->x); 509 | cur = cur->next; 510 | } 511 | STBRP_ASSERT(cur->next == NULL); 512 | 513 | { 514 | int count=0; 515 | cur = context->active_head; 516 | while (cur) { 517 | cur = cur->next; 518 | ++count; 519 | } 520 | cur = context->free_head; 521 | while (cur) { 522 | cur = cur->next; 523 | ++count; 524 | } 525 | STBRP_ASSERT(count == context->num_nodes+2); 526 | } 527 | #endif 528 | 529 | return res; 530 | } 531 | 532 | // [DEAR IMGUI] Added STBRP__CDECL 533 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 534 | { 535 | const stbrp_rect *p = (const stbrp_rect *) a; 536 | const stbrp_rect *q = (const stbrp_rect *) b; 537 | if (p->h > q->h) 538 | return -1; 539 | if (p->h < q->h) 540 | return 1; 541 | return (p->w > q->w) ? -1 : (p->w < q->w); 542 | } 543 | 544 | // [DEAR IMGUI] Added STBRP__CDECL 545 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 546 | { 547 | const stbrp_rect *p = (const stbrp_rect *) a; 548 | const stbrp_rect *q = (const stbrp_rect *) b; 549 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 550 | } 551 | 552 | #ifdef STBRP_LARGE_RECTS 553 | #define STBRP__MAXVAL 0xffffffff 554 | #else 555 | #define STBRP__MAXVAL 0xffff 556 | #endif 557 | 558 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 559 | { 560 | int i, all_rects_packed = 1; 561 | 562 | // we use the 'was_packed' field internally to allow sorting/unsorting 563 | for (i=0; i < num_rects; ++i) { 564 | rects[i].was_packed = i; 565 | } 566 | 567 | // sort according to heuristic 568 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 569 | 570 | for (i=0; i < num_rects; ++i) { 571 | if (rects[i].w == 0 || rects[i].h == 0) { 572 | rects[i].x = rects[i].y = 0; // empty rect needs no space 573 | } else { 574 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 575 | if (fr.prev_link) { 576 | rects[i].x = (stbrp_coord) fr.x; 577 | rects[i].y = (stbrp_coord) fr.y; 578 | } else { 579 | rects[i].x = rects[i].y = STBRP__MAXVAL; 580 | } 581 | } 582 | } 583 | 584 | // unsort 585 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 586 | 587 | // set was_packed flags and all_rects_packed status 588 | for (i=0; i < num_rects; ++i) { 589 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 590 | if (!rects[i].was_packed) 591 | all_rects_packed = 0; 592 | } 593 | 594 | // return the all_rects_packed status 595 | return all_rects_packed; 596 | } 597 | #endif 598 | 599 | /* 600 | ------------------------------------------------------------------------------ 601 | This software is available under 2 licenses -- choose whichever you prefer. 602 | ------------------------------------------------------------------------------ 603 | ALTERNATIVE A - MIT License 604 | Copyright (c) 2017 Sean Barrett 605 | Permission is hereby granted, free of charge, to any person obtaining a copy of 606 | this software and associated documentation files (the "Software"), to deal in 607 | the Software without restriction, including without limitation the rights to 608 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 609 | of the Software, and to permit persons to whom the Software is furnished to do 610 | so, subject to the following conditions: 611 | The above copyright notice and this permission notice shall be included in all 612 | copies or substantial portions of the Software. 613 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 614 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 615 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 616 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 617 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 618 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 619 | SOFTWARE. 620 | ------------------------------------------------------------------------------ 621 | ALTERNATIVE B - Public Domain (www.unlicense.org) 622 | This is free and unencumbered software released into the public domain. 623 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 624 | software, either in source code form or as a compiled binary, for any purpose, 625 | commercial or non-commercial, and by any means. 626 | In jurisdictions that recognize copyright laws, the author or authors of this 627 | software dedicate any and all copyright interest in the software to the public 628 | domain. We make this dedication for the benefit of the public at large and to 629 | the detriment of our heirs and successors. We intend this dedication to be an 630 | overt act of relinquishment in perpetuity of all present and future rights to 631 | this software under copyright law. 632 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 633 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 634 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 635 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 636 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 637 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 638 | ------------------------------------------------------------------------------ 639 | */ 640 | -------------------------------------------------------------------------------- /dependencies/rendering/ui/ui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../../common.hpp" 3 | 4 | namespace ui 5 | { 6 | void initialize() 7 | { 8 | /* fonts */ 9 | { 10 | ImGuiIO* io = &ImGui::GetIO(); 11 | } 12 | 13 | /* images */ 14 | { 15 | 16 | } 17 | } 18 | 19 | void run() 20 | { 21 | if (GetForegroundWindow() != globals.rust_window) 22 | return; 23 | 24 | entity_list.setup(); 25 | entity_list.player_loop(); 26 | entity_list.prefab_loop(); 27 | 28 | /* 29 | * deleted my GUI framework 30 | * might post it onto github 31 | * later on once it's finished 32 | */ 33 | } 34 | } -------------------------------------------------------------------------------- /dependencies/utils/math.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define M_PI 3.14159265358979323846f 4 | #define M_PI_F ((float)(M_PI)) 5 | #define RAD2DEG(x) ((float)(x) * (float)(180.f / M_PI_F)) 6 | 7 | class Vector2 8 | { 9 | public: 10 | float x, y; 11 | 12 | Vector2() { }; 13 | 14 | Vector2(float x, float y) 15 | { 16 | this->x = x; 17 | this->y = y; 18 | }; 19 | 20 | bool is_valid() 21 | { 22 | return (x != 0 && y != 0); 23 | } 24 | 25 | float length() const 26 | { 27 | return std::sqrt((x * x) + (y * y)); 28 | } 29 | 30 | float distance(Vector2 b) 31 | { 32 | return sqrt(pow(b.x - x, 2) + pow(b.y - y, 2)); 33 | } 34 | 35 | void normalize() 36 | { 37 | 38 | if (x < -89) 39 | x = -89; 40 | 41 | 42 | else if (x > 89) 43 | x = 89; 44 | 45 | 46 | if (y < -360) 47 | y += 360; 48 | 49 | 50 | else if (y > 360) 51 | y -= 360; 52 | } 53 | 54 | Vector2& operator*=(float input) 55 | { 56 | x *= input; 57 | y *= input; 58 | return *this; 59 | } 60 | }; 61 | 62 | class Vector3 63 | { 64 | public: 65 | Vector3() 66 | { 67 | x = y = z = 0.f; 68 | } 69 | 70 | Vector3(float fx, float fy, float fz) 71 | { 72 | x = fx; 73 | y = fy; 74 | z = fz; 75 | } 76 | 77 | float x, y, z; 78 | 79 | Vector3 operator+(const Vector3& input) const 80 | { 81 | return Vector3{ x + input.x, y + input.y, z + input.z }; 82 | } 83 | 84 | Vector3 operator-(const Vector3& input) const 85 | { 86 | return Vector3{ x - input.x, y - input.y, z - input.z }; 87 | } 88 | 89 | Vector3 operator/(float input) const 90 | { 91 | return Vector3{ x / input, y / input, z / input }; 92 | } 93 | 94 | Vector3 operator*(float input) const 95 | { 96 | return Vector3{ x * input, y * input, z * input }; 97 | } 98 | 99 | Vector3& operator+=(const Vector3& v) 100 | { 101 | x += v.x; 102 | y += v.y; 103 | z += v.z; 104 | 105 | return *this; 106 | } 107 | 108 | Vector3& operator-=(const Vector3& v) 109 | { 110 | x -= v.x; 111 | y -= v.y; 112 | z -= v.z; 113 | 114 | return *this; 115 | } 116 | 117 | Vector3& operator/=(float input) 118 | { 119 | x /= input; 120 | y /= input; 121 | z /= input; 122 | return *this; 123 | } 124 | 125 | Vector3& operator*=(float input) 126 | { 127 | x *= input; 128 | y *= input; 129 | z *= input; 130 | return *this; 131 | } 132 | 133 | bool operator==(const Vector3& input) const 134 | { 135 | return x == input.x && y == input.y && z == input.z; 136 | } 137 | 138 | void make_absolute() 139 | { 140 | x = std::abs(x); 141 | y = std::abs(y); 142 | z = std::abs(z); 143 | } 144 | 145 | float clamp0to1(float value) 146 | { 147 | float result; 148 | if (value < 0) 149 | { 150 | result = 0; 151 | } 152 | else if (value > 1.f) 153 | { 154 | result = 1.f; 155 | } 156 | else 157 | { 158 | result = value; 159 | } 160 | return result; 161 | } 162 | 163 | float Lerp() 164 | { 165 | return x + (y - x) * clamp0to1(z); 166 | } 167 | 168 | float length_sqr() const 169 | { 170 | return (x * x) + (y * y) + (z * z); 171 | } 172 | 173 | float length() const 174 | { 175 | return (float)sqrt(length_sqr()); 176 | } 177 | 178 | float length_2d() const 179 | { 180 | return (float)sqrt((x * x) + (y * y)); 181 | } 182 | 183 | Vector3 normalize() 184 | { 185 | Vector3 out = *this; 186 | auto len = length(); 187 | if (!len) 188 | return *this; 189 | 190 | out.x /= len; 191 | out.y /= len; 192 | out.z /= len; 193 | return out; 194 | } 195 | 196 | Vector3 cross(Vector3 rhs) 197 | { 198 | return Vector3(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x); 199 | } 200 | 201 | float unity_magnitude() 202 | { 203 | return (float)sqrt((double)(x * x + y * y + z * z)); 204 | } 205 | 206 | Vector3 unity_normalize() 207 | { 208 | float num = unity_magnitude(); 209 | if (num > 1E-05f) 210 | { 211 | x /= num; 212 | y /= num; 213 | z /= num; 214 | } 215 | else 216 | { 217 | x = 0; 218 | y = 0; 219 | z = 0; 220 | } 221 | 222 | return { x,y,z }; 223 | } 224 | 225 | Vector3 normalized() const 226 | { 227 | return { x == 0 ? 0 : x / length(), y == 0 ? 0 : y / length(), z == 0 ? 0 : z / length() }; 228 | } 229 | 230 | float dot(Vector3 input) const 231 | { 232 | return (x * input.x) + (y * input.y) + (z * input.z); 233 | } 234 | 235 | float distance(Vector3 input) const 236 | { 237 | return (*this - input).length(); 238 | } 239 | 240 | float distancesqr(Vector3 input) const 241 | { 242 | Vector3 dif = { x - input.x, y - input.y, z - input.z }; 243 | return dif.x * dif.x + dif.y * dif.y + dif.z * dif.z; 244 | } 245 | 246 | float distance_2d(Vector3 input) const 247 | { 248 | return (*this - input).length_2d(); 249 | } 250 | 251 | void clamp() 252 | { 253 | static_cast(std::clamp(x, -89.f, 89.f)); 254 | static_cast(std::clamp(y, -180.f, 180.f)); 255 | z = 0.f; 256 | return; 257 | } 258 | 259 | bool is_valid() const 260 | { 261 | return !(x == 0.f && y == 0.f && z == 0.f) || (x == -1.f && y == -1.f && z == -1.f); 262 | } 263 | }; 264 | 265 | class Vector4 266 | { 267 | public: 268 | Vector4() 269 | { 270 | x = y = z = w = 0.f; 271 | } 272 | 273 | Vector4(float fx, float fy, float fz, float fw) 274 | { 275 | x = fx; 276 | y = fy; 277 | z = fz; 278 | w = fw; 279 | } 280 | 281 | float x, y, z, w; 282 | 283 | Vector4 operator+(const Vector4& input) const 284 | { 285 | return Vector4{ x + input.x, y + input.y, z + input.z, w + input.w }; 286 | } 287 | 288 | Vector4 operator-(const Vector4& input) const 289 | { 290 | return Vector4{ x - input.x, y - input.y, z - input.z, w - input.w }; 291 | } 292 | 293 | Vector4 operator/(float input) const 294 | { 295 | return Vector4{ x / input, y / input, z / input, w / input }; 296 | } 297 | 298 | Vector4 operator*(float input) const 299 | { 300 | return Vector4{ x * input, y * input, z * input, w * input }; 301 | } 302 | 303 | Vector4& operator-=(const Vector4& v) 304 | { 305 | x -= v.x; 306 | y -= v.y; 307 | z -= v.z; 308 | w -= v.w; 309 | 310 | return *this; 311 | } 312 | 313 | Vector4& operator/=(float input) 314 | { 315 | x /= input; 316 | y /= input; 317 | z /= input; 318 | w /= input; 319 | return *this; 320 | } 321 | 322 | Vector4& operator*=(float input) 323 | { 324 | x *= input; 325 | y *= input; 326 | z *= input; 327 | w *= input; 328 | return *this; 329 | } 330 | 331 | bool operator==(const Vector4& input) const 332 | { 333 | return x == input.x && y == input.y && z == input.z && w == input.w; 334 | } 335 | 336 | void make_absolute() 337 | { 338 | x = std::abs(x); 339 | y = std::abs(y); 340 | z = std::abs(z); 341 | w = std::abs(w); 342 | } 343 | 344 | float length_sqr() const 345 | { 346 | return (x * x) + (y * y) + (z * z) + (w * w); 347 | } 348 | 349 | float length() const 350 | { 351 | return (float)sqrt(length_sqr()); 352 | } 353 | 354 | float length_2d() const 355 | { 356 | return (float)sqrt((x * x) + (y * y)); 357 | } 358 | 359 | Vector4 normalized() const 360 | { 361 | return { x / length(), y / length(), z / length(), w / length() }; 362 | } 363 | 364 | float dot(Vector4 input) const 365 | { 366 | return (x * input.x) + (y * input.y) + (z * input.z) + (w * input.w); 367 | } 368 | 369 | float distance(Vector4 input) const 370 | { 371 | return (*this - input).length(); 372 | } 373 | 374 | float distance_2d(Vector4 input) const 375 | { 376 | return (*this - input).length_2d(); 377 | } 378 | void clamp() 379 | { 380 | static_cast(std::clamp(x, -89.f, 89.f)); 381 | static_cast(std::clamp(y, -180.f, 180.f)); 382 | 383 | z = 0.f; 384 | w = 0.f; 385 | } 386 | 387 | static Vector4 QuaternionLookRotation(Vector3 forward, Vector3 up) 388 | { 389 | Vector3 vector = forward.unity_normalize(); 390 | Vector3 Vector2 = (up).cross(vector).unity_normalize(); 391 | Vector3 Vector3 = (vector).cross(Vector2); 392 | auto m00 = Vector2.x; 393 | auto m01 = Vector2.y; 394 | auto m02 = Vector2.z; 395 | auto m10 = Vector3.x; 396 | auto m11 = Vector3.y; 397 | auto m12 = Vector3.z; 398 | auto m20 = vector.x; 399 | auto m21 = vector.y; 400 | auto m22 = vector.z; 401 | 402 | 403 | float num8 = (m00 + m11) + m22; 404 | auto quaternion = Vector4(); 405 | if (num8 > 0.f) 406 | { 407 | auto num = (float)sqrt(num8 + 1.f); 408 | quaternion.w = num * 0.5f; 409 | num = 0.5f / num; 410 | quaternion.x = (m12 - m21) * num; 411 | quaternion.y = (m20 - m02) * num; 412 | quaternion.z = (m01 - m10) * num; 413 | return quaternion; 414 | } 415 | if ((m00 >= m11) && (m00 >= m22)) 416 | { 417 | auto num7 = (float)sqrt(((1.f + m00) - m11) - m22); 418 | auto num4 = 0.5f / num7; 419 | quaternion.x = 0.5f * num7; 420 | quaternion.y = (m01 + m10) * num4; 421 | quaternion.z = (m02 + m20) * num4; 422 | quaternion.w = (m12 - m21) * num4; 423 | return quaternion; 424 | } 425 | if (m11 > m22) 426 | { 427 | auto num6 = (float)sqrt(((1.f + m11) - m00) - m22); 428 | auto num3 = 0.5f / num6; 429 | quaternion.x = (m10 + m01) * num3; 430 | quaternion.y = 0.5f * num6; 431 | quaternion.z = (m21 + m12) * num3; 432 | quaternion.w = (m20 - m02) * num3; 433 | return quaternion; 434 | } 435 | auto num5 = (float)sqrt(((1.f + m22) - m00) - m11); 436 | auto num2 = 0.5f / num5; 437 | quaternion.x = (m20 + m02) * num2; 438 | quaternion.y = (m21 + m12) * num2; 439 | quaternion.z = 0.5f * num5; 440 | quaternion.w = (m01 - m10) * num2; 441 | return quaternion; 442 | } 443 | 444 | bool is_valid() const 445 | { 446 | return !((x == 0.f && y == 0.f && z == 0.f && w == 0.f) || (x == -1.f && y == -1.f && z == -1.f && w == -1.f)); 447 | } 448 | }; 449 | 450 | Vector3 quaternion_mult(const Vector3* point, Vector4* quat) 451 | { 452 | float num = quat->x * 2.f; 453 | float num2 = quat->y * 2.f; 454 | float num3 = quat->z * 2.f; 455 | float num4 = quat->x * num; 456 | float num5 = quat->y * num2; 457 | float num6 = quat->z * num3; 458 | float num7 = quat->x * num2; 459 | float num8 = quat->x * num3; 460 | float num9 = quat->y * num3; 461 | float num10 = quat->w * num; 462 | float num11 = quat->w * num2; 463 | float num12 = quat->w * num3; 464 | Vector3 result{}; 465 | result.x = (1.f - (num5 + num6)) * point->x + (num7 - num12) * point->y + (num8 + num11) * point->z; 466 | result.y = (num7 + num12) * point->x + (1.f - (num4 + num6)) * point->y + (num9 - num10) * point->z; 467 | result.z = (num8 - num11) * point->x + (num9 + num10) * point->y + (1.f - (num4 + num5)) * point->z; 468 | return result; 469 | } 470 | 471 | float normalize_angle(float angle) 472 | { 473 | while (angle > 360) angle -= 360; 474 | while (angle < 0) angle += 360; 475 | return angle; 476 | } 477 | 478 | Vector2 rotate_point(Vector2 point_to_rotate, Vector2 center_point, float angle) 479 | { 480 | float rad = ((normalize_angle(angle)) * static_cast((3.14159 / 180.f))); 481 | float s = -sin(rad); 482 | float c = cos(rad); 483 | float xnew = point_to_rotate.x * c - point_to_rotate.y * s; 484 | float znew = point_to_rotate.x * s + point_to_rotate.y * c; 485 | point_to_rotate.x -= center_point.x; 486 | point_to_rotate.y -= center_point.y; 487 | point_to_rotate.x = xnew + center_point.x; 488 | point_to_rotate.y = znew + center_point.y; 489 | return point_to_rotate; 490 | } 491 | 492 | double to_rad(double degree) 493 | { 494 | double pi = 3.14159265359; 495 | return (degree * (pi / 180)); 496 | } 497 | 498 | Vector4 to_quat(Vector3 Euler) 499 | { 500 | double heading = to_rad(Euler.x); 501 | double attitude = to_rad(Euler.y); 502 | double bank = to_rad(Euler.z); 503 | 504 | double c1 = cos(heading / 2); 505 | double s1 = sin(heading / 2); 506 | double c2 = cos(attitude / 2); 507 | double s2 = sin(attitude / 2); 508 | double c3 = cos(bank / 2); 509 | double s3 = sin(bank / 2); 510 | double c1c2 = c1 * c2; 511 | double s1s2 = s1 * s2; 512 | Vector4 quat; 513 | quat.w = c1c2 * c3 - s1s2 * s3; 514 | quat.x = c1c2 * s3 + s1s2 * c3; 515 | quat.y = s1 * c2 * c3 + c1 * s2 * s3; 516 | quat.z = c1 * s2 * c3 - s1 * c2 * s3; 517 | return { quat.y, quat.z, (quat.x * -1), quat.w }; 518 | } 519 | 520 | Vector2 calculate_angle(Vector3 src, Vector3 dst) 521 | { 522 | Vector3 dir = src - dst; 523 | return Vector2{ RAD2DEG(asin(dir.y / dir.length())), RAD2DEG(-atan2(dir.x, -dir.z)) }; 524 | } 525 | 526 | //float calculate_bullet_drop(float distance, float speed, float gravity) 527 | //{ 528 | // if (distance < 0.001f) 529 | // return -1; 530 | // 531 | // float bullet_gravity = 9.81f * gravity; 532 | // float bullet_travel_time = distance / speed; 533 | // 534 | // return static_cast(0.5f * bullet_gravity * bullet_travel_time * bullet_travel_time); 535 | //} 536 | 537 | float calculate_bullet_drop(float height, float distance, float velocity, float gravity) 538 | { 539 | float pitch = std::atan2(height, distance); 540 | float bullet_velocity = velocity * std::cos(pitch); 541 | float time = distance / bullet_velocity; 542 | 543 | return (0.5f * gravity * time * time) * 10; 544 | } -------------------------------------------------------------------------------- /dependencies/utils/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | #include 4 | 5 | class utils_t 6 | { 7 | public: 8 | std::string random_str(size_t length) 9 | { 10 | auto randchar = []() -> char 11 | { 12 | const char charset[] = 13 | { 14 | "0123456789" 15 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 16 | "abcdefghijklmnopqrstuvwxyz" 17 | }; 18 | 19 | const size_t max_index = (sizeof(charset) - 1); 20 | return charset[rand() % max_index]; 21 | }; 22 | std::string str(length, 0); 23 | std::generate_n(str.begin(), length, randchar); 24 | return str; 25 | } 26 | 27 | std::string random_lower_str(size_t length) 28 | { 29 | auto randchar = []() -> char 30 | { 31 | const char charset[] = 32 | { 33 | "0123456789" 34 | "abcdefghijklmnopqrstuvwxyz" 35 | }; 36 | 37 | const size_t max_index = (sizeof(charset) - 1); 38 | return charset[rand() % max_index]; 39 | }; 40 | std::string str(length, 0); 41 | std::generate_n(str.begin(), length, randchar); 42 | return str; 43 | } 44 | 45 | int random_int(int min, int max) 46 | { 47 | static bool first = true; 48 | if (first) 49 | { 50 | srand((unsigned int)time(NULL)); 51 | first = false; 52 | } 53 | return min + rand() % ((max + 1) - min); 54 | } 55 | 56 | bool is_running(const char* name) 57 | { 58 | return FindWindowA(NULL, name); 59 | } 60 | 61 | uintptr_t get_component(uintptr_t game_object, const char* name_str) 62 | { 63 | if (!game_object) 64 | return NULL; 65 | 66 | uintptr_t list = memory.read(game_object + 0x30); 67 | for (int i = 0; i < 20; i++) 68 | { 69 | uintptr_t component = memory.read(list + (0x10 * i + 0x8)); 70 | 71 | if (!component) 72 | continue; 73 | 74 | uintptr_t unk1 = memory.read(component + 0x28); 75 | 76 | if (!unk1) 77 | continue; 78 | 79 | uintptr_t name_ptr = memory.read(unk1); 80 | std::string name = memory.read_str(memory.read(name_ptr + 0x10), 18); 81 | 82 | if (!strcmp(name.c_str(), name_str)) 83 | return unk1; 84 | } 85 | 86 | return NULL; 87 | } 88 | } utils; -------------------------------------------------------------------------------- /globals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.hpp" 3 | 4 | struct weapon_info_t 5 | { 6 | Vector4 recoil_value{}; 7 | Vector4 spread_value{}; 8 | bool automatic{}; 9 | 10 | bool has_set_recoil = false; 11 | bool has_set_spread = false; 12 | }; 13 | 14 | class drilled_t 15 | { 16 | private: 17 | public: 18 | /* game */ 19 | HWND rust_window = FindWindowA(NULL, _("Rust")); 20 | uintptr_t game_assembly = NULL; 21 | uintptr_t unity_player = NULL; 22 | uintptr_t base_networkable = NULL; 23 | 24 | /* screen */ 25 | const int screen_w = GetSystemMetrics(SM_CXSCREEN); 26 | const int screen_h = GetSystemMetrics(SM_CYSCREEN); 27 | const float screen_center_x = GetSystemMetrics(SM_CXSCREEN) / 2; 28 | const float screen_center_y = GetSystemMetrics(SM_CYSCREEN) / 2; 29 | 30 | bool menu_open = false; 31 | 32 | float height = 0.f; 33 | std::string weapon_name = _(""); 34 | std::unordered_map weapon_map{}; 35 | weapon_info_t weapon_info{}; 36 | } globals; -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | int main() 4 | { 5 | SetConsoleTitleA(utils.random_lower_str(utils.random_int(12, 26)).c_str()); 6 | SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); 7 | 8 | globals.game_assembly = memory.module_base(_("GameAssembly.dll")); 9 | globals.unity_player = memory.module_base(_("UnityPlayer.dll")); 10 | globals.base_networkable = memory.read(globals.game_assembly + o::BaseNetworkable_c); 11 | 12 | printf(_("[*] RustClient.exe Window @ 0x%p\n"), globals.rust_window); 13 | printf(_("[*] GameAssembly.dll @ 0x%p\n"), globals.game_assembly); 14 | printf(_("[*] UnityPlayer.dll @ 0x%p\n"), globals.unity_player); 15 | 16 | std::thread([&]() 17 | { 18 | while (true) 19 | { 20 | entity_list.cache(); 21 | std::this_thread::sleep_for(std::chrono::microseconds(5000)); 22 | } 23 | }).detach(); 24 | 25 | std::thread([&]() 26 | { 27 | features.run(); 28 | }).detach(); 29 | 30 | std::thread([&]() 31 | { 32 | aimbot.run(); 33 | }).detach(); 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /rust.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31903.59 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rust", "rust.vcxproj", "{DAF4A261-DF27-4627-A3C9-9D1FC5A53648}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Debug|x64.ActiveCfg = Debug|x64 17 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Debug|x64.Build.0 = Debug|x64 18 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Debug|x86.ActiveCfg = Debug|Win32 19 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Debug|x86.Build.0 = Debug|Win32 20 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Release|x64.ActiveCfg = Release|x64 21 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Release|x64.Build.0 = Release|x64 22 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Release|x86.ActiveCfg = Release|Win32 23 | {DAF4A261-DF27-4627-A3C9-9D1FC5A53648}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {49E5422C-9C55-48C7-A46A-159B534F26B3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /rust.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {daf4a261-df27-4627-a3c9-9d1fc5a53648} 25 | rust 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath) 82 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 83 | 84 | 85 | false 86 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath) 87 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 88 | 89 | 90 | 91 | Level3 92 | true 93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | 96 | 97 | Console 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | true 106 | true 107 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 108 | true 109 | 110 | 111 | Console 112 | true 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | false 121 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 122 | true 123 | stdcpp20 124 | 125 | 126 | Console 127 | true 128 | 129 | 130 | 131 | 132 | Level3 133 | true 134 | true 135 | true 136 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 137 | true 138 | stdcpp20 139 | 140 | 141 | Console 142 | true 143 | true 144 | true 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /rust.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | Header Files 80 | 81 | 82 | Header Files 83 | 84 | 85 | Header Files 86 | 87 | 88 | Header Files 89 | 90 | 91 | Header Files 92 | 93 | 94 | Header Files 95 | 96 | 97 | Header Files 98 | 99 | 100 | Header Files 101 | 102 | 103 | Header Files 104 | 105 | 106 | Header Files 107 | 108 | 109 | Header Files 110 | 111 | 112 | Header Files 113 | 114 | 115 | Header Files 116 | 117 | 118 | Header Files 119 | 120 | 121 | Header Files 122 | 123 | 124 | Header Files 125 | 126 | 127 | 128 | 129 | Source Files 130 | 131 | 132 | Source Files 133 | 134 | 135 | Source Files 136 | 137 | 138 | Source Files 139 | 140 | 141 | Source Files 142 | 143 | 144 | Source Files 145 | 146 | 147 | Source Files 148 | 149 | 150 | Source Files 151 | 152 | 153 | -------------------------------------------------------------------------------- /rust.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /sdk/classes/basemounted.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class BaseMounted 5 | { 6 | public: 7 | void setCanHoldItems(bool value) 8 | { 9 | memory.write(reinterpret_cast(this) + o::BaseMountable_canWieldItems, value); 10 | } 11 | }; -------------------------------------------------------------------------------- /sdk/classes/baseplayer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | struct bounding_box_t 5 | { 6 | float x, y, w, h; 7 | Vector3 head_world{}; 8 | Vector2 head_screen{}; 9 | Vector3 foot_world{}; 10 | Vector2 foot_screen{}; 11 | }; 12 | 13 | class BasePlayer 14 | { 15 | private: 16 | public: 17 | uintptr_t getAddress() 18 | { 19 | return reinterpret_cast(this); 20 | } 21 | 22 | PlayerModel* playerModel() 23 | { 24 | return memory.read(reinterpret_cast(this) + o::BasePlayer_playerModel); 25 | } 26 | 27 | PlayerInput* playerInput() 28 | { 29 | return memory.read(reinterpret_cast(this) + o::BasePlayer_playerInput); 30 | } 31 | 32 | PlayerEyes* eyes() 33 | { 34 | return memory.read(reinterpret_cast(this) + o::BasePlayer_eyes); 35 | } 36 | 37 | ModelState* modelState() 38 | { 39 | return memory.read(reinterpret_cast(this) + o::BasePlayer_modelstate); 40 | } 41 | 42 | PlayerWalkMovement* playerWalkMovement() 43 | { 44 | return memory.read(reinterpret_cast(this) + o::BasePlayer_playerWalkMovement); 45 | } 46 | 47 | BaseMounted* mounted() 48 | { 49 | return memory.read(reinterpret_cast(this) + o::BasePlayer_mounted); 50 | } 51 | 52 | void rebuildClothes() 53 | { 54 | memory.write(reinterpret_cast(this) + o::BasePlayer_needsClothesRebuild, true); 55 | } 56 | 57 | void setClientTickInterval(float interval) 58 | { 59 | memory.write(reinterpret_cast(this) + o::BasePlayer_clientTickInterval, interval); 60 | } 61 | 62 | bool isDead() 63 | { 64 | return memory.read(reinterpret_cast(this) + o::BaseCombatEntity_lifestate); 65 | } 66 | 67 | std::string getName() 68 | { 69 | std::wstring wname = memory.read_wstr(memory.read(reinterpret_cast(this) + o::BasePlayer_displayName) + 0x14); 70 | 71 | if (wname.length() > 32 || wname.length() < 2) 72 | return _(""); 73 | 74 | return std::string(wname.begin(), wname.end()); 75 | } 76 | 77 | float getLastSentTickTime() 78 | { 79 | return memory.read(reinterpret_cast(this) + o::BasePlayer_lastSentTickTime); 80 | } 81 | 82 | int getDistance(Vector3 to_position) 83 | { 84 | return getBone(bone_list::head).distance(to_position); 85 | } 86 | 87 | float getHealth() 88 | { 89 | return memory.read(reinterpret_cast(this) + o::BaseCombatEntity_health); 90 | } 91 | 92 | float getMaxHealth() 93 | { 94 | return memory.read(reinterpret_cast(this) + o::BaseCombatEntity_maxHealth); 95 | } 96 | 97 | Item* getHeldItem() 98 | { 99 | int active_id = memory.read(reinterpret_cast(this) + 0x5d0); 100 | 101 | uintptr_t inventory = memory.read(reinterpret_cast(this) + 0x690); 102 | 103 | uintptr_t contianer_belt = memory.read(inventory + 0x28); 104 | 105 | uintptr_t contents = memory.read(contianer_belt + 0x38); 106 | 107 | int size = memory.read(contents + 0x18); 108 | 109 | contents = memory.read(contents + 0x10); 110 | 111 | for (int i = 0; i < size; i++) 112 | { 113 | Item* item = memory.read(contents + (0x20 + (i * 0x8))); 114 | 115 | uintptr_t item_id = memory.read(reinterpret_cast(item) + 0x28); 116 | 117 | if (item_id == active_id) 118 | return item; 119 | } 120 | 121 | return nullptr; 122 | } 123 | 124 | bool isAiming() 125 | { 126 | return getHeldItem()->baseProjectile()->isAiming(); 127 | } 128 | 129 | static enum Flags 130 | { 131 | Unused1 = 1, 132 | Unused2 = 2, 133 | IsAdmin = 4, 134 | ReceivingSnapshot = 8, 135 | Sleeping = 16, 136 | Spectating = 32, 137 | Wounded = 64, 138 | IsDeveloper = 128, 139 | Connected = 256, 140 | ThirdPersonViewmode = 1024, 141 | EyesViewmode = 2048, 142 | ChatMute = 4096, 143 | NoSprint = 8192, 144 | Aiming = 16384, 145 | DisplaySash = 32768, 146 | Relaxed = 65536, 147 | SafeZone = 131072, 148 | ServerFall = 262144, 149 | Incapacitated = 524288, 150 | Workbench1 = 1048576, 151 | Workbench2 = 2097152, 152 | Workbench3 = 4194304 153 | }; 154 | 155 | /* 156 | * change isLocalPlayer and isNpc to 157 | * playerModel()->isLocalPlayer(); 158 | * etc 159 | */ 160 | bool isLocalPlayer() 161 | { 162 | return playerModel()->isLocalPlayer(); 163 | } 164 | 165 | bool isNPC() 166 | { 167 | return playerModel()->isNPC(); 168 | } 169 | 170 | bool hasFlag(Flags flag) { return (memory.read(reinterpret_cast(this) + o::BasePlayer_playerFlags)) & flag; } 171 | 172 | void setFlag(Flags flag) 173 | { 174 | int current_flags = memory.read(reinterpret_cast(this) + o::BasePlayer_playerFlags); 175 | memory.write(reinterpret_cast(this) + o::BasePlayer_playerFlags, current_flags |= flag); 176 | } 177 | 178 | void unsetFlag(Flags flag) 179 | { 180 | int player_flags = memory.read(reinterpret_cast(this) + o::BasePlayer_playerFlags); 181 | 182 | if (hasFlag(flag)) 183 | player_flags -= flag; 184 | 185 | memory.write(reinterpret_cast(this) + o::BasePlayer_playerFlags, player_flags); 186 | } 187 | 188 | Vector3 getBone(bone_list _bone) { return bone.get_entity_bone(reinterpret_cast(this), _bone); } 189 | 190 | bounding_box_t getBoundingBox() 191 | { 192 | bounding_box_t box{}; 193 | 194 | box.head_world = getBone(head).operator+(Vector3(0.f, 0.2f, 0.f)); 195 | box.foot_world = getBone(l_foot).operator+(getBone(r_foot)).operator/(2); 196 | 197 | if (world_to_screen(box.head_world, box.head_screen) && 198 | world_to_screen(box.foot_world, box.foot_screen)) 199 | { 200 | box.h = box.head_screen.y - box.foot_screen.y; 201 | box.w = 2.f * (box.h / 4.f); 202 | box.x = box.foot_screen.x - Vector2(box.w / 2, 0).x; 203 | box.y = box.foot_screen.y - Vector2(box.w / 2, 0).y; 204 | } 205 | 206 | return box; 207 | } 208 | }; -------------------------------------------------------------------------------- /sdk/classes/baseprojectile.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | /* 5 | * TODO: 6 | * - change { 0.f, 0.f, 0.f, 0.f } inside noRecoil function 7 | * to the slider value's we will have in the menu (X, Y) 8 | * - add noSpread resetting 9 | */ 10 | 11 | struct bullet_info 12 | { 13 | float velocity = 333; 14 | float drag = 1.f; 15 | float gravity = 1.f; 16 | float velocity_scale = 1.f; 17 | float velocity_scalar = 1.f; 18 | }; 19 | 20 | struct ProjectileWeaponModModifier 21 | { 22 | bool enabled; 23 | float scalar; 24 | float offset; 25 | }; 26 | 27 | class BaseProjectile 28 | { 29 | public: 30 | void noRecoil() 31 | { 32 | /* check if we already set recoil values for this name in the map */ 33 | if (!globals.weapon_map[globals.weapon_name].has_set_recoil) 34 | { 35 | /* get our recoil properties */ 36 | uintptr_t recoil_properties = memory.read(reinterpret_cast(this) + o::BaseProjectile_recoil); 37 | 38 | /* read our recoil values */ 39 | Vector4 recoil_values = memory.read(recoil_properties + o::RecoilProperties_recoilYawMin); 40 | 41 | /* check if values have already been set, if not then we know the values are the original ones */ 42 | if (recoil_values != Vector4{0.f, 0.f, 0.f, 0.f}) 43 | globals.weapon_map[globals.weapon_name].recoil_value = recoil_values; 44 | 45 | /* set no recoil */ 46 | memory.write(recoil_properties + 0x18, { 0.f, 0.f, 0.f, 0.f }); 47 | 48 | /* know we have set the recoil for this name so that we don't do it again until unset */ 49 | globals.weapon_map[globals.weapon_name].has_set_recoil = true; 50 | } 51 | } 52 | 53 | void noSpread() 54 | { 55 | /* check if we already set spread for this name in the map */ 56 | if (!globals.weapon_map[globals.weapon_name].has_set_spread) 57 | { 58 | /* save the values before modifying it */ 59 | globals.weapon_map[globals.weapon_name].spread_value = memory.read(reinterpret_cast(this) + o::BaseProjectile_aimCone); 60 | 61 | /* set no spread */ 62 | memory.write(reinterpret_cast(this) + o::BaseProjectile_aimCone, { -3.f, -3.f, -3.f, -3.f }); 63 | 64 | /* know we have set the spread for this name so that we don't do it again until unset */ 65 | globals.weapon_map[globals.weapon_name].has_set_spread = true; 66 | } 67 | } 68 | 69 | void pushToMap() 70 | { 71 | /* add weapon name if it doesn't already exist in the map */ 72 | if (globals.weapon_map.count(globals.weapon_name) <= 0) 73 | globals.weapon_map[globals.weapon_name] = globals.weapon_info; 74 | } 75 | 76 | void restoreRecoil() 77 | { 78 | /* if recoil has been set ( { 0.f, 0.f, 0.f, 0.f } )*/ 79 | if (globals.weapon_map[globals.weapon_name].has_set_recoil) 80 | { 81 | uintptr_t recoil_properties = memory.read(reinterpret_cast(this) + o::BaseProjectile_recoil); 82 | /* then set it back to the original values we stored */ 83 | memory.write(recoil_properties + o::RecoilProperties_recoilYawMin, globals.weapon_map[globals.weapon_name].recoil_value); 84 | } 85 | } 86 | 87 | void unsetRecoil() 88 | { 89 | /* set to false, this will make the noRecoil run if this was set to true earlier */ 90 | globals.weapon_map[globals.weapon_name].has_set_recoil = false; 91 | } 92 | 93 | bool isAiming() 94 | { 95 | return memory.read(reinterpret_cast(this) + o::BaseProjectile_aiming); 96 | } 97 | 98 | bool isReloading() 99 | { 100 | return memory.read(reinterpret_cast(this) + o::BaseProjectile_isReloading); 101 | } 102 | 103 | int getMagazineCapacity() 104 | { 105 | uintptr_t magazine = memory.read(reinterpret_cast(this) + o::BaseProjectile_primaryMagazine); 106 | return memory.read(magazine + o::Magazine_capacity); 107 | } 108 | 109 | int getMagazineSize() 110 | { 111 | uintptr_t magazine = memory.read(reinterpret_cast(this) + o::BaseProjectile_primaryMagazine); 112 | return memory.read(magazine + o::Magazine_contents); 113 | } 114 | 115 | bullet_info getBulletInfo() 116 | { 117 | bullet_info info{}; 118 | 119 | info.velocity_scale = memory.read(reinterpret_cast(this) + 0x284); 120 | 121 | uintptr_t magazine = memory.read(reinterpret_cast(this) + o::BaseProjectile_primaryMagazine); 122 | uintptr_t unity_class = memory.read_chain(magazine, { 0x20, 0x10, 0x30 }); 123 | uintptr_t itemModProjectile = utils.get_component(unity_class, _("ItemModProjectile")); 124 | 125 | info.velocity = memory.read(itemModProjectile + 0x34); 126 | 127 | uintptr_t projectileObject = memory.read(itemModProjectile + 0x18); 128 | 129 | uintptr_t unk0 = memory.read(projectileObject + 0x18); 130 | uintptr_t unk1 = memory.read(unk0 + 0x10); 131 | 132 | uintptr_t projectile = utils.get_component(unk1, _("Projectile")); 133 | 134 | Vector2 projectile_info = memory.read(projectile + 0x24); 135 | 136 | info.drag = projectile_info.x; 137 | info.gravity = projectile_info.y; 138 | 139 | uintptr_t children_list = memory.read(reinterpret_cast(this) + 0x40); 140 | 141 | int children_list_size = memory.read(children_list + 0x18); 142 | children_list = memory.read(children_list + 0x10); 143 | 144 | for (int i = 0; i < children_list_size; ++i) 145 | { 146 | uintptr_t child_entity = memory.read(children_list + (0x20 + (i * 0x8))); 147 | std::string child_entity_name = memory.read_str(memory.read(child_entity + 0x10)); 148 | 149 | if (child_entity_name == _("ProjectileWeaponMod")) 150 | { 151 | ProjectileWeaponModModifier velocity_scalar = memory.read((child_entity + 0x178)); 152 | 153 | if (velocity_scalar.enabled) 154 | info.velocity_scalar = velocity_scalar.scalar; 155 | } 156 | } 157 | 158 | return info; 159 | } 160 | }; -------------------------------------------------------------------------------- /sdk/classes/bone.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | enum bone_list 5 | { 6 | pelvis = 1, 7 | l_hip = 2, 8 | l_knee = 3, 9 | l_foot = 4, 10 | l_toe = 5, 11 | l_ankle_scale = 6, 12 | penis = 7, 13 | GenitalCensor = 8, 14 | GenitalCensor_LOD0 = 9, 15 | Inner_LOD0 = 10, 16 | GenitalCensor_LOD1 = 11, 17 | GenitalCensor_LOD2 = 12, 18 | r_hip = 13, 19 | r_knee = 14, 20 | r_foot = 15, 21 | r_toe = 16, 22 | r_ankle_scale = 17, 23 | spine1 = 18, 24 | spine1_scale = 19, 25 | spine2 = 20, 26 | spine3 = 21, 27 | spine4 = 22, 28 | l_clavicle = 23, 29 | l_upperarm = 24, 30 | l_forearm = 25, 31 | l_hand = 26, 32 | l_index1 = 27, 33 | l_index2 = 28, 34 | l_index3 = 29, 35 | l_little1 = 30, 36 | l_little2 = 31, 37 | l_little3 = 32, 38 | l_middle1 = 33, 39 | l_middle2 = 34, 40 | l_middle3 = 35, 41 | l_prop = 36, 42 | l_ring1 = 37, 43 | l_ring2 = 38, 44 | l_ring3 = 39, 45 | l_thumb1 = 40, 46 | l_thumb2 = 41, 47 | l_thumb3 = 42, 48 | IKtarget_righthand_min = 43, 49 | IKtarget_righthand_max = 44, 50 | l_ulna = 45, 51 | neck = 46, 52 | head = 47, 53 | jaw = 48, 54 | eyeTranform = 49, 55 | l_eye = 50, 56 | l_Eyelid = 51, 57 | r_eye = 52, 58 | r_Eyelid = 53, 59 | r_clavicle = 54, 60 | r_upperarm = 55, 61 | r_forearm = 56, 62 | r_hand = 57, 63 | r_index1 = 58, 64 | r_index2 = 59, 65 | r_index3 = 60, 66 | r_little1 = 61, 67 | r_little2 = 62, 68 | r_little3 = 63, 69 | r_middle1 = 64, 70 | r_middle2 = 65, 71 | r_middle3 = 66, 72 | r_prop = 67, 73 | r_ring1 = 68, 74 | r_ring2 = 69, 75 | r_ring3 = 70, 76 | r_thumb1 = 71, 77 | r_thumb2 = 72, 78 | r_thumb3 = 73, 79 | IKtarget_lefthand_min = 74, 80 | IKtarget_lefthand_max = 75, 81 | r_ulna = 76, 82 | l_breast = 77, 83 | r_breast = 78, 84 | BoobCensor = 79, 85 | BreastCensor_LOD0 = 80, 86 | BreastCensor_LOD1 = 81, 87 | BreastCensor_LOD2 = 82, 88 | collision = 83, 89 | displacement = 84 90 | }; 91 | 92 | class bone_t 93 | { 94 | private: 95 | struct transform_access_read_only_t 96 | { 97 | uint64_t transform_data{}; 98 | }; 99 | 100 | struct transform_data_t 101 | { 102 | uint64_t transform_array{}; 103 | uint64_t transform_indices{}; 104 | }; 105 | 106 | struct matrix34_t 107 | { 108 | Vector4 vec0{}; 109 | Vector4 vec1{}; 110 | Vector4 vec2{}; 111 | }; 112 | 113 | Vector3 get_bone_position(uintptr_t pTransform) 114 | { 115 | __m128 result{}; 116 | 117 | const __m128 mulVec0 = { -2.000, 2.000, -2.000, 0.000 }; 118 | const __m128 mulVec1 = { 2.000, -2.000, -2.000, 0.000 }; 119 | const __m128 mulVec2 = { -2.000, -2.000, 2.000, 0.000 }; 120 | 121 | transform_access_read_only_t transform_access_read_only = memory.read(pTransform + 0x38); 122 | unsigned int index = memory.read(pTransform + 0x40); 123 | transform_data_t transform_data = memory.read(transform_access_read_only.transform_data + 0x18); 124 | 125 | if (transform_data.transform_array && transform_data.transform_indices) 126 | { 127 | result = memory.read<__m128>(transform_data.transform_array + 0x30 * index); 128 | int transform_index = memory.read(transform_data.transform_indices + 0x4 * index); 129 | int safe = 0; 130 | while (transform_index >= 0 && safe++ < 200) 131 | { 132 | matrix34_t matrix = memory.read(transform_data.transform_array + 0x30 * transform_index); 133 | 134 | __m128 xxxx = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0x00)); // xxxx 135 | __m128 yyyy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0x55)); // yyyy 136 | __m128 zwxy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0x8E)); // zwxy 137 | __m128 wzyw = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0xDB)); // wzyw 138 | __m128 zzzz = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0xAA)); // zzzz 139 | __m128 yxwy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix.vec1), 0x71)); // yxwy 140 | __m128 tmp7 = _mm_mul_ps(*(__m128*)(&matrix.vec2), result); 141 | 142 | result = _mm_add_ps(_mm_add_ps( 143 | _mm_add_ps( 144 | _mm_mul_ps( 145 | _mm_sub_ps( 146 | _mm_mul_ps(_mm_mul_ps(xxxx, mulVec1), zwxy), 147 | _mm_mul_ps(_mm_mul_ps(yyyy, mulVec2), wzyw)), 148 | _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0xAA))), 149 | _mm_mul_ps( 150 | _mm_sub_ps( 151 | _mm_mul_ps(_mm_mul_ps(zzzz, mulVec2), wzyw), 152 | _mm_mul_ps(_mm_mul_ps(xxxx, mulVec0), yxwy)), 153 | _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0x55)))), 154 | _mm_add_ps( 155 | _mm_mul_ps( 156 | _mm_sub_ps( 157 | _mm_mul_ps(_mm_mul_ps(yyyy, mulVec0), yxwy), 158 | _mm_mul_ps(_mm_mul_ps(zzzz, mulVec1), zwxy)), 159 | _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0x00))), 160 | tmp7)), *(__m128*)(&matrix.vec0)); 161 | 162 | transform_index = memory.read(transform_data.transform_indices + 0x4 * transform_index); 163 | } 164 | } 165 | 166 | return Vector3(result.m128_f32[0], result.m128_f32[1], result.m128_f32[2]); 167 | } 168 | public: 169 | Vector3 get_entity_bone(uintptr_t player, int bone_index) 170 | { 171 | uintptr_t player_model = memory.read(player + 0x130); // BaseEntity->model 172 | uintptr_t bone_transforms = memory.read(player_model + 0x48); // Model->boneTransforms 173 | uintptr_t entity_bone = memory.read(bone_transforms + (0x20 + (bone_index * 0x8))); 174 | uintptr_t bone = memory.read(entity_bone + 0x10); 175 | return get_bone_position(bone); 176 | } 177 | } bone; 178 | -------------------------------------------------------------------------------- /sdk/classes/camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | struct vmatrix_t 5 | { 6 | union 7 | { 8 | struct 9 | { 10 | float _11, _12, _13, _14; 11 | float _21, _22, _23, _24; 12 | float _31, _32, _33, _34; 13 | float _41, _42, _43, _44; 14 | }; 15 | float m[4][4]; 16 | }; 17 | }; 18 | 19 | class camera_t 20 | { 21 | private: 22 | Vector3 position{}; 23 | vmatrix_t vmatrix{}; 24 | public: 25 | bool set_position(Vector3 _position) 26 | { 27 | position = _position; 28 | return (bool)(position.x && position.y && position.z); 29 | } 30 | 31 | void set_vmatrix(vmatrix_t _vmatrix) 32 | { 33 | vmatrix = _vmatrix; 34 | } 35 | 36 | Vector3 get_position() 37 | { 38 | return position; 39 | } 40 | 41 | vmatrix_t get_vmatrix() 42 | { 43 | return vmatrix; 44 | } 45 | 46 | uintptr_t get_object() 47 | { 48 | /* gom -> tagged_object -> game_object -> object_class -> camera_instance */ 49 | const uintptr_t object = memory.read_chain(globals.unity_player, { o::GameObjectManager, 0x08, 0x10, 0x30 }); 50 | const uintptr_t camera = memory.read(object + 0x18); 51 | return camera; 52 | } 53 | } camera; 54 | 55 | bool world_to_screen(const Vector3& entity_position, Vector2& screen_position) 56 | { 57 | Vector3 transform{ camera.get_vmatrix()._14, camera.get_vmatrix()._24, camera.get_vmatrix()._34}; 58 | Vector3 right{ camera.get_vmatrix()._11, camera.get_vmatrix()._21, camera.get_vmatrix()._31 }; 59 | Vector3 up{ camera.get_vmatrix()._12, camera.get_vmatrix()._22, camera.get_vmatrix()._32 }; 60 | 61 | float w = transform.dot(entity_position) + camera.get_vmatrix()._44; 62 | 63 | Vector2 pos{ right.dot(entity_position) + camera.get_vmatrix()._41, up.dot(entity_position) + camera.get_vmatrix()._42 }; 64 | 65 | if (w < 0.098f) 66 | return false; 67 | 68 | screen_position = Vector2(globals.screen_center_x * (1 + pos.x / w), globals.screen_center_y * (1 - pos.y / w)); 69 | 70 | return true; 71 | } -------------------------------------------------------------------------------- /sdk/classes/item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class Item 5 | { 6 | public: 7 | ItemDefinition* itemDefinition() 8 | { 9 | return memory.read(reinterpret_cast(this) + o::Item_info); 10 | } 11 | 12 | BaseProjectile* baseProjectile() 13 | { 14 | return memory.read(reinterpret_cast(this) + o::Item_heldEntity); 15 | } 16 | 17 | bool isValid() 18 | { 19 | return baseProjectile(); 20 | } 21 | }; -------------------------------------------------------------------------------- /sdk/classes/itemdefinition.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class ItemDefinition 5 | { 6 | public: 7 | std::string getShortname() 8 | { 9 | uintptr_t nameptr = memory.read(reinterpret_cast(this) + 0x20); 10 | std::wstring shortname = memory.read_wstr(nameptr + 0x14); 11 | return std::string(shortname.begin(), shortname.end()); 12 | } 13 | 14 | std::string getDisplayName() 15 | { 16 | uintptr_t translation = memory.read(reinterpret_cast(this) + 0x28); 17 | uintptr_t nameptr = memory.read(translation + 0x18); 18 | std::wstring shortname = memory.read_wstr(nameptr + 0x14); 19 | 20 | // shotgun filter 21 | { 22 | std::wstring shotgun_filter = _(L" Shotgun"); 23 | size_t shotgun_pos = shortname.find(shotgun_filter); 24 | if (shotgun_pos != std::string::npos) 25 | shortname.erase(shotgun_pos, shotgun_filter.length()); 26 | } 27 | // shorten some names more 28 | { 29 | std::wstring automatic_filter = _(L"Automatic "); // so we can keep 'semi-rifle', 'semi-pistol', etc... 30 | size_t automatic_pos = shortname.find(automatic_filter); 31 | if (automatic_pos != std::string::npos) 32 | shortname.erase(automatic_pos, automatic_filter.length()); 33 | 34 | std::wstring lr_300_filter = _(L"LR-300 Assault Rifle"); // shorten to 'LR-300' 35 | size_t lr_300_pos = shortname.find(lr_300_filter); 36 | if (lr_300_pos != std::string::npos) 37 | shortname = _(L"LR-300"); 38 | } 39 | 40 | return (shortname.length() > 128 || shortname.empty()) ? _("None") : std::string(shortname.begin(), shortname.end()); 41 | } 42 | }; -------------------------------------------------------------------------------- /sdk/classes/modelstate.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class ModelState 5 | { 6 | public: 7 | static enum Flags 8 | { 9 | Ducked = 1, 10 | Jumped = 2, 11 | OnGround = 4, 12 | Sleeping = 8, 13 | Sprinting = 16, 14 | OnLadder = 32, 15 | Flying = 64, 16 | Aiming = 128, 17 | Prone = 256, 18 | Mounted = 512, 19 | Relaxed = 1024, 20 | OnPhone = 2048, 21 | Crawling = 4096 22 | }; 23 | 24 | void setWaterLevel(float level) 25 | { 26 | memory.write(reinterpret_cast(this) + o::ModelState_waterLevel, level); 27 | } 28 | 29 | bool hasFlag(int flag) 30 | { 31 | return (memory.read(reinterpret_cast(this) + o::ModelState_flags)) & flag; 32 | } 33 | 34 | void setFlag(int flag) 35 | { 36 | int current_flags = memory.read(reinterpret_cast(this) + o::ModelState_flags); 37 | memory.write(reinterpret_cast(this) + o::ModelState_flags, current_flags |= flag); 38 | } 39 | 40 | void unsetFlag(int flag) 41 | { 42 | uintptr_t player_flags = memory.read(reinterpret_cast(this) + o::ModelState_flags); 43 | 44 | if (hasFlag(flag)) 45 | player_flags -= flag; 46 | 47 | memory.write(reinterpret_cast(this) + o::ModelState_flags, player_flags); 48 | } 49 | }; -------------------------------------------------------------------------------- /sdk/classes/playereyes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class PlayerEyes 5 | { 6 | public: 7 | void setViewOffset(Vector3 view_offset) 8 | { 9 | memory.write(reinterpret_cast(this) + o::PlayerEyes_viewOffset, view_offset); 10 | } 11 | 12 | Vector3 getViewOffset() 13 | { 14 | return memory.read(reinterpret_cast(this) + o::PlayerEyes_viewOffset); 15 | } 16 | 17 | void lookAtPoint(Vector2 angles) 18 | { 19 | angles.normalize(); 20 | memory.write(reinterpret_cast(this) + o::PlayerEyes_bodyRotation, to_quat({ angles.x, angles.y, 0.f })); 21 | } 22 | }; -------------------------------------------------------------------------------- /sdk/classes/playerinput.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class PlayerInput 5 | { 6 | public: 7 | Vector2 getViewAngles() 8 | { 9 | return memory.read(reinterpret_cast(this) + o::PlayerInput_bodyAngles); 10 | } 11 | 12 | void setViewAngles(Vector2 angles) 13 | { 14 | memory.write(reinterpret_cast(this) + o::PlayerInput_bodyAngles, angles); 15 | } 16 | 17 | Vector4 getRotation() 18 | { 19 | return memory.read(reinterpret_cast(this) + o::PlayerInput_bodyRotation); 20 | } 21 | }; 22 | 23 | 24 | -------------------------------------------------------------------------------- /sdk/classes/playermodel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | #define SKINTYPE_FEMALE 1 5 | 6 | class PlayerModel 7 | { 8 | public: 9 | Vector3 getTargetVelocity() { return memory.read(reinterpret_cast(this) + o::PlayerModel_newVelocity); } 10 | bool isLocalPlayer() { return memory.read(reinterpret_cast(this) + o::PlayerModel_isLocalPlayer); } 11 | bool isNPC() { return memory.read(reinterpret_cast(this) + o::PlayerModel_IsNPC); } 12 | bool isVisible() { return memory.read(reinterpret_cast(this) + o::PlayerModel_visible); } 13 | 14 | void applyChams() 15 | { 16 | return; 17 | } 18 | }; -------------------------------------------------------------------------------- /sdk/classes/playerwalkmovement.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class PlayerWalkMovement 5 | { 6 | public: 7 | void setCapsuleCenter(float center) 8 | { 9 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_capsuleCenter, center); 10 | } 11 | 12 | void setTargetMovement(Vector3 target) 13 | { 14 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_targetMovement, target); 15 | } 16 | 17 | void setGrounded(float grounded) 18 | { 19 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_grounded, grounded); 20 | } 21 | 22 | void setSprinting(float sprinting) 23 | { 24 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_sprinting, sprinting); 25 | } 26 | 27 | void setGroundAngle(float angle) 28 | { 29 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_groundAngle, angle); 30 | } 31 | void setGroundAngleNew(float angle) 32 | { 33 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_groundAngleNew, angle); 34 | } 35 | 36 | void setJumpTime(float jump_time) 37 | { 38 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_jumpTime, jump_time); 39 | } 40 | 41 | void setGroundTime(float ground_time) 42 | { 43 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_groundTime, ground_time); 44 | } 45 | 46 | void setLandTime(float land_time) 47 | { 48 | memory.write(reinterpret_cast(this) + o::PlayerWalkMovement_landTime, land_time); 49 | } 50 | }; -------------------------------------------------------------------------------- /sdk/classes/prefab.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class prefab_t 5 | { 6 | public: 7 | uintptr_t transform; 8 | Vector3 position; 9 | std::string name; 10 | public: 11 | prefab_t(uintptr_t entity_address, uintptr_t entity_transform, uintptr_t game_object) 12 | { 13 | this->transform = memory.read(entity_transform + 0x38); 14 | this->position = memory.read(this->transform + 0x90); 15 | this->name = memory.read_str(memory.read(game_object + 0x60), 1024); 16 | 17 | /* for dropped items */ 18 | if (this->name.find(_("item_drop.prefab")) != std::string::npos) 19 | this->name = _("item drop"); 20 | 21 | /* removes (world)*/ 22 | std::string world_str = _(" (world)"); 23 | if (this->name.find(world_str) != std::string::npos) 24 | this->name.erase(this->name.find(world_str), world_str.length()); 25 | 26 | /* changes dots to spaces between names */ 27 | std::replace(this->name.begin(), this->name.end(), '.', ' '); // replace all dots in name with a space, looks nicer 28 | } 29 | 30 | prefab_t() = default; 31 | 32 | ~prefab_t() 33 | { 34 | this->transform = NULL; 35 | this->position = { 0.f, 0.f, 0.f }; 36 | this->name = _(""); 37 | } 38 | 39 | std::string get_name() 40 | { 41 | return this->name; 42 | } 43 | 44 | void update() 45 | { 46 | if (!this->position.is_valid()) 47 | this->position = memory.read(this->transform + 0x90); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /sdk/classes/projectile.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | class Projectile 5 | { 6 | public: 7 | float getDrag() 8 | { 9 | return memory.read(reinterpret_cast(this) + o::Projectile_drag); 10 | } 11 | 12 | float getGravityModifier() 13 | { 14 | return memory.read(reinterpret_cast(this) + o::Projectile_gravityModifier); 15 | } 16 | 17 | float getThickness() 18 | { 19 | return memory.read(reinterpret_cast(this) + o::Projectile_thickness); 20 | } 21 | }; -------------------------------------------------------------------------------- /sdk/game/aimbot.hpp: -------------------------------------------------------------------------------- 1 | #include "../../common.hpp" 2 | 3 | #include 4 | 5 | static enum TARGETS 6 | { 7 | HEAD = 47, 8 | BODY = 21, 9 | NEAREST = 3, 10 | }; 11 | 12 | int bone_target = TARGETS::HEAD; 13 | 14 | class aimbot_t 15 | { 16 | private: 17 | Vector3 prediction(Vector3 position) 18 | { 19 | Item* item = players.local->getHeldItem(); 20 | 21 | bullet_info info{}; 22 | 23 | info = item->baseProjectile()->getBulletInfo(); 24 | 25 | float distance_to = camera.get_position().distance(position); 26 | float bullet_speed = info.velocity * (info.velocity_scale * info.velocity_scalar); 27 | float bullet_gravity = info.gravity; 28 | float bullet_time = distance_to / bullet_speed; 29 | float bullet_drag = info.drag; 30 | 31 | Vector3 direction = position - camera.get_position(); 32 | float target_distance = std::sqrt((direction.x) * (direction.x) + (direction.z) * (direction.z)); 33 | float bullet_drop = calculate_bullet_drop(direction.y, target_distance, bullet_speed, bullet_gravity); 34 | 35 | const float time_step = 0.015625f; 36 | 37 | float travelled; 38 | float speed; 39 | float time; 40 | float divider; 41 | 42 | for (float distance_to_travel = 0.f; distance_to_travel < distance_to;) 43 | { 44 | float speed_modifier = 1.f - time_step * bullet_drag; 45 | bullet_speed *= speed_modifier; 46 | 47 | if (bullet_speed <= 0.f || bullet_speed >= 10000.f || travelled >= 10000.f || travelled < 0.f) 48 | break; 49 | 50 | if (time > 8.f) 51 | break; 52 | 53 | speed += (9.81f * bullet_gravity) * time_step; 54 | speed *= speed_modifier; 55 | 56 | distance_to_travel += bullet_speed * time_step; 57 | travelled += speed * time_step; 58 | time += time_step; 59 | } 60 | 61 | Vector3 new_target = position; 62 | 63 | Vector3 velocity = players.aimbot_target->playerModel()->getTargetVelocity() * 0.75f; 64 | 65 | if (velocity.y > 0.f) 66 | velocity.y /= 3.25f; 67 | 68 | new_target.y += bullet_drop; 69 | new_target += velocity * time; 70 | return new_target; 71 | } 72 | 73 | Vector3 find_target() 74 | { 75 | BasePlayer* temp_target{}; 76 | 77 | Vector2 center = { globals.screen_center_x, globals.screen_center_y }; 78 | 79 | float smallest_distance = FLT_MAX; 80 | Vector3 final_aimpoint{}; 81 | 82 | for (const auto& entity : entity_list.player_list) 83 | { 84 | BasePlayer* player = memory.read(entity + 0x28); 85 | 86 | if (!player) 87 | continue; 88 | 89 | if (player->isDead()) 90 | continue; 91 | 92 | if (!player->playerModel()->isVisible()) 93 | continue; 94 | 95 | Vector3 aimpoint{}; 96 | 97 | if (bone_target != TARGETS::NEAREST) aimpoint = player->getBone((bone_list)bone_target); 98 | 99 | if (bone_target == TARGETS::NEAREST) 100 | { 101 | Vector3 head = player->getBone(bone_list::head); 102 | Vector2 head_screen{}; 103 | 104 | if (!world_to_screen(head, head_screen)) 105 | continue; 106 | 107 | Vector3 body = player->getBone(bone_list::head); 108 | Vector2 body_screen{}; 109 | 110 | if (!world_to_screen(body, body_screen)) 111 | continue; 112 | 113 | float body_distance = body_screen.distance(center); 114 | float head_distance = head_screen.distance(center); 115 | 116 | if (body_distance < head_distance) 117 | aimpoint = body; 118 | 119 | if (head_distance < body_distance) 120 | aimpoint = head; 121 | } 122 | 123 | Vector2 aimpoint_screen{}; 124 | 125 | if (!world_to_screen(aimpoint, aimpoint_screen)) 126 | continue; 127 | 128 | float current_distance = aimpoint_screen.distance(center); 129 | 130 | if (current_distance < smallest_distance) 131 | { 132 | temp_target = player; 133 | smallest_distance = current_distance; 134 | final_aimpoint = aimpoint; 135 | } 136 | } 137 | 138 | players.aimbot_target = temp_target; 139 | 140 | return final_aimpoint; 141 | } 142 | public: 143 | void run() 144 | { 145 | while (true) 146 | { 147 | std::this_thread::sleep_for(std::chrono::milliseconds(5)); 148 | 149 | if (!GetAsyncKeyState(VK_XBUTTON2)) 150 | continue; 151 | 152 | Vector3 target = prediction(find_target()); 153 | 154 | if (players.local->getHeldItem()->isValid()) 155 | { 156 | /* regular */ 157 | players.local->playerInput()->setViewAngles(calculate_angle(camera.get_position(), target)); 158 | /* silent-aim */ 159 | //players.local->eyes()->lookAtPoint(calculate_angle(camera.get_position(), target)); 160 | } 161 | } 162 | } 163 | 164 | }aimbot; -------------------------------------------------------------------------------- /sdk/game/entity_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | #include 4 | 5 | typedef unsigned int list_size; 6 | 7 | #define PLAYER_TAG 6 8 | 9 | struct list_info_t 10 | { 11 | std::vector address{}; 12 | int size = NULL; 13 | uintptr_t list = NULL; 14 | uintptr_t base = NULL; 15 | }; 16 | 17 | class entity_list_t 18 | { 19 | private: 20 | list_info_t get_list() 21 | { 22 | list_info_t list_info{}; 23 | 24 | list_info.list = memory.read_chain(globals.base_networkable, { 0xb8, 0x00, 0x10, 0x28 }); 25 | list_info.base = memory.read(list_info.list + 0x18); 26 | list_info.size = memory.read(list_info.list + 0x10); 27 | 28 | /* create our buffer */ 29 | std::unique_ptr entities_buffer(new uintptr_t[list_info.size * sizeof(uintptr_t)]); 30 | 31 | /* read into the buffer */ 32 | memory.read(list_info.base + 0x20, entities_buffer.get(), list_info.size * sizeof(uintptr_t)); 33 | 34 | /* set address in struct */ 35 | list_info.address = { entities_buffer.get(), entities_buffer.get() + (uintptr_t)list_info.size }; 36 | 37 | return list_info; 38 | } 39 | public: 40 | std::vector object_list{}; 41 | 42 | std::vector player_list{}; 43 | std::vector prefab_list{}; 44 | 45 | void cache() 46 | { 47 | std::vector temp_player_list{}; 48 | std::vector temp_prefab_list{}; 49 | 50 | object_list = get_list().address; 51 | 52 | for (const auto& object : object_list) 53 | { 54 | uintptr_t gameobject = memory.read_chain(object, { 0x10, 0x30 }); 55 | unsigned short tag = memory.read(gameobject + 0x54); 56 | 57 | if (tag == PLAYER_TAG) 58 | { 59 | temp_player_list.push_back(memory.read(object + 0x10)); 60 | } 61 | else 62 | { 63 | uintptr_t object_class = memory.read(gameobject + 0x30); 64 | uintptr_t entity = memory.read(object_class + 0x18); 65 | uintptr_t transform = memory.read(object_class + 0x08); 66 | prefab_t prefab_entity = prefab_t(entity, transform, gameobject); 67 | temp_prefab_list.push_back(prefab_entity); 68 | } 69 | } 70 | 71 | player_list = temp_player_list; 72 | temp_player_list.clear(); 73 | 74 | prefab_list = temp_prefab_list; 75 | temp_prefab_list.clear(); 76 | } 77 | 78 | bool setup() 79 | { 80 | /* set game camera position */ 81 | camera.set_position(memory.read(camera.get_object() + 0x42c)); 82 | 83 | /* set game view matrix */ 84 | camera.set_vmatrix(memory.read(camera.get_object() + 0x2e4)); 85 | 86 | return camera.get_position().is_valid(); 87 | } 88 | 89 | void prefab_loop() 90 | { 91 | for (const auto& prefab : prefab_list) 92 | { 93 | Vector2 screen{}; 94 | if (world_to_screen(prefab.position, screen)) 95 | { 96 | /* 97 | * heres where i render stuff for it 98 | */ 99 | } 100 | } 101 | } 102 | 103 | void player_loop() 104 | { 105 | for (const auto& entity : player_list) 106 | { 107 | BasePlayer* player = memory.read(entity + 0x28); 108 | 109 | if (!player) 110 | continue; 111 | 112 | if (player->getDistance(camera.get_position()) > 300) 113 | continue; 114 | 115 | if (player->isDead()) 116 | continue; 117 | 118 | if (player->isLocalPlayer()) 119 | { 120 | players.local = player; 121 | globals.weapon_name = players.local->getHeldItem()->itemDefinition()->getDisplayName(); 122 | 123 | /* 124 | * administrator flags 125 | */ 126 | if (!player->hasFlag(BasePlayer::Flags::IsAdmin)) 127 | player->setFlag(BasePlayer::Flags::IsAdmin); 128 | 129 | /* 130 | * makes us able to shoot in a minicopter 131 | * make sure you alt look to shoot someone 132 | * as you cannot change your viewangles 133 | */ 134 | if (players.local->modelState()->hasFlag(ModelState::Flags::Mounted)) 135 | players.local->mounted()->setCanHoldItems(true); 136 | 137 | 138 | if (players.local->getHeldItem()->isValid()) 139 | { 140 | players.local->getHeldItem()->baseProjectile()->noSpread(); 141 | 142 | players.local->getHeldItem()->baseProjectile()->pushToMap(); 143 | 144 | /* 145 | * readd the commented stuff 146 | */ 147 | //if (no_recoil) 148 | { 149 | players.local->getHeldItem()->baseProjectile()->unsetRecoil(); 150 | players.local->getHeldItem()->baseProjectile()->noRecoil(); 151 | } 152 | //else 153 | //{ 154 | // players.local->getHeldItem()->baseProjectile()->restoreRecoil(); 155 | //} 156 | } 157 | 158 | continue; 159 | } 160 | else 161 | { 162 | bounding_box_t box = player->getBoundingBox(); 163 | 164 | if (!box.foot_screen.x || !box.foot_screen.y || !box.head_screen.x || !box.head_screen.y) 165 | continue; 166 | 167 | /* 168 | * this is all you need for esp, just add it here 169 | */ 170 | } 171 | } 172 | } 173 | } entity_list; 174 | -------------------------------------------------------------------------------- /sdk/game/features.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../common.hpp" 3 | 4 | static enum DIRECTIONS 5 | { 6 | NONE = 0, 7 | LEFT = 1, 8 | RIGHT = 2, 9 | }; 10 | 11 | int direction = 0; 12 | 13 | class features_t 14 | { 15 | private: 16 | void desync() 17 | { 18 | 19 | } 20 | 21 | void interactive_debug_camera() 22 | { 23 | 24 | } 25 | 26 | void fov_changer(float fov) 27 | { 28 | uintptr_t fov_cvar = memory.read_chain(globals.game_assembly, { o::Graphics_c, 0xb8 }); 29 | memory.write(fov_cvar + o::Graphics_fov, fov); 30 | } 31 | public: 32 | void run() 33 | { 34 | while (true) 35 | { 36 | // shoot in air 37 | players.local->modelState()->setFlag(ModelState::Flags::OnGround); 38 | players.local->playerWalkMovement()->setGrounded(1.f); 39 | 40 | // spiderman 41 | players.local->playerWalkMovement()->setGroundAngle(0.f); 42 | players.local->playerWalkMovement()->setGroundAngleNew(0.f); 43 | 44 | // infinite jump 45 | players.local->playerWalkMovement()->setGroundTime(99999.f); 46 | players.local->playerWalkMovement()->setJumpTime(0.51f); 47 | players.local->playerWalkMovement()->setLandTime(0.3f); 48 | 49 | desync(); 50 | interactive_debug_camera(); 51 | fov_changer(120.f); 52 | 53 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); 54 | } 55 | } 56 | } features; -------------------------------------------------------------------------------- /sdk/game/players.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../common.hpp" 4 | 5 | class players_t 6 | { 7 | public: 8 | BasePlayer* local{}; 9 | BasePlayer* aimbot_target{}; 10 | } players; -------------------------------------------------------------------------------- /sdk/offsets.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define rust_offset constexpr uintptr_t 4 | 5 | namespace o 6 | { 7 | // UnityPlayer (ida) 8 | rust_offset GameObjectManager = 0x17C1F18; 9 | 10 | // Script.json 11 | rust_offset BaseEntity_c = 0x3217C48; // BaseEntity_c 12 | rust_offset BaseNetworkable_c = 0x32188A8; // BaseNetworkable_c 13 | rust_offset Graphics_c = 0x32494C8; 14 | 15 | // camera 16 | rust_offset MainCamera_c = 0x32197F8; 17 | 18 | // Graphics 19 | rust_offset grassshadows = 0x10; 20 | rust_offset contactshadows = 0x11; 21 | rust_offset Graphics_drawdistance = 0x14; 22 | rust_offset Graphics_fov = 0x18; 23 | rust_offset Graphics_hud = 0x1C; 24 | rust_offset Graphics_chat = 0x1D; 25 | 26 | // Base Player 27 | rust_offset BasePlayer_modelstate = 0x5F8; 28 | rust_offset BasePlayer_playerFlags = 0x688; 29 | rust_offset BasePlayer_playerModel = 0x4C8; 30 | rust_offset BasePlayer_playerInput = 0x4E8; 31 | rust_offset BasePlayer_playerWalkMovement = 0x4F0; 32 | rust_offset BasePlayer_clientTickInterval = 0x650; 33 | rust_offset BasePlayer_displayName = 0x6E8; 34 | rust_offset BasePlayer_eyes = 0x690; 35 | rust_offset BasePlayer_inventory = 0x698; 36 | rust_offset BasePlayer_needsClothesRebuild = 0x528; 37 | rust_offset BasePlayer_lastSentTickTime = 0x654; 38 | rust_offset BasePlayer_mounted = 0x600; 39 | 40 | // Base Combat Entity 41 | rust_offset BaseCombatEntity_health = 0x22C; 42 | rust_offset BaseCombatEntity_maxHealth = 0x230; 43 | rust_offset BaseCombatEntity_lifestate = 0x224; 44 | 45 | // Model State 46 | rust_offset ModelState_waterLevel = 0x14; 47 | rust_offset ModelState_flags = 0x24; 48 | 49 | // Player Walk Movement 50 | rust_offset PlayerWalkMovement_groundAngle = 0xC4; 51 | rust_offset PlayerWalkMovement_groundAngleNew = 0xC8; 52 | rust_offset PlayerWalkMovement_groundTime = 0xCC; 53 | rust_offset PlayerWalkMovement_jumpTime = 0xD0; 54 | rust_offset PlayerWalkMovement_landTime = 0xD4; 55 | rust_offset PlayerWalkMovement_grounded = 0x4C; 56 | rust_offset PlayerWalkMovement_sprinting = 0x40; 57 | rust_offset PlayerWalkMovement_targetMovement = 0x34; 58 | rust_offset PlayerWalkMovement_capsuleCenter = 0x6C; 59 | 60 | // Player Model 61 | rust_offset PlayerModel_newVelocity = 0x23C; 62 | rust_offset PlayerModel_isLocalPlayer = 0x299; 63 | rust_offset PlayerModel_MaleSkin = 0x1A0; 64 | rust_offset PlayerModel_FemaleSkin = 0x1A8; 65 | rust_offset PlayerModel_IsNPC = 0x320; 66 | rust_offset PlayerModel_visible = 0x288; 67 | 68 | // Player Input 69 | rust_offset PlayerInput_bodyAngles = 0x3C; 70 | rust_offset PlayerInput_bodyRotation = 0x2C; 71 | 72 | // Player Eyes 73 | rust_offset PlayerEyes_viewOffset = 0x38; 74 | rust_offset PlayerEyes_bodyRotation = 0x44; 75 | 76 | // Projectile 77 | rust_offset Projectile_drag = 0x24; 78 | rust_offset Projectile_gravityModifier = 0x28; 79 | rust_offset Projectile_thickness = 0x2C; 80 | 81 | // Base Projectile 82 | rust_offset BaseProjectile_automatic = 0x290; 83 | rust_offset BaseProjectile_canUnloadAmmo = 0x2BC; 84 | rust_offset BaseProjectile_primaryMagazine = 0x2C0; 85 | rust_offset BaseProjectile_aimSway = 0x2D8; 86 | rust_offset BaseProjectile_aimCone = 0x2F0; 87 | rust_offset BaseProjectile_recoil = 0x2E0; 88 | rust_offset BaseProjectile_aiming = 0x311; 89 | rust_offset BaseProjectile_isReloading = 0x340; 90 | rust_offset BaseProjectile_createdProjectiles = 0x370; 91 | 92 | // Magazine 93 | rust_offset Magazine_definition = 0x10; 94 | rust_offset Magazine_capacity = 0x18; 95 | rust_offset Magazine_contents = 0x1C; 96 | rust_offset Magazine_ammoType = 0x20; 97 | 98 | // Recoil Properties 99 | rust_offset RecoilProperties_recoilYawMin = 0x18; 100 | rust_offset RecoilProperties_recoilYawMax = 0x1C; 101 | rust_offset RecoilProperties_recoilPitchMin = 0x20; 102 | rust_offset RecoilProperties_recoilPitchMax = 0x24; 103 | rust_offset RecoilProperties_ADSScale = 0x30; 104 | rust_offset RecoilProperties_movementPenalty = 0x34; 105 | 106 | // Item 107 | rust_offset Item_info = 0x20; 108 | rust_offset Item_uid = 0x28; 109 | rust_offset Item_amount = 0x30; 110 | rust_offset Item_heldEntity = 0x98; 111 | 112 | // Inventory 113 | rust_offset Inventory_containerMain = 0x20; 114 | rust_offset Inventory_containerBelt = 0x28; 115 | rust_offset Inventory_containerWear = 0x30; 116 | rust_offset Inventory_crafting = 0x38; 117 | rust_offset Inventory_loot = 0x40; 118 | 119 | // BaseMountable 120 | rust_offset BaseMountable_pitchClamp = 0x2A8; 121 | rust_offset BaseMountable_yawClamp = 0x2B0; 122 | rust_offset BaseMountable_canWieldItems = 0x2B8; 123 | rust_offset BaseMountable_canDrinkWhileMounted = 0x310; 124 | } 125 | --------------------------------------------------------------------------------