mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-22 05:47:44 +03:00
Fix multiple crashes, add shader fallback
This commit is contained in:
parent
ece7ad0fd3
commit
66b068f5e0
@ -79,7 +79,7 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.Anuken:ucore:a1ae9be'
|
compile 'com.github.Anuken:ucore:dfceb01'
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import io.anuke.mindustry.core.*;
|
|||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.io.Formatter;
|
import io.anuke.mindustry.io.Formatter;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.World;
|
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.ucore.core.Inputs;
|
import io.anuke.ucore.core.Inputs;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
@ -4,11 +4,8 @@ import com.badlogic.gdx.Application.ApplicationType;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.utils.I18NBundle;
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.Control;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.core.Renderer;
|
|
||||||
import io.anuke.mindustry.core.UI;
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.world.World;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
public class Vars{
|
public class Vars{
|
||||||
|
@ -26,7 +26,6 @@ import io.anuke.mindustry.resource.Item;
|
|||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
|
||||||
import io.anuke.ucore.UCore;
|
import io.anuke.ucore.UCore;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
@ -179,17 +178,6 @@ public class Control extends Module{
|
|||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void findCore(){
|
|
||||||
for(int x = 0; x < Vars.world.width(); x ++){
|
|
||||||
for(int y = 0; y < Vars.world.height(); y ++){
|
|
||||||
if(world.tile(x, y).block() == ProductionBlocks.core){
|
|
||||||
core = world.tile(x, y);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile getCore(){
|
public Tile getCore(){
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
@ -433,6 +421,10 @@ public class Control extends Module{
|
|||||||
wavetime = 0f;
|
wavetime = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Inputs.keyUp(Keys.C)){
|
||||||
|
GameState.set(State.playing);
|
||||||
|
}
|
||||||
|
|
||||||
if(Inputs.keyUp(Keys.U)){
|
if(Inputs.keyUp(Keys.U)){
|
||||||
Vars.showUI = !Vars.showUI;
|
Vars.showUI = !Vars.showUI;
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,10 @@ public class Renderer extends RendererModule{
|
|||||||
}else{
|
}else{
|
||||||
boolean smoothcam = Settings.getBool("smoothcam");
|
boolean smoothcam = Settings.getBool("smoothcam");
|
||||||
|
|
||||||
if(control.core == null){ //how is this possible? apparently it is
|
if(control.core == null){
|
||||||
control.findCore();
|
ui.showGameError();
|
||||||
|
GameState.set(State.menu);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(control.core.block() == ProductionBlocks.core){
|
if(control.core.block() == ProductionBlocks.core){
|
||||||
@ -250,9 +252,15 @@ public class Renderer extends RendererModule{
|
|||||||
Tmp.tr2.setRegion(texture);
|
Tmp.tr2.setRegion(texture);
|
||||||
Shaders.shield.region = Tmp.tr2;
|
Shaders.shield.region = Tmp.tr2;
|
||||||
Shaders.shield.hits = shieldHits;
|
Shaders.shield.hits = shieldHits;
|
||||||
|
|
||||||
|
if(Shaders.shield.isFallback){
|
||||||
|
Draw.color(1f, 1f, 1f, 0.3f);
|
||||||
|
Shaders.outline.color = Color.SKY;
|
||||||
|
Shaders.outline.region = Tmp.tr2;
|
||||||
|
}
|
||||||
|
|
||||||
Graphics.end();
|
Graphics.end();
|
||||||
Graphics.shader(Shaders.shield);
|
Graphics.shader(Shaders.shield.isFallback ? Shaders.outline : Shaders.shield);
|
||||||
Graphics.setScreen();
|
Graphics.setScreen();
|
||||||
|
|
||||||
Core.batch.draw(texture, 0, Gdx.graphics.getHeight(), Gdx.graphics.getWidth(), -Gdx.graphics.getHeight());
|
Core.batch.draw(texture, 0, Gdx.graphics.getHeight(), Gdx.graphics.getWidth(), -Gdx.graphics.getHeight());
|
||||||
@ -260,6 +268,8 @@ public class Renderer extends RendererModule{
|
|||||||
Graphics.shader();
|
Graphics.shader();
|
||||||
Graphics.end();
|
Graphics.end();
|
||||||
Graphics.beginCam();
|
Graphics.beginCam();
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addShieldHit(float x, float y){
|
public void addShieldHit(float x, float y){
|
||||||
|
@ -38,7 +38,7 @@ public class UI extends SceneModule{
|
|||||||
Table loadingtable, desctable, configtable;
|
Table loadingtable, desctable, configtable;
|
||||||
MindustrySettingsDialog prefs;
|
MindustrySettingsDialog prefs;
|
||||||
MindustryKeybindDialog keys;
|
MindustryKeybindDialog keys;
|
||||||
Dialog about, restart, levels, upgrades, load, settingserror;
|
Dialog about, restart, levels, upgrades, load, settingserror, gameerror;
|
||||||
MenuDialog menu;
|
MenuDialog menu;
|
||||||
Tooltip tooltip;
|
Tooltip tooltip;
|
||||||
Tile configTile;
|
Tile configTile;
|
||||||
@ -162,6 +162,15 @@ public class UI extends SceneModule{
|
|||||||
settingserror.hide();
|
settingserror.hide();
|
||||||
}).size(80f, 55f).pad(4);
|
}).size(80f, 55f).pad(4);
|
||||||
|
|
||||||
|
gameerror = new Dialog("An error has occured", "dialog");
|
||||||
|
gameerror.content().add(new Label("[SCARLET]An unexpected error has occured, which would have caused a crash. "
|
||||||
|
+ "[]Please report the exact circumstances under which this error occured to the developer: "
|
||||||
|
+ "\n[ORANGE]anukendev@gmail.com[]"){{
|
||||||
|
setWrap(true);
|
||||||
|
}}).width(600f).units(Unit.dp).pad(10f);
|
||||||
|
gameerror.buttons().addButton("OK", ()-> gameerror.hide()).size(200f, 50).units(Unit.dp);
|
||||||
|
//gameerror.setFillParent(true);
|
||||||
|
|
||||||
load = new LoadDialog();
|
load = new LoadDialog();
|
||||||
|
|
||||||
upgrades = new UpgradeDialog();
|
upgrades = new UpgradeDialog();
|
||||||
@ -298,10 +307,13 @@ public class UI extends SceneModule{
|
|||||||
if(e instanceof Table){
|
if(e instanceof Table){
|
||||||
((Table)e).invalidateHierarchy();
|
((Table)e).invalidateHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showGameError(){
|
||||||
|
gameerror.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void updateWeapons(){
|
public void updateWeapons(){
|
||||||
((WeaponFragment)weaponfrag).updateWeapons();
|
((WeaponFragment)weaponfrag).updateWeapons();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@ -10,10 +10,12 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.effect.Fx;
|
import io.anuke.mindustry.entities.effect.Fx;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Sounds;
|
import io.anuke.ucore.core.Sounds;
|
||||||
@ -95,6 +97,11 @@ public class World extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int x, int y){
|
||||||
|
if(tiles == null){
|
||||||
|
ui.showGameError();
|
||||||
|
GameState.set(State.menu);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if(!Mathf.inBounds(x, y, tiles)) return null;
|
if(!Mathf.inBounds(x, y, tiles)) return null;
|
||||||
return tiles[x][y];
|
return tiles[x][y];
|
||||||
}
|
}
|
||||||
@ -103,6 +110,10 @@ public class World extends Module{
|
|||||||
return tile(Mathf.scl2(x, tilesize), Mathf.scl2(y, tilesize));
|
return tile(Mathf.scl2(x, tilesize), Mathf.scl2(y, tilesize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tile[][] getTiles(){
|
||||||
|
return tiles;
|
||||||
|
}
|
||||||
|
|
||||||
public Tile[] getNearby(int x, int y){
|
public Tile[] getNearby(int x, int y){
|
||||||
temptiles[0] = tile(x+1, y);
|
temptiles[0] = tile(x+1, y);
|
||||||
temptiles[1] = tile(x, y+1);
|
temptiles[1] = tile(x, y+1);
|
||||||
@ -179,7 +190,7 @@ public class World extends Module{
|
|||||||
Generator.generate(mapPixmaps[map.ordinal()], tiles);
|
Generator.generate(mapPixmaps[map.ordinal()], tiles);
|
||||||
|
|
||||||
//TODO multiblock core
|
//TODO multiblock core
|
||||||
placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0);
|
placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false);
|
||||||
|
|
||||||
if(map != Map.tutorial){
|
if(map != Map.tutorial){
|
||||||
setDefaultBlocks();
|
setDefaultBlocks();
|
||||||
@ -229,7 +240,7 @@ public class World extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO move to control or player?
|
//TODO move to control or player?
|
||||||
public void placeBlock(int x, int y, Block result, int rotation){
|
public void placeBlock(int x, int y, Block result, int rotation, boolean effects){
|
||||||
Tile tile = tile(x, y);
|
Tile tile = tile(x, y);
|
||||||
|
|
||||||
//just in case
|
//just in case
|
||||||
@ -251,15 +262,15 @@ public class World extends Module{
|
|||||||
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
||||||
}
|
}
|
||||||
|
|
||||||
Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize);
|
if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize);
|
if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Effects.shake(2f, 2f, player);
|
//Effects.shake(2f, 2f, player);
|
||||||
Sounds.play("place");
|
if(effects) Sounds.play("place");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO move this to control?
|
//TODO move this to control?
|
@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities.enemies;
|
package io.anuke.mindustry.entities.enemies;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
@ -37,6 +38,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
protected boolean targetCore = false;
|
protected boolean targetCore = false;
|
||||||
protected boolean stopNearCore = true;
|
protected boolean stopNearCore = true;
|
||||||
protected float mass = 1f;
|
protected float mass = 1f;
|
||||||
|
protected String className;
|
||||||
|
|
||||||
public float idletime = 0f;
|
public float idletime = 0f;
|
||||||
public int spawn;
|
public int spawn;
|
||||||
@ -56,6 +58,8 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
maxhealth = 60;
|
maxhealth = 60;
|
||||||
heal();
|
heal();
|
||||||
|
|
||||||
|
className = ClassReflection.getSimpleName(getClass()).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float drawSize(){
|
public float drawSize(){
|
||||||
@ -252,7 +256,8 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + Mathf.clamp(tier, 1, 3);
|
if(Timers.get(this, "asd", 30)) Gdx.app.error("ENEMY", "Currently drawing at " + x + " " + y);
|
||||||
|
String region = className + "-t" + Mathf.clamp(tier, 1, 3);
|
||||||
|
|
||||||
Shaders.outline.color.set(tierColors[tier - 1]);
|
Shaders.outline.color.set(tierColors[tier - 1]);
|
||||||
Shaders.outline.region = Draw.region(region);
|
Shaders.outline.region = Draw.region(region);
|
||||||
|
@ -87,7 +87,7 @@ public class AndroidInput extends InputAdapter{
|
|||||||
|
|
||||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && Vars.world.validPlace(tilex, tiley, player.recipe.result)){
|
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && Vars.world.validPlace(tilex, tiley, player.recipe.result)){
|
||||||
|
|
||||||
Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation);
|
Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation, true);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
|
@ -56,7 +56,7 @@ public class Input{
|
|||||||
Vars.world.validPlace(tilex(), tiley(), player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
Vars.world.validPlace(tilex(), tiley(), player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
||||||
Vars.control.hasItems(player.recipe.requirements)){
|
Vars.control.hasItems(player.recipe.requirements)){
|
||||||
|
|
||||||
Vars.world.placeBlock(tilex(), tiley(), player.recipe.result, player.rotation);
|
Vars.world.placeBlock(tilex(), tiley(), player.recipe.result, player.rotation, true);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
|
Loading…
Reference in New Issue
Block a user