From 51b415731af62f118c8c958b4f48b7bfcdad3145 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 22 Sep 2024 08:58:09 -0400 Subject: [PATCH] Fixed units sometimes exploding when payload dropped --- core/src/mindustry/entities/comp/PayloadComp.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/entities/comp/PayloadComp.java b/core/src/mindustry/entities/comp/PayloadComp.java index 0122166c94..38b2dcd429 100644 --- a/core/src/mindustry/entities/comp/PayloadComp.java +++ b/core/src/mindustry/entities/comp/PayloadComp.java @@ -148,9 +148,12 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{ boolean dropUnit(UnitPayload payload){ Unit u = payload.unit; + //add random offset to prevent unit stacking + Tmp.v1.rnd(Mathf.random(2f)); + //can't drop ground units //allow stacking for small units for now - otherwise, unit transfer would get annoying - if(!u.canPass(tileX(), tileY()) || Units.count(x, y, u.physicSize(), o -> o.isGrounded() && o.hitSize > 14f) > 1){ + if(!u.canPass(World.toTile(x + Tmp.v1.x), World.toTile(y + Tmp.v1.y)) || Units.count(x, y, u.physicSize(), o -> o.isGrounded() && o.hitSize > 14f) > 1){ return false; } @@ -159,8 +162,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{ //clients do not drop payloads if(Vars.net.client()) return true; - u.set(this); - u.trns(Tmp.v1.rnd(Mathf.random(2f))); + u.set(x + Tmp.v1.x, y + Tmp.v1.y); u.rotation(rotation); //reset the ID to a new value to make sure it's synced u.id = EntityGroup.nextId();