Page 1 of 1

TraitDefinition Override

Posted: Sun Mar 05, 2023 4:23 am
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.

Re: TraitDefinition Override

Posted: Sun Mar 05, 2023 8:05 am
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().

Re: TraitDefinition Override

Posted: Sun Mar 05, 2023 5:13 pm
by Nashnir
Thank you Tony.
You're awesome!

Wish you an amazing week.

Re: TraitDefinition Override

Posted: Mon Mar 13, 2023 10:30 pm
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.