public static void Listener(ColonistBar __instance, ref List <ColonistBar.Entry> ___cachedEntries, ref ColonistBarDrawLocsFinder ___drawLocsFinder, ref List <Vector2> ___cachedDrawLocs, ref float ___cachedScale) { try { if (!Settings.hideInactiveSurrogates) { return; } List <ColonistBar.Entry> toDel = null; //Suppresssion de la barre du haut des surrogates non actifs for (int i = 0; i < ___cachedEntries.Count; i++) { ColonistBar.Entry e = ___cachedEntries[i]; if (e.pawn.IsSurrogateAndroid(false, true)) { if (toDel == null) { toDel = new List <ColonistBar.Entry>(); } toDel.Add(e); } } if (toDel != null) { for (int i = 0; i < toDel.Count; i++) { ColonistBar.Entry e = toDel[i]; ___cachedEntries.Remove(e); } __instance.drawer.Notify_RecachedEntries(); ___drawLocsFinder.CalculateDrawLocs(___cachedDrawLocs, out ___cachedScale); } } catch (Exception e) { Log.Message("[ATPP] Colonistbar.CheckRecacheEntries " + e.Message + " " + e.StackTrace); } }
static bool Prefix(ColonistBar __instance, ref bool ___entriesDirty, ref List <Map> ___tmpMaps, ref List <Pawn> ___tmpPawns, ref List <Caravan> ___tmpCaravans, ref List <ColonistBar.Entry> ___cachedEntries, ref ColonistBarDrawLocsFinder ___drawLocsFinder, ref List <Vector2> ___cachedDrawLocs, ref float ___cachedScale) { if (!___entriesDirty) { return(false); } ___entriesDirty = false; ___cachedEntries.Clear(); if (Find.PlaySettings.showColonistBar) { ___tmpMaps.Clear(); ___tmpMaps.AddRange((IEnumerable <Map>)Find.Maps); ___tmpMaps.SortBy <Map, bool, int>((Func <Map, bool>)(x => !x.IsPlayerHome), (Func <Map, int>)(x => x.uniqueID)); int group = 0; for (int index1 = 0; index1 < ___tmpMaps.Count; ++index1) { ___tmpPawns.Clear(); ___tmpPawns.AddRange(___tmpMaps[index1].mapPawns.FreeColonists); List <Thing> thingList = ___tmpMaps[index1].listerThings.ThingsInGroup(ThingRequestGroup.Corpse); for (int index2 = 0; index2 < thingList.Count; ++index2) { if (!thingList[index2].IsDessicated()) { Pawn innerPawn = ((Corpse)thingList[index2]).InnerPawn; if (innerPawn != null && innerPawn.IsColonist) { ___tmpPawns.Add(innerPawn); } } } List <Pawn> allPawnsSpawned = ___tmpMaps[index1].mapPawns.AllPawnsSpawned; for (int index2 = 0; index2 < allPawnsSpawned.Count; ++index2) { Corpse carriedThing = allPawnsSpawned[index2].carryTracker.CarriedThing as Corpse; if (carriedThing != null && !carriedThing.IsDessicated() && carriedThing.InnerPawn.IsColonist) { ___tmpPawns.Add(carriedThing.InnerPawn); } } PlayerPawnsDisplayOrderUtility.Sort(___tmpPawns); for (int index2 = 0; index2 < ___tmpPawns.Count; ++index2) { ___cachedEntries.Add(new ColonistBar.Entry(___tmpPawns[index2], ___tmpMaps[index1], group)); } if (!___tmpPawns.Any <Pawn>()) { ___cachedEntries.Add(new ColonistBar.Entry((Pawn)null, ___tmpMaps[index1], group)); } ++group; } ___tmpCaravans.Clear(); ___tmpCaravans.AddRange((IEnumerable <Caravan>)Find.WorldObjects.Caravans); ___tmpCaravans.SortBy <Caravan, int>((Func <Caravan, int>)(x => x.ID)); for (int index1 = 0; index1 < ___tmpCaravans.Count; ++index1) { //change from original if (___tmpCaravans[index1].IsPlayerControlled && ___tmpCaravans[index1].pawns.Count != 0) { ___tmpPawns.Clear(); ___tmpPawns.AddRange((IEnumerable <Pawn>)___tmpCaravans[index1].PawnsListForReading); PlayerPawnsDisplayOrderUtility.Sort(___tmpPawns); for (int index2 = 0; index2 < ___tmpPawns.Count; ++index2) { if (___tmpPawns[index2].IsColonist) { ___cachedEntries.Add(new ColonistBar.Entry(___tmpPawns[index2], (Map)null, group)); } } ++group; } } } __instance.drawer.Notify_RecachedEntries(); ___tmpPawns.Clear(); ___tmpMaps.Clear(); ___tmpCaravans.Clear(); ___drawLocsFinder.CalculateDrawLocs(___cachedDrawLocs, out ___cachedScale); return(false); }