Multiplayer (where to do processing) parallel 4-26

I have a multiplayer farm game. I have a bunch of code that performs state management for the plant. This is currently sitting in an actor component attached to my plant actor. It is bound to an event dispatcher. This was done intentionally because as I thought I’d move processing to the client but primarily because all plants on clients can get the dispatch event roughly the same time.

If I were to process the growth event in game state, I can’t seem to think how I can make all plants executed at once. I can iterate through an array and process the event but I’m a little unsure what my options are for parallel processing of the alternative client approach?

Thanks in advance I hope this makes sense

I would calculate it in the GameMode class. This class runs only on the server and so it is save for cheating.

The state of the plants should either be saved in the plants them self (in replicated variables) or in the GameState (which is also replicated and is like the memory of the GameMode).

Then you should simply decide when you want to recalculate your plants and do this in the GameMode in this cycle.

Lets say you recalculate it every 5 seconds than your GameMode checks all plants and recalculates their state. This shouldn’tbe a problem performance wise as long as you don’t replicate tons of plant variables at the same time. The good thing is that only changed variables are replicated iver the network.

If you have performance issues you could build up stacks of plants and only change values in small groups every second or something like this.

Alternatively you could recalculate on every single client but than your server and client state are always a little bit different and you have to do some logic around this.