-
Notifications
You must be signed in to change notification settings - Fork 0
Create SocialEvents Using YAML Files
Shi Johnson-Bey edited this page Feb 21, 2024
·
4 revisions
Specifying social events using YAML files is recommended for folks who might want to open their games for data-file modding. Also, it is an excellent way to specify all your events in one place that's easy to read.
- Right-click in the Project window and select
Create > TDRS > Social Events YAML
. - Name the file whatever you wish
- This file expects social events to be supplied in a list with data fields similar to scriptable object versions. Each of the fields is described below.
- Add your social events to the file
- Add a new
SocialEventsYamlFileLoader
component to the same GameObject as theSocialEngineController
. - Add the YAML file to the
Social Event Yaml Files
list on yourSocialEventsYamlFileLoader
instance. - Try dispatching the event with some characters.
- The sample code in the repo implements a
MockSocialEventCreator
(located inAssets/TDRS_Demo/Scripts/
). This class allows you to specify an event type and a list of characters to bind to the event roles (in order).
- The sample code in the repo implements a
Important
Field names are case-sensitive
-
name
: (required) The name of the event (used when specifying which event to dispatch) -
roles
: (optional) The names of roles of characters who are involved in the social event -
description
: (optional) A string description describing the social event.- This string uses a
[role_name]
template syntax that will substitute role names with the UIDs of the agents bound to those roles. For example, a description of[group_a] ended their feud with [group_b]
, will expand tomontagues ended their feud with capulets
assuming that agents with UIDsmontagues
andcapulets
were bound to rolesgroup_a
andgroup_b
, respectively.
- This string uses a
-
responses
: This is where you specify how agents should react to this event. Each entry corresponds to a different response. Agents can respond to the same event multiple times, assuming they pass the preconditions for multiple response entries.-
preconditions
: (optional) These are RePraxis query statements to run against TDRS' database. Any variables bound with the query can be used within the effect functions. -
effects
: Effect functions to trigger when dispatching this event. You can read more about effect functions on the Social Events Page. -
description
: (optional) A response-specific description. Both even role names and precondition variable names are eligible for substitution using the square bracket syntax.
-
- name: Betrayal
roles:
- "?betrayer"
- "?victim"
description: "[betrayer] betrayed [victim]."
responses:
- effects:
- DecreaseRelationshipStat ?victim ?betrayer Friendship 10 5
- RemoveRelationshipTrait ?victim ?betrayer friend
- preconditions:
- ?victim.relationships.?victim_friend.traits.friend
- neq ?victim_friend ?betrayer
effects:
- DecreaseRelationshipStat ?victim_friend ?betrayer Friendship 5 6
- preconditions:
- ?victim.relationships.?victim_family.traits.family
- neq ?victim_family ?betrayer
effects:
- AddRelationshipTrait ?victim_family ?betrayer angry_at 10
- name: BecomeFriends
roles:
- "?character_a"
- "?character_b"
description: "[character_a] and [character_b] became friends."
responses:
- effects:
- AddRelationshipTrait ?character_a ?character_b friend
- AddRelationshipTrait ?character_b ?character_a friend