mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 03:08:38 +07:00
Debugging, cleanup
This commit is contained in:
parent
3fc278c7b7
commit
1e8b844eac
@ -209,7 +209,7 @@ public class Mechs implements ContentList{
|
||||
Shaders.build.color.set(Palette.accent).a = player.shootHeat;
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.alpha(1f);
|
||||
Draw.rect(armorRegion, player.snappedX(), player.snappedY(), player.rotation);
|
||||
Draw.rect(armorRegion, player.x, player.y, player.rotation);
|
||||
Draw.shader(Shaders.mix);
|
||||
Draw.color(1f, 1f, 1f, alpha);
|
||||
}
|
||||
@ -273,7 +273,7 @@ public class Mechs implements ContentList{
|
||||
Draw.color(Palette.lancerLaser);
|
||||
Draw.alpha(scl/2f);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f), player.rotation - 90);
|
||||
Draw.rect(shield, player.x + Mathf.range(scl/2f), player.y + Mathf.range(scl/2f), player.rotation - 90);
|
||||
Draw.blend();
|
||||
Draw.shader(Shaders.mix);
|
||||
Draw.color();
|
||||
|
@ -56,7 +56,6 @@ public class Control implements ApplicationListener{
|
||||
unlocks = new Unlocks();
|
||||
|
||||
Core.input.setCatch(KeyCode.BACK, true);
|
||||
Core.keybinds.setDefaults(Binding.values());
|
||||
|
||||
Effects.setShakeFalloff(10000f);
|
||||
|
||||
@ -279,7 +278,7 @@ public class Control implements ApplicationListener{
|
||||
if(!Core.settings.getBool("4.0-warning-2", false)){
|
||||
|
||||
Time.run(5f, () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("[accent]WARNING![]");
|
||||
FloatingDialog dialog = new FloatingDialog("WARNING!");
|
||||
dialog.buttons().addButton("$text.ok", () -> {
|
||||
dialog.hide();
|
||||
Core.settings.put("4.0-warning-2", true);
|
||||
@ -294,13 +293,6 @@ public class Control implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
|
||||
/** Called from main logic thread.*/
|
||||
public void runUpdateLogic(){
|
||||
if(!state.is(State.menu)){
|
||||
renderer.minimap.updateUnitArray();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
|
@ -4,12 +4,11 @@ import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.ApplicationListener;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.entities.Entities;
|
||||
import io.anuke.arc.entities.EntityGroup;
|
||||
import io.anuke.arc.entities.EntityQuery;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
@ -172,10 +171,6 @@ public class Logic implements ApplicationListener{
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
if(Vars.control != null){
|
||||
control.runUpdateLogic();
|
||||
}
|
||||
|
||||
if(!state.is(State.menu)){
|
||||
|
||||
if(!state.isPaused()){
|
||||
|
@ -18,11 +18,10 @@ import io.anuke.arc.graphics.g2d.SpriteBatch;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect;
|
||||
@ -32,7 +31,6 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static io.anuke.arc.Core.graphics;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Renderer implements ApplicationListener{
|
||||
@ -44,6 +42,7 @@ public class Renderer implements ApplicationListener{
|
||||
private int targetscale = baseCameraScale;
|
||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||
private Vector2 avgPosition = new Vector2();
|
||||
private float shakeIntensity, shaketime;
|
||||
|
||||
public Renderer(){
|
||||
batch = new SpriteBatch(4096);
|
||||
@ -52,6 +51,11 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
Shaders.init();
|
||||
|
||||
Effects.setScreenShakeProvider((intensity, duration) -> {
|
||||
shakeIntensity = Math.max(intensity, shakeIntensity);
|
||||
shaketime = Math.max(shaketime, duration);
|
||||
});
|
||||
|
||||
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
||||
if(effect == Fx.none) return;
|
||||
if(Core.settings.getBool("effects")){
|
||||
@ -95,6 +99,13 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
camera.position.set(players[0].x, players[0].y);
|
||||
graphics.clear(Color.PURPLE);
|
||||
Draw.proj(camera.projection());
|
||||
players[0].drawAll();
|
||||
Draw.flush();
|
||||
|
||||
/*
|
||||
//TODO hack, find source of this bug
|
||||
Color.WHITE.set(1f, 1f, 1f, 1f);
|
||||
|
||||
@ -119,7 +130,7 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
float prex = camera.position.x, prey = camera.position.y;
|
||||
//TODO update screenshake
|
||||
//updateShake(0.75f);
|
||||
updateShake(0.75f);
|
||||
|
||||
float deltax = camera.position.x - prex, deltay = camera.position.y - prey;
|
||||
float lastx = camera.position.x, lasty = camera.position.y;
|
||||
@ -136,11 +147,24 @@ public class Renderer implements ApplicationListener{
|
||||
if(!ui.chatfrag.chatOpen()){
|
||||
//TODO does not work
|
||||
//ScreenRecorder.record(); //this only does something if CoreGifRecorder is on the class path, which it usually isn't
|
||||
}*/
|
||||
}
|
||||
|
||||
void updateShake(float scale){
|
||||
if(shaketime > 0){
|
||||
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;
|
||||
camera.position.add(Mathf.range(intensity), Mathf.range(intensity));
|
||||
shakeIntensity -= 0.25f * Time.delta();
|
||||
shaketime -= Time.delta();
|
||||
shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f);
|
||||
}else{
|
||||
shakeIntensity = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
camera.update();
|
||||
|
||||
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
||||
camera.position.x = players[0].x;
|
||||
camera.position.y = players[0].y;
|
||||
@ -259,10 +283,10 @@ public class Renderer implements ApplicationListener{
|
||||
Shaders.mix.color.set(Color.WHITE);
|
||||
|
||||
//Graphics.beginShaders(Shaders.outline);
|
||||
//Draw.shader(Shaders.mix, true);
|
||||
Draw.shader(Shaders.mix, true);
|
||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||
//Draw.shader();
|
||||
Draw.shader();
|
||||
blocks.drawTeamBlocks(Layer.turret, team);
|
||||
//Graphics.endShaders();
|
||||
|
||||
|
@ -103,7 +103,10 @@ public class UI implements ApplicationListener{
|
||||
|
||||
TooltipManager.getInstance().animations = false;
|
||||
|
||||
Core.settings.setErrorHandler(e -> Time.run(1f, () -> showError("Failed to access local storage.\nSettings will not be saved.")));
|
||||
Core.settings.setErrorHandler(e -> {
|
||||
e.printStackTrace();
|
||||
Core.app.post(() -> showError("Failed to access local storage.\nSettings will not be saved."));
|
||||
});
|
||||
|
||||
Colors.put("accent", Palette.accent);
|
||||
|
||||
|
@ -399,7 +399,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
tools.row();
|
||||
|
||||
tools.table("underline", t -> t.add("$text.editor.teams"))
|
||||
.colspan(3).height(40).width(size * 3f).padBottom(3);
|
||||
.colspan(3).height(40).width(size * 3f + 3f).padBottom(3);
|
||||
|
||||
tools.row();
|
||||
|
||||
@ -437,7 +437,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
mid.row();
|
||||
|
||||
mid.table("underline", t -> t.add("$text.editor.elevation"))
|
||||
.colspan(3).height(40).width(size * 3f);
|
||||
.colspan(3).height(40).width(size * 3f + 3f);
|
||||
|
||||
mid.row();
|
||||
|
||||
@ -450,8 +450,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
.size(size).get().setAlignment(Align.center, Align.center);
|
||||
|
||||
t.addImageButton("icon-arrow-right", "clear-partial", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
|
||||
.disabled(b -> editor.getDrawElevation() >= 63).size(size);
|
||||
}).colspan(3).height(size).width(size * 3f);
|
||||
.disabled(b -> editor.getDrawElevation() >= 63).size(size).name("aaaaa");
|
||||
}).colspan(3).height(size).width(size * 3f + 3f);
|
||||
|
||||
}).margin(0).left().growY();
|
||||
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.entities;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Bits;
|
||||
import io.anuke.arc.collection.Queue;
|
||||
import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.entities.EntityGroup;
|
||||
@ -285,7 +284,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
@Override
|
||||
public void drawShadow(float offsetX, float offsetY){
|
||||
float x = snappedX(), y = snappedY();
|
||||
float scl = mech.flying ? 1f : boostHeat / 2f;
|
||||
|
||||
Draw.rect(mech.iconRegion, x + offsetX * scl, y + offsetY * scl, rotation - 90);
|
||||
@ -295,8 +293,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
public void draw(){
|
||||
if(dead) return;
|
||||
|
||||
float x = snappedX(), y = snappedY();
|
||||
|
||||
if(!movement.isZero() && moved && !state.isPaused()){
|
||||
walktime += movement.len() / 0.7f * getFloorOn().speedMultiplier;
|
||||
baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f);
|
||||
@ -366,8 +362,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
@Override
|
||||
public void drawStats(){
|
||||
float x = snappedX(), y = snappedY();
|
||||
|
||||
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf()));
|
||||
Draw.alpha(hitTime / hitDuration);
|
||||
Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f), rotation - 90);
|
||||
@ -390,14 +384,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
}
|
||||
|
||||
public float snappedX(){
|
||||
return snapCamera && isLocal ? (int) (x + 0.0001f) : x;
|
||||
}
|
||||
|
||||
public float snappedY(){
|
||||
return snapCamera && isLocal ? (int) (y + 0.0001f) : y;
|
||||
}
|
||||
|
||||
public void drawName(){
|
||||
BitmapFont font = Core.scene.skin.getFont("default-font");
|
||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
|
@ -14,7 +14,7 @@ import io.anuke.arc.util.Disposable;
|
||||
public class IndexedRenderer implements Disposable{
|
||||
private final static int vsize = 5;
|
||||
|
||||
private Shader program = createDefaultShader();
|
||||
private Shader program = BatchShader.create();
|
||||
private Mesh mesh;
|
||||
private float[] tmpVerts = new float[vsize * 6];
|
||||
private float[] vertices;
|
||||
@ -28,33 +28,6 @@ public class IndexedRenderer implements Disposable{
|
||||
resize(sprites);
|
||||
}
|
||||
|
||||
static public Shader createDefaultShader(){
|
||||
String vertexShader = "attribute vec4 " + Shader.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "attribute vec2 " + Shader.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ "uniform mat4 u_projTrans;\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "\n" //
|
||||
+ "void main()\n" //
|
||||
+ "{\n" //
|
||||
+ " v_texCoords = " + Shader.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ " gl_Position = u_projTrans * " + Shader.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "}\n";
|
||||
String fragmentShader = "#ifdef GL_ES\n" //
|
||||
+ "#define LOWP lowp\n" //
|
||||
+ "precision mediump float;\n" //
|
||||
+ "#else\n" //
|
||||
+ "#define LOWP \n" //
|
||||
+ "#endif\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "uniform sampler2D u_texture;\n" //
|
||||
+ "void main()\n"//
|
||||
+ "{\n" //
|
||||
+ " gl_FragColor = texture2D(u_texture, v_texCoords);\n" //
|
||||
+ "}";
|
||||
|
||||
return new Shader(vertexShader, fragmentShader);
|
||||
}
|
||||
|
||||
public void render(Texture texture){
|
||||
Core.gl.glEnable(GL20.GL_BLEND);
|
||||
|
||||
|
@ -67,6 +67,8 @@ public class MinimapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
public void drawEntities(float x, float y, float w, float h){
|
||||
updateUnitArray();
|
||||
|
||||
int sz = baseSize * zoom;
|
||||
float dx = (Core.camera.position.x / tilesize);
|
||||
float dy = (Core.camera.position.y / tilesize);
|
||||
|
@ -6,6 +6,7 @@ import io.anuke.arc.util.I18NBundle;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -15,6 +16,7 @@ public class BundleLoader{
|
||||
|
||||
public static void load(){
|
||||
Core.settings.defaults("locale", "default");
|
||||
Core.keybinds.setDefaults(Binding.values());
|
||||
Core.settings.load();
|
||||
loadBundle();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user