first look at separating Entity and Location

This commit is contained in:
Dylan K. Taylor
2019-08-19 17:20:34 +01:00
parent 591d35889e
commit 2d4a32fc77
36 changed files with 302 additions and 257 deletions

View File

@ -174,12 +174,14 @@ class Explosion{
$explosionBB = new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
/** @var Entity[] $list */
$list = $this->world->getNearbyEntities($explosionBB, $this->what instanceof Entity ? $this->what : null);
foreach($list as $entity){
$distance = $entity->distance($this->source) / $explosionSize;
$entityPos = $entity->getPosition();
$distance = $entityPos->distance($this->source) / $explosionSize;
if($distance <= 1){
$motion = $entity->subtract($this->source)->normalize();
$motion = $entityPos->subtract($this->source)->normalize();
$impact = (1 - $distance) * ($exposure = 1);