コード例 #1
0
ファイル: RouteFile.cs プロジェクト: xiaomailong/OpenRails
 public Tr_RouteFile(STFReader stf)
 {
     stf.MustMatch("(");
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("routeid", () => { RouteID = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("name", () => { Name = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("filename", () => { FileName = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("description", () => { Description = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("maxlinevoltage", () => { MaxLineVoltage = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
         new STFReader.TokenProcessor("routestart", () => { if (RouteStart == null)
                                                            {
                                                                RouteStart = new RouteStart(stf);
                                                            }
                                      }),
         new STFReader.TokenProcessor("environment", () => { Environment = new TRKEnvironment(stf); }),
         new STFReader.TokenProcessor("milepostunitskilometers", () => { MilepostUnitsMetric = true; }),
         new STFReader.TokenProcessor("electrified", () => { Electrified = stf.ReadBoolBlock(false); }),
         new STFReader.TokenProcessor("overheadwireheight", () => { OverheadWireHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, 6.0f); }),
         new STFReader.TokenProcessor("speedlimit", () => { SpeedLimit = stf.ReadFloatBlock(STFReader.UNITS.Speed, 500.0f); }),
         new STFReader.TokenProcessor("defaultcrossingsms", () => { DefaultCrossingSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultcoaltowersms", () => { DefaultCoalTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultdieseltowersms", () => { DefaultDieselTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultwatertowersms", () => { DefaultWaterTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultsignalsms", () => { DefaultSignalSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("temprestrictedspeed", () => { TempRestrictedSpeed = stf.ReadFloatBlock(STFReader.UNITS.Speed, -1f); }),
         // values for tunnel operation
         new STFReader.TokenProcessor("ortssingletunnelarea", () => { SingleTunnelAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, null); }),
         new STFReader.TokenProcessor("ortssingletunnelperimeter", () => { SingleTunnelPerimeterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         new STFReader.TokenProcessor("ortsdoubletunnelarea", () => { DoubleTunnelAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, null); }),
         new STFReader.TokenProcessor("ortsdoubletunnelperimeter", () => { DoubleTunnelPerimeterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         // if > 0 indicates distance from track without forest trees
         new STFReader.TokenProcessor("ortsuserpreferenceforestcleardistance", () => { ForestClearDistance = stf.ReadFloatBlock(STFReader.UNITS.Distance, 0); }),
         // values for superelevation
         new STFReader.TokenProcessor("ortstracksuperelevation", () => { SuperElevationHgtpRadiusM = new Interpolator(stf); }),
     });
     //TODO This should be changed to STFException.TraceError() with defaults values created
     if (RouteID == null)
     {
         throw new STFException(stf, "Missing RouteID");
     }
     if (Name == null)
     {
         throw new STFException(stf, "Missing Name");
     }
     if (Description == null)
     {
         throw new STFException(stf, "Missing Description");
     }
     if (RouteStart == null)
     {
         throw new STFException(stf, "Missing RouteStart");
     }
 }
コード例 #2
0
 public Tr_RouteFile(STFReader stf)
 {
     stf.MustMatch("(");
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("routeid", () => { RouteID = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("name", () => { Name = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("filename", () => { FileName = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("description", () => { Description = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("maxlinevoltage", () => { MaxLineVoltage = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
         new STFReader.TokenProcessor("routestart", () => { if (RouteStart == null)
                                                            {
                                                                RouteStart = new RouteStart(stf);
                                                            }
                                      }),
         new STFReader.TokenProcessor("environment", () => { Environment = new TRKEnvironment(stf); }),
         new STFReader.TokenProcessor("milepostunitskilometers", () => { MilepostUnitsMetric = true; }),
         new STFReader.TokenProcessor("electrified", () => { Electrified = stf.ReadBoolBlock(false); }),
         new STFReader.TokenProcessor("overheadwireheight", () => { OverheadWireHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, 6.0f); }),
         new STFReader.TokenProcessor("speedlimit", () => { SpeedLimit = stf.ReadFloatBlock(STFReader.UNITS.Speed, 500.0f); }),
         new STFReader.TokenProcessor("defaultcrossingsms", () => { DefaultCrossingSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultcoaltowersms", () => { DefaultCoalTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultdieseltowersms", () => { DefaultDieselTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultwatertowersms", () => { DefaultWaterTowerSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("defaultsignalsms", () => { DefaultSignalSMS = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("temprestrictedspeed", () => { TempRestrictedSpeed = stf.ReadFloatBlock(STFReader.UNITS.Speed, -1f); }),
         // values for tunnel operation
         new STFReader.TokenProcessor("ortssingletunnelarea", () => { SingleTunnelAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, null); }),
         new STFReader.TokenProcessor("ortssingletunnelperimeter", () => { SingleTunnelPerimeterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         new STFReader.TokenProcessor("ortsdoubletunnelarea", () => { DoubleTunnelAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, null); }),
         new STFReader.TokenProcessor("ortsdoubletunnelperimeter", () => { DoubleTunnelPerimeterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         // if > 0 indicates distance from track without forest trees
         new STFReader.TokenProcessor("ortsuserpreferenceforestcleardistance", () => { ForestClearDistance = stf.ReadFloatBlock(STFReader.UNITS.Distance, 0); }),
         // if true removes forest trees also from roads
         new STFReader.TokenProcessor("ortsuserpreferenceremoveforesttreesfromroads", () => { RemoveForestTreesFromRoads = stf.ReadBoolBlock(false); }),
         // values for superelevation
         new STFReader.TokenProcessor("ortstracksuperelevation", () => { SuperElevationHgtpRadiusM = new Interpolator(stf); }),
         // images
         new STFReader.TokenProcessor("graphic", () => { Thumbnail = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("loadingscreen", () => { LoadingScreen = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("ortsloadingscreenwide", () => { LoadingScreenWide = stf.ReadStringBlock(null); }),
         // values for OHLE
         new STFReader.TokenProcessor("ortsdoublewireenabled", () => { DoubleWireEnabled = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("ortsdoublewireheight", () => { DoubleWireHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         new STFReader.TokenProcessor("ortstriphaseenabled", () => { TriphaseEnabled = stf.ReadStringBlock(null); }),
         new STFReader.TokenProcessor("ortstriphasewidth", () => { TriphaseWidth = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }),
         // default sms file for turntables and transfertables
         new STFReader.TokenProcessor("ortsdefaultturntablesms", () => { DefaultTurntableSMS = stf.ReadStringBlock(null); }),
         // sms file number in Ttype.dat when train over switch
         new STFReader.TokenProcessor("ortsswitchsmsnumber", () => { SwitchSMSNumber = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("ortscurvesmsnumber", () => { CurveSMSNumber = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("ortscurveswitchsmsnumber", () => { CurveSwitchSMSNumber = stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("ortsopendoorsinaitrains", () => { OpenDoorsInAITrains = stf.ReadBoolBlock(false); }),
     });
     //TODO This should be changed to STFException.TraceError() with defaults values created
     if (RouteID == null)
     {
         throw new STFException(stf, "Missing RouteID");
     }
     if (Name == null)
     {
         throw new STFException(stf, "Missing Name");
     }
     if (Description == null)
     {
         throw new STFException(stf, "Missing Description");
     }
     if (RouteStart == null)
     {
         throw new STFException(stf, "Missing RouteStart");
     }
     if (ForestClearDistance == 0 && RemoveForestTreesFromRoads)
     {
         Trace.TraceWarning("You must define also ORTSUserPreferenceForestClearDistance to avoid trees on roads");
     }
 }