Bugfixes / Possibly fixed unit tests
This commit is contained in:
@@ -13,5 +13,5 @@ varying vec2 v_texCoord;
|
|||||||
void main() {
|
void main() {
|
||||||
vec4 color = texture2D(u_texture, v_texCoord.xy);
|
vec4 color = texture2D(u_texture, v_texCoord.xy);
|
||||||
color = vec4(0.0, 0.0, 0.0, 1.0 - color.r);
|
color = vec4(0.0, 0.0, 0.0, 1.0 - color.r);
|
||||||
gl_FragColor = color * v_color;
|
gl_FragColor = color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public class Vars{
|
|||||||
public static final float itemSize = 5f;
|
public static final float itemSize = 5f;
|
||||||
/**extra padding around the world; units outside this bound will begin to self-destruct.*/
|
/**extra padding around the world; units outside this bound will begin to self-destruct.*/
|
||||||
public static final float worldBounds = 100f;
|
public static final float worldBounds = 100f;
|
||||||
|
/**units outside of this bound will simply die instantly*/
|
||||||
|
public static final float finalWorldBounds = worldBounds + 500;
|
||||||
/**ticks spent out of bound until self destruct.*/
|
/**ticks spent out of bound until self destruct.*/
|
||||||
public static final float boundsCountdown = 60*7;
|
public static final float boundsCountdown = 60*7;
|
||||||
/**size of tiles in units*/
|
/**size of tiles in units*/
|
||||||
|
|||||||
@@ -185,9 +185,7 @@ public class World implements ApplicationListener{
|
|||||||
|
|
||||||
addDarkness(tiles);
|
addDarkness(tiles);
|
||||||
|
|
||||||
int padding = 50;
|
EntityQuery.resizeTree(-finalWorldBounds, -finalWorldBounds, tiles.length * tilesize + finalWorldBounds, tiles[0].length + finalWorldBounds);
|
||||||
|
|
||||||
EntityQuery.resizeTree(-padding * tilesize, -padding * tilesize, (tiles.length + padding) * tilesize, (tiles[0].length + padding) * tilesize);
|
|
||||||
|
|
||||||
generating = false;
|
generating = false;
|
||||||
Events.fire(new WorldLoadEvent());
|
Events.fire(new WorldLoadEvent());
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.anuke.arc.graphics.g2d.Draw;
|
|||||||
import io.anuke.arc.graphics.g2d.Fill;
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
import io.anuke.arc.math.Angles;
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.arc.util.Tmp;
|
import io.anuke.arc.util.Tmp;
|
||||||
@@ -16,41 +15,20 @@ import io.anuke.mindustry.entities.units.UnitState;
|
|||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public abstract class FlyingUnit extends BaseUnit{
|
public abstract class FlyingUnit extends BaseUnit{
|
||||||
protected float[] weaponAngles = {0, 0};
|
protected float[] weaponAngles = {0, 0};
|
||||||
|
|
||||||
protected final UnitState
|
protected final UnitState
|
||||||
|
|
||||||
idle = new UnitState(){
|
|
||||||
public void update(){
|
|
||||||
retarget(() -> {
|
|
||||||
targetClosest();
|
|
||||||
targetClosestEnemyFlag(BlockFlag.target);
|
|
||||||
|
|
||||||
if(target != null){
|
|
||||||
setState(attack);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
target = getClosestCore();
|
|
||||||
if(target != null){
|
|
||||||
circle(50f);
|
|
||||||
}
|
|
||||||
velocity.scl(0.8f);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
attack = new UnitState(){
|
attack = new UnitState(){
|
||||||
public void entered(){
|
public void entered(){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
if(Units.invalidateTarget(target, team, x, y)){
|
if(Units.invalidateTarget(target, team, x, y)){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
@@ -60,19 +38,15 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
retarget(() -> {
|
retarget(() -> {
|
||||||
targetClosest();
|
targetClosest();
|
||||||
|
|
||||||
if(target == null){
|
|
||||||
setState(patrol);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(target == null) targetClosestEnemyFlag(BlockFlag.target);
|
if(target == null) targetClosestEnemyFlag(BlockFlag.target);
|
||||||
if(target == null) targetClosestEnemyFlag(BlockFlag.producer);
|
if(target == null) targetClosestEnemyFlag(BlockFlag.producer);
|
||||||
if(target == null) targetClosestEnemyFlag(BlockFlag.turret);
|
if(target == null) targetClosestEnemyFlag(BlockFlag.turret);
|
||||||
|
|
||||||
if(target == null){
|
if(target == null){
|
||||||
setState(idle);
|
setState(patrol);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
attack(type.attackLength);
|
attack(type.attackLength);
|
||||||
|
|
||||||
@@ -103,6 +77,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
public void update(){
|
public void update(){
|
||||||
retarget(() -> {
|
retarget(() -> {
|
||||||
targetClosest();
|
targetClosest();
|
||||||
|
targetClosestEnemyFlag(BlockFlag.target);
|
||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
setState(attack);
|
setState(attack);
|
||||||
@@ -115,24 +90,6 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
circle(60f + Mathf.absin(Time.time() + id * 23525, 70f, 1200f));
|
circle(60f + Mathf.absin(Time.time() + id * 23525, 70f, 1200f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
retreat = new UnitState(){
|
|
||||||
public void entered(){
|
|
||||||
target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(){
|
|
||||||
if(health >= maxHealth()){
|
|
||||||
state.set(attack);
|
|
||||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
|
||||||
retarget(() -> {
|
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
|
||||||
if(target != null) FlyingUnit.this.target = target.entity;
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
circle(20f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -183,17 +140,13 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
|
|
||||||
if(Units.invalidateTarget(target, this)){
|
if(Units.invalidateTarget(target, this)){
|
||||||
for(boolean left : Mathf.booleans){
|
for(boolean left : Mathf.booleans){
|
||||||
int wi = Mathf.num(left);
|
int wi = Mathf.num(left);
|
||||||
weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi],rotation, 0.1f);
|
weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi],rotation, 0.1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(health <= health * type.retreatPercent &&
|
|
||||||
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
|
|
||||||
setState(retreat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -57,19 +57,6 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
retreat = new UnitState(){
|
|
||||||
public void entered(){
|
|
||||||
target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(){
|
|
||||||
if(health >= maxHealth()){
|
|
||||||
state.set(attack);
|
|
||||||
}
|
|
||||||
|
|
||||||
moveAwayFromCore();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,9 +145,6 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
if(health <= health * type.retreatPercent){
|
|
||||||
setState(retreat);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Units.invalidateTarget(target, this)){
|
if(!Units.invalidateTarget(target, this)){
|
||||||
if(dst(target) < getWeapon().bullet.range()){
|
if(dst(target) < getWeapon().bullet.range()){
|
||||||
|
|||||||
@@ -292,4 +292,12 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
public EntityGroup targetGroup(){
|
public EntityGroup targetGroup(){
|
||||||
return tileGroup;
|
return tileGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return "TileEntity{" +
|
||||||
|
"tile=" + tile +
|
||||||
|
", health=" + health +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,10 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
|
|
||||||
velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta());
|
velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta());
|
||||||
|
|
||||||
|
if(x < -finalWorldBounds || y < -finalWorldBounds || x >= world.width() * tilesize + finalWorldBounds || y >= world.height() * tilesize + finalWorldBounds){
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
|
||||||
if(isFlying()){
|
if(isFlying()){
|
||||||
move(velocity.x * Time.delta(), velocity.y * Time.delta());
|
move(velocity.x * Time.delta(), velocity.y * Time.delta());
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ public class StateMachine{
|
|||||||
if(next != null) next.entered();
|
if(next != null) next.entered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnitState current(){
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean is(UnitState state){
|
public boolean is(UnitState state){
|
||||||
return this.state == state;
|
return this.state == state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,6 +642,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||||
|
if(Core.scene.hasDialog()) return false;
|
||||||
|
|
||||||
float scale = Core.camera.width / Core.graphics.getWidth();
|
float scale = Core.camera.width / Core.graphics.getWidth();
|
||||||
deltaX *= scale;
|
deltaX *= scale;
|
||||||
deltaY *= scale;
|
deltaY *= scale;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class PowerTests extends PowerTestFixture{
|
|||||||
}
|
}
|
||||||
void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){
|
void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){
|
||||||
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
||||||
|
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 1f;
|
||||||
Tile directConsumerTile = createFakeTile(0, 1, createFakeDirectConsumer(requiredPower));
|
Tile directConsumerTile = createFakeTile(0, 1, createFakeDirectConsumer(requiredPower));
|
||||||
|
|
||||||
PowerGraph powerGraph = new PowerGraph();
|
PowerGraph powerGraph = new PowerGraph();
|
||||||
@@ -90,6 +91,7 @@ public class PowerTests extends PowerTestFixture{
|
|||||||
}
|
}
|
||||||
void simulateBufferedConsumption(float producedPower, float maxBuffer, float powerConsumedPerTick, float initialSatisfaction, float expectedSatisfaction, String parameterDescription){
|
void simulateBufferedConsumption(float producedPower, float maxBuffer, float powerConsumedPerTick, float initialSatisfaction, float expectedSatisfaction, String parameterDescription){
|
||||||
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
||||||
|
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 1f;
|
||||||
Tile bufferedConsumerTile = createFakeTile(0, 1, createFakeBufferedConsumer(maxBuffer, maxBuffer > 0.0f ? maxBuffer/powerConsumedPerTick : 1.0f));
|
Tile bufferedConsumerTile = createFakeTile(0, 1, createFakeBufferedConsumer(maxBuffer, maxBuffer > 0.0f ? maxBuffer/powerConsumedPerTick : 1.0f));
|
||||||
bufferedConsumerTile.entity.power.satisfaction = initialSatisfaction;
|
bufferedConsumerTile.entity.power.satisfaction = initialSatisfaction;
|
||||||
|
|
||||||
@@ -134,6 +136,7 @@ public class PowerTests extends PowerTestFixture{
|
|||||||
|
|
||||||
if(producedPower > 0.0f){
|
if(producedPower > 0.0f){
|
||||||
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
|
||||||
|
producerTile.<PowerGenerator.GeneratorEntity>entity().productionEfficiency = 1f;
|
||||||
powerGraph.add(producerTile);
|
powerGraph.add(producerTile);
|
||||||
}
|
}
|
||||||
Tile directConsumerTile = null;
|
Tile directConsumerTile = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user