This message is in reply to a question Pizzaman had, and I wanted to post the answer more publicly so everyone could benefit. You can add parameters to all sprites, or all sprites of a particular type by creating a class that inherits from SpriteBase, then configuring your sprites to inherit from that. First create the base class like this (create a new source code object and delete the lines that put it into the CustomObjects namespace):
public abstract class UserSprite : SpriteBase
{
public string Username;
public int userId;
public UserSprite(LayerBase layer, double x, double y, double dx, double dy, int state, int frame, bool active, Solidity solidity, int color)
: base(layer, x, y, dx, dy, state, frame, active, solidity, color)
{
}
}
This class adds a "Username" and a "userId".
Make sure your project builds. Then go to the sprite definition screen and you should see a new option in the Base Class dropdown list as shown in the attached screenshot. If you choose "UserSprite", the extra values you added in this class will be available in the rule editor.
HOWEVER, the rule editor only shows integer type parameters, so although you will see "userId" in the dropdown lists in the rule editor, you will not see Username. But that doesn't mean you can't use Username. It just means you'll have to type it manually. Most of the built-in functions try to use integers and stay away from strings because it limits complexity and room for error. Notice how the SaveGame functions, for example, use slot numbers instead of saved game file names. Then you don't have to always remember to be quoting your parameters to make sure they're actually strings.