Jump to content
  • Advertisement
Sign in to follow this  
3kimr

Object States

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!