There is no programming language that I know of that provides the same functionality as “states” in UnrealScript. States in UnrealScript are not like ordinary state machines. They are more like layers that you can place on top of objects. Layers that intercept the call method and have access to the internal state of the object.
Starting with UnrealEngine3, you can also stack states, thus having more than one active layer. For instance:
function bar() { // print quux } state S1 { function foo() { // print foo } } state S2 { function foo() { // print bar } function bar() { // print bar } }
Now, when you go to state S2 and call foo () and bar (), you will see "bar bar" When you go to state S1 (from start state or S2) and call the same methods, you will see "foo quux". However, when you are in S2 and push S1 to the status stack, you will see "foo bar" when you call foo () bar () instead of "foo quux".
In any case, return to the original question. One way to get the same state functions as in UnrealScript is to use the AOP language, which provides a dynamic way to enable / disable aspects at runtime.
source share