예제 #1
0
        public static Faction loadFromSave(XmlReader xmlRdr)
        {
            var _name        = "UNKNOWN";
            var str          = "";
            var flag         = false;
            var _neededValue = 100;
            var num          = 0;

            while (xmlRdr.Name != "Faction" && xmlRdr.Name != "EntropyFaction" && xmlRdr.Name != "HubFaction")
            {
                xmlRdr.Read();
            }
            var name = xmlRdr.Name;

            if (xmlRdr.MoveToAttribute("name"))
            {
                _name = xmlRdr.ReadContentAsString();
            }
            if (xmlRdr.MoveToAttribute("id"))
            {
                str = xmlRdr.ReadContentAsString();
            }
            if (xmlRdr.MoveToAttribute("neededVal"))
            {
                _neededValue = xmlRdr.ReadContentAsInt();
            }
            if (xmlRdr.MoveToAttribute("playerVal"))
            {
                num = xmlRdr.ReadContentAsInt();
            }
            if (xmlRdr.MoveToAttribute("playerHasPassed"))
            {
                flag = xmlRdr.ReadContentAsString().ToLower() == "true";
            }
            Faction faction;

            switch (name)
            {
            case "HubFaction":
                faction = new HubFaction(_name, _neededValue);
                break;

            case "EntropyFaction":
                faction = new EntropyFaction(_name, _neededValue);
                break;

            default:
                faction = new Faction(_name, _neededValue);
                break;
            }
            faction.playerValue          = num;
            faction.idName               = str;
            faction.playerHasPassedValue = flag;
            return(faction);
        }
예제 #2
0
        /* Faction.loadFromSave */
        private static Faction LoadFaction(ElementInfo root)
        {
            Faction result;
            string  factionName = root.Attributes.GetValueOrDefault("name", "UNKNOWN");
            int     neededValue = root.Attributes.GetInt("neededVal", 100);

            switch (root.Name)
            {
            case "HubFaction":
                result = new HubFaction(factionName, neededValue);
                break;

            case "EntropyFaction":
                result = new EntropyFaction(factionName, neededValue);
                break;

            case "CustomFaction":
                CustomFaction faction;
                result = faction = new CustomFaction(factionName, 100);
                foreach (var child in root.Children.Where(e => e.Name == "Action"))
                {
                    var action = new CustomFactionAction
                    {
                        ValueRequiredForTrigger = child.Attributes.GetInt("ValueRequired", 10),
                        FlagsRequiredForTrigger = child.Attributes.GetValueOrDefault("Flags", null)
                    };
                    foreach (var info in child.Children)
                    {
                        action.TriggerActions.Add(ActionsLoader.LoadAction(info));
                    }
                    faction.CustomActions.Add(action);
                }

                break;

            default:
                result = new Faction(factionName, neededValue);
                break;
            }

            result.playerValue          = root.Attributes.GetInt("playerVal", 0);
            result.idName               = root.Attributes.GetValueOrDefault("id", "");
            result.playerHasPassedValue = root.Attributes.GetBool("playerHasPassed");

            return(result);
        }
예제 #3
0
        public static Faction LoadFaction(ElementInfo info)
        {
            Faction ret;

            var name   = info.Attributes.GetString("name", "UNKNOWN");
            var needed = info.Attributes.GetInt("neededVal");

            switch (info.Name)
            {
            case "HubFaction":
                ret = new HubFaction(name, needed);
                break;

            case "EntropyFaction":
                ret = new EntropyFaction(name, needed);
                break;

            case "CustomFaction":
                var actions = new List <CustomFactionAction>();
                foreach (var actionSetInfo in info.Children)
                {
                    actions.Add(new CustomFactionAction()
                    {
                        ValueRequiredForTrigger = actionSetInfo.Attributes.GetInt("ValueRequired"),
                        FlagsRequiredForTrigger = actionSetInfo.Attributes.GetString("Flags", null),
                        TriggerActions          = actionSetInfo.Children.Select(ActionsLoader.ReadAction).ToList()
                    });
                }

                ret = new CustomFaction(name, 100)
                {
                    CustomActions = actions
                };
                break;

            default:
                ret = new Faction(name, needed);
                break;
            }

            ret.playerValue          = info.Attributes.GetInt("playerVal");
            ret.idName               = info.Attributes.GetString("id");
            ret.playerHasPassedValue = info.Attributes.GetBool("playerHasPassed");

            return(ret);
        }
예제 #4
0
        private void CheckForGameStateIssuesAndFix()
        {
            if (Settings.IsInExtensionMode)
            {
                return;
            }
            if (this.os.currentMission == null)
            {
                if (this.os.Flags.HasFlag("bitPathStarted") && !this.os.Flags.HasFlag("Victory"))
                {
                    bool flag = false;
                    foreach (KeyValuePair <string, ActiveMission> listingMission in this.listingMissions)
                    {
                        if (listingMission.Value.reloadGoalsSourceFile.Contains("BitPath/BitAdv_Recovery.xml"))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        this.AddMissionToListings("Content/Missions/BitPath/BitAdv_Recovery.xml", -1);
                    }
                }
                if (DLC1SessionUpgrader.HasDLC1Installed && !this.os.Flags.HasFlag("dlc_complete"))
                {
                    bool flag = false;
                    foreach (KeyValuePair <string, ActiveMission> listingMission in this.listingMissions)
                    {
                        if (listingMission.Value.reloadGoalsSourceFile.Contains("CSEC_DLCConnectorIntro.xml"))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        this.AddMissionToListings("Content/DLC/Missions/BaseGameConnectors/Missions/CSEC_DLCConnectorIntro.xml", -1);
                    }
                }
            }
            if (this.GetNumberOfAvaliableMissions() == 0 && this.os.currentMission == null && !this.os.Flags.HasFlag("bitPathStarted"))
            {
                foreach (KeyValuePair <string, Faction> faction in this.os.allFactions.factions)
                {
                    if (faction.Value.idName == "hub")
                    {
                        HubFaction hubFaction = faction.Value as HubFaction;
                        if (hubFaction != null)
                        {
                            hubFaction.ForceStartBitMissions((object)this.os);
                        }
                    }
                }
            }
            int    num1 = 0;
            int    num2 = 0;
            string str  = (string)null;

            foreach (KeyValuePair <string, ActiveMission> listingMission in this.listingMissions)
            {
                bool flag = true;
                if (listingMission.Value.reloadGoalsSourceFile.Contains("DLC"))
                {
                    flag = false;
                }
                if (listingMission.Value.postingAcceptFlagRequirements != null)
                {
                    for (int index = 0; index < listingMission.Value.postingAcceptFlagRequirements.Length; ++index)
                    {
                        if (!this.os.Flags.HasFlag(listingMission.Value.postingAcceptFlagRequirements[index]))
                        {
                            flag = false;
                            if (str == null)
                            {
                                str = listingMission.Key;
                            }
                        }
                    }
                }
                if (flag)
                {
                    ++num1;
                }
                else
                {
                    ++num2;
                }
            }
            if (num1 <= 0 && num2 > 0 && (this.os.currentMission == null && !this.os.Flags.HasFlag("bitPathStarted")))
            {
                foreach (KeyValuePair <string, Faction> faction in this.os.allFactions.factions)
                {
                    if (faction.Value.idName == "hub")
                    {
                        HubFaction hubFaction = faction.Value as HubFaction;
                        if (hubFaction != null)
                        {
                            hubFaction.ForceStartBitMissions((object)this.os);
                        }
                    }
                }
            }
        }