Пример #1
0
        internal static void UpdateState(
            List <AssignLink> links, List <Pawn> pawns, Policy policy)
        {
            List <AssignLink> mapLinks  = null;
            List <AssignLink> zoneLinks = null;
            int currentMap = Find.CurrentMap.uniqueID;

            //get all links from the current map
            mapLinks = links.FindAll(x => x.mapId == currentMap);
            //get all links from the selected zone
            zoneLinks = mapLinks.FindAll(x => x.zone == policy.id);

            foreach (Pawn p in pawns)
            {
                foreach (AssignLink l in zoneLinks)
                {
                    if (l.colonist != null && l.colonist.Equals(p))
                    {
                        l.hostilityResponse =
                            p.playerSettings.hostilityResponse;
                        l.foodPolicy = p.foodRestriction.CurrentFoodRestriction;
                    }
                }
            }

            AssignManager.SetActivePolicy(policy);
        }
        private static void LoadState(
            List <AssignLink> links, List <Pawn> pawns, Policy policy)
        {
            List <AssignLink> mapLinks  = null;
            List <AssignLink> zoneLinks = null;
            int currentMap = Find.VisibleMap.uniqueID;

            //get all links from the current map
            mapLinks = links.FindAll(x => x.mapId == currentMap);
            //get all links from the selected zone
            zoneLinks = mapLinks.FindAll(x => x.zone == policy.id);

            foreach (Pawn p in pawns)
            {
                foreach (AssignLink l in zoneLinks)
                {
                    if (l.colonist != null && l.colonist.Equals(p))
                    {
                        p.outfits.CurrentOutfit = OutfitExits(l.outfit) ?
                                                  l.outfit : null;
                        p.drugs.CurrentPolicy = DrugPolicyExits(l.drugPolicy) ?
                                                l.drugPolicy : null;
                        p.playerSettings.hostilityResponse =
                            l.hostilityResponse;
                        if (Widget_CombatExtended.CombatExtendedAvailable)
                        {
                            Widget_CombatExtended.SetLoadoutById(
                                p, l.loadoutId);
                        }
                    }
                }
            }

            AssignManager.SetActivePolicy(policy);
        }