CheatMenuSA/src/VehExtender.h

29 lines
564 B
C
Raw Normal View History

2021-02-27 15:40:51 -05:00
/*
VS Code extension doesn't work well with template classes
*/
#pragma once
#include <vector>
#include "CVehicle.h"
template <class T>
class VehExtender
{
public:
VehExtender(){};
VehExtender(const VehExtender&) = delete;
T& Get(CVehicle *veh)
{
static std::vector<std::pair<CVehicle*,T>> data;
for (auto it = data.begin(); it < data.end(); ++it)
{
if (it->first == veh)
return it->second;
}
data.push_back({veh, T(veh)});
return data.back().second;
}
};