Create Social Rules Using YAML - ShiJbey/TDRS GitHub Wiki
How to create social rules using YAML
This guide covers how to define new social events using YAML text files. This is an alternative authoring path to using ScriptableObjects. If you want to better familiarize yourself with YAML, the following page has been helpful: https://quickref.me/yaml.
- Right-click in the Project window and select
Create > TDRS > Social Rules YAML - Name the new file whatever you wish.
- Open the file in your editor of choice and remove any placeholder content.
- Create a new social rule list and set the desired social rule fields (described below).
- Add a
SocialRuleYamlFileLoadercomponent to the same GameObject that has yourSocialEngineControllerinstance. - Add the file to the
Rule Yaml Fileslist on theSocialRuleYamlFileLoader. - The rule(s) should now trigger on agent relationships that meet it's preconditions.
Social rule fields
description: A description of the rule. The description use TDRS's string template syntax to substitute the UIDs of the owner and target.precondition: A list of RePraxis query statements to run against on the social engine's database. The?ownerand?targetvariables are pre-bound to the UIDs of the relationship instance that is being evaluated against this rule. You can read more about writing queriesmodifiers: Stat buffs to apply to the relationship instance between the?ownerand the?target.
Example Social Rule Definition
The example rules below assume that we have defined capulet and montague traits that represent characters belonging to the two feuding families in Romeo and Juliet.
- description: Capulets dislike Montagues
precondition:
- ?owner.traits.capulet
- ?target.traits.montague
modifiers:
- statName: Friendship
value: -25
- description: Montagues dislike Capulets
precondition:
- ?owner.traits.montague
- ?target.traits.capulet
modifiers:
- statName: Friendship
value: -25