forked from mastertea/kNumbers
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from maarxx/add_psycasts_squashed
Add Psycasting! Columns! Bars! Icons! A Whole Preset!
- Loading branch information
Showing
13 changed files
with
271 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Numbers | ||
{ | ||
using RimWorld; | ||
using Verse; | ||
|
||
public class DefModExtension_NeedsRoyalty : DefModExtension | ||
{ | ||
//nothing needed, just a tag | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace Numbers | ||
{ | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
[StaticConstructorOnStartup] | ||
public class PawnColumnWorker_Ability : PawnColumnWorker_Icon | ||
{ | ||
|
||
protected override Texture2D GetIconFor(Pawn pawn) | ||
{ | ||
AbilityDef abilityDef = def.Ext().ability; | ||
foreach (Ability a in pawn.abilities.abilities) | ||
{ | ||
if (a.def == abilityDef) | ||
{ | ||
return abilityDef.uiIcon; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public override int GetMinWidth(PawnTable table) | ||
{ | ||
return 26; | ||
} | ||
|
||
protected override string GetHeaderTip(PawnTable table) => def.Ext().ability.GetTooltip() + "\n\n" + "Numbers_ColumnHeader_Tooltip".Translate(); | ||
|
||
public override void DoHeader(Rect rect, PawnTable table) | ||
{ | ||
Rect interactableHeaderRect = GetInteractableHeaderRect(rect, table); | ||
if (Mouse.IsOver(interactableHeaderRect)) | ||
{ | ||
Widgets.DrawHighlight(interactableHeaderRect); | ||
string headerTip = GetHeaderTip(table); | ||
if (!headerTip.NullOrEmpty()) | ||
{ | ||
TooltipHandler.TipRegion(interactableHeaderRect, headerTip); | ||
} | ||
} | ||
if (Widgets.ButtonInvisible(interactableHeaderRect)) | ||
{ | ||
HeaderClicked(rect, table); | ||
} | ||
|
||
Texture2D abilityIcon = def.Ext().ability.uiIcon; | ||
Rect position = new Rect(rect.x, rect.yMax - 26, 26, 26); | ||
GUI.DrawTexture(position, abilityIcon); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace Numbers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
[StaticConstructorOnStartup] | ||
public class PawnColumnWorker_Entropy : PawnColumnWorker | ||
{ | ||
private static readonly Texture2D EntropyBarTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.46f, 0.34f, 0.35f)); | ||
|
||
//mostly from PawnColumnWorker_Need | ||
|
||
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) | ||
{ | ||
if (!pawn.HasPsylink) | ||
return; | ||
|
||
float curEntropyLevel = pawn.psychicEntropy.EntropyRelativeValue; | ||
|
||
float barHeight = 14f; | ||
float barWidth = barHeight + 15f; | ||
if (rect.height < 50f) | ||
{ | ||
barHeight *= Mathf.InverseLerp(0f, 50f, rect.height); | ||
} | ||
|
||
Text.Font = (rect.height <= 55f) ? GameFont.Tiny : GameFont.Small; | ||
Text.Anchor = TextAnchor.UpperLeft; | ||
Rect rect3 = new Rect(rect.x, rect.y + rect.height / 2f, rect.width, rect.height / 2f); | ||
rect3 = new Rect(rect3.x + barWidth, rect3.y, rect3.width - barWidth * 2f, rect3.height - barHeight); | ||
|
||
Widgets.FillableBar(rect3, curEntropyLevel, EntropyBarTex); | ||
|
||
Text.Font = GameFont.Small; | ||
} | ||
|
||
public override int GetMinWidth(PawnTable table) | ||
=> Mathf.Max(base.GetMinWidth(table), 110); | ||
|
||
public override int Compare(Pawn a, Pawn b) | ||
{ | ||
int hasPsylink = a.HasPsylink.CompareTo(b.HasPsylink); | ||
if (hasPsylink != 0) { return hasPsylink; } | ||
return (a.psychicEntropy?.EntropyRelativeValue ?? 0f).CompareTo(b.psychicEntropy?.EntropyRelativeValue ?? 0f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace Numbers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
public class PawnColumnWorker_Psyfocus : PawnColumnWorker | ||
{ | ||
//mostly from PawnColumnWorker_Need | ||
|
||
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) | ||
{ | ||
if (!pawn.HasPsylink) | ||
return; | ||
|
||
float curPsyfocusLevel = pawn.psychicEntropy.CurrentPsyfocus; | ||
float targetPsyfocusLevel = pawn.psychicEntropy.TargetPsyfocus; | ||
|
||
float barHeight = 14f; | ||
float barWidth = barHeight + 15f; | ||
if (rect.height < 50f) | ||
{ | ||
barHeight *= Mathf.InverseLerp(0f, 50f, rect.height); | ||
} | ||
|
||
Text.Font = (rect.height <= 55f) ? GameFont.Tiny : GameFont.Small; | ||
Text.Anchor = TextAnchor.UpperLeft; | ||
Rect rect3 = new Rect(rect.x, rect.y + rect.height / 2f, rect.width, rect.height / 2f); | ||
rect3 = new Rect(rect3.x + barWidth, rect3.y, rect3.width - barWidth * 2f, rect3.height - barHeight); | ||
|
||
Widgets.FillableBar(rect3, curPsyfocusLevel); | ||
|
||
DrawPsyfocusTargetMarkerAt(rect3, targetPsyfocusLevel); | ||
Text.Font = GameFont.Small; | ||
} | ||
|
||
private void DrawPsyfocusTargetMarkerAt(Rect barRect, float pct) | ||
{ | ||
float seekerSize = 12f; | ||
if (barRect.width < 150f) | ||
{ | ||
seekerSize /= 2f; | ||
} | ||
Vector2 vector = new Vector2(barRect.x + barRect.width * pct, barRect.y + barRect.height); | ||
Rect position = new Rect(vector.x - seekerSize / 2f, vector.y, seekerSize, seekerSize); | ||
GUI.DrawTexture(position, StaticConstructorOnGameStart.BarInstantMarkerTex); | ||
} | ||
|
||
public override int GetMinWidth(PawnTable table) | ||
=> Mathf.Max(base.GetMinWidth(table), 110); | ||
|
||
public override int Compare(Pawn a, Pawn b) | ||
{ | ||
int hasPsylink = a.HasPsylink.CompareTo(b.HasPsylink); | ||
if (hasPsylink != 0) { return hasPsylink; } | ||
return (a.psychicEntropy?.CurrentPsyfocus ?? 0f).CompareTo(b.psychicEntropy?.CurrentPsyfocus ?? 0f); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Numbers/PawnColumnWorkers/PawnColumnWorker_PsylinkLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Numbers | ||
{ | ||
using System; | ||
using RimWorld; | ||
using Verse; | ||
|
||
public class PawnColumnWorker_PsylinkLevel : PawnColumnWorker_Text | ||
{ | ||
protected override string GetTextFor(Pawn pawn) | ||
=> (pawn.psychicEntropy?.Psylink?.level ?? 0).ToString(); | ||
|
||
public override int Compare(Pawn a, Pawn b) | ||
=> (a.psychicEntropy?.Psylink?.level ?? 0).CompareTo((b.psychicEntropy?.Psylink?.level ?? 0)); | ||
|
||
public override int GetMinWidth(PawnTable table) | ||
=> base.GetMinWidth(table) + 10; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters