Expiration Condition Handler

v4.0.6

By default if an Expiration Condition is populated, it will be given when the GameCondition expires. To customize the handling of this, you can use an ExpirationConditionHandler. This is a Scriptable Object which utilizes a custom script, so you can fully cusomize how to handle Expiration Conditions.

This is similar to how the QuestRewards are created.

Creating a New Object

Once a Expiration Condition Handler has been scripted, right click in the project and select Game Modules/Expiration Condition Handler/[Name of Handler]

The new Scriptable Object will be created. Name it appropriately, and then customize the values, if any are customizable.

The object is a ModulesScriptableObject which means it has an exposed string uid and Dictionaries as well. In most cases, you likely will not use these, and they can be ignored in the Inspector.

Scripting a new Expiration Condition Handler

It may be easiest to copy the PercentChance script. Search for it and copy it, then rename it as you'd like. Update the code appropriately, adding in the custom logic for your situation.

Be sure to update the CreateAssetMenu fileName and menuName. This will allow you to create the object using the instructions above.

Finally, be sure to attach the handler you'd like to use to any Condition object.

You can do ANYTHING in the HandleExpiration method. Here, we check for the random result, and then add the condition. The yellow highlighted area is a public float which appears in the Inspector. You can add additional content to your class exposed to the Inspector, allowing for virtually any logic you'd like in the HandleExpiration method.

Last updated