示例#1
0
 public void addWaypoint(long time, Path path)
 {
     if (Sim.enableNonLivePaths && type.speed > 0) {
         if (!new SegmentUnit(path.segmentWhen(time), this).canBeUnambiguousParent(time)) time++;
         Tile tile = path.tileWhen (time);
         if (!Waypoint.active (tile.waypointLatest (this))) {
             List<UnitSelection> start = new List<UnitSelection> { new UnitSelection(path, this, time) };
             SegmentUnit prev = start[0].segmentUnit();
             do {
                 // remember segments that unit was previously on in case unit is later removed from them
                 SegmentUnit cur = prev;
                 prev = cur.prev ().FirstOrDefault ();
                 if (prev.g == null || prev.segment.path != cur.segment.path || !prev.segment.unseen) {
                     start.Add (new UnitSelection(cur.segment.path, this, cur.segment.timeStart));
                 }
             } while (prev.g != null && prev.segment.unseen);
             g.events.addEvt (new WaypointAddEvt(time + (tile.centerPos() - path.posWhen(time)).length () / type.speed,
                 this, tile, null, start));
         }
     }
 }