mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-03 04:44:24 +07:00
Fixed ClassCastException thrown on Junction use and turret prediction
This commit is contained in:
parent
d53f12aeb9
commit
4c860a0315
@ -309,6 +309,10 @@ public class Control extends RendererModule{
|
|||||||
if(Inputs.keyDown(Keys.SPACE)){
|
if(Inputs.keyDown(Keys.SPACE)){
|
||||||
Effects.shake(6, 4);
|
Effects.shake(6, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Inputs.keyDown(Keys.Y)){
|
||||||
|
new TestEnemy(0).set(player.x, player.y).add();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GameState.is(State.menu)){
|
if(GameState.is(State.menu)){
|
||||||
|
@ -17,7 +17,7 @@ public class Inventory{
|
|||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
items.put(Item.stone, 2000);
|
items.put(Item.stone, 2000);
|
||||||
items.put(Item.iron, 1);
|
items.put(Item.iron, 2000);
|
||||||
items.put(Item.steel, 2000);
|
items.put(Item.steel, 2000);
|
||||||
items.put(Item.coal, 2000);
|
items.put(Item.coal, 2000);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.entities.*;
|
import io.anuke.ucore.entities.*;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class Enemy extends DestructibleEntity{
|
public class Enemy extends DestructibleEntity{
|
||||||
@ -122,11 +123,11 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
move();
|
move();
|
||||||
|
|
||||||
xvelocity = x - lastx;
|
xvelocity = (x - lastx) / Mathf.delta();
|
||||||
yvelocity = y - lasty;
|
yvelocity = (y - lasty) / Mathf.delta();
|
||||||
|
|
||||||
if(target == null){
|
if(target == null){
|
||||||
direction.add(xvelocity, yvelocity);
|
direction.add(xvelocity * Mathf.delta(), yvelocity * Mathf.delta());
|
||||||
direction.limit(speed*rotatespeed);
|
direction.limit(speed*rotatespeed);
|
||||||
}else{
|
}else{
|
||||||
float angle = angleTo(target);
|
float angle = angleTo(target);
|
||||||
|
22
core/src/io/anuke/mindustry/entities/enemies/TestEnemy.java
Normal file
22
core/src/io/anuke/mindustry/entities/enemies/TestEnemy.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package io.anuke.mindustry.entities.enemies;
|
||||||
|
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class TestEnemy extends Enemy{
|
||||||
|
boolean dir = false;
|
||||||
|
|
||||||
|
public TestEnemy(int spawn) {
|
||||||
|
super(spawn);
|
||||||
|
maxhealth = 99999;
|
||||||
|
heal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void move(){
|
||||||
|
if(Timers.get(this, "asd", 300)){
|
||||||
|
dir = !dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
move(dir ? -0.3f * Mathf.delta() : 0.3f * Mathf.delta(), 0);
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ public class LevelDialog extends Dialog{
|
|||||||
hide();
|
hide();
|
||||||
Vars.ui.showLoading();
|
Vars.ui.showLoading();
|
||||||
Timers.run(16, ()->{
|
Timers.run(16, ()->{
|
||||||
|
Vars.control.reset();
|
||||||
World.loadMap(selectedMap);
|
World.loadMap(selectedMap);
|
||||||
Vars.control.play();
|
Vars.control.play();
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@ public class ProductionBlocks{
|
|||||||
int dir = source.relativeTo(tile.x, tile.y);
|
int dir = source.relativeTo(tile.x, tile.y);
|
||||||
dir = (dir+4)%4;
|
dir = (dir+4)%4;
|
||||||
Tile to = tile.getNearby()[dir];
|
Tile to = tile.getNearby()[dir];
|
||||||
Timers.run(15, ()->{
|
Timers.run(10, ()->{
|
||||||
to.block().handleItem(to, item, tile);
|
to.block().handleItem(to, item, tile);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public class ProductionBlocks{
|
|||||||
int dir = source.relativeTo(dest.x, dest.y);
|
int dir = source.relativeTo(dest.x, dest.y);
|
||||||
dir = (dir+4)%4;
|
dir = (dir+4)%4;
|
||||||
Tile to = dest.getNearby()[dir];
|
Tile to = dest.getNearby()[dir];
|
||||||
return to != null && to.block() != junction && to.block().accept(item, dest, to);
|
return to != null && to.block() != junction && to.block().accept(item, to, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,25 +62,6 @@ public class Turret extends Block{
|
|||||||
Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract);
|
Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawOverlay(Tile tile){
|
|
||||||
/*
|
|
||||||
TurretEntity entity = tile.entity();
|
|
||||||
|
|
||||||
if(entity.ammo <= 0 && ammo != null){
|
|
||||||
Draw.tcolor(Color.SCARLET);
|
|
||||||
Draw.tscl(1 / 8f);
|
|
||||||
//Draw.text("No ammo!", tile.worldx(), tile.worldy() + tilesize);
|
|
||||||
}else if(ammo != null){
|
|
||||||
Draw.tscl(1 / 8f);
|
|
||||||
Draw.tcolor(Color.GREEN);
|
|
||||||
//Draw.text("Ammo: " + entity.ammo, tile.worldx(), tile.worldy() - tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.tscl(Vars.fontscale);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item, Tile dest, Tile source){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return item == ammo && dest.<TurretEntity>entity().ammo < maxammo;
|
return item == ammo && dest.<TurretEntity>entity().ammo < maxammo;
|
||||||
@ -107,7 +88,7 @@ public class Turret extends Block{
|
|||||||
|
|
||||||
if(enemy != null){
|
if(enemy != null){
|
||||||
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation,
|
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation,
|
||||||
Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f),
|
Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed),
|
||||||
0.2f*Mathf.delta());
|
0.2f*Mathf.delta());
|
||||||
float reload = Vars.multiplier*this.reload;
|
float reload = Vars.multiplier*this.reload;
|
||||||
if(Timers.get(tile, reload)){
|
if(Timers.get(tile, reload)){
|
||||||
|
BIN
desktop/gifexport/recording1505164662.gif
Normal file
BIN
desktop/gifexport/recording1505164662.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 877 KiB |
Loading…
Reference in New Issue
Block a user