public override void OnMouseDown(Event e) { if (IsHoverSegmentEnd) { SelectedSegmentEnd = HoverSegmentEnd == Tool.Data.FirstMainSegmentEnd ? Tool.Data.SecondMainSegmentEnd : Tool.Data.FirstMainSegmentEnd; } }
public override void OnPrimaryMouseClicked(Event e) { if (IsSelectedSegmentEnd) { SelectedSegmentEnd = null; } }
public NodeData InsertNode(NetTool.ControlPoint controlPoint, NodeTypeT nodeType = NodeTypeT.Crossing) { if (ToolBase.ToolErrors.None != NetUtil.InsertNode(controlPoint, out ushort nodeID)) { return(null); } Assert(nodeID != 0, "nodeID"); foreach (var segmentID in NetUtil.IterateNodeSegments(nodeID)) { var segEnd = new SegmentEndData(segmentID, nodeID); SegmentEndManager.Instance.SetAt(segmentID: segmentID, nodeID: nodeID, value: segEnd); } var info = controlPoint.m_segment.ToSegment().Info; int nPedLanes = info.CountPedestrianLanes(); bool isRoad = info.m_netAI is RoadBaseAI; if (nodeType == NodeTypeT.Crossing && (nPedLanes < 2 || !isRoad)) { buffer[nodeID] = new NodeData(nodeID); } else { buffer[nodeID] = new NodeData(nodeID, nodeType); } return(buffer[nodeID]); }
private IEnumerable <RoadPair> GetPairs(NodeData data, SegmentEndData segmentEnd) { foreach (var endData in data.SegmentEndDatas) { if (endData != segmentEnd) { yield return(RoadPair.Get(segmentEnd, endData)); } } }
private bool CheckCorner(SegmentEndData segmentData, SideType side) { var hitPos = Tool.Ray.GetRayPosition(segmentData[side].Position.y, out _); if ((segmentData[side].Position - hitPos).magnitude < SegmentEndData.CornerDotRadius) { HoverSegmentEndCenter = null; HoverSegmentEndCircle = null; HoverSegmentEndCorner = segmentData; HoverCorner = side; return(true); } else { return(false); } }
private float GetSideLane(SegmentEndData segmentEnd, SideType side) { var segment = segmentEnd.Id.GetSegment(); var isStart = segmentEnd.IsStartNode; var isInvert = segment.IsInvert(); var isLeft = side == SideType.Left; var isLaneInvert = isStart ^ isInvert; var info = segment.Info; foreach (var i in isLaneInvert ^ !isLeft ? info.m_sortedLanes : info.m_sortedLanes.Reverse()) { var lane = info.m_lanes[i]; if (lane.IsGroundLane()) { return(((isLaneInvert ? -1 : 1) * lane.m_position + (isLeft ? 0.5f : -0.5f) * lane.m_width) * segmentEnd.Stretch); } } return(0f); }
protected override void Reset(IToolMode prevMode) { HoverSegmentEnd = null; SelectedSegmentEnd = null; }
public void SetAt(ushort segmentID, bool startNode, SegmentEndData value) { GetAt(segmentID, startNode) = value; }
public void SetAt(ushort segmentID, ushort nodeID, SegmentEndData value) { bool startNode = NetUtil.IsStartNode(segmentId: segmentID, nodeId: nodeID); SetAt(segmentID, startNode, value); }