Minor cleanup / Trail experiment
This commit is contained in:
@@ -36,7 +36,7 @@ public class UnitTypes implements ContentList{
|
||||
|
||||
//air + building + mining
|
||||
//TODO implement other starter drones
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class, Trailc.class}) UnitType alpha, beta, gamma;
|
||||
|
||||
//air + building + mining + payload
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class, Payloadc.class}) UnitType trident;
|
||||
|
||||
@@ -11,7 +11,7 @@ abstract class TrailComp implements Unitc{
|
||||
@Import UnitType type;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
transient Trail trail = new Trail();
|
||||
transient Trail trail = new Trail(4);
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
@@ -22,7 +22,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
static int sequenceNum = 0;
|
||||
|
||||
/** weapon mount array, never null */
|
||||
@ReadOnly @SyncLocal WeaponMount[] mounts = {};
|
||||
@SyncLocal WeaponMount[] mounts = {};
|
||||
@ReadOnly transient float range, aimX, aimY;
|
||||
@ReadOnly transient boolean isRotate;
|
||||
boolean isShooting;
|
||||
|
||||
@@ -153,7 +153,7 @@ public class OverlayRenderer{
|
||||
Draw.reset();
|
||||
|
||||
Building tile = world.entWorld(v.x, v.y);
|
||||
if(tile != null && tile.interactable(player.team()) && tile.acceptStack(player.unit().item(), player.unit().stack().amount, player.unit()) > 0){
|
||||
if(tile != null && tile.interactable(player.team()) && tile.acceptStack(player.unit().item(), player.unit().stack.amount, player.unit()) > 0){
|
||||
Lines.stroke(3f, Pal.gray);
|
||||
Lines.square(tile.x(), tile.y(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Lines.stroke(1f, Pal.place);
|
||||
|
||||
@@ -8,10 +8,15 @@ import arc.struct.*;
|
||||
import arc.util.pooling.*;
|
||||
|
||||
public class Trail{
|
||||
private static final int length = 20;
|
||||
private Seq<Vec3> points = new Seq<>();
|
||||
private final int length;
|
||||
private final Seq<Vec3> points;
|
||||
private float lastX = -1, lastY = -1;
|
||||
|
||||
public Trail(int length){
|
||||
this.length = length;
|
||||
points = new Seq<>(length);
|
||||
}
|
||||
|
||||
public void draw(Color color, float width){
|
||||
Draw.color(color);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
@Remote(targets = Loc.client, called = Loc.server)
|
||||
public static void dropItem(Player player, float angle){
|
||||
if(net.server() && player.unit().stack().amount <= 0){
|
||||
if(net.server() && player.unit().stack.amount <= 0){
|
||||
throw new ValidateException(player, "Player cannot drop an item.");
|
||||
}
|
||||
|
||||
@@ -129,18 +129,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
||||
public static void transferInventory(Player player, Building tile){
|
||||
if(player == null || tile == null) return;
|
||||
if(net.server() && (player.unit().stack().amount <= 0 || !Units.canInteract(player, tile) ||
|
||||
if(net.server() && (player.unit().stack.amount <= 0 || !Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.depositItem, tile.tile(), action -> {
|
||||
action.itemAmount = player.unit().stack().amount;
|
||||
action.itemAmount = player.unit().stack.amount;
|
||||
action.item = player.unit().item();
|
||||
}))){
|
||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||
}
|
||||
|
||||
Item item = player.unit().item();
|
||||
int amount = player.unit().stack().amount;
|
||||
int amount = player.unit().stack.amount;
|
||||
int accepted = tile.acceptStack(item, amount, player.unit());
|
||||
player.unit().stack().amount -= accepted;
|
||||
player.unit().stack.amount -= accepted;
|
||||
|
||||
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
|
||||
|
||||
@@ -726,7 +726,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
boolean canTapPlayer(float x, float y){
|
||||
return player.within(x, y, playerSelectRange) && player.unit().stack().amount > 0;
|
||||
return player.within(x, y, playerSelectRange) && player.unit().stack.amount > 0;
|
||||
}
|
||||
|
||||
/** Tries to begin mining a tile, returns true if successful. */
|
||||
@@ -866,14 +866,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public void tryDropItems(@Nullable Building tile, float x, float y){
|
||||
if(!droppingItem || player.unit().stack().amount <= 0 || canTapPlayer(x, y) || state.isPaused() ){
|
||||
if(!droppingItem || player.unit().stack.amount <= 0 || canTapPlayer(x, y) || state.isPaused() ){
|
||||
droppingItem = false;
|
||||
return;
|
||||
}
|
||||
|
||||
droppingItem = false;
|
||||
|
||||
ItemStack stack = player.unit().stack();
|
||||
ItemStack stack = player.unit().stack;
|
||||
|
||||
if(tile != null && tile.acceptStack(stack.item, stack.amount, player.unit()) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.unit().stack().amount > 0 && tile.interactable(player.team())){
|
||||
Call.transferInventory(player, tile);
|
||||
|
||||
@@ -280,7 +280,7 @@ public class UnitType extends UnlockableContent{
|
||||
(3f + Mathf.absin(Time.time(), 5f, 1f)) * unit.itemTime);
|
||||
|
||||
if(unit.isLocal()){
|
||||
Fonts.outline.draw(unit.stack().amount + "",
|
||||
Fonts.outline.draw(unit.stack.amount + "",
|
||||
unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY),
|
||||
unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY) - 3,
|
||||
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center
|
||||
@@ -320,7 +320,7 @@ public class UnitType extends UnlockableContent{
|
||||
public void drawWeapons(Unit unit){
|
||||
applyColor(unit);
|
||||
|
||||
for(WeaponMount mount : unit.mounts()){
|
||||
for(WeaponMount mount : unit.mounts){
|
||||
Weapon weapon = mount.weapon;
|
||||
|
||||
for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){
|
||||
|
||||
Reference in New Issue
Block a user