Exemple #1
0
        public AsteroidField(StarSystem parent, Section section, FreelancerData data)
            : base(parent, section, data)
        {
            Cube             = new List <CubeAsteroid>();
            DynamicAsteroids = new List <DynamicAsteroids>();
            LootableZones    = new List <LootableZone>();

            foreach (Section s in ParseFile(data.Freelancer.DataPath + file, data.VFS))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "texturepanels":
                    TexturePanels = new TexturePanelsRef(s, data);
                    break;

                case "properties":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "flag":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            Properties.Add(e[0].ToString());
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "exclusion zones":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "exclusion":
                        case "exclude":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            ExclusionZones.Add(new ExclusionZone(parent, e[0].ToString()));
                            break;

                        case "fog_far":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].FogFar = e[0].ToSingle();
                            break;

                        case "zone_shell":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            break;

                        case "shell_scalar":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ShellScalar = e[0].ToSingle();
                            break;

                        case "max_alpha":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].MaxAlpha = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Color = new Color4(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, 1f);
                            break;

                        case "exclusion_tint":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Tint = new Color3f(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f);
                            break;

                        case "exclude_billboards":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ExcludeBillboards = e[0].ToInt32();
                            break;

                        case "exclude_dynamic_asteroids":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ExcludeDynamicAsteroids = e[0].ToInt32();
                            break;

                        case "empty_cube_frequency":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].EmptyCubeFrequency = e[0].ToSingle();
                            break;

                        case "billboard_count":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].BillboardCount = e[0].ToInt32();
                            break;

                        default:
                            FLLog.Warning("Ini", "Invalid Entry in " + s.Name + ": " + e.Name);
                            break;
                        }
                    }
                    break;

                case "field":
                    Field = new Field(s);
                    break;

                case "cube":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "xaxis_rotation":
                            Cube_RotationX = new Vector4(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle(), e[3].ToSingle());
                            break;

                        case "yaxis_rotation":
                            Cube_RotationY = new Vector4(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle(), e[3].ToSingle());
                            break;

                        case "zaxis_rotation":
                            Cube_RotationZ = new Vector4(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle(), e[3].ToSingle());
                            break;

                        case "asteroid":
                            //if (e.Count < 7 || e.Count > 8) throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            Cube.Add(new CubeAsteroid(e));
                            break;
                        }
                    }
                    break;

                case "band":
                    Band = new Band(parent, s);
                    break;

                case "exclusionband":
                    ExclusionBand = new Band(parent, s);
                    break;

                case "asteroidbillboards":
                    AsteroidBillboards = new AsteroidBillboards(s);
                    break;

                case "dynamicasteroids":
                    DynamicAsteroids.Add(new DynamicAsteroids(s));
                    break;

                case "lootablezone":
                    LootableZones.Add(new LootableZone(s));
                    break;

                default:
                    throw new Exception("Invalid Section in " + file + ": " + s.Name);
                }
            }
        }
Exemple #2
0
 public void AddEquipmentIni(string path, FreelancerData data)
 {
     ParseAndFill(path, data.VFS);
 }
Exemple #3
0
        public Base(Section section, FreelancerData data) : base(data)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            string file = null;

            foreach (Entry e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Nickname != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Nickname = e[0].ToString();
                    break;

                case "system":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (System != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    System = e[0].ToString();
                    break;

                case "strid_name":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (IdsName != 0)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    IdsName = e[0].ToInt32();
                    break;

                case "file":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (file != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    file = e[0].ToString();
                    break;

                case "bgcs_base_run_by":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (BGCSBaseRunBy != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    BGCSBaseRunBy = e[0].ToString();
                    break;

                case "terrain_tiny":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainTiny != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainTiny = e[0].ToString();
                    break;

                case "terrain_sml":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainSml != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainSml = e[0].ToString();
                    break;

                case "terrain_mdm":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainMdm != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainMdm = e[0].ToString();
                    break;

                case "terrain_lrg":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainLrg != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainLrg = e[0].ToString();
                    break;

                case "terrain_dyna_01":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainDyna1 != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainDyna1 = e[0].ToString();
                    break;

                case "terrain_dyna_02":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (TerrainDyna2 != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    TerrainDyna2 = e[0].ToString();
                    break;

                case "autosave_forbidden":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (AutosaveForbidden != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    AutosaveForbidden = e[0].ToBoolean();
                    break;

                default:
                    throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                }
            }

            Rooms = new List <Room>();

            if (VFS.FileExists(data.Freelancer.DataPath + file))
            {
                foreach (Section s in ParseFile(data.Freelancer.DataPath + file))
                {
                    switch (s.Name.ToLowerInvariant())
                    {
                    case "baseinfo":
                        foreach (Entry e in s)
                        {
                            switch (e.Name.ToLowerInvariant())
                            {
                            case "nickname":
                                if (e.Count != 1)
                                {
                                    throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                                }
                                if (Name != null)
                                {
                                    FLLog.Warning("Base", "Duplicate " + e.Name + " Entry in " + s.Name);
                                }
                                Name = e[0].ToString();
                                break;

                            case "start_room":
                                if (e.Count != 1)
                                {
                                    throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                                }
                                if (StartRoom != null)
                                {
                                    FLLog.Warning("Base", "Duplicate " + e.Name + " Entry in " + s.Name);
                                }
                                StartRoom = e[0].ToString();
                                break;

                            case "price_variance":
                                FLLog.Error("Base", "Unimplemented: price_variance");
                                break;

                            default:
                                throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                            }
                        }
                        break;

                    case "room":
                        Rooms.Add(new Room(s, data));
                        break;

                    default:
                        throw new Exception("Invalid Section in " + file + ": " + s.Name);
                    }
                }
            }
            else
            {
                FLLog.Error("Ini", "Base ini could not find file " + file);
            }
        }
        public Light(Section section, FreelancerData gdata)
        {
            foreach (Entry e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    Nickname = e[0].ToString();
                    break;

                case "inherit":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Inherit != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Inherit = gdata.Equipment.FindEquipment(e[0].ToString()) as Light;
                    break;

                case "always_on":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (alwaysOn != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    alwaysOn = e[0].ToBoolean();
                    break;

                case "docking_light":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (dockingLight != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    dockingLight = e[0].ToBoolean();
                    break;

                case "bulb_size":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (bulbSize != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    bulbSize = e[0].ToSingle();
                    break;

                case "glow_size":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (glowSize != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    glowSize = e[0].ToSingle();
                    break;

                case "glow_color":
                    if (e.Count != 3)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (glowColor != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    glowColor = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                    break;

                case "color":
                    if (e.Count != 3)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (color != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    color = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                    break;

                case "flare_cone":
                    if (e.Count != 2)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (flareCone != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    flareCone = new Vector2(e[0].ToInt32(), e[1].ToInt32());
                    break;

                case "intensity":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (intensity != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    intensity = e[0].ToInt32();
                    break;

                case "lightsource_cone":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (lightsourceCone != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    lightsourceCone = e[0].ToInt32();
                    break;

                case "min_color":
                    if (e.Count != 3)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (minColor != null)
                    {
                        FLLog.Warning("Light", "Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    minColor = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                    break;

                case "avg_delay":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (avgDelay != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    avgDelay = e[0].ToSingle();
                    break;

                case "blink_duration":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (blinkDuration != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    blinkDuration = e[0].ToSingle();
                    break;

                case "emit_range":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (emitRange != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    emitRange = e[0].ToSingle();
                    break;

                case "emit_attenuation":
                    if (e.Count != 3)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (emitAttenuation != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    emitAttenuation = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "shape":
                    FLLog.Error("Light", "custom shape not implemented");
                    break;

                default: FLLog.Error("Equipment", "Invalid Entry in " + section.Name + ": " + e.Name); break;
                }
            }
        }
 public HomePageController()
 {
     _homePageServices = new HomePageServices();
     _homePageData     = new HomePageData();
     _freeLancerData   = new FreelancerData();
 }
Exemple #6
0
 public void AddLoadoutsIni(string path, FreelancerData gdata)
 {
     ParseAndFill(path, gdata.VFS);
 }
Exemple #7
0
        public Nebula(StarSystem parent, Section section, FreelancerData data)
            : base(parent, section, data)
        {
            ExteriorShape = new List <string>();
            NebulaLights  = new List <NebulaLight>();


            foreach (Section s in ParseFile(data.Freelancer.DataPath + file, data.VFS))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "texturepanels":
                    TexturePanels = new TexturePanelsRef(s, data);
                    break;

                case "properties":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "flag":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            Properties.Add(e[0].ToString());
                            break;

                        default:
                            FLLog.Warning("Ini", "Invalid Entry in " + s.Name + ": " + e.Name);
                            break;
                        }
                    }
                    break;

                case "fog":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "fog_enabled":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogEnabled != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogEnabled = e[0].ToInt32();
                            break;

                        case "near":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogNear != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogNear = e[0].ToInt32();
                            break;

                        case "distance":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogDistance = e[0].ToInt32();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (FogColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            FogColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "opacity":
                            FLLog.Warning("Nebula", "unimplemented fog opacity");
                            break;

                        case "max_alpha":
                            FLLog.Warning("Nebula", "unimplemented max alpha");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "exclusion zones":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "exclusion":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            ExclusionZones.Add(new ExclusionZone(parent, e[0].ToString()));
                            break;

                        case "fog_far":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].FogFar = e[0].ToSingle();
                            break;

                        case "fog_near":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].FogNear = e[0].ToSingle();
                            break;

                        case "zone_shell":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ZoneShellPath = e[0].ToString();
                            break;

                        case "shell_scalar":
                            //if (e.Count != 1) throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].ShellScalar = e[0].ToSingle();
                            break;

                        case "max_alpha":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].MaxAlpha = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Color = new Color4(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, 1f);
                            break;

                        case "exclusion_tint":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExclusionZones.Count == 0)
                            {
                                throw new Exception(e.Name + " before exclusion");
                            }
                            ExclusionZones[ExclusionZones.Count - 1].Tint = new Color3f(e[0].ToInt32() / 255f, e[0].ToInt32() / 255f, e[0].ToInt32() / 255f);
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "exterior":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "shape":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            ExteriorShape.Add(e[0].ToString());
                            break;

                        case "shape_weights":
                            //if (e.Count != 4) throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            if (ExteriorShapeWeights != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorShapeWeights = new List <int>();
                            foreach (IValue i in e)
                            {
                                ExteriorShapeWeights.Add(i.ToInt32());
                            }
                            break;

                        case "fill_shape":
                            if (e.Count == 0)
                            {
                                FLLog.Warning("Nebula", "empty fill_shape in " + file);
                                break;
                            }
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorFillShape != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorFillShape = e[0].ToString();
                            break;

                        case "plane_slices":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorPlaneSlices != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorPlaneSlices = e[0].ToInt32();
                            break;

                        case "bit_radius":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorBitRadius != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorBitRadius = e[0].ToInt32();
                            break;

                        case "bit_radius_random_variation":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorBitRadiusRandomVariation != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorBitRadiusRandomVariation = e[0].ToSingle();
                            break;

                        case "min_bits":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMinBits != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMinBits = e[0].ToInt32();
                            break;

                        case "max_bits":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMaxBits != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMaxBits = e[0].ToInt32();
                            break;

                        case "move_bit_percent":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorMoveBitPercent != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorMoveBitPercent = e[0].ToSingle();
                            break;

                        case "equator_bias":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorEquatorBias != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorEquatorBias = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ExteriorColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            ExteriorColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "opacity":
                            FLLog.Warning("Nebula", "Exterior opacity not implemented");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "nebulalight":
                    NebulaLights.Add(new NebulaLight(s));
                    break;

                case "clouds":
                    if (CloudsMaxDistance != null)
                    {
                        FLLog.Warning("Ini", "Multiple [Clouds] in Nebula " + ZoneName);
                        break;
                    }
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "max_distance":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsMaxDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsMaxDistance = e[0].ToInt32();
                            break;

                        case "puff_count":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffCount != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffCount = e[0].ToInt32();
                            break;

                        case "puff_radius":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffRadius != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffRadius = e[0].ToInt32();
                            break;

                        case "puff_cloud_size":
                            FLLog.Warning("Nebula", "puff_cloud_size unimplemented");
                            break;

                        case "puff_colora":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffColorA != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffColorA = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                            break;

                        case "puff_colorb":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffColorB != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffColorB = new Color3f(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f);
                            break;

                        case "puff_max_alpha":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffMaxAlpha != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffMaxAlpha = e[0].ToSingle();
                            break;

                        case "puff_shape":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffShape == null)
                            {
                                CloudsPuffShape = new List <string>();
                            }
                            CloudsPuffShape.Add(e[0].ToString());
                            break;

                        case "puff_weights":
                            if (e.Count != 4)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffWeights != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffWeights = new List <int>();
                            foreach (IValue i in e)
                            {
                                CloudsPuffWeights.Add(i.ToInt32());
                            }
                            break;

                        case "puff_drift":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsPuffDrift != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsPuffDrift = e[0].ToSingle();
                            break;

                        case "near_fade_distance":
                            if (e.Count != 2)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsNearFadeDistance != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsNearFadeDistance = new Vector2(e[0].ToSingle(), e[1].ToSingle());
                            break;

                        case "lightning_intensity":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningIntensity != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningIntensity = e[0].ToSingle();
                            break;

                        case "lightning_color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "lightning_gap":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningGap = e[0].ToSingle();
                            break;

                        case "lightning_duration":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (CloudsLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            CloudsLightningDuration = e[0].ToSingle();
                            break;

                        case "disable_clouds":
                            FLLog.Warning("Nebula", "disable_clouds not implemented");
                            break;

                        case "zwrite_clouds":
                            FLLog.Warning("Nebula", "disable_clouds not implemented");
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "backgroundlightning":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "duration":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningDuration = e[0].ToSingle();
                            break;

                        case "gap":
                            if (e.Count != 1)
                            {
                                FLLog.Warning("Ini", "Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningGap = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundLightningColor = BackgroundLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "dynamiclightning":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "gap":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningGap != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningGap = e[0].ToSingle();
                            break;

                        case "duration":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningDuration != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningDuration = e[0].ToSingle();
                            break;

                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "ambient_intensity":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningAmbientIntensity != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningAmbientIntensity = e[0].ToSingle();
                            break;

                        case "intensity_increase":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DynamicLightningIntensityIncrease != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DynamicLightningIntensityIncrease = e[0].ToInt32();
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                default:
                    throw new Exception("Invalid Section in " + file + ": " + s.Name);
                }
            }
        }
Exemple #8
0
        }                                                       // = 642, 0, 198

        public LightSource(Vector3 pos, Color4 color, int range, FreelancerData data)
            : base(pos, data)
        {
            Color = color;
            Range = range;
        }
Exemple #9
0
        public LightSource(Section section, FreelancerData data)
            : base(section, data)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            foreach (Entry e in section)
            {
                if (!parentEntry(e))
                {
                    switch (e.Name.ToLowerInvariant())
                    {
                    case "ids_name":                     // ignore
                        break;

                    case "color":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Color != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Color = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                        break;

                    case "range":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Range != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Range = e[0].ToInt32();
                        break;

                    case "type":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Type != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        switch (e[0].ToString().ToUpperInvariant())
                        {
                        case "DIRECTIONAL": Type = LightType.Directional; break;

                        case "POINT": Type = LightType.Point; break;

                        default: throw new Exception("Invalid Value in " + e.Name + ": " + e[0].ToString());
                        }
                        break;

                    case "atten_curve":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (AttenCurve != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        AttenCurve = e[0].ToString();
                        break;

                    case "attenuation":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Attenuation != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Attenuation = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                        break;

                    case "direction":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Direction != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Direction = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                        break;

                    case "behavior":                     // ignore
                        break;

                    case "color_curve":                     // string, float
                        break;

                    default:
                        throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                    }
                }
            }
        }
Exemple #10
0
        public Room(Section section, FreelancerData data)
        {
            GameData = data;
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            string file = null;

            SceneScripts          = new List <string>();
            Hotspots              = new List <RoomHotspot>();
            ForShipSalePlacements = new List <string>();
            foreach (Entry e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Nickname != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Nickname = e[0].ToString();
                    break;

                case "file":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (file != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    file = e[0].ToString();
                    break;

                default: throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                }
            }
            if (data.VFS.FileExists(data.Freelancer.DataPath + file))
            {
                foreach (Section s in ParseFile(data.Freelancer.DataPath + file, data.VFS))
                {
                    switch (s.Name.ToLowerInvariant())
                    {
                    case "room_info":
                        foreach (Entry e in s)
                        {
                            if (e.Name.ToLowerInvariant() == "set_script")
                            {
                                SceneScripts.Add(e[0].ToString());
                            }
                            if (e.Name.ToLowerInvariant() == "goodscart_script")
                            {
                                GoodscartScript = e[0].ToString();
                            }
                            if (e.Name.ToLowerInvariant() == "scene")
                            {
                                if (e.Count == 3 || e.Count == 4)
                                {
                                    SceneScripts.Add(e[2].ToString());
                                }
                                else
                                {
                                    SceneScripts.Add(e[1].ToString());
                                }
                            }
                        }
                        break;

                    case "room_sound":
                        foreach (Entry e in s)
                        {
                            if (e.Name.ToLowerInvariant() == "music")
                            {
                                Music = e[0].ToString();
                                if (e.Count > 1 && e[1].ToString()
                                    .Equals("oneshot", StringComparison.OrdinalIgnoreCase))
                                {
                                    MusicOneShot = true;
                                }
                            }
                        }
                        break;

                    case "camera":
                        // TODO Room camera
                        foreach (Entry e in s)
                        {
                            if (e.Name.ToLowerInvariant() == "name")
                            {
                                Camera = e[0].ToString();
                            }
                        }
                        break;

                    case "spiels":
                        // TODO Room spiels
                        break;

                    case "playershipplacement":
                        foreach (Entry e in s)
                        {
                            switch (e.Name.ToLowerInvariant())
                            {
                            case "name":
                                PlayerShipPlacement = e[0].ToString();
                                break;

                            case "launching_script":
                                LaunchingScript = e[0].ToString();
                                break;

                            case "landing_script":
                                LandingScript = e[0].ToString();
                                break;
                            }
                        }
                        break;

                    case "characterplacement":
                        foreach (Entry e in s)
                        {
                            switch (e.Name.ToLowerInvariant())
                            {
                            case "start_script":
                                StartScript = e[0].ToString();
                                break;
                            }
                        }
                        break;

                    case "forsaleshipplacement":
                        foreach (Entry e in s)
                        {
                            if (e.Name.Equals("name", StringComparison.OrdinalIgnoreCase))
                            {
                                ForShipSalePlacements.Add(e[0].ToString());
                            }
                        }
                        break;

                    case "hotspot":
                        // TODO Room hotspot
                        var hotspot = new RoomHotspot();
                        foreach (Entry e in s)
                        {
                            switch (e.Name.ToLowerInvariant())
                            {
                            case "name":
                                hotspot.Name = e[0].ToString();
                                break;

                            case "behavior":
                                hotspot.Behavior = e[0].ToString();
                                break;

                            case "room_switch":
                                hotspot.RoomSwitch = e[0].ToString();
                                break;

                            case "set_virtual_room":
                                hotspot.VirtualRoom = e[0].ToString();
                                break;
                            }
                        }
                        Hotspots.Add(hotspot);
                        break;

                    case "flashlightset":
                        // TODO Room flashlightset
                        break;

                    case "flashlightline":
                        // TODO Room flashlightline
                        break;

                    default: throw new Exception("Invalid Section in " + file + ": " + s.Name);
                    }
                }
            }
            else
            {
                FLLog.Error("Ini", "Room file not found " + file);
            }
        }
Exemple #11
0
        public void AddEquipmentIni(string path, FreelancerData data)
        {
            foreach (Section s in ParseFile(path))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "light":
                    Equip.Add(new Light(s, data));
                    break;

                case "power":
                    Equip.Add(FromSection <PowerCore>(s));
                    break;

                case "scanner":
                    break;

                case "tractor":
                    break;

                case "lootcrate":
                    break;

                case "repairkit":
                    break;

                case "countermeasure":
                    break;

                case "countermeasuredropper":
                    break;

                case "shieldbattery":
                    break;

                case "armor":
                    break;

                case "cargopod":
                    break;

                case "commodity":
                    break;

                case "tradelane":
                    break;

                case "internalfx":
                    Equip.Add(FromSection <InternalFx>(s));
                    break;

                case "attachedfx":
                    Equip.Add(FromSection <AttachedFx>(s));
                    break;

                case "shieldgenerator":
                    break;

                case "shield":
                    break;

                case "engine":
                    break;

                case "thruster":
                    Equip.Add(FromSection <Thruster>(s));
                    break;

                case "cloakingdevice":
                    break;

                case "motor":
                    break;

                case "explosion":
                    break;

                case "munition":
                    Munitions.Add(FromSection <Munition>(s));
                    break;

                case "gun":
                    Equip.Add(FromSection <Gun>(s));
                    break;

                case "mine":
                    break;

                case "minedropper":
                    break;

                case "lod":
                    break;

                default: FLLog.Error("Equipment Ini", "Invalid Section in " + path + ": " + s.Name); break;
                }
            }
        }
Exemple #12
0
 protected NamedObject(Vector3 pos, FreelancerData data)
 {
     Pos      = pos;
     GameData = data;
 }
 public UniverseElement(FreelancerData data)
 {
     GameData = data;
 }
Exemple #14
0
        public Loadout(Section section, FreelancerData freelancerIni)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            //Equip = new List<Equip>();
            Equip = new Dictionary <string, AbstractEquipment>();

            int emptyHp = 1;

            foreach (Entry e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Nickname != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Nickname = e[0].ToString();
                    break;

                case "archetype":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Archetype != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Archetype = freelancerIni.Solar.FindSolar(e[0].ToString());
                    break;

                case "equip":
                    //if (e.Count < 1 || e.Count > 2) throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); //TODO: Reverse-engineer this properly
                    //HACK: Come up with a proper way of handling this
                    string key = e.Count == 2 ? e[1].ToString() : "__noHardpoint" + (emptyHp++).ToString("d2");
                    if (e.Count == 2 && e[1].ToString().Trim() == "")
                    {
                        key = "__noHardpoint" + (emptyHp++).ToString("d2");
                    }
                    if (!Equip.ContainsKey(key))
                    {
                        Equip.Add(key, freelancerIni.Equipment.FindEquipment(e[0].ToString()));
                    }
                    break;

                case "cargo":
                    // TODO: Loadout cargo
                    break;

                case "hull":
                    // TODO: Loadout hull?
                    break;

                case "addon":
                    // TODO: Loadout addon?
                    break;

                default:
                    throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                }
            }
        }
Exemple #15
0
        public SystemObject(UniverseIni universe, StarSystem system, Section section, FreelancerData freelancerIni)
            : base(section, freelancerIni)
        {
            if (universe == null)
            {
                throw new ArgumentNullException("universe");
            }
            if (system == null)
            {
                throw new ArgumentNullException("system");
            }
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            this.universe      = universe;
            this.system        = system;
            TradelaneSpaceName = new List <int>();

            foreach (Entry e in section)
            {
                if (!parentEntry(e))
                {
                    switch (e.Name.ToLowerInvariant())
                    {
                    case "ambient_color":
                    case "ambient":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (AmbientColor != null)
                        {
                            FLLog.Warning("Ini", "Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        AmbientColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                        break;

                    case "archetype":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (archetypeName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        archetypeName = e[0].ToString();
                        break;

                    case "star":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Star != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Star = e[0].ToString();
                        break;

                    case "atmosphere_range":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (AtmosphereRange != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        AtmosphereRange = e[0].ToInt32();
                        break;

                    case "burn_color":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (BurnColor != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        BurnColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                        break;

                    case "base":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (baseName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        baseName = e[0].ToString();
                        break;

                    case "msg_id_prefix":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (MsgIdPrefix != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        MsgIdPrefix = e[0].ToString();
                        break;

                    case "jump_effect":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (JumpEffect != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        JumpEffect = e[0].ToString();
                        break;

                    case "behavior":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Behavior != null && Behavior != e[0].ToString())
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Behavior = e[0].ToString();
                        break;

                    case "difficulty_level":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (DifficultyLevel != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        DifficultyLevel = e[0].ToInt32();
                        break;

                    case "goto":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Goto != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Goto = new JumpReference(e[0].ToString(), e[1].ToString(), e[2].ToString());
                        break;

                    case "loadout":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (LoadoutName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        LoadoutName = e[0].ToString();
                        break;

                    case "pilot":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Pilot != null && Pilot != e[0].ToString())
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Pilot = e[0].ToString();
                        break;

                    case "dock_with":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (dockWithName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        dockWithName = e[0].ToString();
                        break;

                    case "voice":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Voice != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Voice = e[0].ToString();
                        break;

                    case "space_costume":
                        if (e.Count < 1 /*|| e.Count > 3*/)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (SpaceCostume != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        SpaceCostume = new Costume(e[0].ToString(), e[1].ToString(), e.Count >= 3 ? e[2].ToString() : string.Empty, freelancerIni);
                        break;

                    case "faction":
                        if (e.Count != 1)
                        {
                            FLLog.Warning("Ini", "Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Faction != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Faction = e[0].ToString();
                        break;

                    case "prev_ring":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (PrevRing != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PrevRing = e[0].ToString();
                        break;

                    case "next_ring":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (nextRingName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        nextRingName = e[0].ToString();
                        break;

                    case "tradelane_space_name":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        TradelaneSpaceName.Add(e[0].ToInt32());
                        break;

                    case "parent":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (parentName != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        parentName = e[0].ToString();
                        break;

                    case "info_card_ids":
                    case "info_card":
                    case "info_ids":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (InfoCardIds != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        InfoCardIds = e[0].ToInt32();
                        break;

                    case "ring":
                        if (e.Count != 2)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        //if ( != null) throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        //TODO
                        break;

                    case "260800":                     // Strange error
                        break;

                    case "rot":
                        FLLog.Warning("SystemObject", "unimplemented: rot");
                        break;

                    default:
                        throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                    }
                }
            }
        }
Exemple #16
0
        public Ship(Section s, FreelancerData fldata)
        {
            foreach (Entry e in s)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    Nickname = e [0].ToString();
                    break;

                case "ids_name":
                    IdsName = e[0].ToInt32();
                    break;

                case "ids_info":
                    IdsInfo = e[0].ToInt32();
                    break;

                case "ids_info1":
                    IdsInfo1 = e[0].ToInt32();
                    break;

                case "ids_info2":
                    IdsInfo2 = e[0].ToInt32();
                    break;

                case "ids_info3":
                    IdsInfo3 = e[0].ToInt32();
                    break;

                case "da_archetype":
                    DaArchetypeName = VFS.GetPath(fldata.Freelancer.DataPath + e [0].ToString());
                    break;

                case "hit_pts":
                    Hitpoints = e [0].ToInt32();
                    break;

                case "nanobot_limit":
                    NanobotLimit = e [0].ToInt32();
                    break;

                case "shield_battery_limit":
                    ShieldBatteryLimit = e [0].ToInt32();
                    break;

                case "hold_size":
                    HoldSize = e [0].ToInt32();
                    break;

                case "mass":
                    Mass = e [0].ToInt32();
                    break;

                case "steering_torque":
                    SteeringTorque = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "angular_drag":
                    AngularDrag = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "rotation_inertia":
                    RotationInertia = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle());
                    break;

                case "strafe_force":
                    StrafeForce = e[0].ToSingle();
                    break;

                case "ship_class":
                    ShipClass = e [0].ToInt32();
                    break;

                case "type":
                    Type = e [0].ToString();
                    break;

                case "material_library":
                    MaterialLibraries.Add(VFS.GetPath(fldata.Freelancer.DataPath + e [0].ToString()));
                    break;

                case "camera_offset":
                    CameraOffset = new Vector3(0, e[0].ToSingle(), e[1].ToSingle());
                    break;

                case "camera_angular_acceleration":
                    CameraAngularAcceleration = e[0].ToSingle();
                    break;

                case "camera_horizontal_turn_angle":
                    CameraHorizontalTurnAngle = e[0].ToSingle();
                    break;

                case "camera_vertical_turn_up_angle":
                    CameraVerticalTurnUpAngle = e[0].ToSingle();
                    break;

                case "camera_vertical_turn_down_angle":
                    CameraVerticalTurnDownAngle = e[0].ToSingle();
                    break;

                case "camera_turn_look_ahead_slerp_amount":
                    CameraTurnLookAheadSlerpAmount = e[0].ToSingle();
                    break;
                }
            }
        }
Exemple #17
0
        public StarSystem(UniverseIni universe, Section section, FreelancerData data)
            : base(data)
        {
            if (universe == null)
            {
                throw new ArgumentNullException("universe");
            }
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            string file = null;

            foreach (Entry e in section)
            {
                switch (e.Name.ToLowerInvariant())
                {
                case "nickname":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Nickname != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Nickname = e[0].ToString();
                    break;

                case "file":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (file != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    file = e[0].ToString();
                    break;

                case "pos":
                    if (e.Count != 2)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Pos != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Pos = new Vector2(e[0].ToSingle(), e[1].ToSingle());
                    break;

                case "msg_id_prefix":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (MsgIdPrefix != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    MsgIdPrefix = e[0].ToString();
                    break;

                case "visit":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (Visit != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    Visit = e[0].ToInt32();
                    break;

                case "strid_name":
                    if (e.Count == 0)
                    {
                        break;
                    }
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (StridName != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    StridName = GameData.Infocards.GetStringResource(e[0].ToInt32());
                    break;

                case "ids_info":
                    if (e.Count == 0)
                    {
                        break;
                    }
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (IdsInfo != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    IdsInfo = GameData.Infocards.GetXmlResource(e[0].ToInt32());
                    break;

                case "navmapscale":
                    if (e.Count != 1)
                    {
                        throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                    }
                    if (NavMapScale != null)
                    {
                        throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                    }
                    NavMapScale = e[0].ToSingle();
                    break;

                default:
                    throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                }
            }

            if (file == null)               //TODO: MultiUniverse
            {
                FLLog.Warning("Ini", "Unimplemented: Possible MultiUniverse system " + Nickname);
                return;
            }

            foreach (Section s in ParseFile(GameData.Freelancer.DataPath + "universe\\" + file))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "systeminfo":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "name":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (Name != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            Name = e[0].ToString();
                            break;

                        case "space_color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (SpaceColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            SpaceColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        case "local_faction":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (LocalFaction != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            LocalFaction = e[0].ToString();
                            break;

                        case "rpop_solar_detection":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (RpopSolarDetection != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            RpopSolarDetection = e[0].ToBoolean();
                            break;

                        case "space_farclip":
                            if (SpaceFarClip != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            SpaceFarClip = e[0].ToSingle();
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "music":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "space":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (MusicSpace != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            MusicSpace = e[0].ToString();
                            break;

                        case "danger":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (MusicDanger != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            MusicDanger = e[0].ToString();
                            break;

                        case "battle":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (MusicBattle != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            MusicBattle = e[0].ToString();
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "archetype":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "ship":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ArchetypeShip == null)
                            {
                                ArchetypeShip = new List <string>();
                            }
                            ArchetypeShip.Add(e[0].ToString());
                            break;

                        case "simple":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ArchetypeSimple == null)
                            {
                                ArchetypeSimple = new List <string>();
                            }
                            ArchetypeSimple.Add(e[0].ToString());
                            break;

                        case "solar":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ArchetypeSolar == null)
                            {
                                ArchetypeSolar = new List <Archetype>();
                            }
                            ArchetypeSolar.Add(GameData.Solar.FindSolar(e[0].ToString()));
                            break;

                        case "equipment":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ArchetypeEquipment == null)
                            {
                                ArchetypeEquipment = new List <string>();
                            }
                            ArchetypeEquipment.Add(e[0].ToString());
                            break;

                        case "snd":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (ArchetypeSnd == null)
                            {
                                ArchetypeSnd = new List <string>();
                            }
                            ArchetypeSnd.Add(e[0].ToString());
                            break;

                        case "voice":
                            if (ArchetypeVoice == null)
                            {
                                ArchetypeVoice = new List <List <string> >();
                            }
                            ArchetypeVoice.Add(new List <string>());
                            foreach (IValue i in e)
                            {
                                ArchetypeVoice[ArchetypeVoice.Count - 1].Add(i.ToString());
                            }
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "dust":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "spacedust":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (Spacedust != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            Spacedust = e[0].ToString();
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "nebula":
                    if (Nebulae == null)
                    {
                        Nebulae = new List <Nebula>();
                    }
                    Nebulae.Add(new Nebula(this, s, GameData));
                    break;

                case "asteroids":
                    if (Asteroids == null)
                    {
                        Asteroids = new List <AsteroidField>();
                    }
                    Asteroids.Add(new AsteroidField(this, s, GameData));
                    break;

                case "ambient":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "color":
                            if (e.Count != 3)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (AmbientColor != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            AmbientColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "lightsource":
                    if (LightSources == null)
                    {
                        LightSources = new List <LightSource>();
                    }
                    LightSources.Add(new LightSource(s, GameData));
                    break;

                case "object":
                    if (Objects == null)
                    {
                        Objects = new List <SystemObject>();
                    }
                    Objects.Add(new SystemObject(universe, this, s, GameData));
                    break;

                case "encounterparameters":
                    if (EncounterParameters == null)
                    {
                        EncounterParameters = new List <EncounterParameter>();
                    }
                    EncounterParameters.Add(new EncounterParameter(s));
                    break;

                case "texturepanels":
                    TexturePanels = new TexturePanelsRef(s, GameData);
                    break;

                case "background":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "basic_stars":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundBasicStarsPath != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundBasicStarsPath = VFS.GetPath(GameData.Freelancer.DataPath + e [0].ToString());
                            break;

                        case "complex_stars":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (BackgroundComplexStarsPath != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundComplexStarsPath = VFS.GetPath(GameData.Freelancer.DataPath + e [0].ToString());
                            break;

                        case "nebulae":
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            string temp = VFS.GetPath(GameData.Freelancer.DataPath + e[0].ToString(), false);
                            if (BackgroundNebulaePath != null && BackgroundNebulaePath != temp)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            BackgroundNebulaePath = temp;
                            break;

                        default:
                            throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name);
                        }
                    }
                    break;

                case "zone":
                    if (Zones == null)
                    {
                        Zones = new List <Zone>();
                    }
                    Zones.Add(new Zone(s, GameData));
                    break;

                case "field":
                    Field = new Field(s);
                    break;

                case "asteroidbillboards":
                    AsteroidBillboards = new AsteroidBillboards(s);
                    break;

                default:
                    throw new Exception("Invalid Section in " + file + ": " + s.Name);
                }
            }
        }
Exemple #18
0
        public Zone(Section section, FreelancerData data)
            : base(section, data)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            MissionType        = new List <List <string> >();
            FactionWeight      = new Dictionary <string, int>();
            DensityRestriction = new Dictionary <string, int>();
            Encounters         = new List <Encounter>();

            foreach (Entry e in section)
            {
                if (!parentEntry(e))
                {
                    switch (e.Name.ToLowerInvariant())
                    {
                    case "shape":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Shape != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        switch (e[0].ToString().ToLowerInvariant())
                        {
                        case "sphere":
                            Shape = ZoneShape.SPHERE;
                            break;

                        case "ellipsoid":
                            Shape = ZoneShape.ELLIPSOID;
                            break;

                        case "box":
                            Shape = ZoneShape.BOX;
                            break;

                        case "cylinder":
                            Shape = ZoneShape.CYLINDER;
                            break;

                        case "ring":
                            Shape = ZoneShape.RING;
                            break;
                        }
                        break;

                    case "attack_ids":
                        if (AttackIds != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        AttackIds = new List <IValue>();
                        foreach (IValue i in e)
                        {
                            AttackIds.Add(i);
                        }
                        break;

                    case "tradelane_attack":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (TradelaneAttack != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        TradelaneAttack = e[0].ToInt32();
                        break;

                    case "property_flags":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (PropertyFlags != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PropertyFlags = e[0].ToInt32();
                        break;

                    case "property_fog_color":
                        if (e.Count != 3)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (PropertyFogColor != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PropertyFogColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f);
                        break;

                    case "music":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Music != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Music = e[0].ToString();
                        break;

                    case "edge_fraction":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (EdgeFraction != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        EdgeFraction = e[0].ToSingle();
                        break;

                    case "spacedust":
                    case "pacedust":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Spacedust != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Spacedust = e[0].ToString();
                        break;

                    case "spacedust_maxparticles":
                    case "spacedusr_maxparticles":
                    case "spacedust_masparticles":
                    case "spacedust _maxparticles":
                    case "spacedust_maxdust":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (SpacedustMaxparticles != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        SpacedustMaxparticles = e[0].ToInt32();
                        break;

                    case "interference":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Interference != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Interference = e[0].ToSingle();
                        break;

                    case "power_modifier":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (PowerModifier != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PowerModifier = e[0].ToSingle();
                        break;

                    case "drag_modifier":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (DragModifier != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        DragModifier = e[0].ToSingle();
                        break;

                    case "comment":
                        if (Comment != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Comment = new List <string>();
                        foreach (IValue i in e)
                        {
                            Comment.Add(i.ToString());
                        }
                        break;

                    case "lane_id":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (LaneId != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        LaneId = e[0].ToInt32();
                        break;

                    case "tradelane_down":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (TradelaneDown != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        TradelaneDown = e[0].ToInt32();
                        break;

                    case "damage":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Damage != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Damage = e[0].ToSingle();
                        break;

                    case "mission_type":
                        MissionType.Add(new List <string>());
                        foreach (IValue i in e)
                        {
                            MissionType[MissionType.Count - 1].Add(i.ToString());
                        }
                        break;

                    case "sort":
                        if (e.Count != 1)
                        {
                            FLLog.Warning("Ini", "Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Sort != null)
                        {
                            FLLog.Warning("Zone", "Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Sort = e[0].ToSingle();
                        break;

                    case "vignette_type":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (VignetteType != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        VignetteType = e[0].ToString();
                        break;

                    case "toughness":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Toughness != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Toughness = e[0].ToInt32();
                        break;

                    case "density":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (Density != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Density = e[0].ToInt32();
                        break;

                    case "population_additive":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (PopulationAdditive != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PopulationAdditive = e[0].ToBoolean();
                        break;

                    case "zone_creation_distance":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (ZoneCreationDistance != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        ZoneCreationDistance = e[0];
                        break;

                    case "repop_time":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (RepopTime != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        RepopTime = e[0].ToInt32();;
                        break;

                    case "max_battle_size":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (MaxBattleSize != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        MaxBattleSize = e[0].ToInt32();
                        break;

                    case "pop_type":
                        if (PopType != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PopType = new List <string>();
                        foreach (IValue i in e)
                        {
                            PopType.Add(i.ToString());
                        }
                        break;

                    case "relief_time":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (ReliefTime != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        ReliefTime = e[0].ToInt32();
                        break;

                    case "path_label":
                        if (PathLabel != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        PathLabel = e.ToList <IValue>();
                        break;

                    case "usage":
                        if (Usage != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        Usage = new List <string>();
                        foreach (IValue i in e)
                        {
                            Usage.Add(i.ToString());
                        }
                        break;

                    case "mission_eligible":
                        if (e.Count != 1)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (MissionEligible != null)
                        {
                            throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name);
                        }
                        MissionEligible = e[0].ToBoolean();
                        break;

                    case "faction_weight":
                        if (e.Count != 2)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (FactionWeight.ContainsKey(e[0].ToString()))
                        {
                            FLLog.Error("Ini", string.Format("Duplicate faction_weight for {0} in {1}, ignoring.", e[0], Nickname ?? "[undefined]"));
                        }
                        else
                        {
                            FactionWeight.Add(e[0].ToString(), e[1].ToInt32());
                        }
                        break;

                    case "density_restriction":
                        if (e.Count != 2)
                        {
                            throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        }
                        if (DensityRestriction.ContainsKey(e[1].ToString()))
                        {
                            FLLog.Error("Ini", string.Format("Duplicate density_restriction for {0} in {1}, ignoring.", e[1], Nickname ?? "[undefined]"));
                        }
                        else
                        {
                            DensityRestriction.Add(e[1].ToString(), e[0].ToInt32());
                        }
                        break;

                    case "encounter":
                        //if (e.Count != 3) throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        //Encounters.Add(new Encounter(e[0].ToString(), e[1].ToInt32(), e[2].ToSingle()));
                        break;

                    case "faction":
                        //TODO: Re-enable encounter parsing
                        //if (Encounters.Count == 0) throw new Exception(e.Name + " before encounter");
                        //if (e.Count == 1) {
                        //Encounters[Encounters.Count - 1].Factions.Add(e[0].ToString(), 100);
                        //}
                        //else if (e.Count != 2) throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count);
                        //else Encounters[Encounters.Count - 1].Factions.Add(e[0].ToString(), e[1].ToSingle());
                        break;

                    default:
                        //throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name);
                        FLLog.Warning("Zone", "Invalid Entry in " + section.Name + ": " + e.Name);
                        break;
                    }
                }
            }
        }