mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-30 09:30:39 +07:00
Implemented desktop carrying
This commit is contained in:
parent
3c3147d665
commit
e79494b5cb
@ -32,10 +32,7 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.ThreadQueue;
|
||||
import io.anuke.ucore.util.Timer;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@ -448,13 +445,26 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
|
||||
if(mech.flying){
|
||||
//prevent strafing backwards, have a penalty for doing so
|
||||
float angDist = Angles.angleDist(rotation, velocity.angle()) / 180f;
|
||||
float penalty = 0.2f;
|
||||
float penalty = 0.2f; //when going 180 degrees backwards, reduce speed to 0.2x
|
||||
speed *= Mathf.lerp(1f, penalty, angDist);
|
||||
}
|
||||
|
||||
//drop from carrier on key press
|
||||
if(Inputs.keyTap("drop_unit") && getCarrier() != null){
|
||||
getCarrier().dropCarry();
|
||||
if(Inputs.keyTap("drop_unit")){
|
||||
if(!mech.flying) {
|
||||
if (getCarrier() != null) {
|
||||
CallEntity.dropSelf(this);
|
||||
}
|
||||
}else if(getCarry() != null){
|
||||
dropCarry();
|
||||
}else{
|
||||
Unit unit = Units.getClosest(team, x, y, 8f,
|
||||
u -> !u.isFlying() && u.getMass() <= mech.carryWeight);
|
||||
|
||||
if(unit != null){
|
||||
carry(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
movement.set(0, 0);
|
||||
|
@ -32,6 +32,13 @@ public interface CarryTrait extends TeamTrait, SolidTrait, TargetTrait{
|
||||
CallEntity.setCarryOf(this instanceof Player ? (Player)this : null, this, unit);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, forward = true, in = In.entities)
|
||||
static void dropSelf(Player player){
|
||||
if(player.getCarrier() != null){
|
||||
player.getCarrier().dropCarry();
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, forward = true, in = In.entities)
|
||||
static void setCarryOf(Player player, CarryTrait trait, CarriableTrait unit){
|
||||
if(player != null){ //when a server recieves this called from a player, set the carrier to the player.
|
||||
|
@ -509,7 +509,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
if(player.getCarry() != null){
|
||||
player.dropCarry(); //drop off unit
|
||||
}else{
|
||||
Unit unit = Units.getClosest(player.getTeam(), Graphics.world(x, y).x, Graphics.world(x, y).y, 4f, u -> !u.isFlying());
|
||||
Unit unit = Units.getClosest(player.getTeam(), Graphics.world(x, y).x, Graphics.world(x, y).y, 4f, u -> !u.isFlying() && u.getMass() <= player.mech.carryWeight);
|
||||
|
||||
if(unit != null){
|
||||
player.pickupTarget = unit;
|
||||
|
@ -14,7 +14,7 @@ public class Mech extends Upgrade {
|
||||
public float armor = 1f;
|
||||
|
||||
public int drillPower = -1;
|
||||
public float carryWeight = 1f;
|
||||
public float carryWeight = 10f;
|
||||
public float buildPower = 1f;
|
||||
public boolean canRepair = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user