Changeset 106 for trunk/UTrack.pas


Ignore:
Timestamp:
Oct 4, 2022, 3:40:36 PM (20 months ago)
Author:
chronos
Message:
  • Added: Show train direction before placement on track.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTrack.pas

    r93 r106  
    1818    BaseTrackPoint: TTrackPoint;
    1919    RelPos: Double;
     20    function GetTrackPosition: Integer;
    2021    function GetVector: TVector;
    2122    procedure Move(Distance: Double);
     
    4344    function GetLinkDown: TTrackLink;
    4445    function GetLinkUp: TTrackLink;
     46    function GetTrackPosition: Integer;
     47
    4548    // Move to TTrackLink later
    4649    function GetDistance: Integer;
     
    109112
    110113{ TTrackPosition }
     114
     115function TTrackPosition.GetTrackPosition: Integer;
     116begin
     117  Result := Round(RelPos);
     118  if Assigned(BaseTrackPoint) then
     119    Result := Result + BaseTrackPoint.GetTrackPosition;
     120end;
    111121
    112122function TTrackPosition.GetVector: TVector;
     
    411421end;
    412422
     423function TTrackPoint.GetTrackPosition: Integer;
     424var
     425  Index: Integer;
     426  I: Integer;
     427begin
     428  Result := 0;
     429  Index := Track.Points.IndexOf(Self);
     430  for I := 0 to Index - 1 do
     431    Result := Result + Track.Points[I].GetDistance;
     432end;
     433
    413434function TTrackPoint.GetDistance: Integer;
    414435var
Note: See TracChangeset for help on using the changeset viewer.