Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include "plugin.h"
- #include <game_sa\CVehicle.h>
- #include <game_sa\RenderWare.h>
- #include <game_sa\CSprite.h>
- #include <game_sa\CFont.h>
- #include "VehicleExtender.h"
- using namespace plugin;
- class VehicleColor{
- public:
- unsigned char red, green, blue;
- VehicleColor(CVehicle *vehicle){
- red = rand() % 255; green = rand() % 255; blue = rand() % 255;
- }
- };
- VehicleExtendedData<VehicleColor> vehicleColorData;
- RpMaterial *MaterialCallback(RpMaterial *material, VehicleColor *color){
- material->color.red = color->red; material->color.green = color->green; material->color.blue = color->blue;
- return material;
- }
- RpAtomic *AtomicCallback(RpAtomic *atomic, VehicleColor *color){
- if (atomic->geometry)
- RpGeometryForAllMaterials(atomic->geometry, MaterialCallback, color);
- return atomic;
- }
- void OnVehicleRender(CVehicle *vehicle){
- if (vehicle->m_pRwObject && vehicle->m_pRwObject->type == rpCLUMP)
- RpClumpForAllAtomics(reinterpret_cast<RpClump*>(vehicle->m_pRwObject), AtomicCallback, vehicleColorData.Get(vehicle));
- }
- void OnScreenDrawing()
- {
- for (int i = 0; i < CPools::ms_pVehiclePool->m_Size; i++)
- {
- if (!CPools::ms_pVehiclePool->IsFreeSlotAtIndex(i))
- {
- CVehicle *vehicle = reinterpret_cast<CVehicle *>(&CPools::ms_pVehiclePool->m_Objects[i]);
- CVector &posn = vehicle->m_pCoords ? vehicle->m_pCoords->pos : vehicle->m_Placement.m_vPosn;
- RwV3d rwp = { posn.x, posn.y, posn.z + 1.0f };
- RwV3d screenCoors; float w, h;
- if (CSprite::CalcScreenCoors(rwp, &screenCoors, &w, &h, true, true))
- {
- CFont::SetAlignment(ALIGN_CENTER);
- CFont::SetColor(CRGBA(vehicleColorData.Get(vehicle)->red, vehicleColorData.Get(vehicle)->green, vehicleColorData.Get(vehicle)->blue, 255));
- CFont::SetOutlinePosition(1);
- CFont::SetBackground(false, false);
- CFont::SetWrapx(500.0);
- CFont::SetScale(0.5, 1.0);
- CFont::SetFontStyle(FONT_SUBTITLES);
- CFont::SetProp(true);
- char text[16];
- sprintf(text, "%d %d %d", vehicleColorData.Get(vehicle)->red, vehicleColorData.Get(vehicle)->green, vehicleColorData.Get(vehicle)->blue);
- CFont::PrintString(screenCoors.x, screenCoors.y, text);
- }
- }
- }
- }
- BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved){
- if (reason == DLL_PROCESS_ATTACH){
- Events::drawingEvent += OnScreenDrawing;
- Events::vehicleRenderEvent += OnVehicleRender;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement