New mech drowning algorithm

This commit is contained in:
Anuken
2021-08-22 15:41:03 -04:00
parent 4e12289eaa
commit 502816d210
3 changed files with 19 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
@@ -62,6 +63,21 @@ abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, Elevati
walkExtension = extendScl;
}
@Replace
@Override
public @Nullable Floor drownFloor(){
//large mechs can only drown when all the nearby floors are deep
if(hitSize >= 12 && canDrown()){
for(Point2 p : Geometry.d8){
Floor f = world.floorWorld(x + p.x * tilesize, y + p.y * tilesize);
if(!f.isDeep()){
return null;
}
}
}
return canDrown() ? floorOn() : null;
}
public float walkExtend(boolean scaled){
//now ranges from -maxExtension to maxExtension*3