public PlayOneShot(STFReader f)
        {
            f.MustMatch("(");
            int count = f.ReadInt(null);

            Files = new string[count];
            int iFile = 0;

            while (!f.EndOfBlock())
            {
                switch (f.ReadString().ToLower())
                {
                case "file":
                    if (iFile < count)
                    {
                        f.MustMatch("(");
                        Files[iFile++] = f.ReadString();
                        f.ReadInt(null);
                        f.SkipRestOfBlock();
                    }
                    else      // MSTS skips extra files
                    {
                        STFException.TraceWarning(f, "Skipped extra File");
                        f.SkipBlock();
                    }
                    break;

                case "selectionmethod":
                    f.MustMatch("(");
                    string s = f.ReadString();
                    switch (s.ToLower())
                    {
                    case "randomselection": SelectionMethod = SelectionMethods.RandomSelection; break;

                    case "sequentialselection": SelectionMethod = SelectionMethods.SequentialSelection; break;

                    default: STFException.TraceWarning(f, "Skipped unknown selection method " + s); break;
                    }
                    f.SkipRestOfBlock();
                    break;

                case "(": f.SkipRestOfBlock(); break;
                }
            }
        }
        public RouteTrackSection(STFReader stf)
        {
            stf.MustMatch("(");
            stf.MustMatch("SectionCurve");
            stf.SkipBlock();
            SectionIndex = stf.ReadUInt(null);
            SectionSize  = new SectionSize();
            float a = stf.ReadFloat(STFReader.UNITS.Distance, null);
            float b = stf.ReadFloat(STFReader.UNITS.None, null);

            if (b == 0)
            // Its straight
            {
                SectionSize.Length = a;
            }
            else
            // its curved
            {
                SectionCurve        = new SectionCurve();
                SectionCurve.Radius = b;
                SectionCurve.Angle  = (float)MathHelper.ToDegrees(a);
            }
            stf.SkipRestOfBlock();
        }
Beispiel #3
0
        }                                               // degrees

        public TrackSection(STFReader stf, bool routeTrackSection)
        {
            if (routeTrackSection)
            {
                stf.MustMatchBlockStart();
                stf.MustMatch("SectionCurve");
                stf.SkipBlock();
                SectionIndex = stf.ReadUInt(null);

                float a = stf.ReadFloat(STFReader.Units.Distance, null);
                float b = stf.ReadFloat(STFReader.Units.None, null);
                if (b == 0) // Its straight
                {
                    Length = a;
                }
                else // its curved
                {
                    Radius = b;
                    Angle  = MathHelper.ToDegrees(a);
                    Curved = true;
                }
                stf.SkipRestOfBlock();
            }
            else
            {
                stf.MustMatchBlockStart();
                SectionIndex = stf.ReadUInt(null);
                stf.ParseBlock(new STFReader.TokenProcessor[] {
                    new STFReader.TokenProcessor("sectionsize", () => { ReadSectionSize(stf); }),
                    new STFReader.TokenProcessor("sectioncurve", () => { ReadSectionCurve(stf); }),
                });
                //if( SectionSize == null )
                //	throw( new STFError( stf, "Missing SectionSize" ) );
                //  note- default TSECTION.DAT does have some missing sections
            }
        }
Beispiel #4
0
 public ShapeDescriptor(STFReader stf)
 {
     Name = stf.ReadString(); // Ignore the filename string. TODO: Check if it agrees with the SD file name? Is this important?
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("esd_detail_level", () => { EsdDetailLevel = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("esd_alternative_texture", () => { EsdAlternativeTexture = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("esd_no_visual_obstruction", () => { EsdNoVisualObstruction = stf.ReadBoolBlock(true); }),
         new STFReader.TokenProcessor("esd_snapable", () => { EsdSnapable = stf.ReadBoolBlock(true); }),
         new STFReader.TokenProcessor("esd_subobj", () => { EsdSubObject = true; stf.SkipBlock(); }),
         new STFReader.TokenProcessor("esd_bounding_box", () => {
             EsdBoundingBox = new EsdBoundingBox(stf);
             if (EsdBoundingBox.Min == null || EsdBoundingBox.Max == null)      // ie quietly handle ESD_Bounding_Box()
             {
                 EsdBoundingBox = null;
             }
         }),
         new STFReader.TokenProcessor("esd_ortssoundfilename", () => { EsdSoundFileName = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("esd_ortsbellanimationfps", () => { EsdBellAnimationFps = stf.ReadFloatBlock(STFReader.Units.Frequency, null); }),
     });
     // TODO - some objects have no bounding box - ie JP2BillboardTree1.sd
     //if (ESD_Bounding_Box == null) throw new STFException(stf, "Missing ESD_Bound_Box statement");
 }
Beispiel #5
0
 public SDShape(STFReader stf)
 {
     stf.ReadString(); // Ignore the filename string. TODO: Check if it agrees with the SD file name? Is this important?
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("esd_detail_level", () => { ESD_Detail_Level = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("esd_alternative_texture", () => { ESD_Alternative_Texture = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("esd_no_visual_obstruction", () => { ESD_No_Visual_Obstruction = stf.ReadBoolBlock(true); }),
         new STFReader.TokenProcessor("esd_snapable", () => { ESD_Snapable = stf.ReadBoolBlock(true); }),
         new STFReader.TokenProcessor("esd_subobj", () => { ESD_SubObj = true; stf.SkipBlock(); }),
         new STFReader.TokenProcessor("esd_bounding_box", () => {
             ESD_Bounding_Box = new ESD_Bounding_Box(stf);
             if (ESD_Bounding_Box.Min == null || ESD_Bounding_Box.Max == null)  // ie quietly handle ESD_Bounding_Box()
             {
                 ESD_Bounding_Box = null;
             }
         }),
         new STFReader.TokenProcessor("esd_ortssoundfilename", () => { ESD_SoundFileName = stf.ReadStringBlock(null); }),
     });
     // TODO - some objects have no bounding box - ie JP2BillboardTree1.sd
     //if (ESD_Bounding_Box == null) throw new STFException(stf, "Missing ESD_Bound_Box statement");
 }