CS2-Kit
C++23 library for CS2 Metamod:Source plugin development
Loading...
Searching...
No Matches
EntityRender.cpp
Go to the documentation of this file.
1#include "Sdk/Schema.hpp"
2
3#include <CS2Kit/Sdk/EntityRender.hpp>
4#include <entity2/entityinstance.h>
5
6namespace CS2Kit::Sdk
7{
8
9void SetEntityRender(CEntityInstance* entity, RenderMode_t mode, uint32_t color)
10{
11 if (!entity)
12 return;
13
14 auto& schema = SchemaService::Instance();
15 int modeOffset = schema.GetOffset("CBaseModelEntity", "m_nRenderMode");
16 int colorOffset = schema.GetOffset("CBaseModelEntity", "m_clrRender");
17 if (modeOffset < 0 || colorOffset < 0)
18 return;
19
20 auto* base = reinterpret_cast<uint8_t*>(entity);
21 *reinterpret_cast<uint8_t*>(base + modeOffset) = static_cast<uint8_t>(mode);
22 *reinterpret_cast<uint32_t*>(base + colorOffset) = color;
23}
24
25} // namespace CS2Kit::Sdk
void SetEntityRender(CEntityInstance *entity, RenderMode_t mode, uint32_t color)