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);
        }
        private static void SaveCurrentState(List <Pawn> pawns)
        {
            int currentMap = Find.VisibleMap.uniqueID;

            //Save current state
            foreach (Pawn p in pawns)
            {
                //find colonist on the current zone in the current map
                AssignLink link = AssignManager.links.Find(
                    x => x.colonist.Equals(p) &&
                    x.zone == AssignManager.GetActivePolicy().id&&
                    x.mapId == currentMap);

                if (link != null)
                {
                    //colonist found! save
                    link.outfit            = p.outfits.CurrentOutfit;
                    link.drugPolicy        = p.drugs.CurrentPolicy;
                    link.hostilityResponse =
                        p.playerSettings.hostilityResponse;
                    if (Widget_CombatExtended.CombatExtendedAvailable)
                    {
                        link.loadoutId = Widget_CombatExtended.GetLoadoutId(p);
                    }
                }
                else
                {
                    //colonist not found. So add it to the AssignLink list
                    int loadoutId = 0;
                    if (Widget_CombatExtended.CombatExtendedAvailable)
                    {
                        loadoutId = Widget_CombatExtended.GetLoadoutId(p);
                    }

                    Outfit outfit = p.outfits.CurrentOutfit;
                    if (p.outfits.CurrentOutfit ==
                        Current.Game.outfitDatabase.AllOutfits[0])
                    {
                        outfit = AssignManager.DefaultOutfit;
                    }

                    AssignManager.links.Add(
                        new AssignLink(
                            AssignManager.GetActivePolicy().id,
                            p,
                            outfit,
                            p.drugs.CurrentPolicy,
                            p.playerSettings.hostilityResponse,
                            loadoutId,
                            currentMap));
                }
            }
        }
Exemplo n.º 3
0
        internal static void SaveCurrentState(List <Pawn> pawns)
        {
            int currentMap = Find.CurrentMap.uniqueID;

            //Save current state
            foreach (Pawn p in pawns)
            {
                //find colonist on the current zone in the current map
                AssignLink link = AssignManager.links.Find(
                    x => p.Equals(x.colonist) &&
                    x.zone == AssignManager.GetActivePolicy().id&&
                    x.mapId == currentMap);

                if (link != null)
                {
                    //colonist found! save
                    link.outfit            = p.outfits.CurrentOutfit;
                    link.drugPolicy        = p.drugs.CurrentPolicy;
                    link.hostilityResponse =
                        p.playerSettings.hostilityResponse;
                    link.foodPolicy = p.foodRestriction.CurrentFoodRestriction;
                    if (Widget_CombatExtended.CombatExtendedAvailable)
                    {
                        link.loadoutId = Widget_CombatExtended.GetLoadoutId(p);
                    }
                }
                else
                {
                    //colonist not found. So add it to the AssignLink list
                    int loadoutId = 0;
                    if (Widget_CombatExtended.CombatExtendedAvailable)
                    {
                        loadoutId = Widget_CombatExtended.GetLoadoutId(p);
                    }

                    Outfit outfit = p.outfits.CurrentOutfit;
                    if (outfit ==
                        Current.Game.outfitDatabase.DefaultOutfit())
                    {
                        outfit = AssignManager.DefaultOutfit;
                    }

                    DrugPolicy drug = p.drugs.CurrentPolicy;
                    if (drug ==
                        Current.Game.drugPolicyDatabase.DefaultDrugPolicy())
                    {
                        drug = AssignManager.DefaultDrugPolicy;
                    }

                    FoodRestriction food = p.foodRestriction.CurrentFoodRestriction;
                    if (food ==
                        Current.Game.foodRestrictionDatabase.DefaultFoodRestriction())
                    {
                        food = AssignManager.DefaultFoodPolicy;
                    }

                    AssignManager.links.Add(
                        new AssignLink(
                            AssignManager.GetActivePolicy().id,
                            p,
                            outfit,
                            food,
                            drug,
                            p.playerSettings.hostilityResponse,
                            loadoutId,
                            currentMap));
                }
            }
        }