Multiple extends

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Multiple extends

Re: Multiple extends

by Graf Zahl » Sat Jan 05, 2019 5:34 pm

It is called 'extension', not 'modification'. I think that says it all.

Re: Multiple extends

by Major Cooke » Sat Jan 05, 2019 4:10 pm

Is it safe to assume that that same restrictions will apply, i.e. you cannot perform an override on the actor functions in the base class when extending it? Just making sure, I figured it would be.

Re: Multiple extends

by Graf Zahl » Thu Jan 03, 2019 1:02 pm

Yes, that would work.

Re: Multiple extends

by Major Cooke » Thu Jan 03, 2019 12:54 pm

@Graf: Ah well. Thanks to CheckReplacement in event handlers, it somewhat makes state label overrides a novelty idea at any rate that's entirely unneeded.

@Matt: Yep, pretty much. Also variables.

Re: Multiple extends

by Matt » Thu Jan 03, 2019 12:47 pm

So basically something like this would work?

Code: Select all

extend class Actor{
	virtual void A_CustomChase(vector3 goalpos,statelabel meleestate,...
		...
}
class CustomZed:Zombieman replaces Zombieman{
	...
	see:
		POSS ABCD 5 A_CustomChase(...
}

Re: Multiple extends

by Graf Zahl » Thu Jan 03, 2019 12:34 pm

No. There can only be one defaults block. This isn't for altering actors but for injecting common code and related data into the base class.
Like, you want some special death state that requires common data and functions. You can now place that stuff in Actor and then inherit from the single monsters and add the new state using that common stuff.

Re: Multiple extends

by Gez » Thu Jan 03, 2019 12:10 pm

But things like, say, giving cacodemons blue blood without replacing them will be possible? Or changing the maxamount property of an ammo type?

Re: Multiple extends

by Graf Zahl » Thu Jan 03, 2019 12:04 pm

State label overrides won't be possible. That'd be too volatile.

Re: Multiple extends

by Major Cooke » Thu Jan 03, 2019 11:43 am

This sounds like it's eventually paving the way towards being able to inject/override states without needing to replace the actor. Removing the need to replace one actor with another just so it doesn't have to be given some little tweaks would be a godsend.

For example, if an addon modifies a state, it could TRULY replace it -- possibly even affecting the goto -- via some definition like:

Code: Select all

extends class Zombieman
{
States.MyAddonIdentifierHere
{
Spawn:
...which would be in the addon code, replacing the spawn state without replacing the actor. But the actor themselves could still use something like Goto <ClassName>::Spawn or something to make it use the original.

But then again I am effectively deluding myself into thinking its even possible. Feel free to correct me if I'm not deluding though!

Re: Multiple extends

by Rip and Tear » Thu Jan 03, 2019 11:30 am

heavy breathing

Re: Multiple extends

by Graf Zahl » Thu Jan 03, 2019 11:03 am

It means that 'extends' blocks to all actor classes can be done in user code. The reason why this wasn't possible yet is that all the native children would have broken if a base class was extended.

For non-actors this isn't really important because there's little to be gained by extending them.

Re: Multiple extends

by Major Cooke » Thu Jan 03, 2019 10:18 am

How will this work when done?

Re: Multiple extends

by Caligari87 » Thu Jan 03, 2019 9:54 am

excited incoherent screaming

Graf you're the best. This'll be a game-changer.

8-)

Re: Multiple extends

by Graf Zahl » Thu Jan 03, 2019 9:40 am

I'm working on it. I'm almost done exporting PlayerPawn which is the last remaining blocker for allowing user-side extends of class Actor.

Re: Multiple extends

by Rip and Tear » Thu Jan 03, 2019 9:18 am

Caligari87 wrote:One potential workaround is to use a static function in a separate thinker/class as a proxy. Matt does this in Hideous Destructor, for example.

Code: Select all

class NewZombieMan : ZombieMan replaces ZombieMan {
    States {
    See:
        POSS AABBCCDD 4 MyFunctions.EnhancedChase(self);
        Loop;
    }
}

class MyFunctions {
    static void EnhancedChase(actor caller) {
        //do fancy movement
        caller.vel.x += 15;
    }
}
8-)
I'm aware of this method and it's definitely the best one available at the time. But having to prefix with `caller` so often leads to rather clunky syntax.

Top