示例#1
0
文件: Track.cs 项目: Reve/ORTS-MG
 /// <summary>
 /// Default constructor used during file parsing.
 /// </summary>
 /// <param name="stf">The STFreader containing the file stream</param>
 public TrackDB(STFReader stf)
 {
     stf.MustMatchBlockStart();
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("tracknodes", () => {
             stf.MustMatchBlockStart();
             int numberOfTrackNodes = stf.ReadInt(null);
             TrackNodes             = new TrackNode[numberOfTrackNodes + 1];
             int idx = 1;
             stf.ParseBlock(new STFReader.TokenProcessor[] {
                 new STFReader.TokenProcessor("tracknode", () => {
                     TrackNodes[idx] = TrackNode.ReadTrackNode(stf, idx, numberOfTrackNodes);
                     if (TrackNodes[idx] is TrackJunctionNode junctionNode)
                     {
                         string key = $"{junctionNode.UiD.WorldId}-{junctionNode.UiD.Location.TileX}-{junctionNode.UiD.Location.TileZ}";
                         if (!junctionNodes.ContainsKey(key))
                         {
                             junctionNodes.Add(key, junctionNode);
                         }
                         // only need any (first) junction node with that key here to relate back to ShapeIndex
                     }
                     ++idx;
                 }),
             });
         }),
示例#2
0
 /// <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); })
             });
         }),
     });
 }