it launches
This commit is contained in:
@@ -73,6 +73,10 @@ public class Vars implements Loadable{
|
||||
public static final float worldBounds = 100f;
|
||||
/** units outside of this bound will simply die instantly */
|
||||
public static final float finalWorldBounds = worldBounds + 500;
|
||||
/** mining range for manual miners */
|
||||
public static final float miningRange = 70f;
|
||||
/** range for building */
|
||||
public static final float buildingRange = 220f;
|
||||
/** ticks spent out of bound until self destruct. */
|
||||
public static final float boundsCountdown = 60 * 7;
|
||||
/** for map generator dialog */
|
||||
|
||||
@@ -518,7 +518,7 @@ public class NetClient implements ApplicationListener{
|
||||
Call.onClientShapshot(lastSent++, player.x, player.y,
|
||||
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
||||
player.vel().x, player.vel().y,
|
||||
player.getMineTile(),
|
||||
player.miner().mineTile(),
|
||||
player.isBoosting, player.isShooting, ui.chatfrag.shown(), player.isBuilding,
|
||||
requests,
|
||||
Core.camera.position.x, Core.camera.position.y,
|
||||
|
||||
@@ -508,7 +508,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
player.mouseX(pointerX);
|
||||
player.mouseY(pointerY);
|
||||
player.setMineTile(mining);
|
||||
player.miner().mineTile(mining);
|
||||
player.isTyping = chatting;
|
||||
player.isBoosting = boosting;
|
||||
player.isShooting = shooting;
|
||||
|
||||
@@ -81,6 +81,7 @@ public class EntityComps{
|
||||
@Override
|
||||
public void type(UnitDef type){
|
||||
this.type = type;
|
||||
controller(type.createController());
|
||||
setupWeapons(type);
|
||||
}
|
||||
|
||||
@@ -678,19 +679,7 @@ public class EntityComps{
|
||||
|
||||
@Component
|
||||
abstract static class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
|
||||
//TODO mock these properly
|
||||
private static final Unitc noUnit = GenericUnitEntity.create();
|
||||
private static final Builderc noBuilder = GenericBuilderEntity.create().with(s -> s.requests(new Queue<BuildRequest>(){
|
||||
@Override
|
||||
public void addLast(BuildRequest object){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(BuildRequest object){
|
||||
}
|
||||
}));
|
||||
|
||||
@NonNull @ReadOnly Unitc unit = noUnit;
|
||||
@NonNull @ReadOnly Unitc unit = Nulls.unit;
|
||||
|
||||
@ReadOnly Team team = Team.sharded;
|
||||
String name = "noname";
|
||||
@@ -739,7 +728,7 @@ public class EntityComps{
|
||||
}
|
||||
|
||||
public void clearUnit(){
|
||||
unit(noUnit);
|
||||
unit(Nulls.unit);
|
||||
}
|
||||
|
||||
public Unitc unit(){
|
||||
@@ -751,23 +740,24 @@ public class EntityComps{
|
||||
return unit;
|
||||
}
|
||||
|
||||
public Minerc miner(){
|
||||
return !(unit instanceof Minerc) ? Nulls.miner : (Minerc)unit;
|
||||
}
|
||||
|
||||
public Builderc builder(){
|
||||
if(!(unit instanceof Builderc)){
|
||||
return noBuilder;
|
||||
}
|
||||
return (Builderc)unit;
|
||||
return !(unit instanceof Builderc) ? Nulls.builder : (Builderc)unit;
|
||||
}
|
||||
|
||||
public void unit(Unitc unit){
|
||||
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
|
||||
this.unit = unit;
|
||||
if(unit != noUnit){
|
||||
if(unit != Nulls.unit){
|
||||
unit.team(team);
|
||||
}
|
||||
}
|
||||
|
||||
boolean dead(){
|
||||
return unit == noUnit;
|
||||
return unit == Nulls.builder;
|
||||
}
|
||||
|
||||
String uuid(){
|
||||
@@ -1223,8 +1213,6 @@ public class EntityComps{
|
||||
|
||||
@Component
|
||||
static abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
static float miningRange = 70f;
|
||||
|
||||
transient float x, y, rotation;
|
||||
|
||||
@Nullable Tile mineTile;
|
||||
@@ -1308,7 +1296,6 @@ public class EntityComps{
|
||||
|
||||
@Component
|
||||
abstract static class BuilderComp implements Unitc{
|
||||
static final float placeDistance = 220f;
|
||||
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||
|
||||
transient float x, y, rotation;
|
||||
@@ -1318,7 +1305,7 @@ public class EntityComps{
|
||||
//boolean building;
|
||||
|
||||
void updateBuilding(){
|
||||
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : placeDistance;
|
||||
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange;
|
||||
|
||||
Iterator<BuildRequest> it = requests.iterator();
|
||||
while(it.hasNext()){
|
||||
@@ -1402,7 +1389,7 @@ public class EntityComps{
|
||||
void drawBuildRequests(){
|
||||
|
||||
for(BuildRequest request : requests){
|
||||
if(request.progress > 0.01f || (buildRequest() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= placeDistance || state.isEditor()))) continue;
|
||||
if(request.progress > 0.01f || (buildRequest() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= buildingRange || state.isEditor()))) continue;
|
||||
|
||||
request.animScale = 1f;
|
||||
if(request.breaking){
|
||||
@@ -1479,7 +1466,7 @@ public class EntityComps{
|
||||
BuildRequest request = buildRequest();
|
||||
Tile tile = world.tile(request.x, request.y);
|
||||
|
||||
if(dst(tile) > placeDistance && !state.isEditor()){
|
||||
if(dst(tile) > buildingRange && !state.isEditor()){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1804,6 +1791,10 @@ public class EntityComps{
|
||||
return ((Object)this) == player || ((Object)this) instanceof Unitc && ((Unitc)((Object)this)).controller() == player;
|
||||
}
|
||||
|
||||
boolean isNull(){
|
||||
return false;
|
||||
}
|
||||
|
||||
<T> T as(Class<T> type){
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ public class DesktopInput extends InputHandler{
|
||||
@Override
|
||||
public void buildUI(Group group){
|
||||
group.fill(t -> {
|
||||
t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.isBuilding() ? 1f : 0f, 0.15f));
|
||||
t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.builder().isBuilding() ? 1f : 0f, 0.15f));
|
||||
t.visible(() -> Core.settings.getBool("hints") && selectRequests.isEmpty());
|
||||
t.touchable(() -> t.getColor().a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
|
||||
t.table(Styles.black6, b -> {
|
||||
b.defaults().left();
|
||||
b.label(() -> Core.bundle.format(!player.isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.label(() -> Core.bundle.format(!isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
b.label(() -> Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.toString())).style(Styles.outlineLabel);
|
||||
b.row();
|
||||
@@ -150,7 +150,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyRelease(Binding.select)){
|
||||
player.isShooting = false;
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(!state.is(State.menu) && Core.input.keyTap(Binding.minimap) && !scene.hasDialog() && !(scene.getKeyboardFocus() instanceof TextField)){
|
||||
@@ -176,8 +176,8 @@ public class DesktopInput extends InputHandler{
|
||||
mode = none;
|
||||
}
|
||||
|
||||
if(player.isShooting && !canShoot()){
|
||||
player.isShooting = false;
|
||||
if(isShooting && !canShoot()){
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(isPlacing()){
|
||||
@@ -272,9 +272,9 @@ public class DesktopInput extends InputHandler{
|
||||
int rawCursorX = world.toTile(Core.input.mouseWorld().x), rawCursorY = world.toTile(Core.input.mouseWorld().y);
|
||||
|
||||
// automatically pause building if the current build queue is empty
|
||||
if(Core.settings.getBool("buildautopause") && player.isBuilding && !player.isBuilding()){
|
||||
player.isBuilding = false;
|
||||
player.buildWasAutoPaused = true;
|
||||
if(Core.settings.getBool("buildautopause") && isBuilding && !player.builder().isBuilding()){
|
||||
isBuilding = false;
|
||||
buildWasAutoPaused = true;
|
||||
}
|
||||
|
||||
if(!selectRequests.isEmpty()){
|
||||
@@ -290,11 +290,11 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.deselect)){
|
||||
player.setMineTile(null);
|
||||
player.miner().mineTile(null);
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.clear_building)){
|
||||
player.clearBuilding();
|
||||
player.builder().clearBuilding();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.schematic_select) && !Core.scene.hasKeyboard()){
|
||||
@@ -346,8 +346,8 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause_building)){
|
||||
player.isBuilding = !player.isBuilding;
|
||||
player.buildWasAutoPaused = false;
|
||||
isBuilding = !isBuilding;
|
||||
buildWasAutoPaused = false;
|
||||
}
|
||||
|
||||
if((cursorX != lastLineX || cursorY != lastLineY) && isPlacing() && mode == placing){
|
||||
@@ -376,12 +376,12 @@ public class DesktopInput extends InputHandler{
|
||||
deleting = true;
|
||||
}else if(selected != null){
|
||||
//only begin shooting if there's no cursor event
|
||||
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.isBuilding) && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.getMineTile() == null && !Core.scene.hasKeyboard()){
|
||||
player.isShooting = true;
|
||||
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.builder().isBuilding()) && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){
|
||||
isShooting = true;
|
||||
}
|
||||
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
|
||||
player.isShooting = true;
|
||||
isShooting = true;
|
||||
}
|
||||
}else if(Core.input.keyTap(Binding.deselect) && isPlacing()){
|
||||
block = null;
|
||||
|
||||
@@ -17,7 +17,6 @@ import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
@@ -25,8 +24,8 @@ import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.Placement.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Administration.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.fragments.*;
|
||||
import mindustry.world.*;
|
||||
@@ -55,6 +54,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public int rotation;
|
||||
public boolean droppingItem;
|
||||
public Group uiGroup;
|
||||
public boolean isShooting, isBuilding = true, buildWasAutoPaused = false;
|
||||
|
||||
protected @Nullable Schematic lastSchematic;
|
||||
protected GestureDetector detector;
|
||||
@@ -627,14 +627,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
boolean canTapPlayer(float x, float y){
|
||||
return Mathf.dst(x, y, player.x, player.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. */
|
||||
boolean tryBeginMine(Tile tile){
|
||||
if(canMine(tile)){
|
||||
//if a block is clicked twice, reset it
|
||||
player.setMineTile(player.getMineTile() == tile ? null : tile);
|
||||
player.miner().mineTile(player.miner().mineTile() == tile ? null : tile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -642,10 +642,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
boolean canMine(Tile tile){
|
||||
return !Core.scene.hasMouse()
|
||||
&& tile.drop() != null && tile.drop().hardness <= player.mech.drillPower
|
||||
&& tile.drop() != null && player.miner().canMine(tile.drop())
|
||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||
&& player.unit().acceptsItem(tile.drop())
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Playerc.mineDistance;
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange;
|
||||
}
|
||||
|
||||
/** Returns the tile at the specified MOUSE coordinates. */
|
||||
@@ -1050,7 +1050,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
//update shooting if not building, not mining and there's ammo left
|
||||
if(!isBuilding() && getMineTile() == null){
|
||||
if(!isBuilding() && mineTile() == null){
|
||||
|
||||
//autofire
|
||||
if(target == null){
|
||||
@@ -1068,7 +1068,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(target != null){
|
||||
setMineTile(null);
|
||||
mineTile(null);
|
||||
}
|
||||
}
|
||||
}else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){
|
||||
|
||||
@@ -63,6 +63,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
/** Down tracking for panning.*/
|
||||
private boolean down = false;
|
||||
|
||||
private Teamc target;
|
||||
|
||||
//region utility methods
|
||||
|
||||
/** Check and assign targets for a specific position. */
|
||||
@@ -70,19 +72,20 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Unitc unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead());
|
||||
|
||||
if(unit != null){
|
||||
player.setMineTile(null);
|
||||
player.target = unit;
|
||||
player.miner().mineTile(null);
|
||||
target = unit;
|
||||
}else{
|
||||
Tile tile = world.ltileWorld(x, y);
|
||||
|
||||
if(tile != null && tile.synthetic() && player.team().isEnemy(tile.team())){
|
||||
Tilec entity = tile.entity;
|
||||
player.setMineTile(null);
|
||||
player.target = entity;
|
||||
}else if(tile != null && player.mech.canHeal && tile.entity != null && tile.team() == player.team() && tile.entity.damaged()){
|
||||
player.setMineTile(null);
|
||||
player.target = tile.entity;
|
||||
}
|
||||
player.miner().mineTile(null);
|
||||
target = entity;
|
||||
//TODO implement healing
|
||||
}//else if(tile != null && player.unit().canHeal && tile.entity != null && tile.team() == player.team() && tile.entity.damaged()){
|
||||
/// player.miner().mineTile(null);
|
||||
// target = tile.entity;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,9 +253,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Boolp schem = () -> lastSchematic != null && !selectRequests.isEmpty();
|
||||
|
||||
group.fill(t -> {
|
||||
t.bottom().left().visible(() -> (player.isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.bottom().left().visible(() -> (player.builder().isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.addImageTextButton("$cancel", Icon.cancel, () -> {
|
||||
player.clearBuilding();
|
||||
player.builder().clearBuilding();
|
||||
selectRequests.clear();
|
||||
mode = none;
|
||||
block = null;
|
||||
@@ -375,8 +378,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
Teamc target = player.target;
|
||||
|
||||
//draw targeting crosshair
|
||||
if(target != null && !state.isEditor()){
|
||||
if(target != lastTarget){
|
||||
@@ -431,7 +432,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
@Override
|
||||
public void useSchematic(Schematic schem){
|
||||
selectRequests.clear();
|
||||
selectRequests.addAll(schematics.toRequests(schem, world.toTile(player.x), world.toTile(player.y)));
|
||||
selectRequests.addAll(schematics.toRequests(schem, player.tileX(), player.tileY()));
|
||||
lastSchematic = schem;
|
||||
}
|
||||
|
||||
@@ -467,7 +468,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
lastLineY = tileY;
|
||||
}else if(!tryTapPlayer(worldx, worldy) && Core.settings.getBool("keyboard")){
|
||||
//shoot on touch down when in keyboard mode
|
||||
player.isShooting = true;
|
||||
isShooting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,11 +603,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(Core.settings.getBool("keyboard")){
|
||||
if(Core.input.keyRelease(Binding.select)){
|
||||
player.isShooting = false;
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
if(player.isShooting && !canShoot()){
|
||||
player.isShooting = false;
|
||||
if(isShooting && !canShoot()){
|
||||
isShooting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -19,6 +20,7 @@ import mindustry.ui.*;
|
||||
public class UnitDef extends UnlockableContent{
|
||||
//TODO implement
|
||||
public @NonNull Prov<? extends UnitController> defaultController = AIController::new;
|
||||
public @NonNull Prov<? extends Unitc> constructor;
|
||||
public boolean flying;
|
||||
public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 0.2f, baseRotateSpeed = 0.1f;
|
||||
public float drag = 0.3f, mass = 1f, accel = 0.1f;
|
||||
@@ -45,14 +47,26 @@ public class UnitDef extends UnlockableContent{
|
||||
public Array<Weapon> weapons = new Array<>();
|
||||
public TextureRegion baseRegion, legRegion, region, cellRegion;
|
||||
|
||||
public UnitDef(String name){
|
||||
public UnitDef(String name, Prov<Unitc> constructor){
|
||||
super(name);
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
||||
public UnitDef(String name){
|
||||
this(name, () -> Nulls.unit);
|
||||
}
|
||||
|
||||
public UnitController createController(){
|
||||
return defaultController.get();
|
||||
}
|
||||
|
||||
public Unitc create(Team team){
|
||||
Unitc unit = constructor.get();
|
||||
unit.team(team);
|
||||
unit.type(this);
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayUnit(table, this);
|
||||
|
||||
Reference in New Issue
Block a user