One thing I liked about Unreal Script is that it included within the language a nice clean mechanism for states in objects.
class Mutilator extends Object;
state Ravage
{
function Attack()
{
// do something horrible and barbaric.
}
}
state Weakened
{
function Attack()
{
// do something horrible and barbaric, only weakened.
}
}
This is a criminally simple example, but you can see what I am getting at. What would I want to look at to implement something like this for Angelscript?
states is an interesting feature, but I don't see how to implement it as a built-in feature in the language without impacting everyone that don't need or want to use it.
The object would need to keep the actual state in some property. Then all the class method calls needs to be routed to the proper implementation through some lookup, similarly to how virtual methods have been implemented in AS.
Without it being a built-in feature you can probably make it work quite well by using pre-fixes, e.g:
class Mutilator : Object
{
function Ravage_Attack()
{
// do something horrible and barbaric.
}
function Weakened_Attack()
{
// do something horrible and barbaric, only weakened.
}
}
When the application calls the methods it can route the call to the correct implementation based on the state it keeps somewhere.
Of course, this won't work when the script calls the methods itself.