public static void AddPoints(Pawn pawn, float points, string entryName) { var need = pawn.needs.TryGetNeed <Need_Karma>(); if (need != null) { if ((need.CurLevel < Need_Karma.BecomeGoodLevel && points > 0) || (need.CurLevel > Need_Karma.BecomeEvilLevel && points < 0)) { points *= 0.33f; } need.CurLevel += points; need.Notify(); ActionLog.For(pawn).Put(entryName, points); } }
protected override void FillTab() { Rect mainRect = new Rect(0f, PreGap, WinSize.x, WinSize.y - PreGap).ContractedBy(WindowGap); Rect topRect = new Rect(0f, 0f, mainRect.width, 40); Rect middleRect = new Rect(0f, 40f, mainRect.width, mainRect.height - 48f); Rect viewRect = new Rect(0f, 0f, mainRect.width - 16f, 1000f); Text.Font = GameFont.Small; GUI.BeginGroup(mainRect); // Checkbox var topListing = new Listing_Standard(GameFont.Small); topListing.Begin(topRect); var loggingEnabledText = ActionLog.EnableLogging ? "Enabled" : "Disabled"; if (topListing.ButtonTextLabeled($"Logging: {loggingEnabledText}", "Toggle")) { ActionLog.EnableLogging = !ActionLog.EnableLogging; } topListing.End(); // Upper rect Widgets.BeginScrollView(middleRect, ref scrollPosition, viewRect); var logListing = new Listing_Standard(GameFont.Small); logListing.Begin(viewRect); foreach (var entry in ActionLog.For(SelPawn).DebugActionLog()) { logListing.Label(entry); } logListing.End(); Widgets.EndScrollView(); GUI.EndGroup(); }
public override void NeedInterval() { if (!Extremist) { if (CurLevel > NeutralLevel) { CurLevel -= Degradation; } else if (CurLevel < NeutralLevel) { CurLevel += Degradation; } } if (!readyForChange) { if (CurLevel > BecomeGoodLevel && CurLevel < BecomeEvilLevel) { readyForChange = true; } } else { // Become good if (CurLevel <= BecomeGoodLevel) { if (pawn.story.traits.HasTrait(BPDefOf.BadPeople_Evil)) { pawn.story.traits.allTraits.RemoveAll(trait => trait.def == BPDefOf.BadPeople_Evil); var actionLog = ActionLog.For(pawn).PickActionList(); if (pawn.IsColonist) { Find.WindowStack.Add(new Dialog_AlteringNotification(pawn, actionLog, AlterType.Good)); } else if (pawn.IsPrisonerOfColony) { Messages.Message("BadPeople_LostTrait".Translate(pawn.Name.ToStringShort, BPDefOf.BadPeople_Evil.degreeDatas[0].label), pawn, MessageTypeDefOf.NeutralEvent); } } readyForChange = false; } // Become evil else if (CurLevel >= BecomeEvilLevel) { if (!pawn.story.traits.HasTrait(BPDefOf.BadPeople_Evil) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath)) { // Remove kind trait if (pawn.story.traits.HasTrait(TraitDefOf.Kind)) { pawn.story.traits.allTraits.RemoveAll(trait => trait.def == TraitDefOf.Kind); } pawn.story.traits.GainTrait(new Trait(BPDefOf.BadPeople_Evil, 0, true)); var actionLog = ActionLog.For(pawn).PickActionList(); if (pawn.IsColonist) { Find.WindowStack.Add(new Dialog_AlteringNotification(pawn, actionLog, AlterType.Bad)); } else if (pawn.IsPrisonerOfColony) { Messages.Message("BadPeople_GainedTrait".Translate(pawn.Name.ToStringShort, BPDefOf.BadPeople_Evil.degreeDatas[0].label), pawn, MessageTypeDefOf.NeutralEvent); } } readyForChange = false; } } }