Skip to content

Commit

Permalink
fixed item entity bouncing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj42 committed Aug 18, 2020
1 parent adb2459 commit 52dac08
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions core/server/src/miniventure/game/world/level/ServerLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,16 @@ public void dropItem(@NotNull final ServerItem item, boolean delayPickup, @NotNu
dropPos.x = itemBounds.x;
dropPos.y = itemBounds.y;

Vector2 dropDir;
boolean freeSecond = false;
if(targetPos == null) {
dropDir = VectorPool.POOL.obtain(0, 0).setToRandomDirection();
freeSecond = true;
}
else
dropDir = targetPos.sub(dropPos);
Vector2 dropDir = null;
if(targetPos != null)
dropDir = targetPos.sub(dropPos).nor(); // FIXME normalize to prevent crazy bouncing; need to find out why that happens

getWorld().cancelIdReservation(ie);
ItemEntity nie = new ItemEntity(getWorld(), item, dropDir, delayPickup);

nie.moveTo(dropPos, free);
if(free || freeSecond) VectorPool.POOL.free(dropDir);
if(free && targetPos != null)
VectorPool.POOL.free(targetPos);
RectPool.POOL.free(itemBounds);
RectPool.POOL.free(closestBounds);
addEntity(nie);
Expand Down

0 comments on commit 52dac08

Please sign in to comment.