public void UpdateGroups(List <ColonistBarGroup> groups, ColonistBarGroup selected)
 {
     this.Message(string.Concat(new object[]
     {
         "UpdateGroups(",
         groups.Count,
         ", ",
         (selected != null) ? selected.Name : "null",
         ")"
     }));
     foreach (ColonistBarGroup current in groups)
     {
         this.Message("group = " + ((current != null) ? current.Name : "null"));
     }
     this.Message("Already selected: " + ((this.currentGroup != null) ? this.currentGroup.Name : "null"));
     if (selected == null && groups.Count > 0)
     {
         selected = this.FindNextGroup(-1);
         this.Message("Previous group: " + ((selected != null) ? selected.Name : "null"));
     }
     this.groups.Clear();
     this.groups.AddRange(groups);
     if (selected == null && groups.Count > 0)
     {
         selected = groups[0];
     }
     this.CurrentGroup = selected;
 }
Esempio n. 2
0
 public void UpdateColonistBarGroups()
 {
     if (!this.enabled)
     {
         return;
     }
     if (this.colonistBarGroups.Count == 0)
     {
         this.colonistBar.UpdateGroups(this.colonistBarGroups, null);
         return;
     }
     if (this.selectedSquad != null)
     {
         ColonistBarGroup selected = null;
         if (this.groupDictionary.TryGetValue(this.selectedSquad, out selected))
         {
             this.colonistBar.UpdateGroups(this.colonistBarGroups, selected);
             return;
         }
     }
     if (SquadManager.Instance.AllColonistsSquad.ShowInColonistBar)
     {
         this.colonistBar.UpdateGroups(this.colonistBarGroups, this.allColonistsGroup);
     }
     else
     {
         this.colonistBar.UpdateGroups(this.colonistBarGroups, null);
     }
 }
Esempio n. 3
0
        public void SelectFavorite(int index)
        {
            Squad favorite = SquadManager.Instance.GetFavorite(index);

            if (favorite != null && favorite.ShowInColonistBar)
            {
                ColonistBarGroup colonistBarGroup = this.groupDictionary[favorite];
                if (colonistBarGroup != null)
                {
                    this.colonistBar.CurrentGroup = colonistBarGroup;
                }
            }
        }
Esempio n. 4
0
 public void SelectedGroupChanged(ColonistBarGroup group)
 {
     if (!this.enabled)
     {
         return;
     }
     if (group != null)
     {
         Squad allColonistsSquad = SquadManager.Instance.AllColonistsSquad;
         this.squadDictionary.TryGetValue(group, out allColonistsSquad);
         this.SelectedSquad = allColonistsSquad;
     }
     else
     {
         this.SelectedSquad = null;
     }
 }
 public void AddGroup(ColonistBarGroup group)
 {
     this.groups.Add(group);
 }
Esempio n. 6
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;
        }