Disable naval units on ground / Mobile payload input
This commit is contained in:
@@ -26,20 +26,13 @@ public class GroundAI extends AIController{
|
||||
}
|
||||
}
|
||||
|
||||
boolean rotate = false, shoot = false;
|
||||
|
||||
if(!Units.invalidateTarget(target, unit, unit.range())){
|
||||
rotate = true;
|
||||
shoot = unit.within(target, unit.range());
|
||||
|
||||
if(unit.type().hasWeapons()){
|
||||
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
|
||||
}
|
||||
}else if(unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
|
||||
unit.controlWeapons(rotate, shoot);
|
||||
}
|
||||
|
||||
protected void moveToCore(FlagTarget path){
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -464,7 +464,7 @@ public class LoadRenderer implements Disposable{
|
||||
Font font = assets.get("tech");
|
||||
font.setColor(Pal.accent);
|
||||
Draw.color(Color.black);
|
||||
font.draw(red + "[[[[ " +key + " ]]\n\n"+orange+"<" + Version.modifier + " " + (Version.build == 0 ? " [init]" : Version.build == -1 ? " custom" : " " + Version.build) + ">", w/2f, h/2f + 110*s, Align.center);
|
||||
font.draw(red + "[[[[ " + key + " ]]\n"+orange+"<" + Version.modifier + " " + (Version.build == 0 ? " [init]" : Version.build == -1 ? " custom" : " " + Version.build) + ">", w/2f, h/2f + 110*s, Align.center);
|
||||
}
|
||||
|
||||
Lines.precise(false);
|
||||
|
||||
@@ -13,7 +13,6 @@ import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
@@ -619,22 +618,12 @@ public class DesktopInput extends InputHandler{
|
||||
if(unit instanceof Payloadc){
|
||||
Payloadc pay = (Payloadc)unit;
|
||||
|
||||
if(Core.input.keyTap(Binding.pickupCargo) && pay.payloads().size < unit.type().payloadCapacity){
|
||||
Unit target = Units.closest(player.team(), pay.x(), pay.y(), unit.type().hitsize * 2.5f, u -> u.isAI() && u.isGrounded() && u.mass() < unit.mass() && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
if(target != null){
|
||||
Call.pickupUnitPayload(player, target);
|
||||
}else if(!pay.hasPayload()){
|
||||
Building tile = world.buildWorld(pay.x(), pay.y());
|
||||
|
||||
if(tile != null && tile.team == unit.team){
|
||||
Call.pickupBlockPayload(player, tile);
|
||||
}
|
||||
}
|
||||
if(Core.input.keyTap(Binding.pickupCargo)){
|
||||
tryPickupPayload();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.dropCargo)){
|
||||
Call.dropPayload(player, player.x, player.y);
|
||||
pay.dropLastPayload();
|
||||
tryDropPayload();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}else if(unit == null){ //just clear the unit (is this used?)
|
||||
player.clearUnit();
|
||||
//make sure it's AI controlled, so players can't overwrite each other
|
||||
}else if(unit.isAI() && unit.team == player.team() && !unit.deactivated){
|
||||
}else if(unit.isAI() && unit.team == player.team() && !unit.deactivated()){
|
||||
player.unit(unit);
|
||||
Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x, unit.y, 0f, unit));
|
||||
if(!player.dead()){
|
||||
@@ -315,7 +315,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(controlledType != null && player.dead()){
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.deactivated);
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.deactivated());
|
||||
|
||||
if(unit != null){
|
||||
Call.unitControl(player, unit);
|
||||
@@ -325,7 +325,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
public void checkUnit(){
|
||||
if(controlledType != null){
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.deactivated);
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType && !u.deactivated());
|
||||
if(unit == null && controlledType == UnitTypes.block){
|
||||
unit = world.buildWorld(player.x, player.y) instanceof ControlBlock ? ((ControlBlock)world.buildWorld(player.x, player.y)).unit() : null;
|
||||
}
|
||||
@@ -340,6 +340,34 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
public void tryPickupPayload(){
|
||||
Unit unit = player.unit();
|
||||
if(!(unit instanceof Payloadc)) return;
|
||||
Payloadc pay = (Payloadc)unit;
|
||||
|
||||
if(pay.payloads().size >= unit.type().payloadCapacity) return;
|
||||
|
||||
Unit target = Units.closest(player.team(), pay.x(), pay.y(), unit.type().hitsize * 2.5f, u -> u.isAI() && u.isGrounded() && u.mass() < unit.mass() && u.within(unit, u.hitSize + unit.hitSize * 1.2f));
|
||||
if(target != null){
|
||||
Call.pickupUnitPayload(player, target);
|
||||
}else if(!pay.hasPayload()){
|
||||
Building tile = world.buildWorld(pay.x(), pay.y());
|
||||
|
||||
if(tile != null && tile.team == unit.team){
|
||||
Call.pickupBlockPayload(player, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tryDropPayload(){
|
||||
Unit unit = player.unit();
|
||||
if(!(unit instanceof Payloadc)) return;
|
||||
Payloadc pay = (Payloadc)unit;
|
||||
|
||||
Call.dropPayload(player, player.x, player.y);
|
||||
pay.dropLastPayload();
|
||||
}
|
||||
|
||||
public float getMouseX(){
|
||||
return Core.input.mouseX();
|
||||
}
|
||||
@@ -848,7 +876,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public @Nullable Unit selectedUnit(){
|
||||
Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, u -> u.isAI() && !u.deactivated);
|
||||
Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, u -> u.isAI() && !u.deactivated());
|
||||
if(unit != null){
|
||||
unit.hitbox(Tmp.r1);
|
||||
Tmp.r1.grow(6f);
|
||||
|
||||
@@ -572,9 +572,18 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
|
||||
//apply command on double tap
|
||||
if(count == 2 && Mathf.within(worldx, worldy, player.unit().x, player.unit().y, player.unit().hitSize * 2f) &&
|
||||
player.unit() instanceof Commanderc){
|
||||
Call.unitCommand(player);
|
||||
if(count == 2 && Mathf.within(worldx, worldy, player.unit().x, player.unit().y, player.unit().hitSize * 2f)){
|
||||
if(player.unit() instanceof Commanderc){
|
||||
Call.unitCommand(player);
|
||||
}
|
||||
|
||||
if(player.unit() instanceof Payloadc){
|
||||
if(((Payloadc)player.unit()).hasPayload()){
|
||||
tryDropPayload();
|
||||
}else{
|
||||
tryPickupPayload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,10 @@ public class Fonts{
|
||||
|
||||
Core.assets.load("tech", Font.class, new FreeTypeFontLoaderParameter("fonts/tech.ttf", new FreeTypeFontParameter(){{
|
||||
size = 18;
|
||||
}})).loaded = f -> Fonts.tech = (Font)f;
|
||||
}})).loaded = f -> {
|
||||
Fonts.tech = (Font)f;
|
||||
((Font)f).getData().down *= 1.5f;
|
||||
};
|
||||
}
|
||||
|
||||
/** Merges the UI and font atlas together for better performance. */
|
||||
|
||||
@@ -342,6 +342,7 @@ public class ResearchDialog extends BaseDialog{
|
||||
|
||||
((TextureRegionDrawable)button.getStyle().imageUp).setRegion(node.selectable ? node.node.content.icon(Cicon.medium) : Icon.lock.getRegion());
|
||||
button.getImage().setColor(!locked(node.node) ? Color.white : node.selectable ? Color.gray : Pal.gray);
|
||||
button.getImage().setScaling(Scaling.bounded);
|
||||
});
|
||||
addChild(button);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
public class UnitPayload implements Payload{
|
||||
public Unit unit;
|
||||
@@ -40,6 +41,8 @@ public class UnitPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public boolean dump(){
|
||||
Floor floor = unit.floorOn();
|
||||
|
||||
//no client dumping
|
||||
if(Vars.net.client()) return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user