From 1002a7400115b36d80ab9f040b42b00cedc843a7 Mon Sep 17 00:00:00 2001 From: Torwent Date: Tue, 31 Aug 2021 12:40:04 +0200 Subject: [PATCH] Move all mm2ms minimap code to mm2ms file #patch --- osr/interface/minimap.simba | 240 ----------------------------------- osr/mm2ms.simba | 241 ++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 240 deletions(-) diff --git a/osr/interface/minimap.simba b/osr/interface/minimap.simba index de28ae44..288fb00e 100644 --- a/osr/interface/minimap.simba +++ b/osr/interface/minimap.simba @@ -130,246 +130,6 @@ end; -function TRSMinimap.GetTileMS(Loc: TPoint; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TRectangle; -begin - if not Self.IsPointOn(Loc) then - Exit; - - if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); - - Result := Self.VecToMSRect( - Vec3(Loc.x - Offset.X, Loc.y - Offset.Y, TileVector.Z), - TileVector.X, TileVector.Y, Angle); -end; - -function TRSMinimap.GetTileMS(Loc: TPoint; Z: Double = 0): TRectangle; overload; -begin - Result := Self.GetTileMS(Loc, [1, 1, Z]); -end; - - - -function TRSMinimap.GetTilePoly(Loc: TPoint; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TPoly; -var - Rect: TRectangle; -begin - if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); - - Rect := Self.GetTileMS(Loc, [TileVector.Y, TileVector.X, 0], Offset, Angle); - - if TileVector.Z = 0 then - Result := Rect.ToTPA - else - Result := Rect.GetPoly(Self.GetTileMS(Loc, TileVector, Offset, Angle)); -end; - -function TRSMinimap.GetTilePoly(Loc: TPoint; Z: Double = 0): TPoly; overload; -begin - Result := Self.GetTilePoly(Loc, [1, 1, Z]); -end; - - - -function TRSMinimap.GetTileArrayMS(LocArray: TPointArray; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TRectArray; -var - Loc: TPoint; -begin - if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); - - for Loc in LocArray.Sorted(Self.Center) do - Result += Self.GetTileMS(Loc, TileVector, Offset, Angle); -end; - -function TRSMinimap.GetTileArrayMS(LocArray: TPointArray; Z: Double = 0): TRectArray; overload; -begin - Result := Self.GetTileArrayMS(LocArray, [1, 1, Z]); -end; - - - -function TRSMinimap.GetTileArrayPolys(LocArray: TPointArray; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TPolyArray; -var - Loc: TPoint; -begin - if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); - - for Loc in LocArray do - Result += Self.GetTilePoly(Loc, TileVector, Offset, Angle); -end; - -function TRSMinimap.GetTileArrayPolys(LocArray: TPointArray; Z: Double = 0): TPolyArray; overload; -begin - Result := Self.GetTileArrayPolys(LocArray, [1, 1, Z]); -end; - - - -//Get a radius in the minimap -function TRSMinimap.GetRadius(Loc: TPoint; Offset: TPoint; Radius: Int32): TCircle; -begin - if (Self.Center.DistanceTo((Loc - Offset)) - Radius) > 80 then - Exit; //This means it's impossible the result will be in the minimap. - - Loc := Loc - Offset; - Result := [Loc.X, Loc.Y, Radius * 4]; -end; - -function TRSMinimap.GetRadius(Loc: TPoint; Radius: Int32): TCircle; overload; -begin - Result := Self.GetRadius(Loc, [0, 0], Radius); -end; - -//Get several radius in the minimap -function TRSMinimap.GetRadiuses(Locs: TPointArray; Offset: TPoint; Radius: Int32): TCircleArray; -var - Loc: TPoint; -begin - for Loc in Locs do - Result += Self.GetRadius(Loc, Offset, Radius); -end; - -function TRSMinimap.GetRadiuses(Loc: TPointArray; Radius: Int32): TCircleArray; overload; -begin - Result := Self.GetRadiuses(Loc, [0, 0], Radius); -end; - - - -//Get the first dot within a radius. -function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Loc, Offset: TPoint; Radius: Int32): TPoint; -var - i: Int32; - Dots: TPointArray; - Circle: TCircle; -begin - Dots := Self.GetDots(Dot); - - Dots.Sort(Self.Center); - - Circle := Self.GetRadius(Loc, Offset, Radius); - for i := 0 to High(Dots) do - if SRL.PointInCircle(Dots[i], Circle.Mean, Circle.Radius) then - Exit(Dots[i]); -end; - -function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32): TPoint; overload; -begin - Result := Self.GetDotInRadius(Dot, Loc, [0, 0], Radius); -end; - -//Get all first dots withing several radius. -function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Locs: TPointArray; Offset: TPoint; Radius: Int32): TPointArray; overload; -var - Loc: TPoint; -begin - for Loc in Locs do - Result += Self.GetDotInRadius(Dot, Loc, Offset, Radius); -end; - -function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32): TPointArray; overload; -begin - Result := Self.GetDotInRadius(Dot, Locs, [0, 0], Radius); -end; - - - -//Get all dots within a radius. -function TRSMinimap.GetDotArrayInRadius(Dot: ERSMinimapDot; Loc, Offset: TPoint; Radius: Int32): TPointArray; -var - i: Int32; - Dots: TPointArray; - Circle: TCircle; -begin - Dots := Self.GetDots(Dot); - - Dots.Sort(Self.Center); - - Circle := Self.GetRadius(Loc, Offset, Radius); - for i := 0 to High(Dots) do - if SRL.PointInCircle(Dots[i], Circle.Mean, Circle.Radius) then - Result += Dots[i]; -end; - -function TRSMinimap.GetDotArrayInRadius(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32): TPointArray; overload; -begin - Result := Self.GetDotArrayInRadius(Dot, Loc, [0, 0], Radius); -end; - -//Get all dots within several radius. -function TRSMinimap.GetDotArrayInRadiuses(Dot: ERSMinimapDot; Locs: TPointArray; Offset: TPoint; Radius: Int32): TPointArray; -var - i: Int32; - ATPA: T2DPointArray; -begin - for i := 0 to High(Locs) do - ATPA += Self.GetDotArrayInRadius(Dot, Locs[i], Offset, Radius); - - Result := ATPA.Merge; - - Result.Sort(Self.Center); -end; - -function TRSMinimap.GetDotArrayInRadiuses(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32): TPointArray; overload; -begin - Result := Self.GetDotArrayInRadiuses(Dot, Locs, [0, 0], Radius); -end; - - -//Get the closest dot tile within a radius -function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectangle; -begin - Result := Self.GetTileMS( - Self.GetDotInRadius(Dot, Loc, RadiusOffset, Radius), - TileVector, Offset, $FFFF); -end; - -function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; Z: Double = 0): TRectangle; overload; -begin - Result := Self.GetDotTileMS(Dot, Loc, Radius, [1, 1, Z]); -end; - - -//Get the closest dot tile within several radius -function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; overload; -begin - Result := Self.GetTileArrayMS(Self.GetDotInRadius(Dot, Locs, RadiusOffset, Radius), - TileVector, Offset, $FFFF); -end; - -function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; Z: Double = 0): TRectArray; overload; -begin - Result := Self.GetDotTileMS(Dot, Locs, Radius, [1, 1, Z]); -end; - - -//Get all dot tiles within a radius -function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; -begin - Result := Self.GetTileArrayMS( - Self.GetDotArrayInRadius(Dot, Loc, RadiusOffset, Radius), - TileVector, Offset, $FFFF); -end; - -function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; Z: Double = 0): TRectArray; overload; -begin - Result := Self.GetDotArrayTilesMS(Dot, Loc, Radius, [1, 1, Z]); -end; - - -//Get all dot tiles within several radius -function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; overload; -begin - Result := Self.GetTileArrayMS( - Self.GetDotArrayInRadiuses(Dot, Locs, RadiusOffset, Radius), - TileVector, Offset, $FFFF); -end; - -function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; Z: Double = 0): TRectArray; overload; -begin - Result := Self.GetDotArrayTilesMS(Dot, Locs, Radius, [1, 1, Z]); -end; - - diff --git a/osr/mm2ms.simba b/osr/mm2ms.simba index 6958a9c4..127a61dc 100644 --- a/osr/mm2ms.simba +++ b/osr/mm2ms.simba @@ -82,3 +82,244 @@ begin end; + +function TRSMinimap.GetTileMS(Loc: TPoint; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TRectangle; +begin + if not Self.IsPointOn(Loc) then + Exit; + + if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); + + Result := Self.VecToMSRect( + Vec3(Loc.x - Offset.X, Loc.y - Offset.Y, TileVector.Z), + TileVector.X, TileVector.Y, Angle); +end; + +function TRSMinimap.GetTileMS(Loc: TPoint; Z: Double = 0): TRectangle; overload; +begin + Result := Self.GetTileMS(Loc, [1, 1, Z]); +end; + + + +function TRSMinimap.GetTilePoly(Loc: TPoint; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TPoly; +var + Rect: TRectangle; +begin + if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); + + Rect := Self.GetTileMS(Loc, [TileVector.Y, TileVector.X, 0], Offset, Angle); + + if TileVector.Z = 0 then + Result := Rect.ToTPA + else + Result := Rect.GetPoly(Self.GetTileMS(Loc, TileVector, Offset, Angle)); +end; + +function TRSMinimap.GetTilePoly(Loc: TPoint; Z: Double = 0): TPoly; overload; +begin + Result := Self.GetTilePoly(Loc, [1, 1, Z]); +end; + + + +function TRSMinimap.GetTileArrayMS(LocArray: TPointArray; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TRectArray; +var + Loc: TPoint; +begin + if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); + + for Loc in LocArray.Sorted(Self.Center) do + Result += Self.GetTileMS(Loc, TileVector, Offset, Angle); +end; + +function TRSMinimap.GetTileArrayMS(LocArray: TPointArray; Z: Double = 0): TRectArray; overload; +begin + Result := Self.GetTileArrayMS(LocArray, [1, 1, Z]); +end; + + + +function TRSMinimap.GetTileArrayPolys(LocArray: TPointArray; TileVector: Vector3; Offset: TPoint = [0, 0]; Angle: Single = $FFFF): TPolyArray; +var + Loc: TPoint; +begin + if (Angle = $FFFF) then Angle := Self.GetCompassAngle(False); + + for Loc in LocArray do + Result += Self.GetTilePoly(Loc, TileVector, Offset, Angle); +end; + +function TRSMinimap.GetTileArrayPolys(LocArray: TPointArray; Z: Double = 0): TPolyArray; overload; +begin + Result := Self.GetTileArrayPolys(LocArray, [1, 1, Z]); +end; + + + +//Get a radius in the minimap +function TRSMinimap.GetRadius(Loc: TPoint; Offset: TPoint; Radius: Int32): TCircle; +begin + if (Self.Center.DistanceTo((Loc - Offset)) - Radius) > 80 then + Exit; //This means it's impossible the result will be in the minimap. + + Loc := Loc - Offset; + Result := [Loc.X, Loc.Y, Radius * 4]; +end; + +function TRSMinimap.GetRadius(Loc: TPoint; Radius: Int32): TCircle; overload; +begin + Result := Self.GetRadius(Loc, [0, 0], Radius); +end; + +//Get several radius in the minimap +function TRSMinimap.GetRadiuses(Locs: TPointArray; Offset: TPoint; Radius: Int32): TCircleArray; +var + Loc: TPoint; +begin + for Loc in Locs do + Result += Self.GetRadius(Loc, Offset, Radius); +end; + +function TRSMinimap.GetRadiuses(Loc: TPointArray; Radius: Int32): TCircleArray; overload; +begin + Result := Self.GetRadiuses(Loc, [0, 0], Radius); +end; + + + +//Get the first dot within a radius. +function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Loc, Offset: TPoint; Radius: Int32): TPoint; +var + i: Int32; + Dots: TPointArray; + Circle: TCircle; +begin + Dots := Self.GetDots(Dot); + + Dots.Sort(Self.Center); + + Circle := Self.GetRadius(Loc, Offset, Radius); + for i := 0 to High(Dots) do + if SRL.PointInCircle(Dots[i], Circle.Mean, Circle.Radius) then + Exit(Dots[i]); +end; + +function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32): TPoint; overload; +begin + Result := Self.GetDotInRadius(Dot, Loc, [0, 0], Radius); +end; + +//Get all first dots withing several radius. +function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Locs: TPointArray; Offset: TPoint; Radius: Int32): TPointArray; overload; +var + Loc: TPoint; +begin + for Loc in Locs do + Result += Self.GetDotInRadius(Dot, Loc, Offset, Radius); +end; + +function TRSMinimap.GetDotInRadius(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32): TPointArray; overload; +begin + Result := Self.GetDotInRadius(Dot, Locs, [0, 0], Radius); +end; + + + +//Get all dots within a radius. +function TRSMinimap.GetDotArrayInRadius(Dot: ERSMinimapDot; Loc, Offset: TPoint; Radius: Int32): TPointArray; +var + i: Int32; + Dots: TPointArray; + Circle: TCircle; +begin + Dots := Self.GetDots(Dot); + + Dots.Sort(Self.Center); + + Circle := Self.GetRadius(Loc, Offset, Radius); + for i := 0 to High(Dots) do + if SRL.PointInCircle(Dots[i], Circle.Mean, Circle.Radius) then + Result += Dots[i]; +end; + +function TRSMinimap.GetDotArrayInRadius(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32): TPointArray; overload; +begin + Result := Self.GetDotArrayInRadius(Dot, Loc, [0, 0], Radius); +end; + +//Get all dots within several radius. +function TRSMinimap.GetDotArrayInRadiuses(Dot: ERSMinimapDot; Locs: TPointArray; Offset: TPoint; Radius: Int32): TPointArray; +var + i: Int32; + ATPA: T2DPointArray; +begin + for i := 0 to High(Locs) do + ATPA += Self.GetDotArrayInRadius(Dot, Locs[i], Offset, Radius); + + Result := ATPA.Merge; + + Result.Sort(Self.Center); +end; + +function TRSMinimap.GetDotArrayInRadiuses(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32): TPointArray; overload; +begin + Result := Self.GetDotArrayInRadiuses(Dot, Locs, [0, 0], Radius); +end; + + +//Get the closest dot tile within a radius +function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectangle; +begin + Result := Self.GetTileMS( + Self.GetDotInRadius(Dot, Loc, RadiusOffset, Radius), + TileVector, Offset, $FFFF); +end; + +function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; Z: Double = 0): TRectangle; overload; +begin + Result := Self.GetDotTileMS(Dot, Loc, Radius, [1, 1, Z]); +end; + + +//Get the closest dot tile within several radius +function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; overload; +begin + Result := Self.GetTileArrayMS(Self.GetDotInRadius(Dot, Locs, RadiusOffset, Radius), + TileVector, Offset, $FFFF); +end; + +function TRSMinimap.GetDotTileMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; Z: Double = 0): TRectArray; overload; +begin + Result := Self.GetDotTileMS(Dot, Locs, Radius, [1, 1, Z]); +end; + + +//Get all dot tiles within a radius +function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; +begin + Result := Self.GetTileArrayMS( + Self.GetDotArrayInRadius(Dot, Loc, RadiusOffset, Radius), + TileVector, Offset, $FFFF); +end; + +function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Loc: TPoint; Radius: Int32; Z: Double = 0): TRectArray; overload; +begin + Result := Self.GetDotArrayTilesMS(Dot, Loc, Radius, [1, 1, Z]); +end; + + +//Get all dot tiles within several radius +function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; TileVector: Vector3; Offset, RadiusOffset: TPoint = [0, 0]): TRectArray; overload; +begin + Result := Self.GetTileArrayMS( + Self.GetDotArrayInRadiuses(Dot, Locs, RadiusOffset, Radius), + TileVector, Offset, $FFFF); +end; + +function TRSMinimap.GetDotArrayTilesMS(Dot: ERSMinimapDot; Locs: TPointArray; Radius: Int32; Z: Double = 0): TRectArray; overload; +begin + Result := Self.GetDotArrayTilesMS(Dot, Locs, Radius, [1, 1, Z]); +end; + +