I’m developing a US election simulator and have been building the Advertising system.
Right now, I’ve made the calculations for the ads either increasing or decreasing the raw vote totals based on the type of ad that is run. This has been connected to a button the UI.
However, I’m running into an issue in how these are deployed. For example, I want to make it so that ads have a diminishing return and eventually end (ex. the ad will end in 4 turns). Should I be adding ads as a component to my states (each state is a child of a parent blueprint that manages their data) that are destroyed?
How would I create a modular system where each ad is it’s own individual actor/component, but can stack and be destroyed after a certain period, if possible?
In general, if some functionality has a lifetime matching (or similar to) an actor’s lifetime, and it depends on that actor or the actor depends or the functionality, then it’s appropriate to pack it in an actor component - in other words, I’d suggest not implementing these ads as components because they’re temporary and barely interact with the actor. Always strive to use the simplest “tool” that accomplishes what you need.
So, based on your description (temporary ads with simple functionality, turns, etc.) I’d recommend you to:
represent ads with a simple struct, all you (seem to) need is the ad’s political “alignment” and maybe some extra numbers (strength, duration, whatever else)
store ads in a separate manager / subsystem (either one you already have or a new one), in a simple array
when the turn rolls over, iterate through the array and apply the effects of the ads, and remove any timed out ads
Hope this helps, if I’m missing some crucial info let me know.