public void Add(TrackedColonist colonist)
 {
     if (!this.colonists.Contains(colonist))
     {
         this.colonists.Add(colonist);
     }
 }
        protected TrackedColonist StartTrackingPawn(Pawn pawn)
        {
            if (pawn == null || !pawn.IsColonist)
            {
                return(null);
            }
            TrackedColonist trackedColonist = null;

            if (this.trackedColonists.TryGetValue(pawn, out trackedColonist))
            {
                this.Message(pawn, "Already tracking colonist");
                return(trackedColonist);
            }
            trackedColonist = new TrackedColonist(pawn);
            if (!this.trackedColonists.ContainsKey(pawn))
            {
                this.trackedColonists.Add(pawn, trackedColonist);
                if (this.ColonistChanged != null)
                {
                    this.ColonistChanged(new ColonistNotification(ColonistNotificationType.New, trackedColonist));
                }
                this.Message(pawn, "Tracking new colonist");
            }
            else
            {
                this.Message(pawn, "Already tracking colonist");
            }
            return(trackedColonist);
        }
 protected void MarkColonistAsWokenFromCryptosleep(TrackedColonist colonist)
 {
     colonist.Cryptosleep = false;
     if (this.ColonistChanged != null)
     {
         this.ColonistChanged(new ColonistNotification(ColonistNotificationType.WokeFromCryptosleep, colonist));
     }
     this.Message(colonist.Pawn, "Tracked colonist has woken from cryptosleep.");
 }
 protected void MarkColonistAsEnteredCryptosleep(TrackedColonist colonist)
 {
     colonist.Cryptosleep = true;
     if (this.ColonistChanged != null)
     {
         this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Cryptosleep, colonist));
     }
     this.Message(colonist.Pawn, "Tracked colonist has entered cryptosleep.");
 }
 protected void MarkColonistAsDeleted(TrackedColonist colonist)
 {
     if (this.ColonistChanged != null)
     {
         this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Deleted, colonist));
     }
     this.Message(colonist.Pawn, "Tracked colonist has been deleted");
     this.removalList.Add(colonist.Pawn);
 }
 protected void MarkColonistAsLost(TrackedColonist colonist)
 {
     if (this.ColonistChanged != null)
     {
         this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Lost, colonist));
     }
     this.Message("Tracked colonist has been missing for more than " + ColonistTracker.MaxMissingDuration + " ticks");
     this.removalList.Add(colonist.Pawn);
 }
        public void StopTrackingPawn(Pawn pawn)
        {
            TrackedColonist trackedColonist = this.FindTrackedColonist(pawn);

            if (trackedColonist != null)
            {
                this.MarkColonistAsDeleted(trackedColonist);
            }
        }
 protected void ReplaceTrackedPawn(TrackedColonist colonist, Pawn replacement)
 {
     this.trackedColonists.Remove(colonist.Pawn);
     colonist.Pawn = replacement;
     this.trackedColonists.Add(colonist.Pawn, colonist);
     this.Message(colonist.Pawn, "Tracked colonist was found.  Pawn was replaced.");
     if (this.ColonistChanged != null)
     {
         this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Replaced, colonist, replacement));
     }
 }
 protected void MarkColonistAsFreed(TrackedColonist colonist)
 {
     colonist.CapturingFaction = null;
     if (!colonist.Pawn.Destroyed)
     {
         if (this.ColonistChanged != null)
         {
             this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Freed, colonist));
         }
         this.Message(colonist.Pawn, "Captured colonist has been freed.");
     }
 }
 protected void MarkColonistAsCaptured(TrackedColonist colonist, Pawn carrier, Faction capturingFaction)
 {
     if (colonist.CapturingFaction != capturingFaction)
     {
         colonist.CapturingFaction = capturingFaction;
         if (this.ColonistChanged != null)
         {
             this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Captured, colonist));
         }
         this.Message(colonist.Pawn, "Colonist has been captured (by " + capturingFaction.name + ")");
     }
 }
        public void ResolveMissingPawn(Pawn pawn, TrackedColonist colonist)
        {
            if (pawn.Dead || pawn.Destroyed)
            {
                this.Message(pawn, "Tracked colonist is dead or destroyed.  Searching for corpse.");
                Corpse corpse = (Corpse)Find.ListerThings.ThingsMatching(this.corpseThingRequest).FirstOrDefault(delegate(Thing thing)
                {
                    Corpse corpse2 = thing as Corpse;
                    return(corpse2 != null && corpse2.innerPawn == pawn);
                });
                if (corpse != null)
                {
                    if (!colonist.Dead)
                    {
                        colonist.Dead = true;
                        if (this.ColonistChanged != null)
                        {
                            this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Died, colonist));
                        }
                    }
                    colonist.Corpse = corpse;
                    this.Message(pawn, "Corpse found.  Colonist is dead.");
                    return;
                }
                this.Message("Corpse not found.");
            }
            Pawn    pawn2   = null;
            Faction faction = this.FindCarryingFaction(pawn, out pawn2);

            if (faction == null)
            {
                Pawn pawn3 = this.FindColonist(pawn);
                if (pawn3 == null)
                {
                    if (!colonist.Missing)
                    {
                        this.MarkColonistAsMissing(colonist);
                    }
                }
                else
                {
                    this.ReplaceTrackedPawn(colonist, pawn3);
                }
                return;
            }
            if (faction != Faction.OfColony)
            {
                colonist.CapturingFaction = faction;
                this.Message(pawn, "Colonist is captured");
                return;
            }
            this.Message(pawn, "Colonist is being rescued");
        }
예제 #12
0
        protected int GetOrderHash(IEnumerable <Pawn> colonists)
        {
            int num = 33;

            foreach (Pawn current in colonists)
            {
                TrackedColonist trackedColonist = ColonistTracker.Instance.FindTrackedColonist(current);
                if (trackedColonist == null || (!trackedColonist.Dead && !trackedColonist.Missing && !trackedColonist.Captured))
                {
                    num = 17 * num + current.GetUniqueLoadID().GetHashCode();
                }
            }
            return(num);
        }
 protected void MarkColonistAsMissing(TrackedColonist colonist)
 {
     if (!colonist.Missing)
     {
         if (colonist.Captured)
         {
             this.Message(colonist.Pawn, "Captured colonist has been removed from the map (by " + colonist.CapturingFaction + ")");
         }
         colonist.Missing          = true;
         colonist.MissingTimestamp = Find.TickManager.TicksGame;
         if (this.ColonistChanged != null)
         {
             this.ColonistChanged(new ColonistNotification(ColonistNotificationType.Missing, colonist));
         }
         this.Message(colonist.Pawn, "Tracked colonist is missing (since " + colonist.MissingTimestamp + ")");
     }
 }
예제 #14
0
        protected void ResetAvailableColonists(Squad squad)
        {
            List <TrackedColonist> list = new List <TrackedColonist>();

            foreach (Pawn current in this.squadManager.AllColonistsSquad.Pawns)
            {
                if (!squad.Pawns.Contains(current))
                {
                    TrackedColonist trackedColonist = ColonistTracker.Instance.FindTrackedColonist(current);
                    if (trackedColonist != null)
                    {
                        list.Add(trackedColonist);
                    }
                }
            }
            this.availableColonistsWidget.ResetItems(list);
        }
예제 #15
0
 protected void ResetSquadMembers(Squad squad)
 {
     if (squad != null)
     {
         List <TrackedColonist> list = new List <TrackedColonist>();
         foreach (Pawn current in squad.Pawns)
         {
             TrackedColonist trackedColonist = ColonistTracker.Instance.FindTrackedColonist(current);
             if (trackedColonist != null)
             {
                 list.Add(trackedColonist);
             }
         }
         this.squadMembersWidget.ResetItems(list);
     }
     else
     {
         this.squadMembersWidget.ResetItems(new List <TrackedColonist>());
     }
 }
        protected void RenderSlot(TrackedColonist slot, Vector2 position)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Rot4           south    = Rot4.South;
            Pawn           pawn     = slot.Pawn;
            PawnGraphicSet graphics = pawn.drawer.renderer.graphics;

            if (!graphics.AllResolved)
            {
                graphics.ResolveAllGraphics();
            }
            bool       flag        = slot.Dead || slot.Missing;
            bool       cryptosleep = slot.Cryptosleep;
            Quaternion identity    = Quaternion.identity;
            Vector3    one         = Vector3.one;

            Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, 0f), identity, one), ColonistBarDrawer.SlotBackgroundMat, 1, this.camera, 0, null);
            MaterialPropertyBlock properties = null;

            if (flag)
            {
                properties = this.deadPropertyBlock;
            }
            else if (slot.Cryptosleep)
            {
                properties = this.cryptosleepPropertyBlock;
            }
            float    num = 1f;
            Material material;

            foreach (Material current in graphics.MatsBodyBaseAt(south, RotDrawMode.Fresh))
            {
                material = current;
                if (flag)
                {
                    material = this.GetDeadMaterial(current);
                }
                else if (cryptosleep)
                {
                    material = this.GetFrozenMaterial(current);
                }
                Graphics.DrawMesh(this.bodyMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.PortraitOffset.x, position.y + ColonistBarDrawer.PortraitOffset.y, num), identity, one), material, 1, this.camera, 0, properties);
                num += 1f;
            }
            Material material2;

            for (int i = 0; i < graphics.apparelGraphics.Count; i++)
            {
                ApparelGraphicRecord apparelGraphicRecord = graphics.apparelGraphics[i];
                if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell)
                {
                    material2 = apparelGraphicRecord.graphic.MatAt(south, null);
                    material2 = graphics.flasher.GetDamagedMat(material2);
                    material  = material2;
                    if (flag)
                    {
                        material = this.GetDeadMaterial(material2);
                    }
                    else if (cryptosleep)
                    {
                        material = this.GetFrozenMaterial(material2);
                    }
                    Graphics.DrawMesh(this.bodyMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.PortraitOffset.x, position.y + ColonistBarDrawer.PortraitOffset.y, num), identity, one), material, 1, this.camera, 0, properties);
                    num += 1f;
                }
            }
            Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, num), identity, one), ColonistBarDrawer.SlotBordersMat, 1, this.camera);
            num += 1f;
            if ((slot.Corpse != null) ? Find.Selector.IsSelected(slot.Corpse) : Find.Selector.IsSelected(pawn))
            {
                Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, num), identity, one), ColonistBarDrawer.SlotSelectedMat, 1, this.camera);
                num += 1f;
            }
            material2 = pawn.drawer.renderer.graphics.HeadMatAt(south, RotDrawMode.Fresh);
            material  = material2;
            if (flag)
            {
                material = this.GetDeadMaterial(material2);
            }
            else if (cryptosleep)
            {
                material = this.GetFrozenMaterial(material2);
            }
            Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties);
            num += 1f;
            bool flag2 = false;
            List <ApparelGraphicRecord> apparelGraphics = graphics.apparelGraphics;

            for (int j = 0; j < apparelGraphics.Count; j++)
            {
                if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead)
                {
                    flag2     = true;
                    material2 = apparelGraphics[j].graphic.MatAt(south, null);
                    material2 = graphics.flasher.GetDamagedMat(material2);
                    material  = material2;
                    if (flag)
                    {
                        material = this.GetDeadMaterial(material2);
                    }
                    else if (cryptosleep)
                    {
                        material = this.GetFrozenMaterial(material2);
                    }
                    Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties);
                    num += 1f;
                }
            }
            if (!flag2 && slot.Pawn.story.hairDef != null)
            {
                material2 = graphics.HairMatAt(south);
                material  = material2;
                if (flag)
                {
                    material = this.GetDeadMaterial(material2);
                }
                else if (cryptosleep)
                {
                    material = this.GetFrozenMaterial(material2);
                }
                Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties);
                num += 1f;
            }
        }
 public override void ExposeData()
 {
     base.ExposeData();
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         this.squads.Clear();
         this.squads.AddRange(SquadManager.Instance.Squads);
         this.missingPawns.Clear();
         HashSet <Pawn> hashSet = new HashSet <Pawn>();
         foreach (Squad current in this.squads)
         {
             foreach (Pawn current2 in current.Pawns)
             {
                 TrackedColonist trackedColonist = ColonistTracker.Instance.FindTrackedColonist(current2);
                 if (trackedColonist.Missing)
                 {
                     hashSet.Add(current2);
                 }
             }
         }
         foreach (Pawn current3 in hashSet)
         {
             this.missingPawns.Add(current3);
         }
         this.favorites.Clear();
         this.favorites.AddRange(SquadManager.Instance.Favorites);
         this.favoriteIds.Clear();
         foreach (Squad current4 in this.favorites)
         {
             if (current4 != null)
             {
                 this.favoriteIds.Add(current4.Id);
             }
             else
             {
                 this.favoriteIds.Add(string.Empty);
             }
         }
         this.currentSquad = SquadManager.Instance.CurrentSquad;
         if (this.currentSquad != null)
         {
             this.currentSquadId = this.currentSquad.Id;
         }
         else
         {
             this.currentSquadId = string.Empty;
         }
         this.squadFilter = SquadManager.Instance.SquadFilter;
         if (this.squadFilter != null)
         {
             this.squadFilterId = this.squadFilter.Id;
         }
         else
         {
             this.squadFilterId = string.Empty;
         }
     }
     Scribe_Values.LookValue <string>(ref this.currentSquadId, "currentSquad", null, false);
     Scribe_Values.LookValue <string>(ref this.squadFilterId, "squadFilter", null, false);
     Scribe_Collections.LookList <string>(ref this.favoriteIds, "favorites", LookMode.Value, null);
     Scribe_Collections.LookList <Pawn>(ref this.missingPawns, "missingPawns", LookMode.Deep, null);
     Scribe_Collections.LookList <Squad>(ref this.squads, "squads", LookMode.Deep, null);
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         if (this.favorites == null)
         {
             this.favorites = new List <Squad>();
         }
         else
         {
             this.favorites.Clear();
         }
         for (int i = 0; i < SquadManager.MaxFavorites; i++)
         {
             this.favorites.Add(null);
         }
         if (this.favoriteIds == null)
         {
             this.favoriteIds = new List <string>();
             for (int j = 0; j < SquadManager.MaxFavorites; j++)
             {
                 this.favoriteIds.Add(string.Empty);
             }
         }
         int num = 0;
         foreach (string current5 in this.favoriteIds)
         {
             this.favorites[num++] = this.FindSquadById(current5);
         }
         this.currentSquad = this.FindSquadById(this.currentSquadId);
         this.squadFilter  = this.FindSquadById(this.squadFilterId);
     }
 }
예제 #18
0
        public void SyncSquadsToColonistBar()
        {
            if (!this.enabled)
            {
                return;
            }
            SquadManager      instance          = SquadManager.Instance;
            ColonistTracker   instance2         = ColonistTracker.Instance;
            AllColonistsSquad allColonistsSquad = SquadManager.Instance.AllColonistsSquad;

            this.groupDictionaryScratch.Clear();
            this.squadDictionaryScratch.Clear();
            this.colonistBarGroups.Clear();
            int count = instance.Squads.Count;

            for (int i = 0; i < count; i++)
            {
                Squad            squad            = instance.Squads[i];
                ColonistBarGroup colonistBarGroup = null;
                if (this.groupDictionary.TryGetValue(squad, out colonistBarGroup) && squad == allColonistsSquad)
                {
                    this.allColonistsGroup = colonistBarGroup;
                }
                if (squad.Pawns.Count > 0 && squad.ShowInColonistBar)
                {
                    bool flag = false;
                    if (colonistBarGroup == null)
                    {
                        colonistBarGroup = new ColonistBarGroup(squad.Pawns.Count);
                        flag             = true;
                    }
                    else if (colonistBarGroup.OrderHash != squad.OrderHash)
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        colonistBarGroup.Clear();
                        colonistBarGroup.Name = squad.Name;
                        colonistBarGroup.Id   = squad.Id;
                        foreach (Pawn current in squad.Pawns)
                        {
                            TrackedColonist trackedColonist = instance2.FindTrackedColonist(current);
                            if (trackedColonist != null)
                            {
                                colonistBarGroup.Add(trackedColonist);
                            }
                        }
                    }
                    this.colonistBarGroups.Add(colonistBarGroup);
                    this.groupDictionaryScratch[squad]            = colonistBarGroup;
                    this.squadDictionaryScratch[colonistBarGroup] = squad;
                }
            }
            Dictionary <ColonistBarGroup, Squad> dictionary  = this.squadDictionary;
            Dictionary <Squad, ColonistBarGroup> dictionary2 = this.groupDictionary;

            this.groupDictionary        = this.groupDictionaryScratch;
            this.squadDictionary        = this.squadDictionaryScratch;
            this.groupDictionaryScratch = dictionary2;
            this.squadDictionaryScratch = dictionary;
        }
 public bool Remove(TrackedColonist colonist)
 {
     return(this.colonists.Remove(colonist));
 }
예제 #20
0
 public ColonistNotification(ColonistNotificationType type, TrackedColonist colonist, Pawn relatedPawn)
 {
     this.type        = type;
     this.colonist    = colonist;
     this.relatedPawn = relatedPawn;
 }
        protected void DrawTextureForSlot(TrackedColonist slot, Vector2 position)
        {
            Pawn pawn = slot.Pawn;

            if (Widgets.InvisibleButton(new Rect(position.x, position.y, ColonistBarDrawer.SlotSize.x, ColonistBarDrawer.SlotSize.y)))
            {
                int button = Event.current.button;
                if (button == 2 && slot.Carrier == null)
                {
                    if (slot.Broken)
                    {
                        this.SelectAllNotSane();
                    }
                    else if (slot.Controllable)
                    {
                        this.SelectAllActive();
                    }
                    else
                    {
                        this.SelectAllDead();
                    }
                }
                if (button == 0)
                {
                    if (Time.time - this.doubleClickTime < 0.3f)
                    {
                        if (!pawn.Dead)
                        {
                            Pawn carrier = slot.Carrier;
                            if (carrier == null)
                            {
                                Find.CameraMap.JumpTo(pawn.Position);
                            }
                            else
                            {
                                Find.CameraMap.JumpTo(carrier.Position);
                            }
                        }
                        else if (slot.Corpse != null)
                        {
                            Find.CameraMap.JumpTo(slot.Corpse.Position);
                        }
                        this.doubleClickTime = -1f;
                    }
                    else
                    {
                        if (!pawn.Dead)
                        {
                            if ((Event.current.shift || Event.current.control) && Find.Selector.IsSelected(pawn))
                            {
                                Find.Selector.Deselect(pawn);
                            }
                            else if (slot.Carrier == null)
                            {
                                if (!Event.current.alt)
                                {
                                    this.pawnSelector.SelectThing(pawn, Event.current.shift);
                                }
                                else if (slot.Broken)
                                {
                                    this.SelectAllNotSane();
                                }
                                else
                                {
                                    this.SelectAllActive();
                                }
                            }
                        }
                        else
                        {
                            if (slot.Corpse == null || slot.Missing)
                            {
                                this.doubleClickTime = -1f;
                                return;
                            }
                            if (Event.current.shift && Find.Selector.IsSelected(slot.Corpse))
                            {
                                Find.Selector.Deselect(slot.Corpse);
                            }
                            else if (Event.current.alt)
                            {
                                this.SelectAllDead();
                            }
                            else
                            {
                                this.pawnSelector.SelectThing(slot.Corpse, Event.current.shift);
                            }
                        }
                        if (!Event.current.shift)
                        {
                            this.doubleClickTime = Time.time;
                        }
                    }
                }
                else
                {
                    this.doubleClickTime = -1f;
                }
                if (button == 1)
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    if (slot.Missing || slot.Corpse != null)
                    {
                        string label = (!slot.Missing) ? "EdB.ColonistBar.RemoveDeadColonist".Translate() : "EdB.ColonistBar.RemoveMissingColonist".Translate();
                        list.Add(new FloatMenuOption(label, delegate
                        {
                            ColonistTracker.Instance.StopTrackingPawn(slot.Pawn);
                        }, MenuOptionPriority.Medium, null, null));
                    }
                    list.Add(new FloatMenuOption("EdB.ColonistBar.HideColonistBar".Translate(), delegate
                    {
                        this.visible = false;
                    }, MenuOptionPriority.Medium, null, null));
                    FloatMenu window = new FloatMenu(list, string.Empty, false, false);
                    Find.WindowStack.Add(window);
                }
            }
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (!slot.Dead)
            {
                if (slot.Incapacitated)
                {
                    GUI.color = new Color(0.7843f, 0f, 0f);
                }
                else if ((double)slot.HealthPercent < 0.95)
                {
                    GUI.color = new Color(0.7843f, 0.7843f, 0f);
                }
                else
                {
                    GUI.color = new Color(0f, 0.7843f, 0f);
                }
                if (slot.Missing)
                {
                    GUI.color = new Color(0.4824f, 0.4824f, 0.4824f);
                }
                float num = ColonistBarDrawer.HealthSize.y * slot.HealthPercent;
                GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.HealthOffset.x, position.y + ColonistBarDrawer.HealthOffset.y + ColonistBarDrawer.HealthSize.y - num, ColonistBarDrawer.HealthSize.x, num), BaseContent.WhiteTex);
            }
            Vector2 vector = Text.CalcSize(pawn.LabelBaseShort);

            if (vector.x > ColonistBarDrawer.MaxLabelSize.x)
            {
                vector.x = ColonistBarDrawer.MaxLabelSize.x;
            }
            vector.x += 4f;
            GUI.color = ColonistBarDrawer.ColorNameUnderlay;
            GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.SlotSize.x / 2f - vector.x / 2f, position.y + ColonistBarDrawer.PortraitSize.y, vector.x, 12f), BaseContent.BlackTex);
            Text.Font = GameFont.Tiny;
            GUI.skin.label.alignment = TextAnchor.UpperCenter;
            Text.Anchor = TextAnchor.UpperCenter;
            Color          color       = Color.white;
            BrokenStateDef brokenState = slot.BrokenState;

            if (brokenState != null)
            {
                color = brokenState.nameColor;
            }
            GUI.color = color;
            Widgets.Label(new Rect(position.x + ColonistBarDrawer.SlotSize.x / 2f - vector.x / 2f, position.y + ColonistBarDrawer.PortraitSize.y - 2f, vector.x, 20f), pawn.LabelBaseShort);
            if (slot.Drafted)
            {
                vector.x -= 4f;
                GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.SlotSize.x / 2f - vector.x / 2f, position.y + ColonistBarDrawer.PortraitSize.y + 11f, vector.x, 1f), BaseContent.WhiteTex);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            string text = null;

            if (slot.Missing)
            {
                text = "EdB.ColonistBar.Status.MISSING".Translate();
            }
            else if (slot.Corpse != null)
            {
                text = "EdB.ColonistBar.Status.DEAD".Translate();
            }
            else if (slot.Captured)
            {
                text = "EdB.ColonistBar.Status.KIDNAPPED".Translate();
            }
            else if (slot.Cryptosleep)
            {
                text = "EdB.ColonistBar.Status.CRYPTOSLEEP".Translate();
            }
            else if (brokenState != null)
            {
                if (brokenState == BrokenStateDefOf.Berserk)
                {
                    text = "EdB.ColonistBar.Status.RAMPAGE".Translate();
                }
                else if (brokenState.defName.Contains("Binging"))
                {
                    text = "EdB.ColonistBar.Status.BINGING".Translate();
                }
                else
                {
                    text = "EdB.ColonistBar.Status.BROKEN".Translate();
                }
            }
            if (text != null)
            {
                Vector2 vector2 = Text.CalcSize(text);
                vector2.x += 4f;
                GUI.color  = new Color(0f, 0f, 0f, 0.4f);
                GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.SlotSize.x / 2f - vector2.x / 2f, position.y + ColonistBarDrawer.PortraitSize.y + 12f, vector2.x, 13f), BaseContent.BlackTex);
                Text.Font = GameFont.Tiny;
                GUI.skin.label.alignment = TextAnchor.UpperCenter;
                Text.Anchor = TextAnchor.UpperCenter;
                GUI.color   = color;
                Widgets.Label(new Rect(position.x + ColonistBarDrawer.SlotSize.x / 2f - vector2.x / 2f, position.y + ColonistBarDrawer.PortraitSize.y + 10f, vector2.x, 20f), text);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.color = new Color(1f, 1f, 1f);
            if (!slot.Cryptosleep)
            {
                if (slot.MentalBreakWarningLevel == 2 && (double)Time.time % 1.2 < 0.4)
                {
                    GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.PortraitOffset.x, position.y + ColonistBarDrawer.PortraitOffset.y, ColonistBarDrawer.MentalHealthSize.x, ColonistBarDrawer.MentalHealthSize.y), ColonistBarDrawer.MentalBreakImminentTex);
                }
                else if (slot.MentalBreakWarningLevel == 1 && (double)Time.time % 1.2 < 0.4)
                {
                    GUI.DrawTexture(new Rect(position.x + ColonistBarDrawer.MentalHealthOffset.x, position.y + ColonistBarDrawer.MentalHealthOffset.y, ColonistBarDrawer.MentalHealthSize.x, ColonistBarDrawer.MentalHealthSize.y), ColonistBarDrawer.UnhappyTex);
                }
            }
        }
        protected void UpdateColonistState(Pawn pawn, TrackedColonist colonist)
        {
            Faction faction = null;
            bool    flag    = false;
            Pawn    pawn2   = null;

            if (pawn.holder != null)
            {
                if (pawn.Destroyed)
                {
                    this.MarkColonistAsMissing(colonist);
                }
                else if (pawn.holder.owner != null)
                {
                    Pawn_CarryTracker pawn_CarryTracker = pawn.holder.owner as Pawn_CarryTracker;
                    if (pawn_CarryTracker != null && pawn_CarryTracker.pawn != null && pawn_CarryTracker.pawn.Faction != null && pawn_CarryTracker.pawn.Faction != Faction.OfColony && pawn_CarryTracker.pawn.Faction.RelationWith(Faction.OfColony).hostile)
                    {
                        pawn2   = pawn_CarryTracker.pawn;
                        faction = pawn2.Faction;
                    }
                    Building_CryptosleepCasket building_CryptosleepCasket = pawn.holder.owner as Building_CryptosleepCasket;
                    if (building_CryptosleepCasket != null)
                    {
                        flag = true;
                        if (!colonist.Cryptosleep)
                        {
                            colonist.Cryptosleep = true;
                            this.Message(pawn, "Colonist has entered cryptosleep.");
                        }
                    }
                    else
                    {
                        colonist.Cryptosleep = false;
                        if (colonist.Cryptosleep)
                        {
                            colonist.Cryptosleep = false;
                            this.Message(pawn, "Colonist has woken from cryptosleep.");
                        }
                    }
                }
            }
            else
            {
                faction = null;
                colonist.Cryptosleep = false;
                if (colonist.Captured)
                {
                    this.Message(pawn, "Captured colonist has been freed.");
                    this.MarkColonistAsFreed(colonist);
                }
                if (colonist.Cryptosleep)
                {
                    colonist.Cryptosleep = false;
                    this.Message(pawn, "Colonist has woken from cryptosleep.");
                }
            }
            if (!colonist.Captured && faction != null)
            {
                this.MarkColonistAsCaptured(colonist, pawn2, faction);
            }
            else if (colonist.Captured && faction == null)
            {
                this.MarkColonistAsFreed(colonist);
            }
            else if (colonist.Captured && faction != colonist.CapturingFaction)
            {
                this.MarkColonistAsCaptured(colonist, pawn2, faction);
            }
            if (flag && !colonist.Cryptosleep)
            {
                this.MarkColonistAsEnteredCryptosleep(colonist);
            }
            else if (!flag && colonist.Cryptosleep)
            {
                this.MarkColonistAsWokenFromCryptosleep(colonist);
            }
            int ticksGame = Find.TickManager.TicksGame;

            if (colonist.Dead && !colonist.Missing)
            {
                if (colonist.Corpse != null)
                {
                    if (colonist.Corpse.Destroyed)
                    {
                        this.MarkColonistAsMissing(colonist);
                    }
                    else if (this.IsBuried(colonist.Corpse))
                    {
                        this.MarkColonistAsBuried(colonist);
                    }
                }
            }
            else if (colonist.Missing)
            {
                int num = ticksGame - colonist.MissingTimestamp;
                if (num > ColonistTracker.MaxMissingDuration)
                {
                    this.MarkColonistAsLost(colonist);
                }
            }
        }