public EndRoadLaneEdgeConnector( EndRoadLaneEdge endRoadLaneEdge ) { this._endRoadLaneEdge = endRoadLaneEdge; this.AddStartFromHandler<RoadConnection>( edge => { this.CommonConnectEndWith( edge.Edge ); // this._endRoadLaneEdge.Routes.AddRoute( new RouteElement( edge, PriorityType.None ) ); } ); this.AddStartFromHandler<JunctionEdge>( roadJunctionEdge => { this.CommonConnectEndWith( roadJunctionEdge.InvertedEdge ); // this._endRoadLaneEdge.Routes.AddRoute( new RouteElement( roadJunctionEdge, PriorityType.None ) ); } ); this.AddStartFromHandler<CarsRemover>( carsRemover => { this.CommonConnectEndWith( carsRemover.Edge ); // this._endRoadLaneEdge.Routes.AddRoute( new RouteElement( carsRemover, PriorityType.None ) ); } ); this.AddEndOnHandler<CarsInserter>( carInserter => this.CommonEndOnHandler( carInserter.RightEdge ) ); this.AddEndOnHandler<JunctionEdge>( e => this.CommonEndOnHandler( e.InvertedEdge ) ); this.AddEndOnHandler<RoadConnection>( edge => this.CommonEndOnHandler( edge.RightEdge ) ); }
public void ConnectBeginWith( EndRoadLaneEdge roadLaneEdge ) { // TODO Check it this.PreviousConnectedEdge = roadLaneEdge; this.OpositeToPreviousEdge = this.GetLaneEdgeOpositeTo( roadLaneEdge ); this.OpositeToPreviousEdge.Translated.Subscribe( x => this._owner.RecalculatePosition() ); this._owner.RecalculatePosition(); }
public void ConnectEndWith( EndRoadLaneEdge roadLaneEdge ) { this.NextConnectedEdge = roadLaneEdge; var otherSideOfLane = this.GetLaneEdgeOpositeTo( roadLaneEdge ); this.OpositeToNextEdge = otherSideOfLane; this.OpositeToNextEdge.Translated.Subscribe( x => this._owner.RecalculatePosition() ); this._owner.RecalculatePosition(); // this._owner.Routes.AddRoute( new RouteElement( roadLaneEdge.RoadLaneBlockParent, PriorityType.None ) ); }
private EndRoadLaneEdge GetLaneEdgeOpositeTo( EndRoadLaneEdge roadLaneEdge ) { var owner = roadLaneEdge.RoadLaneBlockParent; return owner.LeftEdge == roadLaneEdge ? owner.RightEdge : owner.LeftEdge; }