Move BeginPlay() to Thinkers

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: Move BeginPlay() to Thinkers

Re: Move BeginPlay() to Thinkers

by Graf Zahl » Fri Oct 27, 2017 12: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.

Re: Move BeginPlay() to Thinkers

by Major Cooke » Fri Oct 27, 2017 11:33 am

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 all

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.

Re: Move BeginPlay() to Thinkers

by Graf Zahl » Fri Oct 27, 2017 9: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!

Move BeginPlay() to Thinkers

by Major Cooke » Fri Oct 27, 2017 8: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.

Top