public virtual Track NextTrackRandom(Track previousTrack = null) { if (HasValidPath) { List<Track> list; if (previousTrack != null && AvailableConnectedTracks.Count > 1) { list = AvailableConnectedTracks.Where(t => t != previousTrack).ToList(); } else { list = AvailableConnectedTracks; } if (list.Count > 0) return list.RandomElement(); else return null; } return null; }
public virtual Track NextTrack(Direction preferredDir, Track previousTrack = null) { if (preferredDir != Direction.Any && preferredDir!=Direction.Invalid) { Track t = NextTrackInDirection(preferredDir); if (t == null) t = NextTrackRandom(previousTrack); return t; } else { return NextTrackRandom(previousTrack); } }
public virtual Track NextTrack(Track previousTrack = null) { return NextTrack(Direction.Any, previousTrack); }
public bool IsAdjacentTo(Track track) { return this.AllConnectedTracks.Contains(track); }
public Direction DirectionTo(Track track) { if (track.Position.AdjacentToCardinal(this.Position)) { if ((Position + IntVec3.North) == track.Position) { return Direction.Up; } else if ((Position + IntVec3.South) == track.Position) { return Direction.Down; } else if ((Position + IntVec3.East) == track.Position) { return Direction.Right; } else if ((Position + IntVec3.West) == track.Position) { return Direction.Left; } return Direction.Invalid; } return Direction.Invalid; }
private void StartNewMove() { if (CurTrack.HasValidPath && !CurTrack.ShouldStopCart) { destination = CurTrack.NextTrack(direction, previousTrack); if (destination != null && destination.CanBeTravelledTo) { SetupNewMove(); previousTrack = CurTrack; direction = CurTrack.DirectionTo(destination); if (Direction != Direction.Any && Direction != Direction.Invalid) { moving = true; } } } }
private void MoveTo(Track track) { previousTrack = CurTrack; cart.Position = track.Position; moving = false; ticksUntilMove = 0; }
public virtual void StopDead() { moving = false; ticksUntilMove = 1; totalMoveDuration = 1; destination = null; previousTrack = null; }