Пример #1
0
 private void LoadTrack()
 {
     _tri = new TriFile(GameConfig.SelectedTrackDescription.FileName);
     _assembler = new TrackAssembler();
     GameConfig.CurrentTrack = _assembler.Assemble(_tri);
     GameConfig.CurrentTrack.Description = GameConfig.SelectedTrackDescription;
 }
Пример #2
0
        public Track Assemble(TriFile tri)
        {
            _tri = tri;
            AddProgress("Reading track scenery file");
            _trackFam = tri.IsOpenRoad ? new OpenRoadTrackfamFile(tri.FileName, GameConfig.AlternativeTimeOfDay) : new TrackfamFile(tri.FileName, GameConfig.AlternativeTimeOfDay);
            AssembleTrackSegments();

            Track track = new Track();
            track.RoadNodes = _tri.Nodes;
            track.SceneryItems = AssembleSceneryItems();
            track.TerrainSegments = _tri.Segments;
            track.TerrainVertexBuffer = AssembleTerrainVertices();
            track.FenceVertexBuffer = AssembleFenceVertices();
            track.TrackFam = _trackFam;
            track.IsOpenRoad = _tri.IsOpenRoad;

            // Find checkpoint scenery object and use it to mark the end of the track.
            // Or ignore it and mark the end of the track as the last node to allow us to drive past the checkpoint!
            if (tri.IsOpenRoad && GameConfig.RespectOpenRoadCheckpoints)
            {
                foreach (var obj in _tri.Scenery)
                {
                    if (obj.Descriptor.ResourceId == OPEN_ROAD_CHECKPOINT_SCENERYITEM_ID)
                    {
                        track.CheckpointNode = obj.ReferenceNode;
                        break;
                    }
                }
            }
            else
            {
                track.CheckpointNode = _tri.Nodes.Count - 2;
            }

            track.Initialize();
            return track;
        }