mirror of
https://github.com/solcloud/Counter-Strike.git
synced 2025-02-24 03:42:39 +01:00
Few method call avoid
This commit is contained in:
parent
85224194d0
commit
4e72ee56df
@ -110,7 +110,7 @@ final class Backtrack
|
||||
$states[] = $i;
|
||||
}
|
||||
if ($states === []) {
|
||||
$states[] = 0;
|
||||
return [0];
|
||||
}
|
||||
return $states;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class Bullet
|
||||
{
|
||||
|
||||
private Point $origin;
|
||||
private Point $position;
|
||||
public Point $position;
|
||||
private int $originPlayerId;
|
||||
private bool $originPlayerIsAttacker;
|
||||
private int $distanceTraveled;
|
||||
|
@ -31,7 +31,10 @@ class Collision
|
||||
|
||||
public static function pointWithSphere(Point $point, Point $sphereCenter, int $sphereRadius): bool
|
||||
{
|
||||
return Util::distanceSquared($point, $sphereCenter) <= $sphereRadius * $sphereRadius;
|
||||
$dx = $point->x - $sphereCenter->x;
|
||||
$dy = $point->y - $sphereCenter->y;
|
||||
$dz = $point->z - $sphereCenter->z;
|
||||
return (($dx * $dx) + ($dy * $dy) + ($dz * $dz)) <= ($sphereRadius * $sphereRadius);
|
||||
}
|
||||
|
||||
public static function cylinderWithCylinder(
|
||||
|
@ -95,9 +95,9 @@ class HitBox implements Hittable
|
||||
return $armorDamage;
|
||||
}
|
||||
|
||||
public function intersect(Bullet $bullet): bool
|
||||
public function intersect(Point $point): bool
|
||||
{
|
||||
return $this->geometry->intersect($this->player, $bullet->getPosition());
|
||||
return $this->geometry->intersect($this->player, $point);
|
||||
}
|
||||
|
||||
public function getPlayer(): Player
|
||||
|
@ -34,7 +34,7 @@ class PlayerCollider
|
||||
|
||||
public function tryHitPlayer(Bullet $bullet, Backtrack $backtrack): ?Hittable
|
||||
{
|
||||
$bp = $bullet->getPosition();
|
||||
$bp = $bullet->position;
|
||||
foreach ($backtrack->getStates() as $state) {
|
||||
$backtrack->apply($state, $this->playerId);
|
||||
|
||||
@ -48,7 +48,7 @@ class PlayerCollider
|
||||
}
|
||||
|
||||
foreach ($this->hitBoxes as $hitBox) {
|
||||
if ($hitBox->intersect($bullet)) {
|
||||
if ($hitBox->intersect($bp)) {
|
||||
$hitBox->registerHit($bullet);
|
||||
return $hitBox;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user