-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1979 from Wotuu/development
Release v7.0 - Classic dungeon support, phase 1
- Loading branch information
Showing
408 changed files
with
59,644 additions
and
1,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
namespace App\Logic\Structs; | ||
|
||
use App\Models\Floor; | ||
|
||
class IngameXY | ||
{ | ||
private float $x; | ||
|
||
private float $y; | ||
|
||
private ?Floor $floor; | ||
|
||
private ?LatLng $latLng = null; | ||
|
||
/** | ||
* @param float $x | ||
* @param float $y | ||
* @param Floor|null $floor | ||
*/ | ||
public function __construct(float $x = 0, float $y = 0, ?Floor $floor = null) | ||
{ | ||
$this->x = $x; | ||
$this->y = $y; | ||
$this->floor = $floor; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getX(): float | ||
{ | ||
return $this->x; | ||
} | ||
|
||
/** | ||
* @param float $x | ||
* | ||
* @return IngameXY | ||
*/ | ||
public function setX(float $x): IngameXY | ||
{ | ||
$this->x = $x; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getY(): float | ||
{ | ||
return $this->y; | ||
} | ||
|
||
/** | ||
* @param float $y | ||
* | ||
* @return IngameXY | ||
*/ | ||
public function setY(float $y): IngameXY | ||
{ | ||
$this->y = $y; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return Floor|null | ||
*/ | ||
public function getFloor(): ?Floor | ||
{ | ||
return $this->floor; | ||
} | ||
|
||
/** | ||
* @param Floor|null $floor | ||
* | ||
* @return IngameXY | ||
*/ | ||
public function setFloor(?Floor $floor): IngameXY | ||
{ | ||
$this->floor = $floor; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return LatLng | ||
*/ | ||
public function getLatLng(): ?LatLng | ||
{ | ||
return $this->latLng ?? ($this->latLng = $this->calculateLatLng()); | ||
} | ||
|
||
/** | ||
* @return LatLng|null | ||
*/ | ||
private function calculateLatLng(): ?LatLng | ||
{ | ||
$result = null; | ||
|
||
if ($this->floor !== null) { | ||
$latLng = $this->floor->calculateMapLocationForIngameLocation( | ||
$this->x, | ||
$this->y | ||
); | ||
$result = LatLng::fromArray($latLng, $this->floor); | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @param array $ingameXY | ||
* @param Floor|null $floor | ||
* | ||
* @return IngameXY | ||
*/ | ||
public static function fromArray(array $ingameXY, ?Floor $floor): IngameXY | ||
{ | ||
return new IngameXY($ingameXY['x'], $ingameXY['y'], $floor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
namespace App\Logic\Structs; | ||
|
||
use App\Models\Floor; | ||
|
||
class LatLng | ||
{ | ||
private float $lat; | ||
|
||
private float $lng; | ||
|
||
private ?Floor $floor; | ||
|
||
private ?IngameXY $ingameXY = null; | ||
|
||
/** | ||
* @param float $lat | ||
* @param float $lng | ||
* @param Floor|null $floor | ||
*/ | ||
public function __construct(float $lat = 0, float $lng = 0, ?Floor $floor = null) | ||
{ | ||
$this->lat = $lat; | ||
$this->lng = $lng; | ||
$this->floor = $floor; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getLat(): float | ||
{ | ||
return $this->lat; | ||
} | ||
|
||
/** | ||
* @param float $lat | ||
* | ||
* @return LatLng | ||
*/ | ||
public function setLat(float $lat): LatLng | ||
{ | ||
$this->lat = $lat; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getLng(): float | ||
{ | ||
return $this->lng; | ||
} | ||
|
||
/** | ||
* @param float $lng | ||
* | ||
* @return LatLng | ||
*/ | ||
public function setLng(float $lng): LatLng | ||
{ | ||
$this->lng = $lng; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return Floor|null | ||
*/ | ||
public function getFloor(): ?Floor | ||
{ | ||
return $this->floor; | ||
} | ||
|
||
/** | ||
* @param Floor|null $floor | ||
* | ||
* @return LatLng | ||
*/ | ||
public function setFloor(?Floor $floor): LatLng | ||
{ | ||
$this->floor = $floor; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return IngameXY|null | ||
*/ | ||
public function getIngameXY(): ?IngameXY | ||
{ | ||
return $this->ingameXY ?? ($this->ingameXY = $this->calculateIngameCoordinates()); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function calculateIngameCoordinates(): ?IngameXY | ||
{ | ||
$result = null; | ||
|
||
if ($this->floor !== null) { | ||
$ingameXY = $this->floor->calculateIngameLocationForMapLocation( | ||
$this->lat, | ||
$this->lng | ||
); | ||
|
||
$result = IngameXY::fromArray($ingameXY, $this->floor); | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @param array $latLng | ||
* @param Floor|null $floor | ||
* | ||
* @return LatLng | ||
*/ | ||
public static function fromArray(array $latLng, ?Floor $floor): LatLng | ||
{ | ||
return new LatLng($latLng['lat'], $latLng['lng'], $floor); | ||
} | ||
} |
Oops, something went wrong.