Hi guys,
So many servers seem to have an attribute system defined on Mobile class (Player / NPC). This is used for defining temporary or "soft" properties that may or may not exist.
I guess the benefit is the class becomes less cluttered, but what is your opinion on it? Is it bad practice because these are basically now just hidden class members?
Or is it convenient because you may/may not have to define these properties before their used.
Or is it good to reduce the need for having getters/setters for every simple property?
Or am I missing another reason?
Example:
Code:
player.<Boolean>getAttributeOr(AttributeKey.DEFENSIVE_AUTOCAST, false)
This determines whether the player has selected to use Defensive autocast mode or regular autocast mode.
The code to set this attribute would be:
Code:
player.putAttribute(AttributeKey.DEFENSIVE_AUTOCAST, true);
Here's me implementing this into our core repo (feel free to copy and paste if you like):
https://github.com/RSPSApp/elvarg-rsps/pull/65/files
Edit: Since Spooky mentioned varps and I hadn't a clue what they were (don't judge me), here's a link:
What are varps and varbits?