Skip to content

Commit

Permalink
Tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
solcloud committed Oct 22, 2022
1 parent 479854a commit 891bbe5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/src/Traits/Player/GravityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ private function calculateGravity(Point $start, int $amount): int
$candidate->setY($y);
$floorCandidate = $this->world->findFloor($candidate, $this->getBoundingRadius());
if ($floorCandidate) {
$sound = new SoundEvent($this->getPositionImmutable()->setY($y), SoundType::PLAYER_GROUND_TOUCH);
$this->world->makeSound($sound->setPlayer($this)->setSurface($floorCandidate));
$this->setActiveFloor($floorCandidate);
$targetYPosition = $y;
break;
Expand All @@ -47,24 +45,31 @@ private function calculateGravity(Point $start, int $amount): int
break;
}
}

return $targetYPosition;
}

private function setActiveFloor(?Floor $floor): void
{
$this->activeFloor = $floor;
if ($floor) {
$this->checkFallDamage($floor->getY());
$this->checkFallDamage($floor);
$this->removeEvent($this->eventIdJump);
$this->fallHeight = 0;
} else {
$this->fallHeight = $this->position->y;
}
}

private function checkFallDamage(int $floorHeight): void
private function checkFallDamage(Floor $floor): void
{
$floorHeight = $floor->getY();
$fallHeight = $this->fallHeight - $floorHeight;
if ($fallHeight > 3 * Setting::playerObstacleOvercomeHeight()) {
$sound = new SoundEvent($this->getPositionImmutable()->setY($floorHeight), SoundType::PLAYER_GROUND_TOUCH);
$this->world->makeSound($sound->setPlayer($this)->setSurface($floor));
}

$threshold = Setting::playerFallDamageThreshold();
if ($fallHeight < $threshold) {
return;
Expand Down

0 comments on commit 891bbe5

Please sign in to comment.