collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
869 stars 99 forks source link

Add way to access engine configuration #109

Open collinsmith opened 3 years ago

collinsmith commented 3 years ago

Data such as difficulty needs to be made available to multiple systems, such as those creating monsters. This should be injected into systems. I don't know if artemis provides some kind of config properties map, or if the go to solution is to just create a new passive system with accessors. Unsure if any of these configs should be allowed to change during runtime, I think not though.

collinsmith commented 3 years ago

I've settled on creating EngineConfig class which is manually injected into my artemis World. This class consists of final fields for seed and difficulty for the time being. I decided against a PassiveSystem because it just doesn't fit the theme of a passive system (or system in general). I think the benefit of this approach is that I can pass it as a dependency to Map or other objects which require some Riiablo configuration.

This may require a separate issue, but I'd also like to allow access to engine state, e.g., the time of day in the level. This is used for day/night cycles, but also practical uses like the time of day attributes. I don't think this really fits within EngineConfig, so I may need to implement an additional class. This one may actually be a System implementation because I'm assuming time of day will be a float from [0..1] or byte from [0..255] or even a standard unix time (which would be interesting), but this time would need to be updates using the system update function to increment the time delay by the world delta and then perform some time dilation to speed it up by some factor.