mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-16 10:47:40 +07:00
Fixed units sometimes exploding when payload dropped
This commit is contained in:
@ -148,9 +148,12 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
|||||||
boolean dropUnit(UnitPayload payload){
|
boolean dropUnit(UnitPayload payload){
|
||||||
Unit u = payload.unit;
|
Unit u = payload.unit;
|
||||||
|
|
||||||
|
//add random offset to prevent unit stacking
|
||||||
|
Tmp.v1.rnd(Mathf.random(2f));
|
||||||
|
|
||||||
//can't drop ground units
|
//can't drop ground units
|
||||||
//allow stacking for small units for now - otherwise, unit transfer would get annoying
|
//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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +162,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
|||||||
//clients do not drop payloads
|
//clients do not drop payloads
|
||||||
if(Vars.net.client()) return true;
|
if(Vars.net.client()) return true;
|
||||||
|
|
||||||
u.set(this);
|
u.set(x + Tmp.v1.x, y + Tmp.v1.y);
|
||||||
u.trns(Tmp.v1.rnd(Mathf.random(2f)));
|
|
||||||
u.rotation(rotation);
|
u.rotation(rotation);
|
||||||
//reset the ID to a new value to make sure it's synced
|
//reset the ID to a new value to make sure it's synced
|
||||||
u.id = EntityGroup.nextId();
|
u.id = EntityGroup.nextId();
|
||||||
|
Reference in New Issue
Block a user