Hi Tony,
I can't seem to find anything in the API for accessing the relationship trait array at runtime. I have custom relationship traits beyond affinity. The closest thing I can find is:
PixelCrushers.LoveHate.Relationship.traits
However, I can't see a clear way to access this from the FactionManager instance and live FactionDatabase at runtime.
I need the whole array so I can iterate over it.
Let me know what you think, thanks!
- Joe
Accessing custom relationship trait array at runtime
Re: Accessing custom relationship trait array at runtime
Hi Joe,
Iterate through the faction database's relationshipTraitDefinitions array.
To show all relationship types:
A relationship trait's ID is its index in this array. (Love/Hate was designed to support simulations of thousands of simultaneous units, so the underlying structures like this run pretty close to the metal.)
To show Jack's relationship values to Jill:
Iterate through the faction database's relationshipTraitDefinitions array.
To show all relationship types:
Code: Select all
var database = FactionManager.instance.factionDatabase;
for (int i = 0; i < database.relationshipTraitDefinitions.Length; i++)
{
Debug.Log("ID " + i + ": " + database.relationshipTraitDefinitions[i].name");
}
To show Jack's relationship values to Jill:
Code: Select all
for (int i = 0; i < database.relationshipTraitDefinitions.Length; i++)
{
int relationshipTraitID = i;
TraitDefinition relationshipTraitDefinition = database.relationshipTraitDefinitions[i];
float relationshipValue = database.GetRelationshipTrait(jackFactionID, jillFactionID, relationshipTraitID);
Debug.Log("Jack --> Jill " + relationshipTraitDefinition.name + ": " + relationshipValue);
}
Re: Accessing custom relationship trait array at runtime
Wonderful, thank you!
It seems silly in retrospect, but I saw that and thought it would only give me the trait descriptions. Oh well, I should've known you had it covered; your code is always so meticulous.
It seems silly in retrospect, but I saw that and thought it would only give me the trait descriptions. Oh well, I should've known you had it covered; your code is always so meticulous.
Re: Accessing custom relationship trait array at runtime
Thanks! Always happy to help.