mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-10 04:40:10 +07:00
Fixed units sometimes exploding when payload dropped
This commit is contained in:
parent
830fcb6360
commit
51b415731a
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user