Remove more code warnings

This commit is contained in:
amevarashi 2022-04-15 21:46:29 +05:00
parent 9589d3dda6
commit 3c548e6ae4
10 changed files with 155 additions and 177 deletions

View file

@ -1,4 +1,5 @@
using RimWorld; using RimWorld;
using System.Diagnostics.CodeAnalysis;
using Verse; using Verse;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
@ -22,7 +23,9 @@ namespace RJWSexperience.Ideology
public class PreceptComp_SelfTookThoughtTagged : PreceptComp_SelfTookMemoryThought public class PreceptComp_SelfTookThoughtTagged : PreceptComp_SelfTookMemoryThought
{ {
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public string tag; public string tag;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public bool exclusive = false; public bool exclusive = false;
public PreceptComp_SelfTookThoughtTagged() { } public PreceptComp_SelfTookThoughtTagged() { }
@ -57,22 +60,18 @@ namespace RJWSexperience.Ideology
} }
Pawn arg = ev.args.GetArg<Pawn>(HistoryEventArgsNames.Doer); Pawn arg = ev.args.GetArg<Pawn>(HistoryEventArgsNames.Doer);
Pawn partner = ev.args.GetArg<Pawn>(HistoryEventArgsNamesCustom.Partner); Pawn partner = ev.args.GetArg<Pawn>(HistoryEventArgsNamesCustom.Partner);
if (arg.needs != null && arg.needs.mood != null && (!this.onlyForNonSlaves || !arg.IsSlave)) if (arg.needs?.mood != null && (!this.onlyForNonSlaves || !arg.IsSlave))
{ {
if (this.thought.minExpectationForNegativeThought != null && ExpectationsUtility.CurrentExpectationFor(arg).order < this.thought.minExpectationForNegativeThought.order) if (this.thought.minExpectationForNegativeThought != null && ExpectationsUtility.CurrentExpectationFor(arg).order < this.thought.minExpectationForNegativeThought.order)
{ {
return; return;
} }
Thought_Memory thought_Memory = ThoughtMaker.MakeThought(this.thought, precept); Thought_Memory thought_Memory = ThoughtMaker.MakeThought(this.thought, precept);
Thought_KilledInnocentAnimal thought_KilledInnocentAnimal; if (thought_Memory is Thought_KilledInnocentAnimal thought_KilledInnocentAnimal && ev.args.TryGetArg<Pawn>(HistoryEventArgsNames.Victim, out Pawn animal))
Pawn animal;
if ((thought_KilledInnocentAnimal = (thought_Memory as Thought_KilledInnocentAnimal)) != null && ev.args.TryGetArg<Pawn>(HistoryEventArgsNames.Victim, out animal))
{ {
thought_KilledInnocentAnimal.SetAnimal(animal); thought_KilledInnocentAnimal.SetAnimal(animal);
} }
Thought_MemoryObservation thought_MemoryObservation; if (thought_Memory is Thought_MemoryObservation thought_MemoryObservation && ev.args.TryGetArg<Corpse>(HistoryEventArgsNames.Subject, out Corpse target))
Corpse target;
if ((thought_MemoryObservation = (thought_Memory as Thought_MemoryObservation)) != null && ev.args.TryGetArg<Corpse>(HistoryEventArgsNames.Subject, out target))
{ {
thought_MemoryObservation.Target = target; thought_MemoryObservation.Target = target;
} }
@ -83,20 +82,20 @@ namespace RJWSexperience.Ideology
public class PreceptComp_KnowsMemoryThoughtTagged : PreceptComp_KnowsMemoryThought public class PreceptComp_KnowsMemoryThoughtTagged : PreceptComp_KnowsMemoryThought
{ {
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public string tag; public string tag;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public bool exclusive = false; public bool exclusive = false;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public bool applyonpartner = false; public bool applyonpartner = false;
public PreceptComp_KnowsMemoryThoughtTagged() { } public PreceptComp_KnowsMemoryThoughtTagged() { }
public override void Notify_MemberWitnessedAction(HistoryEvent ev, Precept precept, Pawn member) public override void Notify_MemberWitnessedAction(HistoryEvent ev, Precept precept, Pawn member)
{ {
if (!applyonpartner) if (!applyonpartner && ev.args.TryGetArg(HistoryEventArgsNamesCustom.Partner, out Pawn pawn) && pawn == member)
{ {
if (ev.args.TryGetArg(HistoryEventArgsNamesCustom.Partner, out Pawn pawn)) return;
{
if (pawn == member) return;
}
} }
if (tag != null) if (tag != null)
{ {

View file

@ -1,19 +1,12 @@
using System; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
public class PreceptDef_RequirementExtended : PreceptDef public class PreceptDef_RequirementExtended : PreceptDef
{ {
public List<MemeDef> requiredAllMemes = new List<MemeDef>(); [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
} public List<MemeDef> requiredAllMemes = new List<MemeDef>();
}
} }

View file

@ -25,12 +25,9 @@ namespace RJWSexperience.Ideology
public static void Postfix(Pawn otherPawn, Pawn ___pawn, ref float __result) public static void Postfix(Pawn otherPawn, Pawn ___pawn, ref float __result)
{ {
Ideo ideo = ___pawn.Ideo; Ideo ideo = ___pawn.Ideo;
if (ideo != null) if (ideo?.HasPrecept(VariousDefOf.Incestuos_IncestOnly) == true && IdeoUtility.IsIncest(___pawn, otherPawn))
{ {
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly) && IdeoUtility.IsIncest(___pawn, otherPawn)) __result *= 8f;
{
__result *= 8f;
}
} }
} }
} }
@ -51,21 +48,17 @@ namespace RJWSexperience.Ideology
{ {
public static void Postfix(PreceptDef precept, bool checkDuplicates, ref IdeoFoundation __instance, ref AcceptanceReport __result) public static void Postfix(PreceptDef precept, bool checkDuplicates, ref IdeoFoundation __instance, ref AcceptanceReport __result)
{ {
if (precept is PreceptDef_RequirementExtended) if (precept is PreceptDef_RequirementExtended def && !def.requiredAllMemes.NullOrEmpty())
{ {
PreceptDef_RequirementExtended def = precept as PreceptDef_RequirementExtended; for (int i = 0; i < def.requiredAllMemes.Count; i++)
if (!def.requiredAllMemes.NullOrEmpty())
{ {
for (int i = 0; i < def.requiredAllMemes.Count; i++) if (!__instance.ideo.memes.Contains(def.requiredAllMemes[i]))
{ {
if (!__instance.ideo.memes.Contains(def.requiredAllMemes[i])) List<string> report = new List<string>();
{ foreach (MemeDef meme in def.requiredAllMemes) report.Add(meme.LabelCap);
List<string> report = new List<string>();
foreach (MemeDef meme in def.requiredAllMemes) report.Add(meme.LabelCap);
__result = new AcceptanceReport("RequiresMeme".Translate() + ": " + report.ToCommaList()); __result = new AcceptanceReport("RequiresMeme".Translate() + ": " + report.ToCommaList());
return; return;
}
} }
} }
} }

View file

@ -124,9 +124,8 @@ namespace RJWSexperience.Ideology
}; };
get_banged.tickAction = delegate get_banged.tickAction = delegate
{ {
if ((parteners.Count > 0) && (pawn.IsHashIntervalTick(ticks_between_hearts / parteners.Count))) if ((parteners.Count > 0) && pawn.IsHashIntervalTick(ticks_between_hearts / parteners.Count) && pawn.IsHashIntervalTick(ticks_between_hearts))
if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
}; };
get_banged.AddEndCondition(new Func<JobCondition>(() => get_banged.AddEndCondition(new Func<JobCondition>(() =>
{ {

View file

@ -1,45 +1,40 @@
using System; using RimWorld;
using System.Collections.Generic; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse; using Verse;
using rjw;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
public class RitualOutcomeComp_HediffBased : RitualOutcomeComp_QualitySingleOffset public class RitualOutcomeComp_HediffBased : RitualOutcomeComp_QualitySingleOffset
{ {
HediffDef hediffDef = null; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
float minSeverity = 0; public HediffDef hediffDef = null;
string roleId = ""; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float minSeverity = 0;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public string roleId = "";
protected override string LabelForDesc => label; protected override string LabelForDesc => label;
public override bool DataRequired => false; public override bool DataRequired => false;
public override bool Applies(LordJob_Ritual ritual) public override bool Applies(LordJob_Ritual ritual)
{ {
Pawn victim = null; Pawn victim = null;
foreach(RitualRole ritualRole in ritual.assignments.AllRolesForReading) foreach (RitualRole ritualRole in ritual.assignments.AllRolesForReading)
{ {
if (ritualRole != null && ritualRole.id.Contains(roleId)) if (ritualRole?.id.Contains(roleId) == true)
{ {
victim = ritual.assignments.FirstAssignedPawn(ritualRole); victim = ritual.assignments.FirstAssignedPawn(ritualRole);
} }
} }
if (victim != null && hediffDef != null) if (victim != null && hediffDef != null)
{ {
Hediff hediff = victim.health.hediffSet.GetFirstHediffOfDef(hediffDef); Hediff hediff = victim.health.hediffSet.GetFirstHediffOfDef(hediffDef);
if (hediff?.Severity >= minSeverity) if (hediff?.Severity >= minSeverity)
{ {
return true; return true;
} }
} }
return false; return false;
} }
public override ExpectedOutcomeDesc GetExpectedOutcomeDesc(Precept_Ritual ritual, TargetInfo ritualTarget, RitualObligation obligation, RitualRoleAssignments assignments, RitualOutcomeComp_Data data) public override ExpectedOutcomeDesc GetExpectedOutcomeDesc(Precept_Ritual ritual, TargetInfo ritualTarget, RitualObligation obligation, RitualRoleAssignments assignments, RitualOutcomeComp_Data data)
{ {
@ -53,13 +48,14 @@ namespace RJWSexperience.Ideology
positive = true positive = true
}; };
} }
} }
public class RitualOutcomeComp_NeedBased : RitualOutcomeComp_QualitySingleOffset public class RitualOutcomeComp_NeedBased : RitualOutcomeComp_QualitySingleOffset
{ {
NeedDef needDef = null; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
float minAvgNeed = 0; public NeedDef needDef = null;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float minAvgNeed = 0;
protected override string LabelForDesc => label; protected override string LabelForDesc => label;
public override bool DataRequired => false; public override bool DataRequired => false;
@ -71,9 +67,7 @@ namespace RJWSexperience.Ideology
avgNeed += pawn.needs?.TryGetNeed(needDef)?.CurLevel ?? 0f; avgNeed += pawn.needs?.TryGetNeed(needDef)?.CurLevel ?? 0f;
} }
avgNeed /= ritual.assignments.AllPawns.Count; avgNeed /= ritual.assignments.AllPawns.Count;
if (avgNeed >= minAvgNeed) return true; return avgNeed >= minAvgNeed;
return false;
} }
public override ExpectedOutcomeDesc GetExpectedOutcomeDesc(Precept_Ritual ritual, TargetInfo ritualTarget, RitualObligation obligation, RitualRoleAssignments assignments, RitualOutcomeComp_Data data) public override ExpectedOutcomeDesc GetExpectedOutcomeDesc(Precept_Ritual ritual, TargetInfo ritualTarget, RitualObligation obligation, RitualRoleAssignments assignments, RitualOutcomeComp_Data data)
@ -89,7 +83,4 @@ namespace RJWSexperience.Ideology
}; };
} }
} }
} }

View file

@ -1,66 +1,69 @@
using System; using RimWorld;
using System.Collections.Generic; using System;
using System.Linq; using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Tasks;
using rjw;
using RimWorld;
using Verse; using Verse;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
public class StatPart_GenderPrimacy : StatPart public class StatPart_GenderPrimacy : StatPart
{ {
public float modifier; [SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float modifier;
public override string ExplanationPart(StatRequest req) public override string ExplanationPart(StatRequest req)
{ {
Pawn pawn = req.Thing as Pawn; if (!req.HasThing || !(req.Thing is Pawn pawn))
Ideo ideo = null; return null;
if (pawn != null) ideo = pawn.Ideo;
float fact = 1f;
if (ideo != null && !ideo.memes.NullOrEmpty()) for (int i = 0; i < ideo.memes.Count; i++)
{
if (ideo.memes[i] == MemeDefOf.MaleSupremacy)
{
if (pawn.gender == Gender.Male) fact = modifier;
else if (pawn.gender == Gender.Female) fact = 1/modifier;
break;
}
else if (ideo.memes[i] == MemeDefOf.FemaleSupremacy)
{
if (pawn.gender == Gender.Male) fact = 1/modifier;
else if (pawn.gender == Gender.Female) fact = modifier;
break;
}
}
return Keyed.MemeStatFactor(String.Format("{0:0.##}", fact * 100));
}
public override void TransformValue(StatRequest req, ref float val) Ideo ideo = pawn.Ideo;
{ float fact = 1f;
Pawn pawn = req.Thing as Pawn; if (ideo?.memes.NullOrEmpty() == false)
Ideo ideo = null; {
if (pawn != null) ideo = pawn.Ideo; for (int i = 0; i < ideo.memes.Count; i++)
if (ideo != null && !ideo.memes.NullOrEmpty()) for(int i=0; i< ideo.memes.Count; i++) {
{ if (ideo.memes[i] == MemeDefOf.MaleSupremacy)
if (ideo.memes[i] == MemeDefOf.MaleSupremacy) {
{ if (pawn.gender == Gender.Male) fact = modifier;
if (pawn.gender == Gender.Male) val *= modifier; else if (pawn.gender == Gender.Female) fact = 1 / modifier;
else if (pawn.gender == Gender.Female) val /= modifier; break;
break; }
} else if (ideo.memes[i] == MemeDefOf.FemaleSupremacy)
else if(ideo.memes[i] == MemeDefOf.FemaleSupremacy) {
{ if (pawn.gender == Gender.Male) fact = 1 / modifier;
if (pawn.gender == Gender.Male) val /= modifier; else if (pawn.gender == Gender.Female) fact = modifier;
else if (pawn.gender == Gender.Female) val *= modifier; break;
break; }
} }
} }
}
}
return Keyed.MemeStatFactor(String.Format("{0:0.##}", fact * 100));
}
public override void TransformValue(StatRequest req, ref float val)
{
if (!req.HasThing || !(req.Thing is Pawn pawn))
return;
Ideo ideo = pawn.Ideo;
if (ideo?.memes.NullOrEmpty() == false)
{
for (int i = 0; i < ideo.memes.Count; i++)
{
if (ideo.memes[i] == MemeDefOf.MaleSupremacy)
{
if (pawn.gender == Gender.Male) val *= modifier;
else if (pawn.gender == Gender.Female) val /= modifier;
break;
}
else if (ideo.memes[i] == MemeDefOf.FemaleSupremacy)
{
if (pawn.gender == Gender.Male) val /= modifier;
else if (pawn.gender == Gender.Female) val *= modifier;
break;
}
}
}
}
}
} }

View file

@ -18,7 +18,7 @@ namespace RJWSexperience.Ideology
base.ThoughtInterval(); base.ThoughtInterval();
if (recordIncrement != 0) if (recordIncrement != 0)
{ {
pawn.records.AddTo(recordDef, recordIncrement); pawn.records.AddTo(RecordDef, recordIncrement);
recordIncrement = 0; recordIncrement = 0;
} }
} }

View file

@ -1,5 +1,6 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
@ -8,6 +9,7 @@ namespace RJWSexperience.Ideology
/// </summary> /// </summary>
public class ThoughtDef_Opinionbased : ThoughtDef public class ThoughtDef_Opinionbased : ThoughtDef
{ {
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<float> minimumValueforStage = new List<float>(); public List<float> minimumValueforStage = new List<float>();
} }
@ -17,7 +19,7 @@ namespace RJWSexperience.Ideology
public class Thought_Opinionbased : Thought_Memory public class Thought_Opinionbased : Thought_Memory
{ {
protected ThoughtDef_Opinionbased Def => (ThoughtDef_Opinionbased)def; protected ThoughtDef_Opinionbased Def => (ThoughtDef_Opinionbased)def;
protected List<float> minimumValueforStage => Def.minimumValueforStage; protected List<float> MinimumValueforStage => Def.minimumValueforStage;
public override int CurStageIndex public override int CurStageIndex
{ {
@ -25,9 +27,9 @@ namespace RJWSexperience.Ideology
{ {
float value = 0f; float value = 0f;
if (otherPawn != null) value = pawn.relations?.OpinionOf(otherPawn) ?? 0f; if (otherPawn != null) value = pawn.relations?.OpinionOf(otherPawn) ?? 0f;
for (int i = minimumValueforStage.Count - 1; i > 0; i--) for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
{ {
if (minimumValueforStage[i] < value) return i; if (MinimumValueforStage[i] < value) return i;
} }
return 0; return 0;
} }

View file

@ -1,5 +1,6 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
@ -8,8 +9,11 @@ namespace RJWSexperience.Ideology
/// </summary> /// </summary>
public class ThoughtDef_Recordbased : ThoughtDef public class ThoughtDef_Recordbased : ThoughtDef
{ {
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public RecordDef recordDef; public RecordDef recordDef;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<float> minimumValueforStage = new List<float>(); public List<float> minimumValueforStage = new List<float>();
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float increment; public float increment;
} }
@ -19,17 +23,17 @@ namespace RJWSexperience.Ideology
public class Thought_Recordbased : Thought_Memory public class Thought_Recordbased : Thought_Memory
{ {
protected ThoughtDef_Recordbased Def => (ThoughtDef_Recordbased)def; protected ThoughtDef_Recordbased Def => (ThoughtDef_Recordbased)def;
protected RecordDef recordDef => Def.recordDef; protected RecordDef RecordDef => Def.recordDef;
protected List<float> minimumValueforStage => Def.minimumValueforStage; protected List<float> MinimumValueforStage => Def.minimumValueforStage;
public override int CurStageIndex public override int CurStageIndex
{ {
get get
{ {
float value = pawn?.records?.GetValue(recordDef) ?? 0f; float value = pawn?.records?.GetValue(RecordDef) ?? 0f;
for (int i = minimumValueforStage.Count - 1; i > 0; i--) for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
{ {
if (minimumValueforStage[i] < value) return i + 1; if (MinimumValueforStage[i] < value) return i + 1;
} }
return 0; return 0;
} }

View file

@ -1,35 +1,31 @@
using System; using RimWorld;
using rjw;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using UnityEngine; using UnityEngine;
using rjw; using Verse;
namespace RJWSexperience.UI namespace RJWSexperience.UI
{ {
public static class RJWUIUtility public static class RJWUIUtility
{ {
public const float FONTHEIGHT = 22f; public const float FONTHEIGHT = 22f;
public const float CARDHEIGHT = 110f; public const float CARDHEIGHT = 110f;
public const float LISTPAWNSIZE = 100f; public const float LISTPAWNSIZE = 100f;
public const float BASESAT = 0.40f; public const float BASESAT = 0.40f;
public const float ICONSIZE = 30f; public const float ICONSIZE = 30f;
public static void DrawQuirk(this Rect rect, Pawn pawn) public static void DrawQuirk(this Rect rect, Pawn pawn)
{ {
List<Quirk> quirks = Quirk.All.FindAll(x => pawn.Has(x)); List<Quirk> quirks = Quirk.All.FindAll(x => pawn.Has(x));
string quirkstr = quirks.Select(x => x.Key).ToCommaList(); string quirkstr = quirks.Select(x => x.Key).ToCommaList();
string tooltip = ""; string tooltip = "";
Widgets.Label(rect, "Quirks".Translate() + quirkstr); Widgets.Label(rect, "Quirks".Translate() + quirkstr);
if (Mouse.IsOver(rect)) if (Mouse.IsOver(rect))
{ {
if (quirks.NullOrEmpty()) if (quirks.NullOrEmpty())
{ {
tooltip = "NoQuirks".Translate(); tooltip = "NoQuirks".Translate();
@ -47,52 +43,50 @@ namespace RJWSexperience.UI
} }
Widgets.DrawHighlight(rect); Widgets.DrawHighlight(rect);
} }
TooltipHandler.TipRegion(rect, tooltip); TooltipHandler.TipRegion(rect, tooltip);
} }
public static void DrawSexuality(this Rect rect, CompRJW comp) public static void DrawSexuality(this Rect rect, CompRJW comp)
{ {
if (comp != null) if (comp != null)
{ {
string sexuality = Keyed.Sexuality[(int)comp.orientation]; string sexuality = Keyed.Sexuality[(int)comp.orientation];
Widgets.Label(rect, Keyed.RS_Sexuality + ": " + sexuality); Widgets.Label(rect, Keyed.RS_Sexuality + ": " + sexuality);
Widgets.DrawHighlightIfMouseover(rect); Widgets.DrawHighlightIfMouseover(rect);
} }
} }
public static string GetRelationsString(this Pawn pawn, Pawn otherpawn) public static string GetRelationsString(this Pawn pawn, Pawn otherpawn)
{ {
if (otherpawn != null) if (otherpawn != null)
{ {
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn); IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
if (!relations.EnumerableNullOrEmpty()) return relations.Select(x => x.GetGenderSpecificLabel(otherpawn)).ToCommaList().CapitalizeFirst(); if (!relations.EnumerableNullOrEmpty()) return relations.Select(x => x.GetGenderSpecificLabel(otherpawn)).ToCommaList().CapitalizeFirst();
} }
return ""; return "";
} }
public static void DrawBorder(this Rect rect, Texture border, float thickness = 1f) public static void DrawBorder(this Rect rect, Texture border, float thickness = 1f)
{ {
GUI.DrawTexture(new Rect(rect.x,rect.y,rect.width, thickness), border); GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, thickness), border);
GUI.DrawTexture(new Rect(rect.x+rect.width-thickness,rect.y, thickness, rect.height), border); GUI.DrawTexture(new Rect(rect.x + rect.width - thickness, rect.y, thickness, rect.height), border);
GUI.DrawTexture(new Rect(rect.x,rect.y+rect.height - thickness,rect.width, thickness), border); GUI.DrawTexture(new Rect(rect.x, rect.y + rect.height - thickness, rect.width, thickness), border);
GUI.DrawTexture(new Rect(rect.x, rect.y, thickness, rect.height), border); GUI.DrawTexture(new Rect(rect.x, rect.y, thickness, rect.height), border);
} }
public static string GetStatExplanation(Pawn pawn, StatDef stat, float val) public static string GetStatExplanation(Pawn pawn, StatDef stat, float val)
{ {
if (!pawn.Dead) if (!pawn.Dead)
return stat.description + "\n" + return stat.description + "\n" + stat.Worker.GetExplanationFull(StatRequest.For(pawn), ToStringNumberSense.Undefined, val);
stat.Worker.GetExplanationFull(StatRequest.For(pawn), ToStringNumberSense.Undefined, val);
return "Dead".Translate(); return "Dead".Translate();
} }
public static string GetSexDays(int absticks, bool printUnknown = false) public static string GetSexDays(int absticks, bool printUnknown = false)
{ {
if (absticks != 0) return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago; if (absticks != 0) return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago;
else if (printUnknown) return Keyed.Unknown; else if (printUnknown) return Keyed.Unknown;
else return ""; else return "";
} }
}
}
} }