public static Tale_TriplePawn GetLatestTriplePawnTale(TaleDef def, Predicate <Tale_TriplePawn> predicate) { Tale_TriplePawn tale = null; int num = 0; for (int i = 0; i < Find.TaleManager.AllTalesListForReading.Count; i++) { var latestTale = Find.TaleManager.AllTalesListForReading[i]; if (latestTale.def == def && latestTale is Tale_TriplePawn tale_triplePawn && predicate(tale_triplePawn) && (tale == null || latestTale.AgeTicks < num)) { tale = tale_triplePawn; num = latestTale.AgeTicks; } } return(tale); }
public override float OpinionOffset() { if (ThoughtUtility.ThoughtNullified(pawn, def)) { return(0f); } Predicate <Tale_TriplePawn> validator = delegate(Tale_TriplePawn t) { return(pawn == t.firstPawnData.pawn && otherPawn == t.secondPawnData.pawn); }; Tale_TriplePawn latestTale = VSIE_Utils.GetLatestTriplePawnTale(def.taleDef, validator); if (latestTale != null) { float num = 1f; if (latestTale.def.type == TaleType.Expirable) { float value = (float)latestTale.AgeTicks / (latestTale.def.expireDays * 60000f); num = Mathf.InverseLerp(1f, def.lerpOpinionToZeroAfterDurationPct, value); } return(base.CurStage.baseOpinionOffset * num); } return(0f); }