Introduction

The STORM system is a complementary system to the Village Framework.

Its a set of scripts that react to the date, hour, and weather generated, to apply modifications to different visual elements.

The system is made to be easy to extend, and to comprehend, formatting the parameters of a day in a “Mood” to be applied

What is a Mood ?

A mood is composed of 3 things:

  1. Weather : a DatabaseItem that is randomly generated each day

  2. Season : Winter, Spring, Summer or Fall, based of the current month.

    Can be found from DateTime using DateTimeExtension - Database

  3. Period of Day : Sunrise, Morning, Afternoon, Sunset or Night , based of the current hour.

    Can be found from DateTime using DateTimeExtension - Database

It is used to simplify the parameters of a realistic weather to something that can be easily applied to simpler systems, with no heavy calculations necessary for the user.

How Does it Work ?

The StormSystem works when you have a gameobject with the component StormMoodHandler in a scene. It is recommended to add it to the bootstrap.

On start, it will listen to the Village Framework for any change of weather or date, and calculate the mood from the current value, before raising an event to all listeners.

graph LR
  vilmanager[Village Manager] --> Weather@{ shape: rounded, label: "On Weather Changed" }
  vilmanager[Village Manager] --> Date@{ shape: rounded, label: "On Date/Time Changed" }
  Weather --> handler[StormMoodHandler: Calculate and Apply Mood]
  Date --> handler
  handler --> MoodChanged@{shpe: rounded, label: "On Mood Changed"}
  MoodChanged --> listeners[StormMoodListeners :  Aply their modifications]

Storm Listeners

StormMoodListeners are components that listen for a change of mood, to apply modifications. They can be located anywhere in the scene.

They will receive the current mood, and apply modifications that fit a MoodCondition.

A MoodConditon is a list of values for the Weather, Period Of Day, and Season.

You can check if a condition match a mood with:

StormMoodHandler.IsMatchingCondition(currentMood, moodCondition)

For a condition to be true, the value of each field of the mood must be contained in the list of mood condition. (Unless the array of the mood condition is empty, in which case it will be ignored)

Ex:

Current Mood :

Weather : Sun

PeriodOfDay : Morning

Season : Autumn

Conditions : Is Matching ? Explication
Weathers :{ Sun, Rain}
PerioidOfDay : { Morning, Sunrise, Sunset }
Season: {Autumn, Spring} Yes The fields of the current mood are all found in the values of the condition, so it is true.
Weathers :{ Sun, Rain}
PerioidOfDay : { Morning, Sunrise, Sunset }
Season: {Spring} No The Season field only have “Spring” and not Autumn
Weathers :{ Sun, Rain}
PerioidOfDay : { Morning, Sunrise, Sunset }
Season: {} Yes Here the seasons field is empty, so it is ignored
Weathers :{}
PerioidOfDay : {}
Season: {} Yes If all fields are empty, all are ignored, and it will always match any mood

Creating new Listeners

You can create a new StormMoodListener, by creating a new class that inherits from it, and overriding the function OnMoodChanged(MoodDescriptor moodDescriptor). It will be a monobehaviour, so it needs to be added to a gameobject, that is active in hierarchy.

This function is called at start, and everytime the StormMoodHandler calls OnMoodChanged.

Existing Listeners:

Untitled