/// <summary> /// Check if two zones are equal /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { // make sure type same if (obj is ArbiterUserWaypointId) { // cast ArbiterUserWaypointId auwi = (ArbiterUserWaypointId)obj; // check if equal return(auwi.Number == this.Number && auwi.PartitionId.Equals(this.PartitionId)); } // otherwise not equal return(false); }
public void InsertUserWaypoint(Coordinates c) { if (this.Partition is ArbiterLanePartition) { ArbiterLanePartition alp = (ArbiterLanePartition)this.Partition; ArbiterUserWaypoint final = null; if (this.InitialGeneric is ArbiterUserWaypoint) { ArbiterUserWaypoint auw = (ArbiterUserWaypoint)this.InitialGeneric; ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(auw.WaypointId.Number + 1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } else { ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } foreach (ArbiterUserWaypoint aup in alp.UserWaypoints) { if (aup.WaypointId.Number >= final.WaypointId.Number) aup.WaypointId.Number++; } ArbiterUserPartition aup1 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, this.InitialGeneric.GenericId, final.WaypointId), this.Partition, this.InitialGeneric, final); aup1.FinalGeneric = final; aup1.InitialGeneric = this.InitialGeneric; final.Previous = aup1; if (aup1.InitialGeneric is ArbiterUserWaypoint) ((ArbiterUserWaypoint)aup1.InitialGeneric).Next = aup1; ArbiterUserPartition aup2 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, final.WaypointId, this.FinalGeneric.GenericId), this.Partition, final, this.FinalGeneric); aup2.InitialGeneric = final; aup2.FinalGeneric = this.FinalGeneric; final.Next = aup2; if (aup2.FinalGeneric is ArbiterUserWaypoint) ((ArbiterUserWaypoint)aup2.FinalGeneric).Previous = aup2; alp.UserPartitions.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(final); alp.UserWaypoints.Add(final); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup1); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup2); alp.UserPartitions.Add(aup1); alp.UserPartitions.Add(aup2); alp.UserPartitions.Sort(); alp.Lane.ReformPath(); } }
/// <summary> /// Constructor /// </summary> /// <param name="position"></param> /// <param name="waypointId"></param> /// <param name="partition"></param> public ArbiterUserWaypoint(Coordinates position, ArbiterUserWaypointId waypointId, IConnectAreaWaypoints partition) { this.position = position; this.WaypointId = waypointId; this.Partition = partition; }
public void InsertUserWaypoint(Coordinates c) { if (this.Partition is ArbiterLanePartition) { ArbiterLanePartition alp = (ArbiterLanePartition)this.Partition; ArbiterUserWaypoint final = null; if (this.InitialGeneric is ArbiterUserWaypoint) { ArbiterUserWaypoint auw = (ArbiterUserWaypoint)this.InitialGeneric; ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(auw.WaypointId.Number + 1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } else { ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } foreach (ArbiterUserWaypoint aup in alp.UserWaypoints) { if (aup.WaypointId.Number >= final.WaypointId.Number) { aup.WaypointId.Number++; } } ArbiterUserPartition aup1 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, this.InitialGeneric.GenericId, final.WaypointId), this.Partition, this.InitialGeneric, final); aup1.FinalGeneric = final; aup1.InitialGeneric = this.InitialGeneric; final.Previous = aup1; if (aup1.InitialGeneric is ArbiterUserWaypoint) { ((ArbiterUserWaypoint)aup1.InitialGeneric).Next = aup1; } ArbiterUserPartition aup2 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, final.WaypointId, this.FinalGeneric.GenericId), this.Partition, final, this.FinalGeneric); aup2.InitialGeneric = final; aup2.FinalGeneric = this.FinalGeneric; final.Next = aup2; if (aup2.FinalGeneric is ArbiterUserWaypoint) { ((ArbiterUserWaypoint)aup2.FinalGeneric).Previous = aup2; } alp.UserPartitions.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(final); alp.UserWaypoints.Add(final); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup1); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup2); alp.UserPartitions.Add(aup1); alp.UserPartitions.Add(aup2); alp.UserPartitions.Sort(); alp.Lane.ReformPath(); } }