Open
Description
Issue Checklist
- I have properly named my enhancement
- I have checked the Issues/Discussions pages to see if my enhancement has already been suggested
What is your suggestion, and why should it be implemented?
Properties are a Haxe language feature which are similar to variables, but invoke specific functions upon read/write (known as getter/setter functions).
This would be a huge improvement, especially for save data related stuff. It'd save lots of repeated lines related to saving.
Example
Before
/**
* The character IDs.
* This is retrieved from the save data.
*/
public var characterIDs:Dynamic;
// This is called in new()
initializeCharIDs();
// This is repeated a few times throughout the code. Mainly when characterIDs is modified.
Save.instance.modOptions.set("FunkerSelector", characterIDs);
Save.instance.flush();
After
/**
* The character IDs.
* This is retrieved from the save data.
*/
public var characterIDs(get, set):Dynamic;
function get_characterIDs():Dynamic {
var defaultCharacterIDs:Dynamic = {
bf: 'default',
gf: 'default',
dad: 'default'
};
return Save.instance.modOptions.get("FunkerSelector") != null ? Save.instance.modOptions.get("FunkerSelector") : defaultCharacterIDs;
}
function set_characterIDs(value:Dynamic):Dynamic {
characterIDs = value;
Save.instance.modOptions.set("FunkerSelector", characterIDs);
Save.instance.flush();
}
Save data might not really be a good example of this, but there's a lot of other use cases out there.
Activity