コード例 #1
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadSystem(Section sec)
        {
            var sysNick = sec.GetFirstOf("nickname")[0].ToLowerInvariant();
            _log.NewMessage(LogType.Garbage, "Universe: Parsing system {0}", sysNick);

            var stIDSName = GetIDSParm(sec.GetAnySetting("strid_name")[0]);

            var stIDSInfo1 = "";
            if (sec.ContainsAnyOf("ids_info1","ids_short_name"))
                stIDSInfo1 = GetIDSParm(sec.GetAnySetting("ids_info")[0]);

            Gis.Systems.AddSystemsRow(sysNick, stIDSName,stIDSInfo1);

            //string file = Directory.GetParent(ini.filePath).FullName + "\\" + section.GetSetting("file").Str(0);
            //TODO: Warning, hardcoded system path! :S
            var sysFile = new DataFile(_flDataPath + @"\Universe\" + sec.GetFirstOf("file")[0]);

            foreach (var obj in sysFile.GetSections("Object"))
            {
                Setting curset;
                //string pos;
                var idsInfo = "";
                var idsInfo1 = "";

                //TODO: do we need pos?
                //if (obj.TryGetFirstOf("pos", out curset))
                //    pos = string.Join(", ", curset);

                //get infocard for the object
                if (obj.TryGetFirstOf("ids_info", out curset))
                {
                    uint id;
                    if (!uint.TryParse(curset[0], out id))
                    {
                        _log.NewMessage(LogType.Warning, "Can't find ID for object: {0}", curset[0]);
                    }

                    idsInfo = GetIDString(id);
                    if (InfocardMap.ContainsKey(id))
                        idsInfo1 = GetIDString(InfocardMap[id]);
                }

                //add the icard to the base if object is base
                if (obj.TryGetFirstOf("base", out curset))
                    //TODO: really join the stuff, infos are in XML format.
                    Gis.Bases.FindByNickname(curset[0]).Infocard = idsInfo + idsInfo1;

            }

            //TODO: zones needed?
        }
コード例 #2
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadShip(Section sec)
        {
            var nickname = sec.GetFirstOf("nickname")[0];
            _log.NewMessage(LogType.Garbage, "Universe: Parsing ship {0}", nickname);
            var hash = CreateID(nickname.ToLowerInvariant());

            // fail if equip already presents
            if (Gis.Ships.FindByHash(hash) != null) return;

            uint holdSize = 0;

            if (sec.ContainsAnyOf("hold_size"))
                holdSize = uint.Parse(sec.GetFirstOf("hold_size")[0]);

            var shipReadableName = "";
            if (sec.ContainsAnyOf("ids_name", "strid_name"))
                shipReadableName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]);

            var infocard = "";
            if (sec.ContainsAnyOf("ids_info"))
                infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]);

            Gis.Ships.AddShipsRow(hash, nickname,shipReadableName, infocard,holdSize);

            foreach (var set in sec.GetSettings("da_archetype"))
            {
                var utf = new UtfFile(_flDataPath + Path.DirectorySeparatorChar + set[0]);
                foreach (var hp in utf.Hardpoints.Where(hp => hp.ToLowerInvariant().Contains("cloak")))
                {
                    var ghr = Gis.Ships.FindByHash(hash).GetHardpointsRows();

                    if (ghr.Any(hpS => hpS.Name == hp)) continue;
                    //TODO cloak names
                    Gis.Hardpoints.AddHardpointsRow(Gis.Ships.FindByHash(hash), hp, EquipTypes.Cloak.ToString(),"cloak");
                }
            }

            foreach (var hpSet in sec.GetSettings("hp_type"))
            {
                var type = HpMap[hpSet[0]];

                foreach (var hp in hpSet.Skip(1))
                {
                    var hp1 = hp;
                    var q = 0;
                    var ghr = Gis.Ships.FindByHash(hash).GetHardpointsRows().FirstOrDefault(hpS => hpS.Name == hp1);
                    if (nickname == "dsy_no_elite")
                        q++;
                    if (ghr != null)
                    {
                        ghr.HPType += String.Format(" {0}", hpSet[0]);
                        continue;
                    }
                    Gis.Hardpoints.AddHardpointsRow(Gis.Ships.FindByHash(hash), hp, type.ToString(),hpSet[0]);
                }
            }
        }
コード例 #3
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadLoadout(Section sec, DataFile file)
        {
            //if (sec.GetFirstOf("category")[0] != "ship") return;
            //done in LINQ
            var hullNickName = sec.GetFirstOf("hull")[0];

            //TODO: foreach or FirstOrDefault?
            var shSection = file.GetSections("Good").FirstOrDefault(w =>
                (w.GetFirstOf("category")[0] == "shiphull") &
                (w.GetFirstOf("nickname")[0] == hullNickName)
                );

            if (shSection == null)
            {
                _log.NewMessage(LogType.Warning, "Can't find package for shiphull {0}!", hullNickName);
                return;
            }

                var shipNickname = shSection.GetFirstOf("ship")[0];
                var shiphash = CreateID(shipNickname);

                uint defaultSound = 0;
                uint defaultPowerPlant = 0;
                uint defaultEngine = 0;

                foreach (var set in sec.GetSettings("addon"))
                {
                    if (set.Count != 3)
                    {
                        _log.NewMessage(LogType.Warning,
                            "Package for ship {0}: addon {1} has wrong arg count", shipNickname, set[0]);
                        continue;
                    }

                    var equipNick = set[0];
                    var item = Gis.Equipment.FindByHash(CreateID(equipNick));
                    if (item == null)
                    {
                        _log.NewMessage(LogType.Warning, @"Can't find {0} in DB: from loadout {1} \ {2}", equipNick,
                            hullNickName, shipNickname);
                        continue;
                    }

                    EquipTypes eqType;
                    Enum.TryParse(item.Type, out eqType);

                    switch (eqType)
                    {
                        case EquipTypes.Engine:
                            defaultEngine = item.Hash;
                            break;
                        case EquipTypes.Powerplant:
                            defaultPowerPlant = item.Hash;
                            break;
                        case EquipTypes.InternalFX:
                            defaultSound = item.Hash;
                            break;
                            case EquipTypes.Light:
                            if (set[1] == "internal")
                                _log.NewMessage(LogType.Warning, "Invalid hardpoint for light {0} (internal): {1}", equipNick, hullNickName);
                            break;
                        case EquipTypes.AttachedFX:
                             if (set[1] == "internal")
                                 _log.NewMessage(LogType.Warning, "Invalid hardpoint for attachedFX {0} (internal): {1}", equipNick, hullNickName);
                            break;
                    }

                }
                Gis.ShipDefaultInternals.AddShipDefaultInternalsRow(Gis.Ships.FindByHash(shiphash), defaultEngine,
                    defaultSound, defaultPowerPlant);
        }
コード例 #4
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadFaction(Section sec)
        {
            var nickname = sec.GetFirstOf("nickname")[0];
            _log.NewMessage(LogType.Garbage, "Universe: Parsing faction {0}", nickname);
            var hash = CreateFactionID(nickname);

            if (Gis.Factions.FindByHash(hash) != null) return;

            var factionName = "";
            if (sec.ContainsAnyOf("ids_name", "strid_name"))
                factionName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]);

            // TODO: ignore empty IDS based on setting
            if (factionName == "") return;

            var shortName = "";
            if (sec.ContainsAnyOf("ids_info1", "ids_short_name"))
                shortName = GetIDSParm(sec.GetAnySetting("ids_info1", "ids_short_name")[0]);

            var infocard = "";
            if (sec.ContainsAnyOf("ids_info"))
                infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]);

            Gis.Factions.AddFactionsRow(hash, nickname, factionName, shortName, infocard);
        }
コード例 #5
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadEquip(Section sec, EquipTypes equipType)
        {
            var nickname = sec.GetFirstOf("nickname")[0];
            _log.NewMessage(LogType.Garbage, "Universe: Parsing equipment {0}", nickname);
            var hash = CreateID(nickname.ToLowerInvariant());

            // fail if equip already presents
            if (Gis.Equipment.FindByHash(hash) != null) return;

            var stIDSName = "";
            if (sec.ContainsAnyOf("ids_name", "strid_name"))
                stIDSName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]);

            // TODO: ignore empty IDS based on setting
            //if (stIDSName == "") return;

            var infocard = "";
            if (sec.ContainsAnyOf("ids_info"))
                infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]);

            float volume = 0;
            if (sec.ContainsAnyOf("volume"))
                volume = float.Parse(sec.GetFirstOf("volume")[0], Nfi);

            // Tested on Disco 4.87.6, no hits beyond this line.
            //var stIDSInfo1 = "";
            //if (sec.ContainsAnyOf("ids_info1","ids_short_name"))
            //    stIDSInfo1 = GetIDSParm(sec.GetAnySetting("ids_info1", "ids_short_name")[0]);

            // Careful with this one below!
            //if (stIDSInfo1 == "") return;
            //var stIDSInfo2 = "";
            //if (sec.ContainsAnyOf("ids_info2"))
            //    stIDSInfo2 = GetIDSParm(sec.GetFirstOf("ids_info2")[0]);

            //var stIDSInfo3 = "";
            //if (sec.ContainsAnyOf("ids_info3"))
            //    stIDSInfo3 = GetIDSParm(sec.GetFirstOf("ids_info3")[0]);

            //string keys = hash.ToString() + " 0x" + hash.ToString("X");

            var hpType = "";
            switch (equipType)
            {
                case EquipTypes.Engine:
                    if (sec.ContainsAnyOf("hp_type"))
                        hpType = sec.GetFirstOf("hp_type")[0];
                    break;
                case EquipTypes.Gun:
                    hpType = sec.GetFirstOf("hp_gun_type")[0];
                    equipType = HpMap[hpType];
                    break;
               case EquipTypes.ShieldGen:
                    hpType = sec.GetFirstOf("hp_type")[0];
                    equipType = HpMap[hpType];
                    break;
               case EquipTypes.CountermeasureDropper:
                    hpType = "hp_countermeasure_dropper";
                    break;
               case EquipTypes.Thruster:
                    hpType = "hp_thruster";
                    break;
                    case EquipTypes.Cargo:
                    break;
                default:
                    break;
            }
            // ReSharper disable RedundantArgumentName
            Gis.Equipment.AddEquipmentRow(
                Hash: hash,
                Type: equipType.ToString(),
                Hardpoint: hpType,
                Nickname: nickname,
                Name: stIDSName,
                Infocard: infocard,
                Volume: volume);
            // ReSharper restore RedundantArgumentName
        }
コード例 #6
0
ファイル: Universe.cs プロジェクト: utrack/FLSAM
        private static void LoadBase(Section sec)
        {
            var nickname = sec.GetFirstOf("nickname")[0];
            //var file = _flDataPath + sec.GetFirstOf("file");
            _log.NewMessage(LogType.Garbage, "Universe: Parsing base {0}", nickname);
            var stIDSName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]);
            var system = sec.GetFirstOf("system")[0];
            Gis.Bases.AddBasesRow(nickname, stIDSName,system,"");

            //TODO: do we rly need room data?
            //FLGameData:Ln 191
        }