Merge branch 'master' of https://github.com/Anuken/Mindustry into tsunami

 Conflicts:
	core/assets/icons/icons.properties
	core/assets/sprites/block_colors.png
	core/assets/sprites/fallback/sprites.atlas
	core/assets/sprites/fallback/sprites3.png
	core/assets/sprites/fallback/sprites4.png
	core/assets/sprites/fallback/sprites5.png
	core/assets/sprites/fallback/sprites7.png
	core/assets/sprites/fallback/sprites8.png
	core/assets/sprites/sprites.atlas
	core/assets/sprites/sprites.png
	core/assets/sprites/sprites2.png
	core/assets/sprites/sprites4.png
	core/assets/sprites/sprites5.png
	core/src/mindustry/content/Blocks.java
This commit is contained in:
slava0135
2020-09-30 09:48:18 +03:00
33 changed files with 13791 additions and 13571 deletions

View File

@@ -80,6 +80,7 @@ public class EntityProcess extends BaseProcessor{
//replace all self() invocations with this //replace all self() invocations with this
.replaceAll("this\\.<(.*)>self\\(\\)", "this") .replaceAll("this\\.<(.*)>self\\(\\)", "this")
.replaceAll("self\\(\\)", "this") .replaceAll("self\\(\\)", "this")
.replaceAll(" yield ", "")
); );
} }
} }

View File

@@ -173,18 +173,29 @@ allprojects{
} }
tasks.withType(JavaCompile){ tasks.withType(JavaCompile){
sourceCompatibility = 1.8 targetCompatibility = 8
targetCompatibility = 1.8 sourceCompatibility = 14
options.encoding = "UTF-8" options.encoding = "UTF-8"
options.compilerArgs += ["-Xlint:deprecation"] options.compilerArgs += ["-Xlint:deprecation"]
} }
} }
//compile with java 8 compatibility for everything except the annotati project configure(project(":annotations")){
tasks.withType(JavaCompile){
targetCompatibility = 8
sourceCompatibility = 8
}
}
//compile with java 8 compatibility for everything except the annotation project
configure(subprojects - project(":annotations")){ configure(subprojects - project(":annotations")){
tasks.withType(JavaCompile){ tasks.withType(JavaCompile){
if(JavaVersion.current() != JavaVersion.VERSION_1_8){ if(JavaVersion.current() != JavaVersion.VERSION_1_8){
options.compilerArgs.addAll(['--release', '8']) options.compilerArgs.addAll(['--release', '8', '--enable-preview'])
}
doFirst{
options.compilerArgs = options.compilerArgs.findAll{it != '--enable-preview' }
} }
} }
@@ -288,6 +299,8 @@ project(":core"){
compileOnly project(":annotations") compileOnly project(":annotations")
annotationProcessor project(":annotations") annotationProcessor project(":annotations")
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:0.3.0'
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -1119,6 +1119,7 @@ block.arc.name = Arc
block.rtg-generator.name = RTG Generator block.rtg-generator.name = RTG Generator
block.spectre.name = Spectre block.spectre.name = Spectre
block.meltdown.name = Meltdown block.meltdown.name = Meltdown
block.foreshadow.name = Foreshadow
block.container.name = Container block.container.name = Container
block.launch-pad.name = Launch Pad block.launch-pad.name = Launch Pad
block.launch-pad-large.name = Large Launch Pad block.launch-pad-large.name = Large Launch Pad

View File

@@ -312,3 +312,4 @@
63424=corvus|unit-corvus-medium 63424=corvus|unit-corvus-medium
63423=memory-bank|block-memory-bank-medium 63423=memory-bank|block-memory-bank-medium
63422=tsunami|block-tsunami-medium 63422=tsunami|block-tsunami-medium
63422=foreshadow|block-foreshadow-medium

Binary file not shown.

Before

Width:  |  Height:  |  Size: 815 B

After

Width:  |  Height:  |  Size: 815 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 KiB

After

Width:  |  Height:  |  Size: 949 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 KiB

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 KiB

After

Width:  |  Height:  |  Size: 425 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 KiB

After

Width:  |  Height:  |  Size: 421 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -74,7 +74,7 @@ public class Blocks implements ContentList{
coreShard, coreFoundation, coreNucleus, vault, container, unloader, coreShard, coreFoundation, coreNucleus, vault, container, unloader,
//turrets //turrets
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown, segment, parallax, tsunami, duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, foreshadow, spectre, meltdown, segment, parallax, tsunami
//units //units
commandCenter, commandCenter,
@@ -1582,7 +1582,7 @@ public class Blocks implements ContentList{
health = 250 * size * size; health = 250 * size * size;
range = 140f; range = 140f;
hasPower = true; hasPower = true;
consumes.power(8f); consumes.powerCond(8f, (PointDefenseBuild b) -> b.target != null);
size = 2; size = 2;
shootLength = 5f; shootLength = 5f;
bulletDamage = 25f; bulletDamage = 25f;
@@ -1685,6 +1685,48 @@ public class Blocks implements ContentList{
health = 145 * size * size; health = 145 * size * size;
}}; }};
foreshadow = new ItemTurret("foreshadow"){{
float brange = range = 500f;
requirements(Category.turret, with(Items.copper, 1000, Items.metaglass, 600, Items.surgealloy, 300, Items.plastanium, 175, Items.thorium, 350));
ammo(
Items.surgealloy, new PointBulletType(){{
shootEffect = Fx.instShoot;
hitEffect = Fx.instHit;
smokeEffect = Fx.smokeCloud;
trailEffect = Fx.instTrail;
despawnEffect = Fx.instBomb;
trailSpacing = 20f;
damage = 1300;
tileDamageMultiplier = 0.5f;
speed = brange;
hitShake = 6f;
ammoMultiplier = 1f;
}}
);
rotateSpeed = 2.5f;
reloadTime = 200f;
restitution = 0.2f;
ammoUseEffect = Fx.shellEjectBig;
recoilAmount = 5f;
restitution = 0.009f;
cooldown = 0.009f;
shootShake = 4f;
shots = 1;
size = 4;
shootCone = 2f;
shootSound = Sounds.shootBig;
unitSort = (u, x, y) -> -u.maxHealth;
coolantMultiplier = 0.09f;
health = 150 * size * size;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 2f)).update(false).optional(true, true);
consumes.powerCond(10f, (TurretBuild entity) -> entity.target != null || (entity.logicControlled() && entity.logicShooting));
}};
spectre = new ItemTurret("spectre"){{ spectre = new ItemTurret("spectre"){{
requirements(Category.turret, with(Items.copper, 900, Items.graphite, 300, Items.surgealloy, 250, Items.plastanium, 175, Items.thorium, 250)); requirements(Category.turret, with(Items.copper, 900, Items.graphite, 300, Items.surgealloy, 250, Items.plastanium, 175, Items.thorium, 250));
ammo( ammo(
@@ -1707,7 +1749,7 @@ public class Blocks implements ContentList{
shootCone = 24f; shootCone = 24f;
shootSound = Sounds.shootBig; shootSound = Sounds.shootBig;
health = 155 * size * size; health = 160 * size * size;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 2f)).update(false).optional(true, true); consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 2f)).update(false).optional(true, true);
}}; }};

View File

@@ -455,6 +455,79 @@ public class Fx{
}), }),
instBomb = new Effect(15f, 100f, e -> {
color(Pal.bulletYellowBack);
stroke(e.fout() * 4f);
Lines.circle(e.x, e.y, 4f + e.finpow() * 20f);
for(int i = 0; i < 4; i++){
Drawf.tri(e.x, e.y, 6f, 80f * e.fout(), i*90 + 45);
}
color();
for(int i = 0; i < 4; i++){
Drawf.tri(e.x, e.y, 3f, 30f * e.fout(), i*90 + 45);
}
}),
instTrail = new Effect(30, e -> {
for(int i = 0; i < 2; i++){
color(i == 0 ? Pal.bulletYellowBack : Pal.bulletYellow);
float m = i == 0 ? 1f : 0.5f;
float rot = e.rotation + 180f;
float w = 15f * e.fout() * m;
Drawf.tri(e.x, e.y, w, (30f + Mathf.randomSeedRange(e.id, 15f)) * m, rot);
Drawf.tri(e.x, e.y, w, 10f * m, rot + 180f);
}
}),
instShoot = new Effect(24f, e -> {
e.scaled(10f, b -> {
color(Color.white, Pal.bulletYellowBack, b.fin());
stroke(b.fout() * 3f + 0.2f);
Lines.circle(b.x, b.y, b.fin() * 50f);
});
color(Pal.bulletYellowBack);
for(int i : Mathf.signs){
Drawf.tri(e.x, e.y, 13f * e.fout(), 85f, e.rotation + 90f * i);
Drawf.tri(e.x, e.y, 13f * e.fout(), 50f, e.rotation + 20f * i);
}
}),
instHit = new Effect(20f, 200f, e -> {
color(Pal.bulletYellowBack);
for(int i = 0; i < 2; i++){
color(i == 0 ? Pal.bulletYellowBack : Pal.bulletYellow);
float m = i == 0 ? 1f : 0.5f;
for(int j = 0; j < 5; j++){
float rot = e.rotation + Mathf.randomSeedRange(e.id + j, 50f);
float w = 23f * e.fout() * m;
Drawf.tri(e.x, e.y, w, (80f + Mathf.randomSeedRange(e.id + j, 40f)) * m, rot);
Drawf.tri(e.x, e.y, w, 20f * m, rot + 180f);
}
}
e.scaled(10f, c -> {
color(Pal.bulletYellow);
stroke(c.fout() * 2f + 0.2f);
Lines.circle(e.x, e.y, c.fin() * 30f);
});
e.scaled(12f, c -> {
color(Pal.bulletYellowBack);
randLenVectors(e.id, 25, 5f + e.fin() * 80f, e.rotation, 60f, (x, y) -> {
Fill.square(e.x + x, e.y + y, c.fout() * 3f, 45f);
});
});
}),
hitLaser = new Effect(8, e -> { hitLaser = new Effect(8, e -> {
color(Color.white, Pal.heal, e.fin()); color(Color.white, Pal.heal, e.fin());
stroke(0.5f + e.fout()); stroke(0.5f + e.fout());
@@ -1074,28 +1147,11 @@ public class Fx{
}), }),
railHit = new Effect(18f, 200f, e -> { railHit = new Effect(18f, 200f, e -> {
if(true){ color(Pal.orangeSpark);
color(Pal.orangeSpark);
for(int i : Mathf.signs){ for(int i : Mathf.signs){
Drawf.tri(e.x, e.y, 10f * e.fout(), 60f, e.rotation + 140f * i); Drawf.tri(e.x, e.y, 10f * e.fout(), 60f, e.rotation + 140f * i);
}
}else{
e.scaled(7f, b -> {
color(Color.white, Color.lightGray, b.fin());
stroke(b.fout() * 2f + 0.2f);
Lines.circle(b.x, b.y, b.fin() * 28f);
});
color(Pal.orangeSpark);
float rot = e.rotation + Mathf.randomSeedRange(e.id, 20f);
float w = 9f * e.fout();
Drawf.tri(e.x, e.y, w, 100f, rot);
Drawf.tri(e.x, e.y, w, 10f, rot + 180f);
} }
}), }),
lancerLaserShoot = new Effect(21f, e -> { lancerLaserShoot = new Effect(21f, e -> {
@@ -1109,7 +1165,7 @@ public class Fx{
lancerLaserShootSmoke = new Effect(26f, e -> { lancerLaserShootSmoke = new Effect(26f, e -> {
color(Color.white); color(Color.white);
float length = e.data == null || !(e.data instanceof Float) ? 70f : (Float)e.data; float length = !(e.data instanceof Float) ? 70f : (Float)e.data;
randLenVectors(e.id, 7, length, e.rotation, 0f, (x, y) -> { randLenVectors(e.id, 7, length, e.rotation, 0f, (x, y) -> {
lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f);

View File

@@ -109,6 +109,9 @@ public class TechTree implements ContentList{
node(Items.coal, with(Items.lead, 3000), () -> { node(Items.coal, with(Items.lead, 3000), () -> {
node(Items.graphite, with(Items.coal, 1000), () -> { node(Items.graphite, with(Items.coal, 1000), () -> {
node(illuminator, () -> {
});
node(graphitePress, () -> { node(graphitePress, () -> {
node(Items.titanium, with(Items.graphite, 6000, Items.copper, 10000, Items.lead, 10000), () -> { node(Items.titanium, with(Items.graphite, 6000, Items.copper, 10000, Items.lead, 10000), () -> {
node(pneumaticDrill, () -> { node(pneumaticDrill, () -> {
@@ -351,8 +354,10 @@ public class TechTree implements ContentList{
}); });
node(lancer, () -> { node(lancer, () -> {
node(meltdown, () -> { node(foreshadow, () -> {
node(meltdown, () -> {
});
}); });
node(shockMine, () -> { node(shockMine, () -> {

View File

@@ -446,7 +446,7 @@ public class UnitTypes implements ContentList{
mineTier = 1; mineTier = 1;
hitSize = 29f; hitSize = 29f;
itemCapacity = 80; itemCapacity = 80;
health = 19000f; health = 18000f;
buildSpeed = 1.7f; buildSpeed = 1.7f;
armor = 9f; armor = 9f;
landShake = 1.5f; landShake = 1.5f;
@@ -488,7 +488,7 @@ public class UnitTypes implements ContentList{
firstShotDelay = Fx.greenLaserCharge.lifetime; firstShotDelay = Fx.greenLaserCharge.lifetime;
bullet = new LaserBulletType(){{ bullet = new LaserBulletType(){{
length = 500f; length = 460f;
damage = 550f; damage = 550f;
width = 75f; width = 75f;

View File

@@ -417,7 +417,7 @@ public class MapGenerateDialog extends BaseDialog{
public void set(Block floor, Block wall, Block ore, Team team){ public void set(Block floor, Block wall, Block ore, Team team){
this.floor = floor.id; this.floor = floor.id;
this.block = wall.id; this.block = wall.id;
this.ore = ore.id; this.ore = floor.asFloor().isLiquid ? 0 : ore.id;
this.team = (byte)team.id; this.team = (byte)team.id;
} }

View File

@@ -175,6 +175,18 @@ public class Units{
} }
} }
/** Returns the closest target enemy. First, units are checked, then tile entities. */
public static Teamc bestTarget(Team team, float x, float y, float range, Boolf<Unit> unitPred, Boolf<Building> tilePred, Sortf sort){
if(team == Team.derelict) return null;
Unit unit = bestEnemy(team, x, y, range, unitPred, sort);
if(unit != null){
return unit;
}else{
return findEnemyTile(team, x, y, range, tilePred);
}
}
/** Returns the closest enemy of this team. Filter by predicate. */ /** Returns the closest enemy of this team. Filter by predicate. */
public static Unit closestEnemy(Team team, float x, float y, float range, Boolf<Unit> predicate){ public static Unit closestEnemy(Team team, float x, float y, float range, Boolf<Unit> predicate){
if(team == Team.derelict) return null; if(team == Team.derelict) return null;
@@ -195,6 +207,26 @@ public class Units{
return result; return result;
} }
/** Returns the closest enemy of this team using a custom comparison function. Filter by predicate. */
public static Unit bestEnemy(Team team, float x, float y, float range, Boolf<Unit> predicate, Sortf sort){
if(team == Team.derelict) return null;
result = null;
cdist = 0f;
nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> {
if(e.dead() || !predicate.get(e)) return;
float dst2 = sort.cost(e, x, y);
if(dst2 < range*range && (result == null || dst2 < cdist)){
result = e;
cdist = dst2;
}
});
return result;
}
/** Returns the closest ally of this team. Filter by predicate. No range. */ /** Returns the closest ally of this team. Filter by predicate. No range. */
public static Unit closest(Team team, float x, float y, Boolf<Unit> predicate){ public static Unit closest(Team team, float x, float y, Boolf<Unit> predicate){
result = null; result = null;
@@ -297,4 +329,7 @@ public class Units{
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons); nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
} }
public interface Sortf{
float cost(Unit unit, float x, float y);
}
} }

View File

@@ -71,6 +71,9 @@ public abstract class BulletType extends Content{
public boolean hittable = true; public boolean hittable = true;
/** Whether this bullet can be reflected. */ /** Whether this bullet can be reflected. */
public boolean reflectable = true; public boolean reflectable = true;
/** Whether to move the bullet back depending on delta to fix some delta-time realted issues.
* Do not change unless you know what you're doing. */
public boolean backMove = true;
/** Bullet range override. */ /** Bullet range override. */
public float range = -1f; public float range = -1f;
@@ -212,7 +215,7 @@ public abstract class BulletType extends Content{
} }
if(instantDisappear){ if(instantDisappear){
b.time(lifetime); b.time = lifetime;
} }
} }
@@ -274,7 +277,11 @@ public abstract class BulletType extends Content{
bullet.owner = owner; bullet.owner = owner;
bullet.team = team; bullet.team = team;
bullet.vel.trns(angle, speed * velocityScl); bullet.vel.trns(angle, speed * velocityScl);
bullet.set(x - bullet.vel.x * Time.delta, y - bullet.vel.y * Time.delta); if(backMove){
bullet.set(x - bullet.vel.x * Time.delta, y - bullet.vel.y * Time.delta);
}else{
bullet.set(x, y);
}
bullet.lifetime = lifetime * lifetimeScl; bullet.lifetime = lifetime * lifetimeScl;
bullet.data = data; bullet.data = data;
bullet.drag = drag; bullet.drag = drag;

View File

@@ -0,0 +1,70 @@
package mindustry.entities.bullet;
import arc.math.geom.*;
import arc.util.*;
import mindustry.*;
import mindustry.entities.*;
import mindustry.gen.*;
public class PointBulletType extends BulletType{
private static float cdist = 0f;
private static Unit result;
public float trailSpacing = 10f;
public PointBulletType(){
scaleVelocity = true;
lifetime = 100f;
collides = false;
keepVelocity = false;
backMove = false;
}
@Override
public void init(Bullet b){
super.init(b);
float px = b.x + b.lifetime * b.vel.x,
py = b.y + b.lifetime * b.vel.y,
rot = b.rotation();
Geometry.iterateLine(0f, b.x, b.y, px, py, trailSpacing, (x, y) -> {
trailEffect.at(x, y, rot);
});
b.time = b.lifetime;
b.set(px, py);
//calculate hit entity
cdist = 0f;
result = null;
float range = 1f;
Units.nearbyEnemies(b.team, px - range, py - range, range*2f, range*2f, e -> {
if(e.dead()) return;
e.hitbox(Tmp.r1);
if(!Tmp.r1.contains(px, py)) return;
float dst = e.dst(px, py) - e.hitSize;
if((result == null || dst < cdist)){
result = e;
cdist = dst;
}
});
if(result != null){
b.collision(result, px, py);
}else{
Building build = Vars.world.buildWorld(px, py);
if(build != null && build.team != b.team){
build.collision(b);
}
}
b.remove();
b.vel.setZero();
}
}

View File

@@ -1213,31 +1213,35 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
@Override @Override
public double sense(LAccess sensor){ public double sense(LAccess sensor){
if(sensor == LAccess.x) return x; return switch(sensor){
if(sensor == LAccess.y) return y; case x -> x;
if(sensor == LAccess.team) return team.id; case y -> y;
if(sensor == LAccess.health) return health; case team -> team.id;
if(sensor == LAccess.maxHealth) return maxHealth(); case health -> health;
if(sensor == LAccess.efficiency) return efficiency(); case maxHealth -> maxHealth();
if(sensor == LAccess.rotation) return rotation; case efficiency -> efficiency();
if(sensor == LAccess.totalItems && items != null) return items.total(); case rotation -> rotation;
if(sensor == LAccess.totalLiquids && liquids != null) return liquids.total(); case totalItems -> items == null ? 0 : items.total();
if(sensor == LAccess.totalPower && power != null && block.consumes.hasPower()) return power.status * (block.consumes.getPower().buffered ? block.consumes.getPower().capacity : 1f); case totalLiquids -> liquids == null ? 0 : liquids.total();
if(sensor == LAccess.itemCapacity) return block.itemCapacity; case totalPower -> power == null || !block.consumes.hasPower() ? 0 : power.status * (block.consumes.getPower().buffered ? block.consumes.getPower().capacity : 1f);
if(sensor == LAccess.liquidCapacity) return block.liquidCapacity; case itemCapacity -> block.itemCapacity;
if(sensor == LAccess.powerCapacity) return block.consumes.hasPower() ? block.consumes.getPower().capacity : 0f; case liquidCapacity -> block.liquidCapacity;
if(sensor == LAccess.powerNetIn && power != null) return power.graph.getLastScaledPowerIn() * 60; case powerCapacity -> block.consumes.hasPower() ? block.consumes.getPower().capacity : 0f;
if(sensor == LAccess.powerNetOut && power != null) return power.graph.getLastScaledPowerOut() * 60; case powerNetIn -> power == null ? 0 : power.graph.getLastScaledPowerIn() * 60;
if(sensor == LAccess.powerNetStored && power != null) return power.graph.getLastPowerStored(); case powerNetOut -> power == null ? 0 : power.graph.getLastScaledPowerOut() * 60;
if(sensor == LAccess.powerNetCapacity && power != null) return power.graph.getLastCapacity(); case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
return 0; case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
default -> 0;
};
} }
@Override @Override
public Object senseObject(LAccess sensor){ public Object senseObject(LAccess sensor){
if(sensor == LAccess.type) return block; return switch(sensor){
case type -> block;
default -> noSensed;
};
return noSensed;
} }
@Override @Override

View File

@@ -75,24 +75,28 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override @Override
public double sense(LAccess sensor){ public double sense(LAccess sensor){
if(sensor == LAccess.totalItems) return stack().amount; return switch(sensor){
if(sensor == LAccess.rotation) return rotation; case totalItems -> stack().amount;
if(sensor == LAccess.health) return health; case rotation -> rotation;
if(sensor == LAccess.maxHealth) return maxHealth; case health -> health;
if(sensor == LAccess.x) return x; case maxHealth -> maxHealth;
if(sensor == LAccess.y) return y; case x -> x;
if(sensor == LAccess.team) return team.id; case y -> y;
if(sensor == LAccess.shooting) return isShooting() ? 1 : 0; case team -> team.id;
if(sensor == LAccess.shootX) return aimX(); case shooting -> isShooting() ? 1 : 0;
if(sensor == LAccess.shootY) return aimY(); case shootX -> aimX();
return 0; case shootY -> aimY();
default -> 0;
};
} }
@Override @Override
public Object senseObject(LAccess sensor){ public Object senseObject(LAccess sensor){
if(sensor == LAccess.type) return type; return switch(sensor){
case type -> type;
default -> noSensed;
};
return noSensed;
} }
@Override @Override

View File

@@ -17,7 +17,7 @@ import java.util.*;
public class FileChooser extends BaseDialog{ public class FileChooser extends BaseDialog{
private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath()); private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
static Fi lastDirectory = homeDirectory; static Fi lastDirectory = Core.files.absolute(Core.settings.getString("lastDirectory", homeDirectory.absolutePath()));
private Table files; private Table files;
Fi directory = lastDirectory; Fi directory = lastDirectory;
@@ -108,7 +108,7 @@ public class FileChooser extends BaseDialog{
ImageButton home = new ImageButton(Icon.home); ImageButton home = new ImageButton(Icon.home);
home.clicked(() -> { home.clicked(() -> {
directory = homeDirectory; directory = homeDirectory;
lastDirectory = directory; setLastDirectory(directory);
updateFiles(true); updateFiles(true);
}); });
@@ -187,7 +187,7 @@ public class FileChooser extends BaseDialog{
TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet); TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet);
upbutton.clicked(() -> { upbutton.clicked(() -> {
directory = directory.parent(); directory = directory.parent();
lastDirectory = directory; setLastDirectory(directory);
updateFiles(true); updateFiles(true);
}); });
@@ -217,7 +217,7 @@ public class FileChooser extends BaseDialog{
updateFileFieldStatus(); updateFileFieldStatus();
}else{ }else{
directory = directory.child(filename); directory = directory.child(filename);
lastDirectory = directory; setLastDirectory(directory);
updateFiles(true); updateFiles(true);
} }
}); });
@@ -242,6 +242,11 @@ public class FileChooser extends BaseDialog{
if(open) filefield.clearText(); if(open) filefield.clearText();
} }
public static void setLastDirectory(Fi directory){
lastDirectory = directory;
Core.settings.put("lastDirectory", directory.absolutePath());
}
private String shorten(String string){ private String shorten(String string){
int max = 30; int max = 30;
if(string.length() <= max){ if(string.length() <= max){
@@ -269,14 +274,14 @@ public class FileChooser extends BaseDialog{
if(!canBack()) return; if(!canBack()) return;
index--; index--;
directory = history.get(index - 1); directory = history.get(index - 1);
lastDirectory = directory; setLastDirectory(directory);
updateFiles(false); updateFiles(false);
} }
public void forward(){ public void forward(){
if(!canForward()) return; if(!canForward()) return;
directory = history.get(index); directory = history.get(index);
lastDirectory = directory; setLastDirectory(directory);
index++; index++;
updateFiles(false); updateFiles(false);
} }

View File

@@ -703,7 +703,7 @@ public class HudFragment extends Fragment{
t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad); t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad);
t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f); t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f);
t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> { t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> {
b.color.set(player.displayAmmo() ? player.dead() ? Pal.ammo : player.unit().type().ammoType.color : Pal.health); b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type().ammoType.color : Pal.health);
}); });
t.getChildren().get(1).toFront(); t.getChildren().get(1).toFront();

View File

@@ -14,6 +14,7 @@ import arc.util.io.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.entities.Units.*;
import mindustry.entities.bullet.*; import mindustry.entities.bullet.*;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.gen.*; import mindustry.gen.*;
@@ -67,6 +68,7 @@ public abstract class Turret extends Block{
public float coolantMultiplier = 5f; public float coolantMultiplier = 5f;
/** Effect displayed when coolant is used. */ /** Effect displayed when coolant is used. */
public Effect coolEffect = Fx.fuelburn; public Effect coolEffect = Fx.fuelburn;
public Sortf unitSort = Unit::dst2;
protected Vec2 tr = new Vec2(); protected Vec2 tr = new Vec2();
protected Vec2 tr2 = new Vec2(); protected Vec2 tr2 = new Vec2();
@@ -306,9 +308,9 @@ public abstract class Turret extends Block{
protected void findTarget(){ protected void findTarget(){
if(targetAir && !targetGround){ if(targetAir && !targetGround){
target = Units.closestEnemy(team, x, y, range, e -> !e.dead() && !e.isGrounded()); target = Units.bestEnemy(team, x, y, range, e -> !e.dead() && !e.isGrounded(), unitSort);
}else{ }else{
target = Units.closestTarget(team, x, y, range, e -> !e.dead() && (e.isGrounded() || targetAir) && (!e.isGrounded() || targetGround)); target = Units.bestTarget(team, x, y, range, e -> !e.dead() && (e.isGrounded() || targetAir) && (!e.isGrounded() || targetGround), b -> true, unitSort);
} }
} }
@@ -397,7 +399,7 @@ public abstract class Turret extends Block{
} }
protected void bullet(BulletType type, float angle){ protected void bullet(BulletType type, float angle){
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x, y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f; float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + tr.x, y + tr.y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f;
type.create(this, team, x + tr.x, y + tr.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl); type.create(this, team, x + tr.x, y + tr.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl);
} }

View File

@@ -45,6 +45,8 @@ task run(dependsOn: classes, type: JavaExec){
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true") jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
} }
jvmArgs += "-XX:+ShowCodeDetailsInExceptionMessages"
/*spriteHashFile.parentFile.mkdirs() /*spriteHashFile.parentFile.mkdirs()
String spriteHash = hashDirectory() String spriteHash = hashDirectory()
if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){ if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){