Files
WulaFallenEmpireRW/MCP/vector_cache/ColonistBarColonistDrawer-DrawIcons.txt
2025-08-11 21:22:41 +08:00

985 lines
27 KiB
Plaintext

根据向量相似度分析,与 'DrawIcons, ColonistBarColonistDrawer' 最相关的代码定义如下:
---
**文件路径 (精确匹配):** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\ColonistBarColonistDrawer.txt`
```csharp
public class ColonistBarColonistDrawer
{
private struct IconDrawCall
{
public Texture2D texture;
public string tooltip;
public Color? color;
public IconDrawCall(Texture2D texture, string tooltip = null, Color? color = null)
{
this.texture = texture;
this.tooltip = tooltip;
this.color = color;
}
}
private Dictionary<string, string> pawnLabelsCache = new Dictionary<string, string>();
private static readonly Texture2D MoodBGTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.4f, 0.47f, 0.53f, 0.44f));
private static readonly Texture2D MoodAtlas = ContentFinder<Texture2D>.Get("UI/Widgets/SubtleGradient");
private static readonly Texture2D DeadColonistTex = ContentFinder<Texture2D>.Get("UI/Misc/DeadColonist");
private static readonly Texture2D Icon_FormingCaravan = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/FormingCaravan");
private static readonly Texture2D Icon_MentalStateNonAggro = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/MentalStateNonAggro");
private static readonly Texture2D Icon_MentalStateAggro = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/MentalStateAggro");
private static readonly Texture2D Icon_MedicalRest = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/MedicalRest");
private static readonly Texture2D Icon_Sleeping = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Sleeping");
private static readonly Texture2D Icon_Fleeing = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Fleeing");
private static readonly Texture2D Icon_Attacking = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Attacking");
private static readonly Texture2D Icon_Idle = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Idle");
private static readonly Texture2D Icon_Burning = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Burning");
private static readonly Texture2D Icon_Inspired = ContentFinder<Texture2D>.Get("UI/Icons/ColonistBar/Inspired");
private static readonly Texture2D MoodGradient = ContentFinder<Texture2D>.Get("UI/Widgets/MoodGradient");
public static readonly Vector2 PawnTextureSize = new Vector2(ColonistBar.BaseSize.x - 2f, 75f);
public static readonly Vector3 PawnTextureCameraOffset = new Vector3(0f, 0f, 0.3f);
public const float PawnTextureCameraZoom = 1.28205f;
private const float PawnTextureHorizontalPadding = 1f;
private static readonly float BaseIconAreaWidth = PawnTextureSize.x;
private static readonly float BaseIconMaxSize = 20f;
private const float BaseGroupFrameMargin = 12f;
public const float DoubleClickTime = 0.5f;
public const float FactionIconSpacing = 2f;
public const float IdeoRoleIconSpacing = 2f;
public const float SlaveIconSpacing = 2f;
private const float MoodGradientHeight = 35f;
private static List<IconDrawCall> tmpIconsToDraw = new List<IconDrawCall>();
private ColonistBar ColonistBar => Find.ColonistBar;
public void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering)
{
float alpha = ColonistBar.GetEntryRectAlpha(rect);
bool num = Prefs.VisibleMood && colonist.needs?.mood != null && colonist.mindState.mentalBreaker.CanDoRandomMentalBreaks && !colonist.Dead && !colonist.Downed;
MoodThreshold moodThreshold = MoodThresholdExtensions.CurrentMoodThresholdFor(colonist);
Color color = moodThreshold.GetColor();
color.a *= alpha;
ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref alpha);
if (reordering)
{
alpha *= 0.5f;
}
Color color3 = (GUI.color = new Color(1f, 1f, 1f, alpha));
if (num && alpha >= 1f)
{
float num2 = moodThreshold.EdgeExpansion();
if (num2 > 0f)
{
GUI.color = color;
Widgets.DrawAtlas(rect.ExpandedBy(num2), MoodAtlas);
GUI.color = color3;
}
}
GUI.DrawTexture(rect, ColonistBar.BGTex);
if (colonist.needs != null && colonist.needs.mood != null)
{
Rect position = rect.ContractedBy(2f);
float num3 = position.height * colonist.needs.mood.CurLevelPercentage;
position.yMin = position.yMax - num3;
position.height = num3;
GUI.DrawTexture(position, MoodBGTex);
}
if (num && alpha >= 1f)
{
float transparency = ((moodThreshold < MoodThreshold.Major) ? 0.1f : 0.15f);
Widgets.DrawBoxSolid(rect, moodThreshold.GetColor().ToTransparent(transparency));
}
if (highlight)
{
int thickness = ((rect.width <= 22f) ? 2 : 3);
GUI.color = Color.white;
Widgets.DrawBox(rect, thickness);
GUI.color = color3;
}
Rect rect2 = rect.ContractedBy(-2f * ColonistBar.Scale);
if ((colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist)) && !WorldRendererUtility.WorldSelected)
{
DrawSelectionOverlayOnGUI(colonist, rect2);
}
else if (WorldRendererUtility.WorldSelected && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
{
DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
}
GUI.DrawTexture(GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, PawnTextureSize, Rot4.South, PawnTextureCameraOffset, 1.28205f));
if (num)
{
Rect rect3 = rect.ContractedBy(1f);
Widgets.BeginGroup(rect3);
Rect position2 = rect3.AtZero();
position2.yMin = position2.yMax - 35f;
GUI.color = color;
GUI.DrawTexture(position2, MoodGradient);
GUI.color = color3;
Widgets.EndGroup();
}
GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);
DrawIcons(rect, colonist);
GUI.color = color3;
if (colonist.Dead)
{
GUI.DrawTexture(rect, DeadColonistTex);
}
float num4 = 4f * ColonistBar.Scale;
Vector2 pos = new Vector2(rect.center.x, rect.yMax - num4);
GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + ColonistBar.SpaceBetweenColonistsHorizontal - 2f, pawnLabelsCache);
Text.Font = GameFont.Small;
GUI.color = Color.white;
}
private Rect GroupFrameRect(int group)
{
float num = 99999f;
float num2 = 0f;
float num3 = 0f;
List<ColonistBar.Entry> entries = ColonistBar.Entries;
List<Vector2> drawLocs = ColonistBar.DrawLocs;
for (int i = 0; i < entries.Count; i++)
{
if (entries[i].group == group)
{
num = Mathf.Min(num, drawLocs[i].x);
num2 = Mathf.Max(num2, drawLocs[i].x + ColonistBar.Size.x);
num3 = Mathf.Max(num3, drawLocs[i].y + ColonistBar.Size.y);
}
}
return new Rect(num, 0f, num2 - num, num3 - 0f).ContractedBy(-12f * ColonistBar.Scale);
}
public void DrawGroupFrame(int group)
{
Rect position = GroupFrameRect(group);
Map map = ColonistBar.Entries.Find((ColonistBar.Entry x) => x.group == group).map;
float num = ((map == null) ? ((!WorldRendererUtility.WorldSelected) ? 0.75f : 1f) : ((map == Find.CurrentMap && !WorldRendererUtility.WorldSelected) ? 1f : 0.75f));
Widgets.DrawRectFast(position, new Color(0.5f, 0.5f, 0.5f, 0.4f * num));
}
private void ApplyEntryInAnotherMapAlphaFactor(Map map, ref float alpha)
{
if (map == null)
{
if (!WorldRendererUtility.WorldSelected)
{
alpha = Mathf.Min(alpha, 0.4f);
}
}
else if (map != Find.CurrentMap || WorldRendererUtility.WorldSelected)
{
alpha = Mathf.Min(alpha, 0.4f);
}
}
public void HandleClicks(Rect rect, Pawn colonist, int reorderableGroup, out bool reordering)
{
if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 2 && Mouse.IsOver(rect))
{
Event.current.Use();
CameraJumper.TryJump(colonist);
}
reordering = ReorderableWidget.Reorderable(reorderableGroup, rect, useRightButton: true);
if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
{
Event.current.Use();
}
}
public void HandleGroupFrameClicks(int group)
{
Rect rect = GroupFrameRect(group);
if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && Mouse.IsOver(rect) && !ColonistBar.AnyColonistOrCorpseAt(UI.MousePositionOnUIInverted))
{
bool worldSelected = WorldRendererUtility.WorldSelected;
if ((!worldSelected && !Find.Selector.dragBox.IsValidAndActive) || (worldSelected && !Find.WorldSelector.dragBox.IsValidAndActive))
{
Find.Selector.dragBox.active = false;
Find.WorldSelector.dragBox.active = false;
ColonistBar.Entry entry = ColonistBar.Entries.Find((ColonistBar.Entry x) => x.group == group);
Map map = entry.map;
if (map == null)
{
if (WorldRendererUtility.WorldSelected)
{
CameraJumper.TrySelect(entry.pawn);
}
else
{
CameraJumper.TryJumpAndSelect(entry.pawn);
}
}
else
{
if (!CameraJumper.TryHideWorld() && Find.CurrentMap != map)
{
SoundDefOf.MapSelected.PlayOneShotOnCamera();
}
Current.Game.CurrentMap = map;
}
}
}
if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
{
Event.current.Use();
}
}
public void Notify_RecachedEntries()
{
pawnLabelsCache.Clear();
}
public void ClearLabelCache()
{
pawnLabelsCache.Clear();
}
public Rect GetPawnTextureRect(Vector2 pos)
{
float x = pos.x;
float y = pos.y;
Vector2 vector = PawnTextureSize * ColonistBar.Scale;
return new Rect(x + 1f, y - (vector.y - ColonistBar.Size.y) - 1f, vector.x, vector.y).ContractedBy(1f);
}
private void DrawIcons(Rect rect, Pawn colonist)
{
if (colonist.Dead)
{
return;
}
tmpIconsToDraw.Clear();
bool flag = false;
if (colonist.CurJob != null)
{
JobDef def = colonist.CurJob.def;
if (def == JobDefOf.AttackMelee || def == JobDefOf.AttackStatic)
{
flag = true;
}
else if (def == JobDefOf.Wait_Combat && colonist.stances.curStance is Stance_Busy stance_Busy && stance_Busy.focusTarg.IsValid)
{
flag = true;
}
}
if (colonist.IsFormingCaravan())
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_FormingCaravan, "ActivityIconFormingCaravan".Translate()));
}
if (colonist.InAggroMentalState)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_MentalStateAggro, colonist.MentalStateDef.LabelCap));
}
else if (colonist.InMentalState)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_MentalStateNonAggro, colonist.MentalStateDef.LabelCap));
}
else if (colonist.InBed() && colonist.CurrentBed().Medical)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_MedicalRest, "ActivityIconMedicalRest".Translate()));
}
else
{
if (colonist.CurJob != null && colonist.jobs.curDriver.asleep)
{
goto IL_01c5;
}
if (colonist.GetCaravan() != null)
{
Pawn_NeedsTracker needs = colonist.needs;
if (needs != null && needs.rest?.Resting == true)
{
goto IL_01c5;
}
}
if (colonist.CurJob != null && colonist.CurJob.def == JobDefOf.FleeAndCower)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_Fleeing, "ActivityIconFleeing".Translate()));
}
else if (flag)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_Attacking, "ActivityIconAttacking".Translate()));
}
else if (colonist.mindState.IsIdle && GenDate.DaysPassed >= 1)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_Idle, "ActivityIconIdle".Translate()));
}
}
goto IL_02b4;
IL_01c5:
tmpIconsToDraw.Add(new IconDrawCall(Icon_Sleeping, "ActivityIconSleeping".Translate()));
goto IL_02b4;
IL_02b4:
if (colonist.IsBurning())
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_Burning, "ActivityIconBurning".Translate()));
}
if (colonist.Inspired)
{
tmpIconsToDraw.Add(new IconDrawCall(Icon_Inspired, colonist.InspirationDef.LabelCap));
}
if (colonist.IsSlaveOfColony)
{
tmpIconsToDraw.Add(new IconDrawCall(colonist.guest.GetIcon()));
}
else
{
bool flag2 = false;
if (colonist.Ideo != null)
{
Ideo ideo = colonist.Ideo;
Precept_Role role = ideo.GetRole(colonist);
if (role != null)
{
tmpIconsToDraw.Add(new IconDrawCall(role.Icon, null, ideo.Color));
flag2 = true;
}
}
if (!flag2)
{
Faction faction = null;
if (colonist.HasExtraMiniFaction())
{
faction = colonist.GetExtraMiniFaction();
}
else if (colonist.HasExtraHomeFaction())
{
faction = colonist.GetExtraHomeFaction();
}
if (faction != null)
{
tmpIconsToDraw.Add(new IconDrawCall(faction.def.FactionIcon, null, faction.Color));
}
}
}
float num = Mathf.Min(BaseIconAreaWidth / (float)tmpIconsToDraw.Count, BaseIconMaxSize) * ColonistBar.Scale;
Vector2 pos = new Vector2(rect.x + 1f, rect.yMax - num - 1f);
foreach (IconDrawCall item in tmpIconsToDraw)
{
GUI.color = item.color ?? Color.white;
DrawIcon(item.texture, ref pos, num, item.tooltip);
GUI.color = Color.white;
}
}
private void DrawIcon(Texture2D icon, ref Vector2 pos, float iconSize, string tooltip = null)
{
Rect rect = new Rect(pos.x, pos.y, iconSize, iconSize);
GUI.DrawTexture(rect, icon);
if (tooltip != null)
{
TooltipHandler.TipRegion(rect, tooltip);
}
pos.x += iconSize;
}
private void DrawSelectionOverlayOnGUI(Pawn colonist, Rect rect)
{
Thing target = colonist;
if (colonist.Dead)
{
target = colonist.Corpse;
}
SelectionDrawerUtility.DrawSelectionOverlayOnGUI(target, rect, 0.4f * ColonistBar.Scale, 20f * ColonistBar.Scale);
}
private void DrawCaravanSelectionOverlayOnGUI(Caravan caravan, Rect rect)
{
SelectionDrawerUtility.DrawSelectionOverlayOnGUI(caravan, rect, 0.4f * ColonistBar.Scale, 20f * ColonistBar.Scale);
}
}
```
---
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\ColonistBar.txt`
**相似度:** 0.7704
```csharp
public class ColonistBar
{
public struct Entry
{
public Pawn pawn;
public Map map;
public int group;
public Action<int, int> reorderAction;
public Action<int, Vector2> extraDraggedItemOnGUI;
public Entry(Pawn pawn, Map map, int group)
{
this.pawn = pawn;
this.map = map;
this.group = group;
reorderAction = delegate(int from, int to)
{
Find.ColonistBar.Reorder(from, to, group);
};
extraDraggedItemOnGUI = delegate(int index, Vector2 dragStartPos)
{
Find.ColonistBar.DrawColonistMouseAttachment(index, dragStartPos, group);
};
}
}
public ColonistBarColonistDrawer drawer = new ColonistBarColonistDrawer();
private ColonistBarDrawLocsFinder drawLocsFinder = new ColonistBarDrawLocsFinder();
private List<Entry> cachedEntries = new List<Entry>();
private List<Vector2> cachedDrawLocs = new List<Vector2>();
private List<int> cachedReorderableGroups = new List<int>();
private float cachedScale = 1f;
private bool entriesDirty = true;
private List<Pawn> colonistsToHighlight = new List<Pawn>();
public static readonly Texture2D BGTex = Command.BGTex;
public static readonly Vector2 BaseSize = new Vector2(48f, 48f);
public const float BaseSelectedTexJump = 20f;
public const float BaseSelectedTexScale = 0.4f;
public const float EntryInAnotherMapAlpha = 0.4f;
public const float BaseSpaceBetweenGroups = 25f;
public const float BaseSpaceBetweenColonistsHorizontal = 24f;
public const float BaseSpaceBetweenColonistsVertical = 32f;
private const float WeaponIconOffsetScaleFactor = 1.05f;
private const float WeaponIconScaleFactor = 0.75f;
private static List<Pawn> tmpPawns = new List<Pawn>();
private static List<Map> tmpMaps = new List<Map>();
private static List<Caravan> tmpCaravans = new List<Caravan>();
private static List<Pawn> tmpColonistsInOrder = new List<Pawn>();
private static List<Pair<Thing, Map>> tmpColonistsWithMap = new List<Pair<Thing, Map>>();
private static List<Thing> tmpColonists = new List<Thing>();
private static List<Thing> tmpMapColonistsOrCorpsesInScreenRect = new List<Thing>();
private static List<Pawn> tmpCaravanPawns = new List<Pawn>();
public List<Entry> Entries
{
get
{
CheckRecacheEntries();
return cachedEntries;
}
}
private bool ShowGroupFrames
{
get
{
List<Entry> entries = Entries;
int num = -1;
for (int i = 0; i < entries.Count; i++)
{
num = Mathf.Max(num, entries[i].group);
}
return num >= 1;
}
}
public float Scale => cachedScale;
public List<Vector2> DrawLocs => cachedDrawLocs;
public Vector2 Size => BaseSize * Scale;
public float SpaceBetweenColonistsHorizontal => 24f * Scale;
private bool Visible
{
get
{
if (UI.screenWidth < 800 || UI.screenHeight < 500)
{
return false;
}
if (Find.TilePicker.Active)
{
return false;
}
return true;
}
}
public void MarkColonistsDirty()
{
entriesDirty = true;
}
public void ColonistBarOnGUI()
{
if (!Visible)
{
return;
}
if (Event.current.type != EventType.Layout)
{
List<Entry> entries = Entries;
int num = -1;
bool showGroupFrames = ShowGroupFrames;
int value = -1;
for (int i = 0; i < cachedDrawLocs.Count; i++)
{
Rect rect = new Rect(cachedDrawLocs[i].x, cachedDrawLocs[i].y, Size.x, Size.y);
Entry entry = entries[i];
bool flag = num != entry.group;
num = entry.group;
if (Event.current.type == EventType.Repaint)
{
if (flag)
{
value = ReorderableWidget.NewGroup(entry.reorderAction, ReorderableDirection.Horizontal, new Rect(0f, 0f, UI.screenWidth, UI.screenHeight), SpaceBetweenColonistsHorizontal, entry.extraDraggedItemOnGUI);
}
cachedReorderableGroups[i] = value;
}
bool reordering;
if (entry.pawn != null)
{
drawer.HandleClicks(rect, entry.pawn, cachedReorderableGroups[i], out reordering);
}
else
{
reordering = false;
}
if (Event.current.type != EventType.Repaint)
{
continue;
}
if (flag && showGroupFrames)
{
drawer.DrawGroupFrame(entry.group);
}
if (entry.pawn != null)
{
drawer.DrawColonist(rect, entry.pawn, entry.map, colonistsToHighlight.Contains(entry.pawn), reordering);
ThingWithComps thingWithComps = entry.pawn.equipment?.Primary;
if ((Prefs.ShowWeaponsUnderPortraitMode == ShowWeaponsUnderPortraitMode.Always || (Prefs.ShowWeaponsUnderPortraitMode == ShowWeaponsUnderPortraitMode.WhileDrafted && entry.pawn.Drafted)) && thingWithComps != null && thingWithComps.def.IsWeapon)
{
Widgets.ThingIcon(new Rect(rect.x, rect.y + rect.height * 1.05f, rect.width, rect.height).ScaledBy(0.75f), thingWithComps, 1f, null, stackOfOne: true);
}
}
}
num = -1;
if (showGroupFrames)
{
for (int j = 0; j < cachedDrawLocs.Count; j++)
{
Entry entry2 = entries[j];
bool num2 = num != entry2.group;
num = entry2.group;
if (num2)
{
drawer.HandleGroupFrameClicks(entry2.group);
}
}
}
}
if (Event.current.type == EventType.Repaint)
{
colonistsToHighlight.Clear();
}
}
private void CheckRecacheEntries()
{
if (!entriesDirty)
{
return;
}
entriesDirty = false;
cachedEntries.Clear();
int num = 0;
if (Find.PlaySettings.showColonistBar)
{
tmpMaps.Clear();
tmpMaps.AddRange(Find.Maps);
tmpMaps.SortBy((Map x) => !x.IsPlayerHome, (Map x) => x.uniqueID);
for (int i = 0; i < tmpMaps.Count; i++)
{
tmpPawns.Clear();
tmpPawns.AddRange(tmpMaps[i].mapPawns.FreeColonists);
tmpPawns.AddRange(tmpMaps[i].mapPawns.ColonySubhumansControllable);
List<Thing> list = tmpMaps[i].listerThings.ThingsInGroup(ThingRequestGroup.Corpse);
for (int j = 0; j < list.Count; j++)
{
if (!list[j].IsDessicated())
{
Pawn innerPawn = ((Corpse)list[j]).InnerPawn;
if (innerPawn != null && innerPawn.IsColonist)
{
tmpPawns.Add(innerPawn);
}
}
}
IReadOnlyList<Pawn> allPawnsSpawned = tmpMaps[i].mapPawns.AllPawnsSpawned;
for (int k = 0; k < allPawnsSpawned.Count; k++)
{
if (allPawnsSpawned[k].carryTracker.CarriedThing is Corpse corpse && !corpse.IsDessicated() && corpse.InnerPawn.IsColonist)
{
tmpPawns.Add(corpse.InnerPawn);
}
}
foreach (Pawn tmpPawn in tmpPawns)
{
if (tmpPawn.playerSettings.displayOrder == -9999999)
{
tmpPawn.playerSettings.displayOrder = Mathf.Max(tmpPawns.MaxBy((Pawn p) => p.playerSettings.displayOrder).playerSettings.displayOrder, 0) + 1;
}
}
PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
foreach (Pawn tmpPawn2 in tmpPawns)
{
cachedEntries.Add(new Entry(tmpPawn2, tmpMaps[i], num));
}
if (!tmpPawns.Any())
{
cachedEntries.Add(new Entry(null, tmpMaps[i], num));
}
num++;
}
tmpCaravans.Clear();
tmpCaravans.AddRange(Find.WorldObjects.Caravans);
tmpCaravans.SortBy((Caravan x) => x.ID);
for (int l = 0; l < tmpCaravans.Count; l++)
{
if (!tmpCaravans[l].IsPlayerControlled)
{
continue;
}
tmpPawns.Clear();
tmpPawns.AddRange(tmpCaravans[l].PawnsListForReading);
PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
for (int m = 0; m < tmpPawns.Count; m++)
{
if (tmpPawns[m].IsColonist || tmpPawns[m].IsColonySubhumanPlayerControlled)
{
cachedEntries.Add(new Entry(tmpPawns[m], null, num));
}
}
num++;
}
}
cachedReorderableGroups.Clear();
foreach (Entry cachedEntry in cachedEntries)
{
_ = cachedEntry;
cachedReorderableGroups.Add(-1);
}
drawer.Notify_RecachedEntries();
tmpPawns.Clear();
tmpMaps.Clear();
tmpCaravans.Clear();
drawLocsFinder.CalculateDrawLocs(cachedDrawLocs, out cachedScale, num);
}
public float GetEntryRectAlpha(Rect rect)
{
if (Messages.CollidesWithAnyMessage(rect, out var messageAlpha))
{
return Mathf.Lerp(1f, 0.2f, messageAlpha);
}
return 1f;
}
public void Highlight(Pawn pawn)
{
if (Visible && !colonistsToHighlight.Contains(pawn))
{
colonistsToHighlight.Add(pawn);
}
}
public void Reorder(int from, int to, int entryGroup)
{
int num = 0;
Pawn pawn = null;
Pawn pawn2 = null;
Pawn pawn3 = null;
for (int i = 0; i < cachedEntries.Count; i++)
{
if (cachedEntries[i].group == entryGroup && cachedEntries[i].pawn != null)
{
if (num == from)
{
pawn = cachedEntries[i].pawn;
}
if (num == to)
{
pawn2 = cachedEntries[i].pawn;
}
pawn3 = cachedEntries[i].pawn;
num++;
}
}
if (pawn == null)
{
return;
}
int num2 = pawn2?.playerSettings.displayOrder ?? (pawn3.playerSettings.displayOrder + 1);
for (int j = 0; j < cachedEntries.Count; j++)
{
Pawn pawn4 = cachedEntries[j].pawn;
if (pawn4 == null)
{
continue;
}
if (pawn4.playerSettings.displayOrder == num2)
{
if (pawn2 != null && cachedEntries[j].group == entryGroup)
{
pawn4.playerSettings.displayOrder++;
}
}
else if (pawn4.playerSettings.displayOrder > num2)
{
pawn4.playerSettings.displayOrder++;
}
else
{
pawn4.playerSettings.displayOrder--;
}
}
pawn.playerSettings.displayOrder = num2;
MarkColonistsDirty();
MainTabWindowUtility.NotifyAllPawnTables_PawnsChanged();
}
public void DrawColonistMouseAttachment(int index, Vector2 dragStartPos, int entryGroup)
{
Pawn pawn = null;
Vector2 vector = default(Vector2);
int num = 0;
for (int i = 0; i < cachedEntries.Count; i++)
{
if (cachedEntries[i].group == entryGroup && cachedEntries[i].pawn != null)
{
if (num == index)
{
pawn = cachedEntries[i].pawn;
vector = cachedDrawLocs[i];
break;
}
num++;
}
}
if (pawn != null)
{
RenderTexture iconTex = PortraitsCache.Get(pawn, ColonistBarColonistDrawer.PawnTextureSize, Rot4.South, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f);
Rect rect = new Rect(vector.x, vector.y, Size.x, Size.y);
Rect pawnTextureRect = drawer.GetPawnTextureRect(rect.position);
pawnTextureRect.position += Event.current.mousePosition - dragStartPos;
Rect? customRect = pawnTextureRect;
GenUI.DrawMouseAttachment(iconTex, "", 0f, default(Vector2), customRect);
}
}
public bool AnyColonistOrCorpseAt(Vector2 pos)
{
if (!TryGetEntryAt(pos, out var entry))
{
return false;
}
return entry.pawn != null;
}
public bool TryGetEntryAt(Vector2 pos, out Entry entry)
{
List<Vector2> drawLocs = DrawLocs;
List<Entry> entries = Entries;
Vector2 size = Size;
for (int i = 0; i < drawLocs.Count; i++)
{
if (new Rect(drawLocs[i].x, drawLocs[i].y, size.x, size.y).Contains(pos))
{
entry = entries[i];
return true;
}
}
entry = default(Entry);
return false;
}
public List<Pawn> GetColonistsInOrder()
{
List<Entry> entries = Entries;
tmpColonistsInOrder.Clear();
for (int i = 0; i < entries.Count; i++)
{
if (entries[i].pawn != null)
{
tmpColonistsInOrder.Add(entries[i].pawn);
}
}
return tmpColonistsInOrder;
}
public List<Thing> ColonistsOrCorpsesInScreenRect(Rect rect)
{
List<Vector2> drawLocs = DrawLocs;
List<Entry> entries = Entries;
Vector2 size = Size;
tmpColonistsWithMap.Clear();
for (int i = 0; i < drawLocs.Count; i++)
{
if (rect.Overlaps(new Rect(drawLocs[i].x, drawLocs[i].y, size.x, size.y)))
{
Pawn pawn = entries[i].pawn;
if (pawn != null)
{
Thing first = ((!pawn.Dead || pawn.Corpse == null || !pawn.Corpse.SpawnedOrAnyParentSpawned) ? ((Thing)pawn) : ((Thing)pawn.Corpse));
tmpColonistsWithMap.Add(new Pair<Thing, Map>(first, entries[i].map));
}
}
}
if (WorldRendererUtility.WorldSelected && tmpColonistsWithMap.Any((Pair<Thing, Map> x) => x.Second == null))
{
tmpColonistsWithMap.RemoveAll((Pair<Thing, Map> x) => x.Second != null);
}
else if (tmpColonistsWithMap.Any((Pair<Thing, Map> x) => x.Second == Find.CurrentMap))
{
tmpColonistsWithMap.RemoveAll((Pair<Thing, Map> x) => x.Second != Find.CurrentMap);
}
tmpColonists.Clear();
for (int j = 0; j < tmpColonistsWithMap.Count; j++)
{
tmpColonists.Add(tmpColonistsWithMap[j].First);
}
tmpColonistsWithMap.Clear();
return tmpColonists;
}
public List<Thing> MapColonistsOrCorpsesInScreenRect(Rect rect)
{
tmpMapColonistsOrCorpsesInScreenRect.Clear();
if (!Visible)
{
return tmpMapColonistsOrCorpsesInScreenRect;
}
List<Thing> list = ColonistsOrCorpsesInScreenRect(rect);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Spawned)
{
tmpMapColonistsOrCorpsesInScreenRect.Add(list[i]);
}
}
return tmpMapColonistsOrCorpsesInScreenRect;
}
public List<Pawn> CaravanMembersInScreenRect(Rect rect)
{
tmpCaravanPawns.Clear();
if (!Visible)
{
return tmpCaravanPawns;
}
List<Thing> list = ColonistsOrCorpsesInScreenRect(rect);
for (int i = 0; i < list.Count; i++)
{
if (list[i] is Pawn pawn && pawn.IsCaravanMember())
{
tmpCaravanPawns.Add(pawn);
}
}
return tmpCaravanPawns;
}
public List<Caravan> CaravanMembersCaravansInScreenRect(Rect rect)
{
tmpCaravans.Clear();
if (!Visible)
{
return tmpCaravans;
}
List<Pawn> list = CaravanMembersInScreenRect(rect);
for (int i = 0; i < list.Count; i++)
{
tmpCaravans.Add(list[i].GetCaravan());
}
return tmpCaravans;
}
public Caravan CaravanMemberCaravanAt(Vector2 at)
{
if (!Visible)
{
return null;
}
if (ColonistOrCorpseAt(at) is Pawn pawn && pawn.IsCaravanMember())
{
return pawn.GetCaravan();
}
return null;
}
public Thing ColonistOrCorpseAt(Vector2 pos)
{
if (!Visible)
{
return null;
}
if (!TryGetEntryAt(pos, out var entry))
{
return null;
}
Pawn pawn = entry.pawn;
if (pawn != null && pawn.Dead && pawn.Corpse != null && pawn.Corpse.SpawnedOrAnyParentSpawned)
{
return pawn.Corpse;
}
return pawn;
}
}
```