Disable naval units on ground / Mobile payload input

This commit is contained in:
Anuken
2020-08-17 16:15:51 -04:00
parent 9a48028508
commit 7ecf5aa26d
11 changed files with 83 additions and 32 deletions

View File

@@ -73,7 +73,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc{
Fx.unitDrop.at(this);
//can't drop ground units
if((tileOn() == null || tileOn().solid()) && u.elevation < 0.1f){
if(((tileOn() == null || tileOn().solid()) && u.elevation < 0.1f) || (!floorOn().isLiquid && u instanceof WaterMovec)){
return false;
}

View File

@@ -35,6 +35,20 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
}
}
@Override
@Replace
public void lookAt(float angle){
if(onLiquid()){
rotation = Angles.moveToward(rotation, angle, type.rotateSpeed * Time.delta);
}
}
@Override
@Replace
public boolean canShoot(){
return onLiquid();
}
@Override
public void add(){
tleft.clear();
@@ -79,5 +93,9 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
Floor on = isFlying() ? Blocks.air.asFloor() : floorOn();
return on.isDeep() ? 1.3f : 1f;
}
public boolean onLiquid(){
return floorOn().isLiquid;
}
}

View File

@@ -76,9 +76,15 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
aimY = y;
}
boolean canShoot(){
return true;
}
/** Update shooting and rotation for this unit. */
@Override
public void update(){
boolean can = canShoot();
for(WeaponMount mount : mounts){
Weapon weapon = mount.weapon;
mount.reload = Math.max(mount.reload - Time.delta * reloadMultiplier, 0);
@@ -91,7 +97,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
}
//rotate if applicable
if(weapon.rotate && (mount.rotate || mount.shoot)){
if(weapon.rotate && (mount.rotate || mount.shoot) && can){
float axisX = this.x + Angles.trnsx(rotation - 90, weapon.x, weapon.y),
axisY = this.y + Angles.trnsy(rotation - 90, weapon.x, weapon.y);
@@ -104,6 +110,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
//shoot if applicable
if(mount.shoot && //must be shooting
can && //must be able to shoot
(ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo) && //check ammo
(!weapon.alternate || mount.side == weapon.flipSprite) &&
vel.len() >= mount.weapon.minShootVelocity && //check velocity requirements