public SavedSettlementInfo(SettlementInfo baseInfo, int count, bool discovered, bool strongholdOvertaken)
        {
            ID = baseInfo.ID;
            Type = baseInfo.Type;
            Text = baseInfo.Text;
            TotalCount = baseInfo.TotalCount;
            X = baseInfo.X;
            Y = baseInfo.Y;

            if (!strongholdOvertaken) Faction = FactionType.military;

            Count = count;
            Discovered = discovered;
        }
        public Dictionary <string, SavedSettlementInfo> GetSettlementsInfo()
        {
            Dictionary <string, SavedSettlementInfo> returnValue = new Dictionary <string, SavedSettlementInfo>();

            foreach (SavedObject1 o in _objects)
            {
                if (SettlementInfoLookup.SettlementList.ContainsKey(o.NameHash))
                {
                    SettlementInfo      i  = SettlementInfoLookup.SettlementList[o.NameHash];
                    SavedSettlementInfo i2 = new SavedSettlementInfo(i, o.Count, o.HasBeenDiscovered == 1, o.HasBeenOvertaken == 1);
                    returnValue.Add(i.ID, i2);
                }
            }
            return(returnValue);
        }
Beispiel #3
0
        static SettlementInfoLookup()
        {
            _settlementList        = new Dictionary <uint, SettlementInfo>();
            _itemsToSettlementList = new Dictionary <uint, string>();

            try
            {
                string appdir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                XmlDocument doc = new XmlDocument();
                doc.Load(File.OpenRead(Path.Combine(Path.Combine(appdir, "SettlementsInfo"), "Settlements.xml")));

                XmlNodeList itemNodes = doc.GetElementsByTagName("settlementitems");
                foreach (XmlNode n in itemNodes)
                {
                    string id = n.Attributes["id"].Value;
                    foreach (XmlNode c in n.ChildNodes)
                    {
                        string siid = c.Attributes["iid"].Value;
                        uint   iid  = uint.Parse(siid, System.Globalization.NumberStyles.HexNumber, null);
                        _itemsToSettlementList.Add(iid, id);
                    }
                }

                itemNodes = doc.GetElementsByTagName("settlement");
                foreach (XmlNode n in itemNodes)
                {
                    SettlementInfo i = new SettlementInfo(n);
                    uint           index;
                    if (n.Attributes["index"] == null)
                    {
                        if (n.Attributes["name"] == null)
                        {
                            throw new Exception("need name or index...");
                        }
                        index = NameLookup.GetHash(n.Attributes["name"].Value);
                    }
                    else
                    {
                        index = uint.Parse(n.Attributes["index"].Value);
                    }
                    _settlementList.Add(index, i);
                }
            }
            catch { }
        }
        public SavedSettlementInfo(SettlementInfo baseInfo, int count, bool discovered, bool strongholdOvertaken)
        {
            ID         = baseInfo.ID;
            Type       = baseInfo.Type;
            Text       = baseInfo.Text;
            TotalCount = baseInfo.TotalCount;
            X          = baseInfo.X;
            Y          = baseInfo.Y;

            if (!strongholdOvertaken)
            {
                Faction = FactionType.military;
            }

            Count      = count;
            Discovered = discovered;
        }
        static SettlementInfoLookup()
        {
            _settlementList = new Dictionary<uint, SettlementInfo>();
            _itemsToSettlementList = new Dictionary<uint, string>();

            try
            {
                string appdir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                XmlDocument doc = new XmlDocument();
                doc.Load(File.OpenRead(Path.Combine(Path.Combine(appdir, "SettlementsInfo"), "Settlements.xml")));

                XmlNodeList itemNodes = doc.GetElementsByTagName("settlementitems");
                foreach (XmlNode n in itemNodes)
                {
                    string id = n.Attributes["id"].Value;
                    foreach (XmlNode c in n.ChildNodes)
                    {
                        string siid = c.Attributes["iid"].Value;
                        uint iid = uint.Parse(siid, System.Globalization.NumberStyles.HexNumber, null);
                        _itemsToSettlementList.Add(iid, id);
                    }
                }            
                
                itemNodes = doc.GetElementsByTagName("settlement");
                foreach (XmlNode n in itemNodes)
                {
                    SettlementInfo i = new SettlementInfo(n);
                    uint index;
                    if (n.Attributes["index"] == null)
                    {
                        if (n.Attributes["name"] == null) throw new Exception("need name or index...");
                        index = NameLookup.GetHash(n.Attributes["name"].Value);
                    }
                    else
                    {
                        index = uint.Parse(n.Attributes["index"].Value);
                    }
                    _settlementList.Add(index, i);
                }
            }
            catch { }
        }