Example #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));
         }
     }
 }
Example #2
0
 // methods above involve commanding selected units
 /// <summary>
 /// sets pos to where base of path should be drawn at, and returns whether it should be drawn
 /// </summary>
 private bool pathDrawPos(Path path, ref Vector3 pos)
 {
     if (g.timeGame < path.moves[0].timeStart) return false;
     if (selPlayer != path.player) {
         if (path.timeSimPast != long.MaxValue) return false;
         if (!path.tileWhen (g.timeGame).playerVisWhen(selPlayer, g.timeGame)) return false;
     }
     pos = simToDrawPos(path.posWhen(g.timeGame), unitDepth);
     return true;
 }