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(); }), }); }
private void ParseTrain(STFReader stf) { stf.MustMatchBlockStart(); TrainService = stf.ReadString(); TrainStartingTime = stf.ReadInt(-1); stf.SkipRestOfBlock(); }
/// <summary> /// Reads the ID from filestream /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="index">The index of this TrItem in the list of TrItems</param> private protected void ParseTrackItemId(STFReader stf, int index) { stf.MustMatchBlockStart(); TrackItemId = stf.ReadUInt(null); Debug.Assert(index == TrackItemId, "Index Mismatch"); stf.SkipRestOfBlock(); }
/// <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; } } }), }); }
public static Interpolator2D CreateInterpolator2D(this STFReader stf) { List <double> xlist = new List <double>(); List <Interpolator> ilist = new List <Interpolator>(); stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { xlist.Add(stf.ReadFloat(STFReader.Units.Any, null)); ilist.Add(stf.CreateInterpolator()); } stf.SkipRestOfBlock(); int n = xlist.Count; if (n < 2) { STFException.TraceWarning(stf, "Interpolator must have at least two x values."); } double[] xArray = new double[n]; Interpolator[] yArray = new Interpolator[n]; for (int i = 0; i < n; i++) { xArray[i] = xlist[i]; yArray[i] = ilist[i]; if (i > 0 && xArray[i - 1] >= xArray[i]) { STFException.TraceWarning(stf, " Interpolator x values must be increasing."); } } return(new Interpolator2D(xArray, yArray)); }
protected void ParseScaleRange(STFReader stf) { stf.MustMatch("("); MinValue = stf.ReadDouble(null); MaxValue = stf.ReadDouble(null); stf.SkipRestOfBlock(); }
protected void ParseScaleRange(STFReader stf) { stf.MustMatchBlockStart(); ScaleRangeMin = stf.ReadFloat(null); ScaleRangeMax = stf.ReadFloat(null); stf.SkipRestOfBlock(); }
public SectionSize(STFReader stf) { stf.MustMatch("("); Width = stf.ReadFloat(STFReader.UNITS.Distance, null); Length = stf.ReadFloat(STFReader.UNITS.Distance, null); stf.SkipRestOfBlock(); }
private void ReadSectionSize(STFReader stf) { stf.MustMatchBlockStart(); Width = stf.ReadFloat(STFReader.Units.Distance, null); Length = stf.ReadFloat(STFReader.Units.Distance, null); stf.SkipRestOfBlock(); }
public SectionCurve(STFReader stf) { stf.MustMatch("("); Radius = stf.ReadFloat(STFReader.UNITS.Distance, null); Angle = stf.ReadFloat(STFReader.UNITS.None, null); stf.SkipRestOfBlock(); }
internal WorldSoundRegion(STFReader stf, TrackItem[] trItems) { TrackNodes = new List <int>(); stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("soundregiontracktype", () => { TrackType = stf.ReadIntBlock(-1); }), new STFReader.TokenProcessor("soundregionroty", () => { RotY = stf.ReadFloatBlock(STFReader.Units.None, float.MaxValue); }), new STFReader.TokenProcessor("tritemid", () => { stf.MustMatchBlockStart(); stf.ReadInt(0);//dummy read int trItemId = stf.ReadInt(-1); if (trItemId != -1) { if (trItemId >= trItems.Length) { STFException.TraceWarning(stf, $"Ignored invalid TrItemId {trItemId}"); } else { TrackNodes.Add(trItemId); } } 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); }
/// <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 Interpolator2D(STFReader stf) { List <float> xlist = new List <float>(); List <Interpolator> ilist = new List <Interpolator>(); stf.MustMatch("("); while (!stf.EndOfBlock()) { xlist.Add(stf.ReadFloat(STFReader.UNITS.Any, null)); ilist.Add(new Interpolator(stf)); } stf.SkipRestOfBlock(); int n = xlist.Count; if (n < 2) { STFException.TraceWarning(stf, "Interpolator must have at least two x values."); } X = new float[n]; Y = new Interpolator[n]; Size = n; for (int i = 0; i < n; i++) { X[i] = xlist[i]; Y[i] = ilist[i]; if (i > 0 && X[i - 1] >= X[i]) { STFException.TraceWarning(stf, " Interpolator x values must be increasing."); } } }
protected virtual float ParseSwitchVal(STFReader stf) { stf.MustMatch("("); var switchVal = (float)(stf.ReadDouble(0)); stf.SkipRestOfBlock(); return(switchVal); }
protected int ParseNumStyle(STFReader stf) { stf.MustMatch("("); var style = stf.ReadInt(0); stf.SkipRestOfBlock(); return(style); }
/// <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(); }
private void ReadSectionCurve(STFReader stf) { Curved = true; stf.MustMatchBlockStart(); Radius = stf.ReadFloat(STFReader.Units.Distance, null); Angle = stf.ReadFloat(STFReader.Units.None, 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> 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 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(); }
protected virtual float ParseSwitchVal(STFReader stf) { stf.MustMatchBlockStart(); var switchVal = stf.ReadFloat(0); stf.SkipRestOfBlock(); return(switchVal); }
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(); }
// Used by subclasses Gauge and Digital protected virtual Color ParseControlColor(STFReader stf) { stf.MustMatchBlockStart(); Color colour = new Color(stf.ReadInt(0) / 255f, stf.ReadInt(0) / 255f, stf.ReadInt(0) / 255f, 1.0f); stf.SkipRestOfBlock(); return(colour); }
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; } } }
} //TODO: probably also 12 is invalid. #endregion public PathDataPoint(STFReader stf) { 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)); JunctionFlag = stf.ReadInt(null); InvalidFlag = stf.ReadInt(null); stf.SkipRestOfBlock(); }
public RouteStart(STFReader stf) { stf.MustMatch("("); WX = stf.ReadDouble(null); // tilex WZ = stf.ReadDouble(null); // tilez X = stf.ReadDouble(null); Z = stf.ReadDouble(null); stf.SkipRestOfBlock(); }
public PathNode(STFReader stf) { stf.MustMatchBlockStart(); PathFlags = (PathFlags)stf.ReadHex(0); NextMainNode = stf.ReadUInt(null); NextSidingNode = stf.ReadUInt(null); PathDataPoint = stf.ReadUInt(null); stf.SkipRestOfBlock(); }
public TrPathNode(STFReader stf) { stf.MustMatch("("); pathFlags = stf.ReadHex(0); nextMainNode = stf.ReadUInt(null); nextSidingNode = stf.ReadUInt(null); fromPDP = stf.ReadUInt(null); stf.SkipRestOfBlock(); }
public TRKEnvironment(STFReader stf) { stf.MustMatch("("); for (int i = 0; i < 12; ++i) { string s = stf.ReadString(); ENVFileNames[i] = stf.ReadStringBlock(null); } stf.SkipRestOfBlock(); }