Closed xFrednet closed 4 years ago
Hi @xFrednet,
I think the idea of a simple World subclass would be a good way to go. To prevent bloat, I'm not sure if I'd want to add something to the main code, but a simple example would be nice to include in repository perhaps.
For my personal projects, I tend to arrange them by Scenes. I use one World
instance per Scene, and add the Processors on instantiation. For those that need it, I just pass a scene reference into those Processors that need it. Something like:
def __init__(self):
self.world.add_processor(AttackProcessor(scene=self))
self.world.add_processor(CollisionProcessor(scene=self))
self.world.add_processor(MovementProcessor())
self.world.add_processor(CommandProcessor(scene=self))
.....
All Scenes
share the same high level Audio playback interface, and SaveGame interface, so all of the Processors with a reference to the scene will also be able to access these. The "SaveManager" is in essence a shared resource manager. Adding a dedicated resource manager in this same vein would be pretty easy to do.
Since I use separate World instances for each Scene in my designs, it makes sense to my brain. If I was going to use a single World instance for the entire application, I would probably just add things to the World instead (as you've mentioned).
Does this make sense? Sorry if it's a bit hard to follow :sweat_smile:
Hey thank you very much for the response. It makes sense to split up the game into different scenes. I could also add the resources in the sub class if i really need them.
Thank you for the response 🙃
Hello, I just wanted to ask: What are your thoughts on adding a
Resource
type to esper? Before esper I've used amethyst as an ECS for Rust. That system uses so calledResource
to share data that is not specific to an direct entity. For example a global score that gets accessed by multiple systems.The formal definition of a
Resource
by amethyst:I know that I could just distribute the value to the systems at the creation time or simply add a new member to the world class. However, I believe it might be beneficial to have a shared resource marked as one by accessing them through
world.get_resource(<Type>)
for example. Do you have any thoughts on this?