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.

  1. Right-click in the Project window and select Create > TDRS > Social Rules YAML
  2. Name the new file whatever you wish.
  3. Open the file in your editor of choice and remove any placeholder content.
  4. Create a new social rule list and set the desired social rule fields (described below).
  5. Add a SocialRuleYamlFileLoader component to the same GameObject that has your SocialEngineController instance.
  6. Add the file to the Rule Yaml Files list on the SocialRuleYamlFileLoader.
  7. 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 ?owner and ?target variables are pre-bound to the UIDs of the relationship instance that is being evaluated against this rule. You can read more about writing queries
  • modifiers: Stat buffs to apply to the relationship instance between the ?owner and 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