So I stumbled across the feature that you can chain methodmaps (see below).
Spoiler
Code:
#include <sourcemod>
enum Chain
{
INVALID_CHAIN = -1
};
methodmap Chain
{
public Chain Do()
{
// Some other code
return this;
}
};
public Plugin myinfo =
{
name = "",
author = "",
version = "",
description = "",
url = ""
};
public void OnPluginStart()
{
Chain test = view_as<Chain>(1);
test.Do().Do().Do();
}
I think this would be useful to implement in some of the methodmaps that come with sourcemod, such as StringMap. Of course, this would only work with functions where return value isn't needed.
Here would be an example:
Spoiler
Code:
void SomeFunction()
{
StringMap foo = new StringMap();
int value;
foo.SetValue("bar", 1).SetString("full", "foobar").GetValue("bar", value);
}
This wouldn't be difficult to change in the current methodmaps for at least the functions that would normally return void, or even some like
StringMap.GetValue() that returns a boolean. It could be modified to support default values like
KeyValues.GetNum().
If not possible, I could even write up some extended methodmaps to apply this functionality under types (tags? I don't know the term here) like
StringMapEx.
__________________