示例#1
0
        private void ReadRangeFlag(IRangeFlag rangeFlag, XmlNode rangeFlagNode)
        {
            var type = (RangeFlagType)Enum.Parse(typeof(RangeFlagType), rangeFlagNode.GetFieldValue("type"));

            rangeFlag.RangeFlagType = type;

            switch (type)
            {
            case RangeFlagType.Crosswalk:
            case RangeFlagType.Tunnel:
                var index = byte.Parse(rangeFlagNode.GetFieldValue("index"));
                var unkn4 = ushort.Parse(rangeFlagNode.GetFieldValue("unkn4"));
                rangeFlag.Index = index;
                rangeFlag.Unkn4 = unkn4;
                goto case RangeFlagType.RailroadCrossing;

            case RangeFlagType.RailroadCrossing:
            case RangeFlagType.Parking:
            case RangeFlagType.BusStop:
            case RangeFlagType.TrainStation:
                var from     = float.Parse(rangeFlagNode.GetFieldValue("from"));
                var distance = float.Parse(rangeFlagNode.GetFieldValue("distance"));
                var unkn5    = float.Parse(rangeFlagNode.GetFieldValue("unkn5"));
                rangeFlag.From     = from;
                rangeFlag.Distance = distance;
                rangeFlag.Unkn5    = unkn5;
                break;
            }
        }
示例#2
0
        private void ReadLane(ILaneDefinition lane, IRoadmapFactory roadmapFactory, XmlNode laneNode)
        {
            var width        = float.Parse(laneNode.GetFieldValue("width"));
            var type         = (LaneType)Enum.Parse(typeof(LaneType), laneNode.GetFieldValue("type"));
            var flags        = (LaneFlags)Enum.Parse(typeof(LaneFlags), laneNode.GetFieldValue("flags"));
            var centerOffset = ushort.Parse(laneNode.GetFieldValue("centerOffset"));

            lane.Width        = width;
            lane.LaneType     = type;
            lane.LaneFlags    = flags;
            lane.CenterOffset = centerOffset;

            var rangeFlagNodes = laneNode.SelectNodes("rangeFlags/rangeFlag");

            foreach (XmlNode rangeFlagNode in rangeFlagNodes)
            {
                IRangeFlag rangeFlag = roadmapFactory.RangeFlag();
                ReadRangeFlag(rangeFlag, rangeFlagNode);
                lane.RangeFlags.Add(rangeFlag);
            }
        }
示例#3
0
        private void WriteRangeFlag(IRangeFlag flag, XmlDocument xml, XmlNode node)
        {
            node.AddFieldWithValue(xml, "type", flag.RangeFlagType.ToString());
            switch (flag.RangeFlagType)
            {
            case RangeFlagType.Crosswalk:
            case RangeFlagType.Tunnel:
                node.AddFieldWithValue(xml, "index", flag.Index);
                node.AddFieldWithValue(xml, "unkn4", flag.Unkn4);
                goto case RangeFlagType.RailroadCrossing;

            case RangeFlagType.RailroadCrossing:
            case RangeFlagType.Parking:
            case RangeFlagType.BusStop:
            case RangeFlagType.TrainStation:
                node.AddFieldWithValue(xml, "from", flag.From);
                node.AddFieldWithValue(xml, "distance", flag.Distance);
                node.AddFieldWithValue(xml, "unkn5", flag.Unkn5);
                break;
            }
        }
示例#4
0
        private void ReadRoad(IRoadDefinition road, IRoadmapFactory roadmapFactory, XmlNode roadNode)
        {
            var roadGraphEdgeIndex         = StrWithMaxValueNegativeOneToUshort(roadNode.GetFieldValue("roadGraphEdgeIndex"));
            var oppositeRoadGraphEdgeIndex = StrWithMaxValueNegativeOneToUshort(roadNode.GetFieldValue("oppositeRoadGraphEdgeIndex"));
            var oppositeLanesCount         = byte.Parse(roadNode.GetFieldValue("oppositeLanesCount"));
            var forwardLanesCount          = byte.Parse(roadNode.GetFieldValue("forwardLanesCount"));
            var maxSpawnedCars             = byte.Parse(roadNode.GetFieldValue("maxSpawnedCars"));
            var direction   = (RoadDirection)Enum.Parse(typeof(RoadDirection), roadNode.GetFieldValue("direction"));
            var splineIndex = ushort.Parse(roadNode.GetFieldValue("splineIndex"));
            var type        = (RoadType)Enum.Parse(typeof(RoadType), roadNode.GetFieldValue("type"));

            road.RoadGraphEdgeIndex         = roadGraphEdgeIndex;
            road.OppositeRoadGraphEdgeIndex = oppositeRoadGraphEdgeIndex;
            road.OppositeLanesCount         = oppositeLanesCount;
            road.ForwardLanesCount          = forwardLanesCount;
            road.MaxSpawnedCars             = maxSpawnedCars;
            road.Direction       = direction;
            road.RoadSplineIndex = splineIndex;
            road.RoadType        = type;

            var laneNodes = roadNode.SelectNodes("lanes/lane");

            foreach (XmlNode laneNode in laneNodes)
            {
                ILaneDefinition lane = roadmapFactory.Lane();
                ReadLane(lane, roadmapFactory, laneNode);
                road.Lanes.Add(lane);
            }

            var rangeFlagNodes = roadNode.SelectNodes("rangeFlags/rangeFlag");

            foreach (XmlNode rangeFlagNode in rangeFlagNodes)
            {
                IRangeFlag rangeFlag = roadmapFactory.RangeFlag();
                ReadRangeFlag(rangeFlag, rangeFlagNode);
                road.RangeFlags.Add(rangeFlag);
            }
        }