/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> internal RoadTrackDB(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tracknodes", () => { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); TrackNodes = new TrackNode[count + 1]; int idx = 1; stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tracknode", () => { TrackNodes[idx] = TrackNode.ReadTrackNode(stf, idx, count); ++idx; }), }); }), new STFReader.TokenProcessor("tritemtable", () => { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); TrItemTable = new TrackItem[count]; int idx = -1; stf.ParseBlock(() => ++ idx == -1, new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("levelcritem", () => { TrItemTable[idx] = new RoadLevelCrossingItem(stf, idx); }), new STFReader.TokenProcessor("emptyitem", () => { TrItemTable[idx] = new EmptyItem(stf, idx); }), new STFReader.TokenProcessor("carspawneritem", () => { TrItemTable[idx] = new RoadCarSpawner(stf, idx); }) }); }), }); }
static IDictionary <string, SignalDrawState> ReadDrawStates(STFReader stf) { stf.MustMatch("("); int count = stf.ReadInt(null); Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signaldrawstate", () => { if (drawStates.Count >= count) { STFException.TraceWarning(stf, "Skipped extra SignalDrawState"); } else { SignalDrawState drawState = new SignalDrawState(stf); if (drawStates.ContainsKey(drawState.Name)) { string TempNew = String.Copy("DST"); TempNew = String.Concat(TempNew, drawStates.Count.ToString()); drawStates.Add(TempNew, drawState); STFException.TraceInformation(stf, "Duplicate SignalDrawState name \'" + drawState.Name + "\', using name \'" + TempNew + "\' instead"); } else { drawStates.Add(drawState.Name, drawState); } } }), }); if (drawStates.Count < count) { STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)"); } return(drawStates); }
internal override void Update(STFReader stf) { stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("id", () => { ID = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("activation_level", () => { ActivationLevel = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("outcomes", () => { if (Outcomes == null) { Outcomes = new Outcomes(stf); } else { Outcomes.Update(stf); } }), new STFReader.TokenProcessor("texttodisplayoncompletioniftriggered", () => { TextToDisplayOnCompletionIfTriggered = stf.ReadStringBlock(""); }), new STFReader.TokenProcessor("texttodisplayoncompletionifnotriggered", () => { TextToDisplayOnCompletionIfNotTriggered = stf.ReadStringBlock(""); }), new STFReader.TokenProcessor("name", () => { Name = stf.ReadStringBlock(""); }), new STFReader.TokenProcessor("time", () => { Time = (int)stf.ReadFloatBlock(STFReader.Units.Time, null); }), new STFReader.TokenProcessor("ortscontinue", () => { OrtsContinue = stf.ReadIntBlock(0); }), new STFReader.TokenProcessor("ortsactsoundfile", () => OrtsActivitySoundProcessor(stf)), new STFReader.TokenProcessor("ortsweatherchange", () => { WeatherChange = new OrtsWeatherChange(stf); }), }); }
public void Parse(string lowercasetoken, STFReader stf) { switch (lowercasetoken) { case "wagon(ortspantographs": List.Clear(); stf.MustMatch("("); stf.ParseBlock( new[] { new STFReader.TokenProcessor( "pantograph", () => { List.Add(new Pantograph(Wagon)); List.Last().Parse(stf); } ) } ); if (List.Count() == 0) { throw new InvalidDataException("ORTSPantographs block with no pantographs"); } break; } }
public Transfertable(STFReader stf, Simulator simulator) : base(stf, simulator) { signalRef = Simulator.Signals; string animation; WorldPosition.XNAMatrix.M44 = 100000000; //WorlPosition not yet defined, will be loaded when loading related tile stf.MustMatch("("); stf.ParseBlock(new[] { new STFReader.TokenProcessor("wfile", () => { WFile = stf.ReadStringBlock(null); WorldPosition.TileX = int.Parse(WFile.Substring(1, 7)); WorldPosition.TileZ = int.Parse(WFile.Substring(8, 7)); }), new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }), new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null); Animations.Add(animation.ToLower()); }), new STFReader.TokenProcessor("length", () => { Length = stf.ReadFloatBlock(STFReader.UNITS.None, null); }), new STFReader.TokenProcessor("xoffset", () => { CenterOffset.X = stf.ReadFloatBlock(STFReader.UNITS.None, null); }), new STFReader.TokenProcessor("zoffset", () => { CenterOffset.Z = -stf.ReadFloatBlock(STFReader.UNITS.None, null); }), new STFReader.TokenProcessor("trackshapeindex", () => { TrackShapeIndex = stf.ReadIntBlock(-1); InitializeOffsetsAndTrackNodes(); }), }); }
internal ORTrackData(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsmaxviewingdistance", () => { MaxViewingDistance = stf.ReadFloatBlock(STFReader.Units.Distance, null); }), }); }
public OpenRailsData(STFReader stf) { stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsdll", () => { DLL = stf.ReadStringBlock(null); }), }); }
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 Turntable(STFReader stf, Simulator simulator) : base(stf, simulator) { signalRef = Simulator.SignalEnvironment; string animation; Matrix position = Matrix.Identity; position.M44 = 100000000; //WorlPosition not yet defined, will be loaded when loading related tile; stf.MustMatch("("); stf.ParseBlock(new[] { new STFReader.TokenProcessor("wfile", () => { WFile = stf.ReadStringBlock(null); WorldPosition = new WorldPosition(int.Parse(WFile.Substring(1, 7)), int.Parse(WFile.Substring(8, 7)), position); }), new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }), new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null); Animations.Add(animation.ToLower()); }), new STFReader.TokenProcessor("diameter", () => { Length = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("xoffset", () => { CenterOffset.X = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("zoffset", () => { CenterOffset.Z = -stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("trackshapeindex", () => { TrackShapeIndex = stf.ReadIntBlock(-1); InitializeAnglesAndTrackNodes(); }), }); }
public FreightAnimationDiscrete(STFReader stf) { stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("subtype", () => { var typeString = stf.ReadStringBlock(null); switch (typeString) { default: SubType = FreightAnimationDiscrete.Type.DEFAULT; break; } }), new STFReader.TokenProcessor("shape", () => { ShapeFileName = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("offset", () => { stf.MustMatch("("); XOffset = stf.ReadFloat(STFReader.UNITS.Distance, 0); YOffset = stf.ReadFloat(STFReader.UNITS.Distance, 0); ZOffset = stf.ReadFloat(STFReader.UNITS.Distance, 0); stf.MustMatch(")"); }), new STFReader.TokenProcessor("loadweight", () => { LoadWeight = stf.ReadFloatBlock(STFReader.UNITS.Mass, 0); }), new STFReader.TokenProcessor("loadedatstart", () => { LoadedAtStart = stf.ReadBoolBlock(true); }), }); }
public float FullCentreOfGravityM_Y = -9999; // get centre of gravity after adjusted for freight animation public FreightAnimationContinuous(STFReader stf, MSTSWagon wagon) { stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("intakepoint", () => { wagon.IntakePointList.Add(new IntakePoint(stf)); wagon.IntakePointList.Last().LinkedFreightAnim = this; LinkedIntakePoint = wagon.IntakePointList.Last(); }), new STFReader.TokenProcessor("shape", () => { ShapeFileName = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("maxheight", () => { MaxHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, 0); }), new STFReader.TokenProcessor("minheight", () => { MinHeight = stf.ReadFloatBlock(STFReader.UNITS.Distance, 0); }), new STFReader.TokenProcessor("freightweightwhenfull", () => { FreightWeightWhenFull = stf.ReadFloatBlock(STFReader.UNITS.Mass, 0); }), new STFReader.TokenProcessor("fullatstart", () => { FullAtStart = stf.ReadBoolBlock(true); }), // additions to manage consequences of variable weight on friction and brake forces new STFReader.TokenProcessor("fullortsdavis_a", () => { FullORTSDavis_A = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }), new STFReader.TokenProcessor("fullortsdavis_b", () => { FullORTSDavis_B = stf.ReadFloatBlock(STFReader.UNITS.Resistance, -1); }), new STFReader.TokenProcessor("fullortsdavis_c", () => { FullORTSDavis_C = stf.ReadFloatBlock(STFReader.UNITS.ResistanceDavisC, -1); }), new STFReader.TokenProcessor("fullortswagonfrontalarea", () => { FullORTSWagonFrontalAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, -1); }), new STFReader.TokenProcessor("fullortsdavisdragconstant", () => { FullORTSDavisDragConstant = stf.ReadFloatBlock(STFReader.UNITS.Any, -1); }), new STFReader.TokenProcessor("fullmaxbrakeforce", () => { FullMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }), new STFReader.TokenProcessor("fullmaxhandbrakeforce", () => { FullMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }), new STFReader.TokenProcessor("fullcentreofgravity_y", () => { FullCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }) }); }
private bool saveConnected = true; // Transfertable is connected to a track internal TransferTable(STFReader stf) { string animation; Matrix location = Matrix.Identity; location.M44 = 100_000_000; //WorlPosition not yet defined, will be loaded when loading related tile; stf.MustMatch("("); stf.ParseBlock(new[] { new STFReader.TokenProcessor("wfile", () => { WFile = stf.ReadStringBlock(null); position = new WorldPosition(int.Parse(WFile.Substring(1, 7), CultureInfo.InvariantCulture), int.Parse(WFile.Substring(8, 7), CultureInfo.InvariantCulture), location); }), new STFReader.TokenProcessor("uid", () => { UID = stf.ReadIntBlock(-1); }), new STFReader.TokenProcessor("animation", () => { animation = stf.ReadStringBlock(null); Animations.Add(animation); }), new STFReader.TokenProcessor("verticaltransfer", () => { verticalTransfer = stf.ReadBoolBlock(false); }), new STFReader.TokenProcessor("length", () => { Length = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("xoffset", () => { offset.X = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("zoffset", () => { offset.Z = -stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("yoffset", () => { offset.Y = stf.ReadFloatBlock(STFReader.Units.None, null); }), new STFReader.TokenProcessor("trackshapeindex", () => { TrackShapeIndex = stf.ReadIntBlock(-1); InitializeOffsetsAndTrackNodes(); }), }); }
public CabViewControls(STFReader stf, string basepath) { stf.MustMatch("("); int count = stf.ReadInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("dial", () => { Add(new CVCDial(stf, basepath)); }), new STFReader.TokenProcessor("gauge", () => { Add(new CVCGauge(stf, basepath)); }), new STFReader.TokenProcessor("lever", () => { Add(new CVCDiscrete(stf, basepath)); }), new STFReader.TokenProcessor("twostate", () => { Add(new CVCDiscrete(stf, basepath)); }), new STFReader.TokenProcessor("tristate", () => { Add(new CVCDiscrete(stf, basepath)); }), new STFReader.TokenProcessor("multistate", () => { Add(new CVCDiscrete(stf, basepath)); }), new STFReader.TokenProcessor("multistatedisplay", () => { Add(new CVCMultiStateDisplay(stf, basepath)); }), new STFReader.TokenProcessor("cabsignaldisplay", () => { Add(new CVCSignal(stf, basepath)); }), new STFReader.TokenProcessor("digital", () => { Add(new CVCDigital(stf, basepath)); }), new STFReader.TokenProcessor("combinedcontrol", () => { Add(new CVCDiscrete(stf, basepath)); }), new STFReader.TokenProcessor("firebox", () => { Add(new CVCFirebox(stf, basepath)); }), new STFReader.TokenProcessor("digitalclock", () => { Add(new CVCDigitalClock(stf, basepath)); }) }); //TODO Uncomment when parsed all type /* * if (count != this.Count) STFException.ReportWarning(inf, "CabViewControl count mismatch"); */ }
private static IDictionary <string, LightTexture> ReadLightTextures(STFReader stf) { stf.MustMatch("("); int count = stf.ReadInt(null); Dictionary <string, LightTexture> lightTextures = new Dictionary <string, LightTexture>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("lighttex", () => { if (lightTextures.Count >= count) { STFException.TraceWarning(stf, "Skipped extra LightTex"); } else { LightTexture lightTexture = new LightTexture(stf); if (lightTextures.ContainsKey(lightTexture.Name)) { STFException.TraceWarning(stf, "Skipped duplicate LightTex " + lightTexture.Name); } else { lightTextures.Add(lightTexture.Name, lightTexture); } } }), }); if (lightTextures.Count < count) { STFException.TraceWarning(stf, (count - lightTextures.Count).ToString() + " missing LightTex(s)"); } return(lightTextures); }
/// <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; } } }), }); }
internal TimeTable(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("startingspeed", () => { InitialSpeed = stf.ReadFloatBlock(STFReader.Units.Any, null); }), }); }
static List <SignalSubObject> ReadSignalSubObjects(STFReader stf) { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); List <SignalSubObject> signalSubObjects = new List <SignalSubObject>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalsubobj", () => { if (signalSubObjects.Count >= count) { STFException.TraceWarning(stf, "Skipped extra SignalSubObj"); } else { SignalSubObject signalSubObject = new SignalSubObject(stf); if (signalSubObject.Index != signalSubObjects.Count) { STFException.TraceWarning(stf, $"Invalid SignalSubObj index; expected {signalSubObjects.Count}, got {signalSubObject.Index}"); } signalSubObjects.Add(signalSubObject); } }), }); if (signalSubObjects.Count < count) { STFException.TraceWarning(stf, $"{(count - signalSubObjects.Count)} missing SignalSubObj(s)"); } return(signalSubObjects); }
public Tr_SMS(STFReader stf) { stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("scalabiltygroup", () => { ScalabiltyGroups.Add(new ScalabiltyGroup(stf)); }), }); }
public ORTRKData(STFReader stf) { stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsmaxviewingdistance", () => { MaxViewingDistance = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); }), }); }
public TrainSet(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("traincfg", () => { ParseTrainConfig(stf); }), }); }
public ORCarSpawnerFile(string fileName, string shapePath) { using (STFReader stf = new STFReader(fileName, false)) { var listCount = stf.ReadInt(null); string listName = null; stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("carspawnerlist", () => { if (--listCount < 0) { STFException.TraceWarning(stf, "Skipped extra CarSpawner List"); } else { stf.MustMatchBlockStart(); stf.MustMatch("ListName"); listName = stf.ReadStringBlock(null); CarSpawners.Add(new CarSpawnerList(stf, shapePath, listName)); } }), }); if (listCount > 0) { STFException.TraceWarning(stf, listCount + " missing CarSpawner List(s)"); } } }
public WorldSoundRegion(STFReader stf, TrItem[] trItems) { TrackNodes = new List <int>(); stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("soundregiontracktype", () => { SoundRegionTrackType = stf.ReadIntBlock(-1); }), new STFReader.TokenProcessor("soundregionroty", () => { ROTy = stf.ReadFloatBlock(STFReader.UNITS.None, float.MaxValue); }), new STFReader.TokenProcessor("tritemid", () => { stf.MustMatch("("); var dummy = stf.ReadInt(0); var trItemId = stf.ReadInt(-1); if (trItemId != -1) { if (trItemId >= trItems.Length) { STFException.TraceWarning(stf, string.Format("Ignored invalid TrItemId {0}", trItemId)); } else { TrackNodes.Add(trItemId); } } stf.SkipRestOfBlock(); }), }); }
public CarSpawnerBlock(STFReader stf, string shapePath, List <CarSpawnerList> carSpawnerLists, string listName) { var spawnerDataItems = new List <CarSpawnerItemData>(); { var count = stf.ReadInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("carspawneritem", () => { if (--count < 0) { STFException.TraceWarning(stf, "Skipped extra CarSpawnerItem"); } else { var dataItem = new CarSpawnerItemData(stf, shapePath); if (File.Exists(dataItem.name)) { spawnerDataItems.Add(dataItem); } else { STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem.name)); } } }), }); if (count > 0) { STFException.TraceWarning(stf, count + " missing CarSpawnerItem(s)"); } } CarSpawnerList carSpawnerList = new CarSpawnerList(spawnerDataItems, listName); carSpawnerLists.Add(carSpawnerList); }
static List <SignalLight> ReadLights(STFReader stf) { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); List <SignalLight> lights = new List <SignalLight>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signallight", () => { if (lights.Count >= lights.Capacity) { STFException.TraceWarning(stf, "Skipped extra SignalLight"); } else { lights.Add(new SignalLight(stf)); } }), }); lights.Sort(SignalLight.Comparer); for (int i = 0; i < lights.Count; i++) { if (lights[i].Index != i) { STFException.TraceWarning(stf, $"Invalid SignalLight index; expected {i}, got {lights[i].Index}"); } } return(lights); }
public CabViewControls(STFReader stf, string basePath) { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("dial", () => { Add(new CabViewDialControl(stf, basePath)); }), new STFReader.TokenProcessor("gauge", () => { Add(new CabViewGaugeControl(stf, basePath)); }), new STFReader.TokenProcessor("lever", () => { Add(new CabViewDiscreteControl(stf, basePath)); }), new STFReader.TokenProcessor("twostate", () => { Add(new CabViewDiscreteControl(stf, basePath)); }), new STFReader.TokenProcessor("tristate", () => { Add(new CabViewDiscreteControl(stf, basePath)); }), new STFReader.TokenProcessor("multistate", () => { Add(new CabViewDiscreteControl(stf, basePath)); }), new STFReader.TokenProcessor("multistatedisplay", () => { Add(new CabViewMultiStateDisplayControl(stf, basePath)); }), new STFReader.TokenProcessor("cabsignaldisplay", () => { Add(new CabViewSignalControl(stf, basePath)); }), new STFReader.TokenProcessor("digital", () => { Add(new CabViewDigitalControl(stf, basePath)); }), new STFReader.TokenProcessor("combinedcontrol", () => { Add(new CabViewDiscreteControl(stf, basePath)); }), new STFReader.TokenProcessor("firebox", () => { Add(new CabViewFireboxControl(stf, basePath)); }), new STFReader.TokenProcessor("dialclock", () => { ProcessDialClock(stf, basePath); }), new STFReader.TokenProcessor("digitalclock", () => { Add(new CabViewDigitalClockControl(stf, basePath)); }) }); if (count != Count) { STFException.TraceInformation(stf, $"CabViewControl count mismatch - expected {count} but found {Count} controls."); } }
private Dictionary <string, SignalDrawState> ReadDrawStates(STFReader stf) { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signaldrawstate", () => { if (drawStates.Count >= count) { STFException.TraceWarning(stf, "Skipped extra SignalDrawState"); } else { SignalDrawState drawState = new SignalDrawState(stf); if (drawStates.ContainsKey(drawState.Name)) { string newState = $"DST{drawStates.Count}"; drawStates.Add(newState, drawState); STFException.TraceInformation(stf, $"Duplicate SignalDrawState name \'{drawState.Name}\', using name \'{newState}\' instead"); } else { drawStates.Add(drawState.Name, drawState); } } }), }); if (drawStates.Count < count) { STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)"); } return(drawStates); }
internal override void Update(STFReader stf) { stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("eventtypelocation", () => { stf.MustMatchBlockStart(); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("id", () => { ID = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("ortstriggeringtrain", () => { ParseTrain(stf); }), new STFReader.TokenProcessor("activation_level", () => { ActivationLevel = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("outcomes", () => { if (Outcomes == null) { Outcomes = new Outcomes(stf); } else { Outcomes.Update(stf); } }), new STFReader.TokenProcessor("name", () => { Name = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("texttodisplayoncompletioniftriggered", () => { TextToDisplayOnCompletionIfTriggered = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("texttodisplayoncompletionifnottriggered", () => { TextToDisplayOnCompletionIfNotTriggered = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("triggeronstop", () => { TriggerOnStop = stf.ReadBoolBlock(true); }), new STFReader.TokenProcessor("location", () => { stf.MustMatchBlockStart(); location = new WorldLocation(stf.ReadInt(null), stf.ReadInt(null), stf.ReadFloat(STFReader.Units.None, null), 0f, stf.ReadFloat(STFReader.Units.None, null)); RadiusM = stf.ReadFloat(STFReader.Units.Distance, null); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortscontinue", () => { OrtsContinue = stf.ReadIntBlock(0); }), new STFReader.TokenProcessor("ortsactsoundfile", () => OrtsActivitySoundProcessor(stf)), new STFReader.TokenProcessor("ortsweatherchange", () => { WeatherChange = new OrtsWeatherChange(stf); }), }); }
private List <SignalAspect> ReadAspects(STFReader stf) { stf.MustMatchBlockStart(); int count = stf.ReadInt(null); List <SignalAspect> aspects = new List <SignalAspect>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalaspect", () => { if (aspects.Count >= aspects.Capacity) { STFException.TraceWarning(stf, "Skipped extra SignalAspect"); } else { SignalAspect aspect = new SignalAspect(stf); if (aspects.Any(sa => sa.Aspect == aspect.Aspect)) { STFException.TraceWarning(stf, "Skipped duplicate SignalAspect " + aspect.Aspect); } else { aspects.Add(aspect); } } }), }); return(aspects); }
internal OrtsWeatherChange(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsovercast", () => { stf.MustMatchBlockStart(); Overcast = stf.ReadFloat(STFReader.Units.None, -1); OvercastTransitionTime = stf.ReadInt(-1); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortsfog", () => { stf.MustMatchBlockStart(); Fog = stf.ReadFloat(STFReader.Units.None, -1); FogTransitionTime = stf.ReadInt(-1); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortsprecipitationintensity", () => { stf.MustMatchBlockStart(); PrecipitationIntensity = stf.ReadFloat(STFReader.Units.None, -1); PrecipitationIntensityTransitionTime = stf.ReadInt(-1); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortsprecipitationliquidity", () => { stf.MustMatchBlockStart(); PrecipitationLiquidity = stf.ReadFloat(STFReader.Units.None, -1); PrecipitationLiquidityTransitionTime = stf.ReadInt(-1); stf.MustMatchBlockEnd(); }) }); }
private static IDictionary <string, SignalShape> ReadSignalShapes(STFReader stf) { stf.MustMatch("("); int count = stf.ReadInt(null); Dictionary <string, SignalShape> signalShapes = new Dictionary <string, SignalShape>(count); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalshape", () => { if (signalShapes.Count >= count) { STFException.TraceWarning(stf, "Skipped extra SignalShape"); } else { SignalShape signalShape = new SignalShape(stf); if (signalShapes.ContainsKey(signalShape.ShapeFileName)) { STFException.TraceWarning(stf, "Skipped duplicate SignalShape " + signalShape.ShapeFileName); } else { signalShapes.Add(signalShape.ShapeFileName, signalShape); } } }), }); if (signalShapes.Count < count) { STFException.TraceWarning(stf, (count - signalShapes.Count).ToString() + " missing SignalShape(s)"); } return(signalShapes); }