I’m adding the concept of Civilizations to my game and each player will select their own Civilization.
As far as implementation goes, I’d like to create a generic abstract Object called “CivilizationAbstract” and additional generic Objects that inherit “CivilizationAbstract” for each Civilization (like American, German, Korean, etc).
However, I haven’t found a way to instantiate/new-up these generic Objects. If I were to reparent them as children of Actor objects I think that would be overkill – they don’t need to be instantiated into the world/level and they don’t need Actor events.
Here’s some more details regarding the planned process that will be using these Civilization objects (in case this helps you understand what I’m trying to achieve).
- In GameMode, during event OnPostLogin: a Team struct is created and saved into an array stored in GameMode. This Team struct contains information like Team Color, Team Civilization (which is of type interface “ICivilization” which is implemented by “CivilizationAbstract”), Team Defeated, etc.
- In GameMode, during event OnPostLogin: after a Team struct is created, a COPY (different memory reference) of the struct is saved in PlayerState for the current PlayerController/PlayerPawn that is being created.
- At this point a master copy of the Team struct is in GameMode (server side only, that’s good). A copy of it is stored in PlayerState on the server and replicated to all clients.
- When a PlayerController creates a new Building or Military Unit, a copy of the Team struct (stored in PlayerController’s PlayerState) is saved inside of the Actor. This allows me to track which team owns which Actors in the world (this should support multiple people sharing the same team).
My final questions are: How can I instantiate a generic Object? If this is not possible, what would your recommended approach be to achieve this?
And for added clarity these Civilization objects will contain information about that Civ, like:
- Icon(s)
- Description
- Civilization specific benefits i.e. one Civ might provide a military production cost discount for the duration of the game while another Civ might provide increased gather rates for certain resources.*