World Manager - Generic world management system

Hey everyone,

After recently launching CTS, and seeing how quickly and well the weather management system was accepted, and then having some awesome conversations in the Gaia 2 beta, I made the first cut of a new and generic free and open source environmental management system.

In the image below we have lighting, skies, clouds, terrain, terrain shading, weather, and sound, and they all need to be synchronized properly to create the immersion you want. I do this all the time and its just painful!

3151976--239587--Grab 20170718154552 w1822h1084 x185y65z125r143.jpg

The Problem:

I want make a game, and none of the assets I want to use are integrated. I want a common way to create and manage my scenes with things such as time of day, terrain, lighting and weather all working together.

The Solution:

World Manager (WAPI) - A generic world and environment command and control system for Unity that enables environmental assets to play nicely together.

It does this by providing a simple but powerful interface that allows you to control the components that render your environment a generic and coordinated way.

The intention is to bridge the gap between assets and make it easier to develop games by plugging them together using a common API. You will still configure your assets individually to your own taste, but coordination and control is generic and centralised.

Assets can choose which parts of the API they implement and regardless of how much they support, you will get value from this system because of the way it coordinates their behaviour.

Additionally, WAPI introduces a global set of shader variables, so that any shader that implements WAPI will automatically be updated when settings change without requiring the overhead associated with the subscription mechanism.

This API will be kept stable and professionaly maintained, and will also be available as a free unity asset (soon).

Basic Usage Pattern:

o generate events, and get and set values use the following generic format e.g. WorldManager.Instance.Api()

To receive events when values are changed implement your own listener via the IWorldApiChangeHandler interface and then connect it up e.g.

public class WorldController : MonoBehaviour, IWorldApiChangeHandler
{
    .. your stuff..

    void Start()
    {
        ConnectToWorldAPI();
    }

    //Let world manager API know you want to handle events
    void ConnectToWorldAPI()
    {
        WorldManager.Instance.AddListener(this);
    }

    //Let world manager API know that you are no longer interested
    void DisconnectFromWorldAPI()
    {
        WorldManager.Instance.RemoveListener(this);
    }

    //If this object has been added as a listener then it will be called whenever an event is fired,
    //use the changeArgs.HasChanged method to filter for the events you are interested in
    public void OnWorldChanged(WorldChangeArgs changeArgs)
    {
        if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.GameTimeChanged))
        {
            //Grab game time
            m_timeNow = (float)changeArgs.manager.GetTimeDecimal();

            //Do whatever logic you want
            m_timeNow += 0.25f;

            //Set it back into world manager -> NOTE you would never do THIS SPECIFIC THING
            //as this will cause another OnWorldChanged event to be generated, which would in turn
            //cause this to be executed again in one nasty loop
            WorldManager.Instance.SetDecimalTime(m_timeNow);
        }
    }
}

Take a look at WorldController.cs for a simple example of how to use the API. It both listens to things and also implements a simple user interface that controls it in the editor and at runtime.

To use as global variables in shaders the general naming standard is WAPI[PropertyName], however in many instances the data has been stored in vectors for efficient transfer to the GPU, so take a peek at the code to get the naming. At the very least however all shader variables are prefixed with WAPI.

API Categories:

  • IsActive
  • Time
  • Player Location, Sea Level, Latitude & Longitude, Scene Center & Size
  • Temperature and humidity
  • Wind
  • Fog
  • Rain
  • Hail
  • Snow
  • Thunder
  • Clouds
  • Moon
  • Season
  • Sound Levels
  • Extensions
  • Serilialisation

Serialisation System

The serialisation system allows you to manage the process of saving and loading WAPI data. The choice of when to do this and how to store the serialised data are up to you.

Extension System

The extension system allows you to create your own extension sub classes and add them to WAPI to be managed. You could add additional game state information as well handlers for Update and LateUpdate and have them called on your extensions when World Manager updates. Just derive your class from WorldManagerExtension, and add it to the extensions list.

I have made the source available here for comment. The WorldManager.cs file has the bulk of the API work : https://github.com/adamgoodrich/WorldManager

And when it's been through some peer review I will maintain and publish it as a free asset on the store.

In the next few days I will also extend on the demo, and show it working with some more sophisticated assets.

Love to get your feedback.

18 Likes

The small prints says: does not support infinite world

I don't understand your point nor do I agree with your comment. The majority of the API's have nothing to do with world size.

If you would like to be positive and contribute ideas and suggestions then go for it - this is a free service to the community in an attempt to solve a tedious problem, and community feedback will determine how or even if this is further developed.

11 Likes

Sorry for the cheap jokes lol, it was a reference to some stance with gaia, since I support/seek infinite terrain system. Wasn't as funny as I think it was so I apologize.

2 Likes

Looks interesting however I've rolled my own now which I'll be using.

Love to get your feedback on this if you would consider having a quick look. Thoughts and feedback much appreciated.

Sure. I could probably use it alongside mine & plug some of my system in to it, but at a later date. (It deals with real world weather from forecasts, dependent on location of the game world in lat long, failing that it simulates the weather)

Just had a brief play around with it and I can see the potential. Just need to plug all the different systems in to it.

1 Like

Sounds great :) But.. What will be this? For other weather systems? Like UniStorm?

Any weather system that wants to support it. I am playing around with a preview Enviro integration right now :)

World Manager still very new - by tomorrow I will have a nice sample controller UX working, and it will be pretty cool seeing it all work together with Enviro.

3 Likes

Oh I get it :)

Ohh it's great.
What do you expect from amazing asset? Free? Here we are.

Gonna love to use it, thanks for sharing

I think something like this has a lot of potential! Excited to see where it goes. I think it is a great resource for those of us who are asset junkies and can't make up our mind on which day/night/weather system we want to use. Any chance of a save system where we can backup/share our weather/fx/lighting configurations similar to CTS Profiles, Gaia Sessions, etc?

You guys are AWESOME!

2 Likes

Please just rename this thing to WeatherManager. WorldManager name is to be used for something else indeed, that represents Worlds, not Weather features. (in my game there is already namespace WorldAPI, and classes like WorldManager, ChunksProcessor and so on, by coincidence :))

And this system is a gem.

I hadn't thought of it til Petersvp mentioned it, but it's actually more like an environment Manage than a world manager as far as I can see.
That said, having a custom namespace to avoid clashes is a must, and something that has already been done in at least Gaia (and I imagine in all your other assets too).

I'll need something like that for (an not infinite, but very very large) world I've been working on for a long while now, I'll likely look at the source and see if I can help out once I get to that point in our development. :)

Looks like a way for us to integrate our own assets, such as Enviro or Tenkoku with CTS and Gaia or other terrain/environment assets.

This is not a weather system, but a way to integrate all those parts, weather, terrain, shaders, etc., together more easily. So if you own Tenkoku then you can integrate it with Megaspats or CTS and/or Gaia. I own Enviro so I can integrate that easily with Gaia and CTS.

This is not one asset that will do it all, but a free asset, yes, FREE, that we can use to integrate different assets together.

And the name World Manager is absolutely perfect!

3 Likes

I initially thought of Enviro API, but there is a product called Enviro, so chose World manager because I hadn't seen it before.

Everything is namespaced within WorldAPI so in general this should not be a problem to use. Changing that to WAPI would also be a simple thing to do now.

It is however more than just a weather system and I am open to different names. People are already integrating and I don't want to waste their time, so if you have alternatives then please fire them off now.

I like the idea, seems like something everyone can put to good use. I have spent countless hours myself tweaking around settings of open world environment and atmosphere gestalt (overall).

If something like this is to be born I would personally love to see a demo!

Regarding Fog values -> don't make values absolute, don't get hold of the full value, just of *changes to initial values

Also think that WorldManger is a good name. After all it refers (based on the description) to the Player's world and that could be anything from a Planet to a Galaxy say.. so your full World is whichever size you want it to be and composed of whichever amount of subWorlds on it. I guess?

Then I guess it should have statusInfo puller methods on the different aspects its supporting too. Or does it only will support WorldManager.Instance.OnApiChangedHandler() for now? Like not only I be able to learn of a 'change' but also of actual conditions...

So say if my Mage player is about to cast a water element based spell and say I can read something similar to:

if (WorldManager.Instance.WorldInfo.Weather.isRain) Mage.Spells.WaterElement.isOnBonus = true;

And things like this? Or am I asking/deviating too much from the original intention of the manager?

2 Likes

Just a guess...if I read all this correctly....

If an asset developer of a weather system wants to hook into something that will allow your mage to do this, then probably. But it depends on the weather system you use and if the developer wants to add that. :) Or you can add it yourself.

You have to purchase the weather asset though.