game-programming-patterns icon indicating copy to clipboard operation
game-programming-patterns copied to clipboard

Saving data with component pattern instead of inheritance.

Open conqueran opened this issue 3 years ago • 0 comments

This may be a newbie question but it is unclear to me how to save data when using a component pattern. For example say I have a Room class with max 5 random monsters that all inherit from the Monster class. If I don't use inheritance how can I save the data of these monsters without knowing the info at runtime? My room might spawn 5 Tree monsters, or 2 snakes and 3 blobs or something else.. What kind of pointer do I use (I can't use Monster * monster[ 5 ] in the Room class anymore... I also asked this on stack overflow https://stackoverflow.com/questions/71280409/how-to-save-c-class-data-from-a-template-when-using-component-pattern

conqueran avatar Feb 26 '22 22:02 conqueran