DeedReporterWithActorTraitInfluence.cs
Code: Select all
using UnityEngine;
using PixelCrushers.LoveHate;
public class DeedReporterWithActorTraitInfluence : DeedReporter
{
private FactionMember me;
protected override void Awake()
{
base.Awake();
me = GetComponent<FactionMember>();
}
public override void ReportDeedByActor(FactionMember actor, string tag, FactionMember target)
{
base.ReportDeedByActor(actor, tag, target);
DeedTemplate deedTemplate;
if (FindDeedTemplate(tag, out deedTemplate))
{
for (int i = 0; i < deedTemplate.traits.Length; i++)
{
var adjustment = deedTemplate.traits[i] * (Mathf.Abs(deedTemplate.impact) / 100);
me.faction.traits[i] = Mathf.Clamp(me.faction.traits[i] + adjustment, -100, 100);
}
}
}
}