mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-06 07:30:35 +07:00
it launches
This commit is contained in:
parent
65857d77c4
commit
8172e69f8c
@ -29,6 +29,7 @@ public class EntityProcess extends BaseProcessor{
|
||||
ObjectMap<String, Stype> componentNames = new ObjectMap<>();
|
||||
ObjectMap<Stype, Array<Stype>> componentDependencies = new ObjectMap<>();
|
||||
ObjectMap<Stype, Array<Stype>> defComponents = new ObjectMap<>();
|
||||
ObjectMap<Svar, String> varInitializers = new ObjectMap<>();
|
||||
ObjectSet<String> imports = new ObjectSet<>();
|
||||
|
||||
{
|
||||
@ -161,7 +162,9 @@ public class EntityProcess extends BaseProcessor{
|
||||
}
|
||||
//add initializer if it exists
|
||||
if(tree.getInitializer() != null){
|
||||
fbuilder.initializer(tree.getInitializer().toString());
|
||||
String init = tree.getInitializer().toString();
|
||||
varInitializers.put(f, init);
|
||||
fbuilder.initializer(init);
|
||||
}
|
||||
|
||||
if(!isFinal) fbuilder.addModifiers(Modifier.PROTECTED);
|
||||
@ -377,19 +380,24 @@ public class EntityProcess extends BaseProcessor{
|
||||
write(def.builder, imports.asArray());
|
||||
}
|
||||
|
||||
//store nulls
|
||||
TypeSpec.Builder nullsBuilder = TypeSpec.classBuilder("Nulls").addModifiers(Modifier.PUBLIC).addModifiers(Modifier.FINAL);
|
||||
|
||||
//create mock types of all components
|
||||
for(Stype interf : interfaces){
|
||||
Array<Stype> dependencies = interf.allInterfaces();
|
||||
dependencies.add(interf);
|
||||
Log.info(interf + ": sub " + interf.allSuperclasses() + " " + interf.allInterfaces());
|
||||
|
||||
//indirect interfaces to implement methods for
|
||||
Array<Stype> dependencies = interf.allInterfaces().and(interf);
|
||||
Array<Smethod> methods = dependencies.flatMap(Stype::methods);
|
||||
methods.sort(Structs.comparing(Object::toString));
|
||||
methods.sortComparing(Object::toString);
|
||||
|
||||
//used method signatures
|
||||
ObjectSet<String> signatures = new ObjectSet<>();
|
||||
|
||||
TypeSpec.Builder nullBuilder = TypeSpec.classBuilder("Null" + interf.name().substring(0, interf.name().length() - 1))
|
||||
.addModifiers(Modifier.PUBLIC, Modifier.FINAL);
|
||||
//create null builder
|
||||
String baseName = interf.name().substring(0, interf.name().length() - 1);
|
||||
String className = "Null" + baseName;
|
||||
TypeSpec.Builder nullBuilder = TypeSpec.classBuilder(className)
|
||||
.addModifiers(Modifier.FINAL);
|
||||
|
||||
nullBuilder.addSuperinterface(interf.tname());
|
||||
|
||||
@ -397,11 +405,21 @@ public class EntityProcess extends BaseProcessor{
|
||||
String signature = method.toString();
|
||||
if(signatures.contains(signature)) continue;
|
||||
|
||||
Stype type = method.type();
|
||||
Stype compType = interfaceToComp(method.type());
|
||||
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
|
||||
|
||||
if(!method.isVoid()){
|
||||
builder.addStatement("return " + getDefault(method.ret().toString()));
|
||||
if(method.name().equals("isNull")){
|
||||
builder.addStatement("return true");
|
||||
}else{
|
||||
Svar variable = compType == null || method.params().size > 0 ? null : compType.fields().find(v -> v.name().equals(method.name()));
|
||||
if(variable == null || !varInitializers.containsKey(variable)){
|
||||
builder.addStatement("return " + getDefault(method.ret().toString()));
|
||||
}else{
|
||||
String init = varInitializers.get(variable);
|
||||
builder.addStatement("return " + (init.equals("{}") ? "new " + variable.mirror().toString() : "") + init);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nullBuilder.addMethod(builder.build());
|
||||
@ -409,10 +427,12 @@ public class EntityProcess extends BaseProcessor{
|
||||
signatures.add(signature);
|
||||
}
|
||||
|
||||
//write(nullBuilder);
|
||||
nullsBuilder.addField(FieldSpec.builder(interf.cname(), Strings.camelize(baseName)).initializer("new " + className + "()").addModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC).build());
|
||||
|
||||
Log.info("Methods to override for {0}:\n{1}\n\n", interf, methods.toString("\n", s -> "&lg> &lb" + s));
|
||||
write(nullBuilder);
|
||||
}
|
||||
|
||||
write(nullsBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class Stype extends Selement<TypeElement>{
|
||||
}
|
||||
|
||||
public Array<Stype> allInterfaces(){
|
||||
return interfaces().flatMap(Stype::allInterfaces).distinct();
|
||||
return interfaces().flatMap(s -> s.allInterfaces().and(s)).distinct();
|
||||
}
|
||||
|
||||
public Array<Stype> superclasses(){
|
||||
@ -33,8 +33,7 @@ public class Stype extends Selement<TypeElement>{
|
||||
}
|
||||
|
||||
public Array<Stype> allSuperclasses(){
|
||||
//this is truly PEAK efficiency
|
||||
return superclasses().flatMap(Stype::allSuperclasses).distinct();
|
||||
return superclasses().flatMap(s -> s.allSuperclasses().and(s)).distinct();
|
||||
}
|
||||
|
||||
public Stype superclass(){
|
||||
|
@ -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);
|
||||
|
@ -17,6 +17,7 @@ import mindustry.core.GameState.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.desktop.steam.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Net.*;
|
||||
import mindustry.type.*;
|
||||
@ -136,9 +137,9 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
boolean[] isShutdown = {false};
|
||||
|
||||
Events.on(ClientLoadEvent.class, event -> {
|
||||
player.name = SVars.net.friends.getPersonaName();
|
||||
player.name(SVars.net.friends.getPersonaName());
|
||||
Core.settings.defaults("name", SVars.net.friends.getPersonaName());
|
||||
Core.settings.put("name", player.name);
|
||||
Core.settings.put("name", player.name());
|
||||
Core.settings.save();
|
||||
//update callbacks
|
||||
Core.app.addListener(new ApplicationListener(){
|
||||
@ -260,8 +261,8 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
gameMapWithWave += " | Wave " + state.wave;
|
||||
}
|
||||
gameMode = state.rules.pvp ? "PvP" : state.rules.attackMode ? "Attack" : "Survival";
|
||||
if(net.active() && playerGroup.size() > 1){
|
||||
gamePlayersSuffix = " | " + playerGroup.size() + " Players";
|
||||
if(net.active() && Groups.player.size() > 1){
|
||||
gamePlayersSuffix = " | " + Groups.player.size() + " Players";
|
||||
}
|
||||
}else{
|
||||
if(ui.editor != null && ui.editor.isShown()){
|
||||
|
@ -348,7 +348,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
if(result == SteamResult.OK){
|
||||
currentLobby = steamID;
|
||||
|
||||
smat.setLobbyData(steamID, "name", player.name);
|
||||
smat.setLobbyData(steamID, "name", player.name());
|
||||
smat.setLobbyData(steamID, "mapname", world.getMap() == null ? "Unknown" : state.rules.zone == null ? world.getMap().name() : state.rules.zone.localizedName);
|
||||
smat.setLobbyData(steamID, "version", Version.build + "");
|
||||
smat.setLobbyData(steamID, "versionType", Version.type);
|
||||
|
@ -9,6 +9,7 @@ import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.Stats.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -53,18 +54,18 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
private void checkUpdate(){
|
||||
if(campaign()){
|
||||
SStat.maxUnitActive.max(unitGroup.count(t -> t.team() == player.team()));
|
||||
SStat.maxUnitActive.max(Groups.unit.count(t -> t.team() == player.team()));
|
||||
|
||||
if(unitGroup.count(u -> u.getType() == UnitTypes.phantom && u.team() == player.team()) >= 10){
|
||||
if(Groups.unit.count(u -> u.type() == UnitTypes.phantom && u.team() == player.team()) >= 10){
|
||||
active10Phantoms.complete();
|
||||
}
|
||||
|
||||
if(unitGroup.count(u -> u.getType() == UnitTypes.crawler && u.team() == player.team()) >= 50){
|
||||
if(Groups.unit.count(u -> u.type() == UnitTypes.crawler && u.team() == player.team()) >= 50){
|
||||
active50Crawlers.complete();
|
||||
}
|
||||
|
||||
for(Tilec entity : player.team().cores()){
|
||||
if(!content.items().contains(i -> i.type == ItemType.material && entity.items().get(i) < entity.block.itemCapacity)){
|
||||
if(!content.items().contains(i -> i.type == ItemType.material && entity.items().get(i) < entity.block().itemCapacity)){
|
||||
fillCoreAllCampaign.complete();
|
||||
break;
|
||||
}
|
||||
@ -92,7 +93,7 @@ public class SStats implements SteamUserStatsCallback{
|
||||
});
|
||||
|
||||
Events.on(Trigger.newGame, () -> Core.app.post(() -> {
|
||||
if(campaign() && player.closestCore() != null && player.closestCore().items.total() >= 10 * 1000){
|
||||
if(campaign() && player.closestCore() != null && player.closestCore().items().total() >= 10 * 1000){
|
||||
drop10kitems.complete();
|
||||
}
|
||||
}));
|
||||
@ -216,7 +217,7 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
Events.on(PlayerJoin.class, e -> {
|
||||
if(Vars.net.server()){
|
||||
SStat.maxPlayersServer.max(Vars.playerGroup.size());
|
||||
SStat.maxPlayersServer.max(Groups.player.size());
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user