public void Update()
 {
     if (this.pawn == null)
     {
         return;
     }
     this.incapacitated = false;
     if (this.pawn.health != null)
     {
         this.health        = this.pawn.health.summaryHealth.SummaryHealthPercent;
         this.incapacitated = this.pawn.health.Downed;
     }
     else
     {
         this.health = 0f;
     }
     this.kidnapped = false;
     if (this.pawn.holder != null)
     {
         if (this.pawn.Destroyed)
         {
             this.missing = true;
         }
         else if (this.pawn.holder.owner != null)
         {
             Pawn_CarryTracker pawn_CarryTracker = this.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)
             {
                 this.kidnapped = true;
             }
         }
     }
     this.dead = this.pawn.Dead;
     if (this.dead && this.WasReplaced(this.pawn))
     {
         this.dead = false;
     }
     this.sanity = null;
     if (this.pawn.mindState != null && this.pawn.mindState.broken != null)
     {
         this.sanity = this.pawn.mindState.broken.CurStateDef;
     }
     this.drafted         = (!this.dead && this.pawn.Drafted);
     this.psychologyLevel = 0;
     if (this.pawn.mindState != null && this.pawn.mindState.breaker != null && !this.pawn.Downed && !this.pawn.Dead)
     {
         if (this.pawn.mindState.breaker.HardBreakImminent)
         {
             this.psychologyLevel = 2;
         }
         else if (this.pawn.mindState.breaker.MentalBreakApproaching)
         {
             this.psychologyLevel = 1;
         }
     }
 }
        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);
                }
            }
        }