TraitDefinition Override

Announcements, support questions, and discussion for Love/Hate.
Post Reply
Nashnir
Posts: 11
Joined: Mon Aug 17, 2020 5:03 am

TraitDefinition Override

Post by Nashnir »

Hi Tony,

I love the asset and have been integrating it into my systems.
Currently I have been trying to integrate RPG style stats into the system and I have come across a hurdle.

I have overridden a lot of function in Faction member (especially EvaluateRumor()) to handle the change and the flexibility of your code has made it quite easy.
I have avoided overriding any other class at the moment.

Now, I feel the need to add more information to TraitDefinition like trait category, and probably a Scriptable Object to hold additional data that can be used in EvaluateRumor or ModifyPersonality.

I feel I have two choices,
1. Update TraitDefinition class
2. Create a TraitDefinitionV2 and Create a new Faction Database and all the following required classes.

Any suggestions that could result in the least amount of change.
User avatar
Tony Li
Posts: 20635
Joined: Thu Jul 18, 2013 1:27 pm

Re: TraitDefinition Override

Post by Tony Li »

Hi,

The Rumor class has a customData field that can point to any type of object to hold extra data:

Code: Select all

public object customData = null;
In the upcoming version 1.10.34 (planned for release this week) I'll add the same to TraitDefinition so you can add your own data.

The FactionDatabaseEditor class's methods are virtual. If you want to extend it to draw your extra data, you can make a subclass of FactionDatabase and a subclass of FactionDatabaseEditor that adds extra GUI drawing code to methods such as OnDrawPersonalityTraitDefListElement().
Nashnir
Posts: 11
Joined: Mon Aug 17, 2020 5:03 am

Re: TraitDefinition Override

Post by Nashnir »

Thank you Tony.
You're awesome!

Wish you an amazing week.
User avatar
Tony Li
Posts: 20635
Joined: Thu Jul 18, 2013 1:27 pm

Re: TraitDefinition Override

Post by Tony Li »

The update was delayed a bit (it should be available later this week), but I did have a chance to add this to TraitDefinition:

Code: Select all

public string customData = string.Empty;
Note: It's a string so that it can be serialized properly when saving the FactionDatabase. If your custom object is serializable, you can use something like JsonUtility to serialize and deserialize it.
Post Reply