internal ActivitySound(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsactsoundfile", () => { stf.MustMatchBlockStart(); string soundFile = stf.ReadString(); SoundFile = Path.Combine(FolderStructure.RouteFromActivity(stf.FileName).SoundFile(soundFile)); if (!EnumExtension.GetValue(stf.ReadString(), out OrtsActivitySoundFileType soundFileType)) { stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown activity sound file type " + stf.ReadString()); SoundFileType = OrtsActivitySoundFileType.None; } else { SoundFileType = soundFileType; } stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortssoundlocation", () => { stf.MustMatchBlockStart(); location = new WorldLocation(stf.ReadInt(null), stf.ReadInt(null), stf.ReadFloat(STFReader.Units.None, null), stf.ReadFloat(STFReader.Units.None, null), stf.ReadFloat(STFReader.Units.None, null)); stf.MustMatchBlockEnd(); }), });
// SigSubJnLinkIf is not supported /// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalSubObj(STFReader stf) { SignalSubType = -1; // not (yet) specified stf.MustMatch("("); Index = stf.ReadInt(null); MatrixName = stf.ReadString().ToUpper(); Description = stf.ReadString(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("sigsubtype", () => { SignalSubType = SignalSubTypes.IndexOf(stf.ReadStringBlock(null).ToUpper()); }), new STFReader.TokenProcessor("sigsubstype", () => { SignalSubSignalType = stf.ReadStringBlock(null).ToLowerInvariant(); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatch("("); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "optional": Optional = true; break; case "default": Default = true; break; case "back_facing": BackFacing = true; break; case "jn_link": JunctionLink = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown SignalSubObj flag " + stf.ReadString()); break; } } }), }); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalLight(STFReader stf) { stf.MustMatchBlockStart(); Index = stf.ReadInt(null); Name = stf.ReadString().ToLowerInvariant(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("radius", () => { Radius = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("position", () => { stf.MustMatchBlockStart(); position = new Vector3(stf.ReadFloat(null), stf.ReadFloat(null), stf.ReadFloat(null)); stf.SkipRestOfBlock(); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "semaphore_change": SemaphoreChange = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown SignalLight flag " + stf.ReadString()); break; } } }), }); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> internal LightTexture(STFReader stf) { stf.MustMatchBlockStart(); Name = stf.ReadString(); TextureFile = stf.ReadString(); uv = new Matrix2x2(stf.ReadFloat(null), stf.ReadFloat(null), stf.ReadFloat(null), stf.ReadFloat(null)); stf.SkipRestOfBlock(); }
public TrackType(STFReader stf) { stf.MustMatchBlockStart(); Label = stf.ReadString(); InsideSound = stf.ReadString(); OutsideSound = stf.ReadString(); stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public LightTexture(STFReader stf) { stf.MustMatchBlockStart(); Name = stf.ReadString().ToLowerInvariant(); TextureFile = stf.ReadString(); uv = new Matrix2x2(stf.ReadFloat(null), stf.ReadFloat(null), stf.ReadFloat(null), stf.ReadFloat(null)); stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalShape(STFReader stf) { stf.MustMatchBlockStart(); ShapeFileName = Path.GetFileName(stf.ReadString()); Description = stf.ReadString(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalsubobjs", () => { SignalSubObjs = ReadSignalSubObjects(stf); }), }); }
public Variable_Trigger(STFReader f) { f.MustMatch("("); string eventString = f.ReadString(); Threshold = f.ReadFloat(STFReader.UNITS.None, null); switch (eventString.ToLower()) { case "speed_inc_past": Event = Events.Speed_Inc_Past; break; case "speed_dec_past": Event = Events.Speed_Dec_Past; break; case "distance_inc_past": { Event = Events.Distance_Inc_Past; Threshold = Threshold * Threshold; break; } case "distance_dec_past": { Event = Events.Distance_Dec_Past; Threshold = Threshold * Threshold; break; } case "variable1_inc_past": Event = Events.Variable1_Inc_Past; break; case "variable1_dec_past": Event = Events.Variable1_Dec_Past; break; case "variable2_inc_past": Event = Events.Variable2_Inc_Past; break; case "variable2_dec_past": Event = Events.Variable2_Dec_Past; break; case "variable3_inc_past": Event = Events.Variable3_Inc_Past; break; case "variable3_dec_past": Event = Events.Variable3_Dec_Past; break; case "brakecyl_inc_past": Event = Events.BrakeCyl_Inc_Past; break; case "brakecyl_dec_past": Event = Events.BrakeCyl_Dec_Past; break; case "curveforce_inc_past": Event = Events.CurveForce_Inc_Past; break; case "curveforce_dec_past": Event = Events.CurveForce_Dec_Past; break; } while (!f.EndOfBlock()) { ParsePlayCommand(f, f.ReadString().ToLower()); } }
public ClockShape(STFReader stf, string shapePath) { stf.MustMatch("("); Name = stf.ReadString(); if (stf.ReadString() == "analog") { ClockType = OR.ClockType.Analog; } stf.SkipRestOfBlock(); }
//Type of OR-Clock -> analog, digital public Clock(STFReader stf, string shapePath) { stf.MustMatch("("); Name = shapePath + stf.ReadString(); if (EnumExtension.GetValue(stf.ReadString(), out ClockType type)) { ClockType = type; } stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="ORTSMode">Process SignalType for ORTS mode (always set NumClearAhead_ORTS only)</param> public SignalType(STFReader stf, bool ORTSMode) : this() { stf.MustMatch("("); Name = stf.ReadString().ToLowerInvariant(); int numClearAhead = -2; int numdefs = 0; stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalfntype", () => { FnType = ReadFnType(stf); }), //[Rob Roeterdink] value was not passed new STFReader.TokenProcessor("signallighttex", () => { LightTextureName = stf.ReadStringBlock("").ToLowerInvariant(); }), new STFReader.TokenProcessor("signallights", () => { Lights = ReadLights(stf); }), new STFReader.TokenProcessor("signaldrawstates", () => { DrawStates = ReadDrawStates(stf); }), new STFReader.TokenProcessor("signalaspects", () => { Aspects = ReadAspects(stf); }), new STFReader.TokenProcessor("approachcontrolsettings", () => { ApproachControlDetails = ReadApproachControlDetails(stf); }), new STFReader.TokenProcessor("signalnumclearahead", () => { numClearAhead = numClearAhead >= -1 ? numClearAhead : stf.ReadIntBlock(null); numdefs++; }), new STFReader.TokenProcessor("semaphoreinfo", () => { SemaphoreInfo = stf.ReadFloatBlock(STFReader.UNITS.None, null); }), new STFReader.TokenProcessor("sigflashduration", () => { stf.MustMatch("("); FlashTimeOn = stf.ReadFloat(STFReader.UNITS.None, null); FlashTimeOff = stf.ReadFloat(STFReader.UNITS.None, null); stf.SkipRestOfBlock(); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatch("("); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "abs": Abs = true; break; case "no_gantry": NoGantry = true; break; case "semaphore": Semaphore = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown SignalType flag " + stf.ReadString()); break; } } }), }); if (ORTSMode) { // In ORTS mode : always set value for NumClearAhead_ORTS NumClearAhead_MSTS = -2; NumClearAhead_ORTS = numClearAhead; } else { // In MSTS mode : if one line for SignalNumClearAhead defined, set value for NumClearAhead_MSTS, otherwise set value for NumClearAhead_ORTS NumClearAhead_MSTS = numdefs == 1 ? numClearAhead : -2; NumClearAhead_ORTS = numdefs == 2 ? numClearAhead : -2; } }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public LightTexture(STFReader stf) { stf.MustMatch("("); Name = stf.ReadString().ToLowerInvariant(); TextureFile = stf.ReadString(); u0 = stf.ReadFloat(STFReader.UNITS.None, null); v0 = stf.ReadFloat(STFReader.UNITS.None, null); u1 = stf.ReadFloat(STFReader.UNITS.None, null); v1 = stf.ReadFloat(STFReader.UNITS.None, null); stf.SkipRestOfBlock(); }
protected void ParseType(STFReader stf) { stf.MustMatchBlockStart(); if (!EnumExtension.GetValue(stf.ReadString(), out CabViewControlType type)) { stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown ControlType " + stf.ReadString()); ControlType = CabViewControlType.None; } ControlType = type; //stf.ReadItem(); // Skip repeated Class Type stf.SkipRestOfBlock(); }
private void ParseTrain(STFReader stf) { stf.MustMatchBlockStart(); TrainService = stf.ReadString(); TrainStartingTime = stf.ReadInt(-1); stf.SkipRestOfBlock(); }
/// <summary> /// Reads the SData from filestream /// </summary> /// <param name="stf">The STFreader containing the file stream</param> private protected void ParseTrackItemSData(STFReader stf) { stf.MustMatchBlockStart(); SData1 = stf.ReadFloat(STFReader.Units.None, null); SData2 = stf.ReadString(); stf.SkipRestOfBlock(); }
public void Parse(STFReader stf) { stf.MustMatch("("); MinimumValue = stf.ReadFloat(STFReader.UNITS.None, null); MaximumValue = stf.ReadFloat(STFReader.UNITS.None, null); StepSize = stf.ReadFloat(STFReader.UNITS.None, null); IntermediateValue = CurrentValue = stf.ReadFloat(STFReader.UNITS.None, null); string token = stf.ReadItem(); // s/b numnotches if (string.Compare(token, "NumNotches", true) != 0) // handle error in gp38.eng where extra parameter provided before NumNotches statement { stf.ReadItem(); } stf.MustMatch("("); stf.ReadInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("notch", () => { stf.MustMatch("("); float value = stf.ReadFloat(STFReader.UNITS.None, null); int smooth = stf.ReadInt(null); string type = stf.ReadString(); Notches.Add(new MSTSNotch(value, smooth, type, stf)); if (type != ")") { stf.SkipRestOfBlock(); } }), }); SetValue(CurrentValue); }
public Initial_Trigger(STFReader f) { f.MustMatch("("); while (!f.EndOfBlock()) { ParsePlayCommand(f, f.ReadString().ToLower()); } }
internal PlayerServices(STFReader stf) { stf.MustMatchBlockStart(); Name = stf.ReadString(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("player_traffic_definition", () => { PlayerTraffics = new PlayerTraffics(stf); }), }); }
public CarSpawner(STFReader stf, string shapePath) { stf.MustMatchBlockStart(); //pre fit in the shape path so no need to do it again and again later Name = shapePath + stf.ReadString(); Distance = stf.ReadFloat(STFReader.Units.Distance, null); stf.SkipRestOfBlock(); }
public EngineClass(STFReader stf) { stf.MustMatch("("); stf.ReadString(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("type", () => { Type = stf.ReadStringBlock(null); }), }); }
public CarSpawnerItemData(STFReader stf, string shapePath) { stf.MustMatch("("); //pre fit in the shape path so no need to do it again and again later name = shapePath + stf.ReadString(); dist = stf.ReadFloat(STFReader.UNITS.Distance, null); stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalAspect(STFReader stf) { SpeedLimit = -1; stf.MustMatchBlockStart(); string aspectName = stf.ReadString(); if (!EnumExtension.GetValue(aspectName, out SignalAspectState aspect)) { STFException.TraceInformation(stf, "Skipped unknown signal aspect " + aspectName); Aspect = SignalAspectState.Unknown; } else { Aspect = aspect; } DrawStateName = stf.ReadString().ToLowerInvariant(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("speedmph", () => { SpeedLimit = (float)Speed.MeterPerSecond.FromMpH(stf.ReadFloatBlock(STFReader.Units.None, 0)); }), new STFReader.TokenProcessor("speedkph", () => { SpeedLimit = (float)Speed.MeterPerSecond.FromKpH(stf.ReadFloatBlock(STFReader.Units.None, 0)); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "asap": Asap = true; break; case "or_speedreset": Reset = true; break; case "or_nospeedreduction": NoSpeedReduction = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown DrawLight flag " + stf.ReadString()); break; } } }), }); }
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; } } }
private protected void OrtsActivitySoundProcessor(STFReader stf) { stf.MustMatchBlockStart(); string soundFile = stf.ReadString(); SoundFile = FolderStructure.RouteFromActivity(stf.FileName).SoundFile(soundFile); if (!EnumExtension.GetValue(stf.ReadString(), out OrtsActivitySoundFileType soundFileType)) { stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown activity sound file type " + stf.ReadString()); SoundFileType = OrtsActivitySoundFileType.None; } else { SoundFileType = soundFileType; } stf.MustMatchBlockEnd(); }
protected void ParseStyle(STFReader stf) { stf.MustMatchBlockStart(); string styleTemp = stf.ReadString(); if (char.IsDigit(styleTemp[0])) { styleTemp = (styleTemp + styleTemp.Substring(0, 2)).Remove(0, 2); } if (!EnumExtension.GetValue(styleTemp, out CabViewControlStyle style)) { stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown ControlStyle " + stf.ReadString()); ControlStyle = CabViewControlStyle.None; } ControlStyle = style; stf.SkipRestOfBlock(); }
public Discrete_Trigger(STFReader f) { f.MustMatch("("); TriggerID = f.ReadInt(null); while (!f.EndOfBlock()) { ParsePlayCommand(f, f.ReadString().ToLower()); } }
// SigSubJnLinkIf is not supported /// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> internal SignalSubObject(STFReader stf) { SignalSubType = SignalSubType.None; stf.MustMatchBlockStart(); Index = stf.ReadInt(null); MatrixName = stf.ReadString().ToUpperInvariant(); Description = stf.ReadString(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("sigsubtype", () => { if (EnumExtension.GetValue(stf.ReadStringBlock(null), out SignalSubType subType)) { SignalSubType = subType; } }), new STFReader.TokenProcessor("sigsubstype", () => { SignalSubSignalType = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToUpperInvariant()) { case "OPTIONAL": Optional = true; break; case "DEFAULT": Default = true; break; case "BACK_FACING": BackFacing = true; break; case "JN_LINK": JunctionLink = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown SignalSubObj flag " + stf.ReadString()); break; } } }), });
public TRKEnvironment(STFReader stf) { stf.MustMatch("("); for (int i = 0; i < 12; ++i) { string s = stf.ReadString(); ENVFileNames[i] = stf.ReadStringBlock(null); } stf.SkipRestOfBlock(); }
internal ServiceTraffic(STFReader stf) { stf.MustMatchBlockStart(); Name = stf.ReadString(); stf.MustMatch("serial"); Serial = stf.ReadIntBlock(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("service_definition", () => { ServiceTraffics.Add(new ServiceTraffics(stf)); }), }); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalDrawState(STFReader stf) { stf.MustMatchBlockStart(); Index = stf.ReadInt(null); Name = stf.ReadString().ToLowerInvariant(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("drawlights", () => { DrawLights = ReadDrawLights(stf); }), new STFReader.TokenProcessor("semaphorepos", () => { SemaphorePosition = stf.ReadFloatBlock(STFReader.Units.None, 0); }), }); }