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