I’m making a The Binding of Isaac clone to practice, and I’m figuring out how to do the enemy generation.
I’ve thought of making an EnemyIndex module / resource / class that scans the project for enemy scenes and adds them to a dictionary where they are classified. Then, this module can be called anywhere to generate a set of enemies for a room. My question is, should I store ?:
The paths of the enemy scenes
The packed scenes of the enemies
A mix of both. A custom “EnemyResource” that hold either the packed scene or the path to the scene + additional data (difficulty of the enemy…)
I don’t know how resource-intensive packed scenes and resources are. I’m inclined to choose option C because functionally it seems the most scalable, but I’m scared of over engineering or programming something that is inefficient or takes too many resources
Yeah, I want something like that. For the room scenes in my dungeon, I use a RoomIndex resource that scans a specific directory for RoomScenes and loads their paths, classifying them by type (boss room, initial room, normal room…).
Then when the dungeon is generated and a room has to be instantiated, the index is consulted and the room is loaded from the path. I could have directly stored the packed scenes instead of just the paths, but I figured that if the number of room scenes grew too much, it could turn really inefficient.
For now, the number of enemies is lower than the number of RoomScenes (Although I guess they have the potential to grow more), and they will be instantiated more often and on runtime, as they are only generated when the player steps into a room, so it seems like preloading their scenes will be better. Thanks a lot.
I highly doubt I’ll run into any performance issues as my game is really small, but I want to be prepared for the future.
I guess I’ll go with packed scenes because enemies are generated “on runtime” when the player steps into a room, so I guess it is more efficient to preload their scenes.