[No] Move BeginPlay() to Thinkers

Moderators: Developers, ZDoom.org Team

Move BeginPlay() to Thinkers

Postby Major Cooke » Fri Oct 27, 2017 9:41 am

Since ChangeStatNum can only be applied in BeginPlay, I think it would be logical to move the BeginPlay() function from inside of Actor to Thinker.
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Move BeginPlay() to Thinkers

Postby Graf Zahl » Fri Oct 27, 2017 10:02 am

This cannot be done and is not needed. The main problem with actors is that they are not constructed by your own code but by an internal actor factory (i.e Actor.Spawn.) BeginPlay is merely a callback in there that allows you to perform some customization which under normal circumstances would happen in the constructor.

Unless you do not build your own thinker creation factory the place to change the statnum is your thinker's constructor.

If you want to change the statnum of a system created thinker, think again. Not a good idea!
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Move BeginPlay() to Thinkers

Postby Major Cooke » Fri Oct 27, 2017 12:33 pm

Graf Zahl wrote:This cannot be done and is not needed. The main problem with actors is that they are not constructed by your own code but by an internal actor factory (i.e Actor.Spawn.) BeginPlay is merely a callback in there that allows you to perform some customization which under normal circumstances would happen in the constructor.

Unless you do not build your own thinker creation factory the place to change the statnum is your thinker's constructor.


Oh, so you mean this?
Code: Select allExpand view
MyThinker t = new("MyThinker");
t.ChangeStatNum(STAT_USER);

That seems to work. Very well, I suppose I can just have a global class statically do that for me.

Graf Zahl wrote:If you want to change the statnum of a system created thinker, think again. Not a good idea!


You mean like ACS/Map thinkers? I have no intention of doing such a thing. I just meant for hand-made thinkers created via ZScript with the "new" function. And setting things like SFX actors onto a different statnum so actors that do a lot of stat searching can have their workloads minimized. Helps hugely with the changes I made with (i.e.) AEons of Death so gibs can stop lagging upon creation, because it gets a count of how many gibs are currently around and doesn't spawn anymore if there are too many. As you know, AEoD can get clusterfucky with with so many special effects going on and actors that shouldn't be bothered searching for anything other than gibs, by gibs alone.

That's about as far as I go, just for the sake of optimizing gameplay and making it far more efficient.
User avatar
Major Cooke
Slaughterer of Sewers
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Move BeginPlay() to Thinkers

Postby Graf Zahl » Fri Oct 27, 2017 1:32 pm

Major Cooke wrote:That seems to work. Very well, I suppose I can just have a global class statically do that for me.


Well, what do you think how this works for actors? You'll never see them created with 'new'. Instead there's a static function to spawn them - and it's this function that calls BeginPlay. If you create a thinker with new and then initialize it, it's your own code that performs the setup so no facility in the engine can call BeginPlay.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests