Removed carrying
This commit is contained in:
@@ -272,7 +272,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
NetConnection connection = player.con;
|
NetConnection connection = player.con;
|
||||||
if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return;
|
if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return;
|
||||||
|
|
||||||
boolean verifyPosition = !player.isDead() && netServer.admins.getStrict() && headless && player.getCarrier() == null;
|
boolean verifyPosition = !player.isDead() && netServer.admins.getStrict() && headless;
|
||||||
|
|
||||||
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = Time.millis() - 16;
|
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = Time.millis() - 16;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTrait{
|
public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||||
public static final int timerSync = 2;
|
public static final int timerSync = 2;
|
||||||
public static final int timerAbility = 3;
|
public static final int timerAbility = 3;
|
||||||
private static final int timerShootLeft = 0;
|
private static final int timerShootLeft = 0;
|
||||||
@@ -76,7 +76,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
private float walktime;
|
private float walktime;
|
||||||
private Queue<BuildRequest> placeQueue = new Queue<>();
|
private Queue<BuildRequest> placeQueue = new Queue<>();
|
||||||
private Tile mining;
|
private Tile mining;
|
||||||
private CarriableTrait carrying;
|
|
||||||
private Vector2 movement = new Vector2();
|
private Vector2 movement = new Vector2();
|
||||||
private boolean moved;
|
private boolean moved;
|
||||||
|
|
||||||
@@ -91,8 +90,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
player.dead = true;
|
player.dead = true;
|
||||||
player.placeQueue.clear();
|
player.placeQueue.clear();
|
||||||
|
|
||||||
player.dropCarry();
|
|
||||||
|
|
||||||
float explosiveness = 2f + (player.inventory.hasItem() ? player.inventory.getItem().item.explosiveness * player.inventory.getItem().amount : 0f);
|
float explosiveness = 2f + (player.inventory.hasItem() ? player.inventory.getItem().item.explosiveness * player.inventory.getItem().amount : 0f);
|
||||||
float flammability = (player.inventory.hasItem() ? player.inventory.getItem().item.flammability * player.inventory.getItem().amount : 0f);
|
float flammability = (player.inventory.hasItem() ? player.inventory.getItem().item.flammability * player.inventory.getItem().amount : 0f);
|
||||||
Damage.dynamicExplosion(player.x, player.y, flammability, explosiveness, 0f, player.getSize() / 2f, Palette.darkFlame);
|
Damage.dynamicExplosion(player.x, player.y, flammability, explosiveness, 0f, player.getSize() / 2f, Palette.darkFlame);
|
||||||
@@ -184,21 +181,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CarriableTrait getCarry(){
|
|
||||||
return carrying;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCarry(CarriableTrait unit){
|
|
||||||
this.carrying = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getCarryWeight(){
|
|
||||||
return mech.carryWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBuildPower(Tile tile){
|
public float getBuildPower(Tile tile){
|
||||||
return mech.buildPower;
|
return mech.buildPower;
|
||||||
@@ -241,7 +223,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFlying(){
|
public boolean isFlying(){
|
||||||
return mech.flying || boostHeat > liftoffBoost || isCarried();
|
return mech.flying || boostHeat > liftoffBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -284,7 +266,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(){
|
public void removed(){
|
||||||
dropCarryLocal();
|
|
||||||
|
|
||||||
TileEntity core = getClosestCore();
|
TileEntity core = getClosestCore();
|
||||||
if(core != null && ((CoreEntity) core).currentUnit == this){
|
if(core != null && ((CoreEntity) core).currentUnit == this){
|
||||||
@@ -547,11 +528,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
status.update(this); //status effect updating also happens with non locals for effect purposes
|
status.update(this); //status effect updating also happens with non locals for effect purposes
|
||||||
updateVelocityStatus(); //velocity too, for visual purposes
|
updateVelocityStatus(); //velocity too, for visual purposes
|
||||||
|
|
||||||
if(getCarrier() != null){
|
|
||||||
x = getCarrier().getX();
|
|
||||||
y = getCarrier().getY();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Net.server()){
|
if(Net.server()){
|
||||||
updateShooting(); //server simulates player shooting
|
updateShooting(); //server simulates player shooting
|
||||||
}
|
}
|
||||||
@@ -595,23 +571,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
speed *= Mathf.lerp(1f, penalty, Angles.angleDist(rotation, velocity.angle()) / 180f);
|
speed *= Mathf.lerp(1f, penalty, Angles.angleDist(rotation, velocity.angle()) / 180f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//drop from carrier on key press
|
|
||||||
if(!ui.chatfrag.chatOpen() && Core.input.keyTap(Binding.drop_unit)){
|
|
||||||
if(!mech.flying){
|
|
||||||
if(getCarrier() != null){
|
|
||||||
Call.dropSelf(this);
|
|
||||||
}
|
|
||||||
}else if(getCarry() != null){
|
|
||||||
dropCarry();
|
|
||||||
}else{
|
|
||||||
Unit unit = Units.getClosest(team, x, y, 8f, u -> !u.isFlying() && u.mass() <= mech.carryWeight);
|
|
||||||
|
|
||||||
if(unit != null){
|
|
||||||
carry(unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
movement.setZero();
|
movement.setZero();
|
||||||
|
|
||||||
float xa = Core.input.axis(Binding.move_x);
|
float xa = Core.input.axis(Binding.move_x);
|
||||||
@@ -628,18 +587,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
movement.limit(speed).scl(Time.delta());
|
movement.limit(speed).scl(Time.delta());
|
||||||
|
|
||||||
if(getCarrier() == null){
|
if(!ui.chatfrag.chatOpen()){
|
||||||
if(!ui.chatfrag.chatOpen()){
|
velocity.add(movement.x, movement.y);
|
||||||
velocity.add(movement.x, movement.y);
|
|
||||||
}
|
|
||||||
float prex = x, prey = y;
|
|
||||||
updateVelocityStatus();
|
|
||||||
moved = dst(prex, prey) > 0.001f;
|
|
||||||
}else{
|
|
||||||
velocity.setZero();
|
|
||||||
x = Mathf.lerpDelta(x, getCarrier().getX(), 0.1f);
|
|
||||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
|
||||||
}
|
}
|
||||||
|
float prex = x, prey = y;
|
||||||
|
updateVelocityStatus();
|
||||||
|
moved = dst(prex, prey) > 0.001f;
|
||||||
|
|
||||||
if(!ui.chatfrag.chatOpen()){
|
if(!ui.chatfrag.chatOpen()){
|
||||||
float baseLerp = mech.getRotationAlpha(this);
|
float baseLerp = mech.getRotationAlpha(this);
|
||||||
@@ -680,9 +633,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(dst(moveTarget) < 2f){
|
if(dst(moveTarget) < 2f){
|
||||||
if(moveTarget instanceof CarriableTrait){
|
if(tapping){
|
||||||
carry((CarriableTrait) moveTarget);
|
|
||||||
}else if(tapping){
|
|
||||||
Tile tile = ((TileEntity) moveTarget).tile;
|
Tile tile = ((TileEntity) moveTarget).tile;
|
||||||
tile.block().tapped(tile, this);
|
tile.block().tapped(tile, this);
|
||||||
}
|
}
|
||||||
@@ -693,12 +644,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
moveTarget = null;
|
moveTarget = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getCarrier() != null){
|
|
||||||
velocity.setZero();
|
|
||||||
x = Mathf.lerpDelta(x, getCarrier().getX(), 0.1f);
|
|
||||||
y = Mathf.lerpDelta(y, getCarrier().getY(), 0.1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
movement.set(targetX - x, targetY - y).limit(isBoosting && !mech.flying ? mech.boostSpeed : mech.speed);
|
movement.set(targetX - x, targetY - y).limit(isBoosting && !mech.flying ? mech.boostSpeed : mech.speed);
|
||||||
movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f));
|
movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f));
|
||||||
|
|
||||||
@@ -726,7 +671,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
float lx = x, ly = y;
|
float lx = x, ly = y;
|
||||||
updateVelocityStatus();
|
updateVelocityStatus();
|
||||||
moved = dst(lx, ly) > 0.001f && !isCarried();
|
moved = dst(lx, ly) > 0.001f;
|
||||||
|
|
||||||
if(mech.flying){
|
if(mech.flying){
|
||||||
//hovering effect
|
//hovering effect
|
||||||
@@ -804,7 +749,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
dead = true;
|
dead = true;
|
||||||
target = null;
|
target = null;
|
||||||
moveTarget = null;
|
moveTarget = null;
|
||||||
carrier = null;
|
|
||||||
health = maxHealth();
|
health = maxHealth();
|
||||||
boostHeat = drownTime = hitTime = 0f;
|
boostHeat = drownTime = hitTime = 0f;
|
||||||
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.io.IOException;
|
|||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.state;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait, CarriableTrait, InventoryTrait{
|
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait, InventoryTrait{
|
||||||
/**Total duration of hit flash effect*/
|
/**Total duration of hit flash effect*/
|
||||||
public static final float hitDuration = 9f;
|
public static final float hitDuration = 9f;
|
||||||
/**Percision divisor of velocity, used when writing. For example a value of '2' would mean the percision is 1/2 = 0.5-size chunks.*/
|
/**Percision divisor of velocity, used when writing. For example a value of '2' would mean the percision is 1/2 = 0.5-size chunks.*/
|
||||||
@@ -56,7 +56,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
protected final StatusController status = new StatusController();
|
protected final StatusController status = new StatusController();
|
||||||
protected Team team = Team.blue;
|
protected Team team = Team.blue;
|
||||||
|
|
||||||
protected CarryTrait carrier;
|
|
||||||
protected float drownTime;
|
protected float drownTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,21 +68,11 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CarryTrait getCarrier(){
|
|
||||||
return carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean collidesGrid(int x, int y){
|
public boolean collidesGrid(int x, int y){
|
||||||
return !isFlying();
|
return !isFlying();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCarrier(CarryTrait carrier){
|
|
||||||
this.carrier = carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Team getTeam(){
|
public Team getTeam(){
|
||||||
return team;
|
return team;
|
||||||
@@ -202,7 +191,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
queryRect.setSize(queryRect.getWidth() * scaling);
|
queryRect.setSize(queryRect.getWidth() * scaling);
|
||||||
|
|
||||||
Units.getNearby(queryRect, t -> {
|
Units.getNearby(queryRect, t -> {
|
||||||
if(t == this || t.getCarrier() == this || getCarrier() == t || t.isFlying() != isFlying()) return;
|
if(t == this || t.isFlying() != isFlying()) return;
|
||||||
float dst = dst(t);
|
float dst = dst(t);
|
||||||
moveVector.set(x, y).sub(t.getX(), t.getY()).setLength(1f * (1f - (dst / queryRect.getWidth())));
|
moveVector.set(x, y).sub(t.getX(), t.getY()).setLength(1f * (1f - (dst / queryRect.getWidth())));
|
||||||
applyImpulse(moveVector.x, moveVector.y);
|
applyImpulse(moveVector.x, moveVector.y);
|
||||||
@@ -236,12 +225,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
public void updateVelocityStatus(){
|
public void updateVelocityStatus(){
|
||||||
Floor floor = getFloorOn();
|
Floor floor = getFloorOn();
|
||||||
|
|
||||||
if(isCarried()){ //carried units do not take into account velocity normally
|
|
||||||
set(carrier.getX(), carrier.getY());
|
|
||||||
velocity.set(carrier.velocity());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
|
|
||||||
status.update(this);
|
status.update(this);
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
|
||||||
|
|
||||||
import io.anuke.arc.entities.trait.SolidTrait;
|
|
||||||
|
|
||||||
public interface CarriableTrait extends TeamTrait, TargetTrait, SolidTrait{
|
|
||||||
|
|
||||||
default boolean isCarried(){
|
|
||||||
return getCarrier() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
CarryTrait getCarrier();
|
|
||||||
|
|
||||||
void setCarrier(CarryTrait carrier);
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
|
||||||
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
|
||||||
import io.anuke.mindustry.content.Fx;
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
|
||||||
import io.anuke.mindustry.gen.Call;
|
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.entities.trait.SolidTrait;
|
|
||||||
|
|
||||||
public interface CarryTrait extends TeamTrait, SolidTrait, TargetTrait{
|
|
||||||
|
|
||||||
@Remote(called = Loc.both, targets = Loc.both, forward = true)
|
|
||||||
static void dropSelf(Player player){
|
|
||||||
if(player != null && player.getCarrier() != null){
|
|
||||||
player.getCarrier().dropCarry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Remote(called = Loc.both, targets = Loc.both, forward = true)
|
|
||||||
static void setCarryOf(Player player, CarryTrait trait, CarriableTrait unit){
|
|
||||||
if(trait == null) return;
|
|
||||||
if(player != null){ //when a server recieves this called from a player, set the carrier to the player.
|
|
||||||
trait = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(trait.getCarry() != null){ //already carrying something, drop it
|
|
||||||
//drop current
|
|
||||||
Effects.effect(Fx.unitDrop, trait.getCarry());
|
|
||||||
trait.getCarry().setCarrier(null);
|
|
||||||
trait.setCarry(null);
|
|
||||||
|
|
||||||
if(unit != null){
|
|
||||||
trait.carry(unit); //now carry this new thing
|
|
||||||
}
|
|
||||||
}else if(unit != null){ //not currently carrying anything, make sure it's not null
|
|
||||||
trait.setCarry(unit);
|
|
||||||
unit.setCarrier(trait);
|
|
||||||
|
|
||||||
Effects.effect(Fx.unitPickup, trait);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**Returns the thing this carrier is carrying.*/
|
|
||||||
CarriableTrait getCarry();
|
|
||||||
|
|
||||||
/**Sets the carrying unit. Internal use only! Use {@link #carry(CarriableTrait)} to set state.*/
|
|
||||||
void setCarry(CarriableTrait unit);
|
|
||||||
|
|
||||||
/**Returns maximum mass this carrier can carry.*/
|
|
||||||
float getCarryWeight();
|
|
||||||
|
|
||||||
/**Drops the unit that is being carried, if applicable.*/
|
|
||||||
default void dropCarry(){
|
|
||||||
carry(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
default void dropCarryLocal(){
|
|
||||||
setCarryOf(null, this, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not override unless absolutely necessary.
|
|
||||||
* Carries a unit. To drop a unit, call with {@code null}.
|
|
||||||
*/
|
|
||||||
default void carry(CarriableTrait unit){
|
|
||||||
Call.setCarryOf(this instanceof Player ? (Player) this : null, this, unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,6 @@ import io.anuke.arc.util.Time;
|
|||||||
import io.anuke.mindustry.entities.Predict;
|
import io.anuke.mindustry.entities.Predict;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -18,10 +16,9 @@ import io.anuke.mindustry.world.meta.BlockFlag;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
public abstract class FlyingUnit extends BaseUnit{
|
||||||
protected static Vector2 vec = new Vector2();
|
protected static Vector2 vec = new Vector2();
|
||||||
|
|
||||||
protected CarriableTrait carrying;
|
|
||||||
protected final UnitState
|
protected final UnitState
|
||||||
|
|
||||||
idle = new UnitState(){
|
idle = new UnitState(){
|
||||||
@@ -125,21 +122,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
moveBy(x, y);
|
moveBy(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CarriableTrait getCarry(){
|
|
||||||
return carrying;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCarry(CarriableTrait unit){
|
|
||||||
this.carrying = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getCarryWeight(){
|
|
||||||
return type.carryWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
super.update();
|
super.update();
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class UnitType extends UnlockableContent{
|
|||||||
public float maxVelocity = 5f;
|
public float maxVelocity = 5f;
|
||||||
public float retreatPercent = 0.2f;
|
public float retreatPercent = 0.2f;
|
||||||
public float armor = 0f;
|
public float armor = 0f;
|
||||||
public float carryWeight = 1f;
|
|
||||||
public int itemCapacity = 30;
|
public int itemCapacity = 30;
|
||||||
public ObjectSet<Item> toMine = ObjectSet.with(Items.lead, Items.copper);
|
public ObjectSet<Item> toMine = ObjectSet.with(Items.lead, Items.copper);
|
||||||
public float buildPower = 0.3f, minePower = 0.7f;
|
public float buildPower = 0.3f, minePower = 0.7f;
|
||||||
|
|||||||
@@ -547,27 +547,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
//add to selection queue if it's a valid BREAK position
|
//add to selection queue if it's a valid BREAK position
|
||||||
cursor = cursor.target();
|
cursor = cursor.target();
|
||||||
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy()));
|
selection.add(new PlaceRequest(cursor.worldx(), cursor.worldy()));
|
||||||
}else if(!canTapPlayer(worldx, worldy)){
|
}else if(!canTapPlayer(worldx, worldy) && !tileTapped(cursor.target())){
|
||||||
boolean consumed = false;
|
tryBeginMine(cursor);
|
||||||
//else, try and carry units
|
|
||||||
if(player.mech.flying){
|
|
||||||
if(player.getCarry() != null){
|
|
||||||
consumed = true;
|
|
||||||
player.dropCarry(); //drop off unit
|
|
||||||
}else{
|
|
||||||
Unit unit = Units.getClosest(player.getTeam(), Core.input.mouseWorld(x, y).x, Core.input.mouseWorld(x, y).y, 4f, u -> !u.isFlying() && u.mass() <= player.mech.carryWeight);
|
|
||||||
|
|
||||||
if(unit != null){
|
|
||||||
consumed = true;
|
|
||||||
player.moveTarget = unit;
|
|
||||||
Effects.effect(Fx.select, unit.getX(), unit.getY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!consumed && !tileTapped(cursor.target())){
|
|
||||||
tryBeginMine(cursor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import io.anuke.mindustry.entities.Unit;
|
|||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.ShooterTrait;
|
import io.anuke.mindustry.entities.traits.ShooterTrait;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
@@ -92,46 +90,6 @@ public class TypeIO{
|
|||||||
return bulletGroup.getByID(id);
|
return bulletGroup.getByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WriteClass(CarriableTrait.class)
|
|
||||||
public static void writeCarriable(ByteBuffer buffer, CarriableTrait unit){
|
|
||||||
if(unit == null){
|
|
||||||
buffer.put((byte) -1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
buffer.put((byte) unit.getGroup().getID());
|
|
||||||
buffer.putInt(unit.getID());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReadClass(CarriableTrait.class)
|
|
||||||
public static CarriableTrait readCarriable(ByteBuffer buffer){
|
|
||||||
byte gid = buffer.get();
|
|
||||||
if(gid == -1){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int id = buffer.getInt();
|
|
||||||
return (CarriableTrait) Entities.getGroup(gid).getByID(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WriteClass(CarryTrait.class)
|
|
||||||
public static void writeCarry(ByteBuffer buffer, CarryTrait unit){
|
|
||||||
if(unit == null || unit.getGroup() == null){
|
|
||||||
buffer.put((byte) -1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
buffer.put((byte) unit.getGroup().getID());
|
|
||||||
buffer.putInt(unit.getID());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReadClass(CarryTrait.class)
|
|
||||||
public static CarryTrait readCarry(ByteBuffer buffer){
|
|
||||||
byte gid = buffer.get();
|
|
||||||
if(gid == -1){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int id = buffer.getInt();
|
|
||||||
return (CarryTrait) Entities.getGroup(gid).getByID(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WriteClass(BaseUnit.class)
|
@WriteClass(BaseUnit.class)
|
||||||
public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){
|
public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){
|
||||||
buffer.put((byte) unitGroups[unit.getTeam().ordinal()].getID());
|
buffer.put((byte) unitGroups[unit.getTeam().ordinal()].getID());
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class Mech extends UnlockableContent{
|
|||||||
public float cellTrnsY = 0f;
|
public float cellTrnsY = 0f;
|
||||||
public float mineSpeed = 1f;
|
public float mineSpeed = 1f;
|
||||||
public int drillPower = -1;
|
public int drillPower = -1;
|
||||||
public float carryWeight = 10f;
|
|
||||||
public float buildPower = 1f;
|
public float buildPower = 1f;
|
||||||
public Color trailColor = Palette.boostFrom;
|
public Color trailColor = Palette.boostFrom;
|
||||||
public Color trailColorTo = Palette.boostTo;
|
public Color trailColorTo = Palette.boostTo;
|
||||||
|
|||||||
Reference in New Issue
Block a user