feat: add Convar<T> for real convar creation/deletion/access
This PR adds Convar<T> which is a strongly typed variant of ConVar which provides better safety (no raw pointer accesses), as well as the ability to create real-convars that exist within the engine (and can be found using find foo in the console) amongst other things.
TODO:
- Add BasePlugin based registration so that convars are automatically unloaded (similar to FakeConvar). Should the
.Createstatic be restricted?
This looks awesome. Would be great to also have a list of known ConVars that utilize this to reduce mistake of accidentally using the wrong type with a ConVar. This however would be fitting in another PR I suppose.
https://cs2.poggu.me/dumped-data/convar-list
This looks awesome. Would be great to also have a list of known ConVars that utilize this to reduce mistake of accidentally using the wrong type with a ConVar. This however would be fitting in another PR I suppose.
https://cs2.poggu.me/dumped-data/convar-list
Yes I know of that. But implement some of these at least into C# as statically typed to make use of the strength of static typing and static code analysis to reduce mistakes and catch erronous usage at compile time.
For example would it be suitable to do something similar to this?
public static class KnownConVars
{
public static ConVar<bool> SvCheats = new ConVar<bool>("sv_cheats");
public static ConVar<int> MpWarmupTime = new ConVar<int>("mp_warmuptime");
public static ConVar<float> MaxSpeed = new ConVar<float>("sv_maxspeed");
// Example: Add other ConVars here...
}