public void RemovePawnsFromOtherColonies(ColonyGroup mainGroup, List <Pawn> pawns) { var colonyKeysToRemove = new List <Map>(); foreach (var group in this.colonyGroups) { if (group.Value != mainGroup) { colonyKeysToRemove.Add(group.Key); } } foreach (var key in colonyKeysToRemove) { if (colonyGroups.TryGetValue(key, out var colonyGroup)) { foreach (var pawn in pawns) { if (colonyGroup.pawns?.Contains(pawn) ?? false) { colonyGroup.Disband(pawn); } } if (colonyGroup.pawns is null || colonyGroup.pawns.Count == 0) { colonyGroups.Remove(key); } } } }
public override void UpdateData() { base.UpdateData(); if (this.prevColonyGroup is null) { var map = this.pawns.FirstOrDefault(x => x.Spawned && x.Map != null)?.Map; if (map != null) { prevColonyGroup = TacticUtils.AllColonyGroups.FirstOrDefault(x => x.Map == map); } } }
public PawnGroup(Pawn pawn) { this.Init(); this.Add(pawn); this.groupID = CreateGroupID(); this.curGroupName = this.defaultGroupName + " " + this.groupID; var map = pawn.Map; if (map != null) { prevColonyGroup = TacticUtils.AllColonyGroups.FirstOrDefault(x => x.Map == map); } }
public Entry(Pawn pawn, Map map, int group, CaravanGroup caravanGroup, ColonyGroup colonyGroup) { this.pawn = pawn; this.map = map; this.group = group; this.caravanGroup = caravanGroup; this.colonyGroup = colonyGroup; reorderAction = delegate(int from, int to) { TacticUtils.TacticalColonistBar.Reorder(from, to, group); }; extraDraggedItemOnGUI = delegate(int index, Vector2 dragStartPos) { TacticUtils.TacticalColonistBar.DrawColonistMouseAttachment(index, dragStartPos, group); }; }
public PawnGroup(List <Pawn> pawns) { this.Init(); foreach (var pawn in pawns) { this.Add(pawn); } this.groupID = CreateGroupID(); this.curGroupName = this.defaultGroupName + " " + this.groupID; var map = this.pawns.FirstOrDefault(x => x.Spawned && x.Map != null)?.Map; if (map != null) { prevColonyGroup = TacticUtils.AllColonyGroups.FirstOrDefault(x => x.Map == map); } }
public ColonyGroup CreateOrJoinColony(List <Pawn> pawns, Map map) { if (this.colonyGroups is null) { this.colonyGroups = new Dictionary <Map, ColonyGroup>(); } if (this.pawnGroups is null) { this.pawnGroups = new List <PawnGroup>(); } if (this.colonyGroups.TryGetValue(map, out ColonyGroup colonyGroup) && colonyGroup != null) { colonyGroup.Add(pawns); } else { var newColony = new ColonyGroup(pawns); this.colonyGroups[map] = newColony; if (!map.IsPlayerHome || map.ParentFaction != Faction.OfPlayer) { newColony.ConvertToTaskForce(); } } RemovePawnsFromOtherColonies(this.colonyGroups[map], pawns); RecheckCaravanGroups(); foreach (var pawnGroup in this.pawnGroups.Where(x => x.Map == map)) { foreach (var pawn in pawns) { if (pawnGroup.formerPawns != null && pawnGroup.formerPawns.Contains(pawn)) { pawnGroup.Add(pawn); } } } this.colonyGroups[map].UpdateData(); TacticUtils.TacticalColonistBar.MarkColonistsDirty(); return(this.colonyGroups[map]); }
public void RemovePawnsFromOtherColonies(ColonyGroup mainGroup, List <Pawn> pawns) { var colonyKeysToRemove = new List <Map>(); foreach (var group in this.colonyGroups) { if (group.Value != mainGroup) { colonyKeysToRemove.Add(group.Key); } } foreach (var key in colonyKeysToRemove) { if (colonyGroups.ContainsKey(key)) { colonyGroups[key].Disband(pawns); if (colonyGroups.ContainsKey(key) && colonyGroups[key].ActivePawns.Count == 0) { colonyGroups.Remove(key); } } } }
public static List <PawnGroup> GetAllSubGroupFor(ColonyGroup colonyGroup) { return(TacticalGroups.pawnGroups.Where(x => x.isSubGroup && (x.pawns.Any(y => y.Map == colonyGroup.Map) || x.prevColonyGroup == colonyGroup)).ToList()); }