About weather
#2
I'm not sure I'm following what you're suggesting. What exactly does "observable" in this context mean? Why would you need a weather management class, why not add just a member or two to the cWorld class?

I've already mind-designed a system for weather that would be, I believe, adequate. Doesn't require any new classes, doesn't require any changes to the threading model, it's pretty and simple:
1. Each world starts with Sunny
2. An interval is selected, depending on the weather type, how long the current weather lasts.
3. When the interval runs out, a new weather and according interval are selected.

So, this change would require:
1. Add the interval member to cWorld
2. Add or modify cWorld::ChangeWeather() function to change weather and set a new interval
3. cWorld's TickWeather should only check the interval and once it elapses, call the ChangeWeather() function with weather.
4. Make cWorld::ChangeWeather accessible from Lua.

I don't think adding a thread just for weather is a good idea. A thread consumes quite a few resources that we cannot spare on some small-footprint platforms (stack RAM) and brings synchronization issues with it (critical sections with possible deadlocks).

However, I'm totally for the idea of each world having a separate tick thread. This is out of the scope of this post, though (not that it would be that difficult to implement that).
Optional configuration: world may have no weather changes (think Nether) -> ChangeWeather checks if a change is allowed. Even more comfortable - allow the kinds of weathers and their interval lengths to be ini-adjusted.
Reply
Thanks given by:


Messages In This Thread
About weather - by cedeel - 06-11-2012, 11:49 PM
RE: About weather - by xoft - 06-11-2012, 11:59 PM
RE: About weather - by cedeel - 06-12-2012, 12:10 AM
RE: About weather - by xoft - 06-12-2012, 12:35 AM
RE: About weather - by Taugeshtu - 06-12-2012, 12:53 AM
RE: About weather - by cedeel - 06-12-2012, 01:02 AM
RE: About weather - by Taugeshtu - 06-12-2012, 01:11 AM



Users browsing this thread: 3 Guest(s)