mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-05 13:08:20 +07:00
Added full block descriptions, improved shield shaders
This commit is contained in:
parent
aedf46257a
commit
806b762333
@ -8,6 +8,7 @@ uniform sampler2D u_texture;
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_texsize;
|
||||
uniform float u_time;
|
||||
uniform float u_scaling;
|
||||
uniform vec2 u_offset;
|
||||
|
||||
varying vec4 v_color;
|
||||
@ -19,7 +20,7 @@ void main() {
|
||||
|
||||
vec2 coords = (T * u_texsize) + u_offset;
|
||||
|
||||
T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 250.0, sin(coords.x / 3.0 + u_time / 20.0) / 250.0);
|
||||
T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 250.0, sin(coords.x / 3.0 + u_time / 20.0) / 250.0) * u_scaling;
|
||||
|
||||
float si = 1.0 + sin(u_time / 20.0 /*+ (coords.x + coords.y) / 30.0*/) / 8.0;
|
||||
|
||||
|
@ -126,13 +126,11 @@ public class Renderer extends RendererModule{
|
||||
|
||||
long time = TimeUtils.nanoTime();
|
||||
drawDefault();
|
||||
if(Timers.get("profiled", profileTime)) Profiler.draw = TimeUtils.timeSinceNanos(time);
|
||||
if(Timers.get("profiled", profileTime))
|
||||
Profiler.draw = TimeUtils.timeSinceNanos(time);
|
||||
|
||||
if(Vars.debug && Vars.debugGL && Timers.get("profile", 60)){
|
||||
UCore.log("shaders: " + GLProfiler.shaderSwitches,
|
||||
"calls: " + GLProfiler.drawCalls,
|
||||
"bindings: " + GLProfiler.textureBindings,
|
||||
"vertices: " + GLProfiler.vertexCount.average);
|
||||
UCore.log("shaders: " + GLProfiler.shaderSwitches, "calls: " + GLProfiler.drawCalls, "bindings: " + GLProfiler.textureBindings, "vertices: " + GLProfiler.vertexCount.average);
|
||||
}
|
||||
|
||||
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
||||
@ -150,11 +148,13 @@ public class Renderer extends RendererModule{
|
||||
|
||||
long time = TimeUtils.nanoTime();
|
||||
renderTiles();
|
||||
if(Timers.get("profilebd", profileTime)) Profiler.blockDraw = TimeUtils.timeSinceNanos(time);
|
||||
if(Timers.get("profilebd", profileTime))
|
||||
Profiler.blockDraw = TimeUtils.timeSinceNanos(time);
|
||||
|
||||
time = TimeUtils.nanoTime();
|
||||
Entities.draw();
|
||||
if(Timers.get("profileed", profileTime)) Profiler.entityDraw = TimeUtils.timeSinceNanos(time);
|
||||
if(Timers.get("profileed", profileTime))
|
||||
Profiler.entityDraw = TimeUtils.timeSinceNanos(time);
|
||||
|
||||
drawShield();
|
||||
|
||||
@ -181,9 +181,7 @@ public class Renderer extends RendererModule{
|
||||
if(entity instanceof Enemy){
|
||||
Enemy enemy = (Enemy) entity;
|
||||
|
||||
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight)
|
||||
.setCenter(camera.position.x, camera.position.y)
|
||||
.overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){
|
||||
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -294,6 +292,23 @@ public class Renderer extends RendererModule{
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
if(Vars.debug && Vars.debugChunks){
|
||||
Draw.color(Color.YELLOW);
|
||||
Draw.thick(1f);
|
||||
for(int x = -crangex; x <= crangex; x++){
|
||||
for(int y = -crangey; y <= crangey; y++){
|
||||
int worldx = Mathf.scl(camera.position.x, chunksize * tilesize) + x;
|
||||
int worldy = Mathf.scl(camera.position.y, chunksize * tilesize) + y;
|
||||
|
||||
if(!Mathf.inBounds(worldx, worldy, floorCache))
|
||||
continue;
|
||||
Draw.linerect(worldx * chunksize * tilesize, worldy * chunksize * tilesize,
|
||||
chunksize * tilesize, chunksize * tilesize);
|
||||
}
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void renderCache(int cx, int cy){
|
||||
@ -316,6 +331,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
void renderPixelOverlay(){
|
||||
|
||||
//draw tutorial placement point
|
||||
if(Vars.control.tutorial.showBlock()){
|
||||
int x = World.core.x + Vars.control.tutorial.getPlacePoint().x;
|
||||
int y = World.core.y + Vars.control.tutorial.getPlacePoint().y;
|
||||
@ -333,7 +349,9 @@ public class Renderer extends RendererModule{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android) && AndroidInput.mode == PlaceMode.cursor){
|
||||
//draw placement box
|
||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements)
|
||||
&& (!ui.hasMouse() || android) && AndroidInput.mode == PlaceMode.cursor){
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
|
||||
@ -352,8 +370,7 @@ public class Renderer extends RendererModule{
|
||||
x = tilex * tilesize;
|
||||
y = tiley * tilesize;
|
||||
|
||||
boolean valid = World.validPlace(tilex, tiley, player.recipe.result) && (android ||
|
||||
Input.cursorNear());
|
||||
boolean valid = World.validPlace(tilex, tiley, player.recipe.result) && (android || Input.cursorNear());
|
||||
|
||||
Vector2 offset = player.recipe.result.getPlaceOffset();
|
||||
|
||||
@ -361,9 +378,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
Draw.color(valid ? Color.PURPLE : Color.SCARLET);
|
||||
Draw.thickness(2f);
|
||||
Draw.linecrect(x + offset.x, y + offset.y,
|
||||
tilesize * player.recipe.result.width + si,
|
||||
tilesize * player.recipe.result.height + si);
|
||||
Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, tilesize * player.recipe.result.height + si);
|
||||
|
||||
player.recipe.result.drawPlace(tilex, tiley, valid);
|
||||
|
||||
@ -390,7 +405,8 @@ public class Renderer extends RendererModule{
|
||||
//block breaking
|
||||
if(Inputs.buttonDown(Buttons.RIGHT) && World.validBreak(Input.tilex(), Input.tiley())){
|
||||
Tile tile = World.tile(Input.tilex(), Input.tiley());
|
||||
if(tile.isLinked()) tile = tile.getLinked();
|
||||
if(tile.isLinked())
|
||||
tile = tile.getLinked();
|
||||
Vector2 offset = tile.block().getPlaceOffset();
|
||||
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, player.breaktime / tile.getBreakTime());
|
||||
@ -409,6 +425,7 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
}
|
||||
|
||||
//draw selected block health
|
||||
if(player.recipe == null && !ui.hasMouse()){
|
||||
Tile tile = World.tile(Input.tilex(), Input.tiley());
|
||||
|
||||
@ -420,8 +437,7 @@ public class Renderer extends RendererModule{
|
||||
Vector2 offset = target.block().getPlaceOffset();
|
||||
|
||||
if(target.entity != null)
|
||||
drawHealth(target.entity.x + offset.x, target.entity.y - 3f - target.block().height/2f * Vars.tilesize + offset.y,
|
||||
target.entity.health, target.entity.maxhealth);
|
||||
drawHealth(target.entity.x + offset.x, target.entity.y - 3f - target.block().height / 2f * Vars.tilesize + offset.y, target.entity.health, target.entity.maxhealth);
|
||||
|
||||
target.block().drawPixelOverlay(target);
|
||||
}
|
||||
@ -429,6 +445,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
boolean smoothcam = Settings.getBool("smoothcam");
|
||||
|
||||
//draw entity health bars
|
||||
for(Entity entity : Entities.all()){
|
||||
if(entity instanceof DestructibleEntity && !(entity instanceof TileEntity)){
|
||||
DestructibleEntity dest = ((DestructibleEntity) entity);
|
||||
|
@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Shader;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
@ -35,10 +36,14 @@ public class Shaders{
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float scale = Settings.getBool("pixelate") ? 1 : Core.cameraScale / Core.camera.zoom;
|
||||
float scaling = Core.cameraScale / 4f / Core.camera.zoom;
|
||||
shader.setUniformf("u_color", color);
|
||||
shader.setUniformf("u_time", Timers.time());
|
||||
shader.setUniformf("u_scaling", scaling);
|
||||
shader.setUniformf("u_offset", Tmp.v1.set(Core.camera.position.x, Core.camera.position.y));
|
||||
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth() / scale,
|
||||
region.getTexture().getHeight() / scale));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -665,7 +665,33 @@ public class UI extends SceneModule{
|
||||
header.addImage(region).size(8*5).padTop(4).units(Unit.dp);
|
||||
Label nameLabel = new Label(recipe.result.formalName);
|
||||
nameLabel.setWrap(true);
|
||||
header.add(nameLabel).padLeft(4).width(160f).units(Unit.dp);
|
||||
header.add(nameLabel).padLeft(4).width(135f).units(Unit.dp);
|
||||
|
||||
//extra info
|
||||
if(recipe.result.fullDescription != null){
|
||||
header.addButton("?", ()->{
|
||||
Label desclabel = new Label(recipe.result.fullDescription);
|
||||
desclabel.setWrap(true);
|
||||
|
||||
boolean wasPaused = GameState.is(State.paused);
|
||||
GameState.set(State.paused);
|
||||
|
||||
FloatingDialog d = new FloatingDialog("Block Info");
|
||||
Table top = new Table();
|
||||
top.left();
|
||||
top.add(new Image(region)).size(8*5).units(Unit.dp);
|
||||
top.add("[orange]"+recipe.result.formalName).padLeft(6f).units(Unit.dp);
|
||||
d.content().add(top).fill().left();
|
||||
d.content().row();
|
||||
d.content().add(desclabel).width(600).units(Unit.dp);
|
||||
d.buttons().addButton("OK", ()->{
|
||||
if(!wasPaused) GameState.set(State.playing);
|
||||
d.hide();
|
||||
}).size(110, 50).pad(10f).units(Unit.dp);
|
||||
d.show();
|
||||
}).fillX().top().right().size(36f, 40f).units(Unit.dp);
|
||||
}
|
||||
|
||||
|
||||
desctable.add().pad(2).units(Unit.dp);
|
||||
|
||||
|
@ -31,6 +31,8 @@ public class Vars{
|
||||
public static boolean debug = false;
|
||||
//whether to debug openGL info
|
||||
public static boolean debugGL = false;
|
||||
//whether to draw chunk borders
|
||||
public static boolean debugChunks = false;
|
||||
//whether turrets have infinite ammo (only with debug)
|
||||
public static boolean infiniteAmmo = true;
|
||||
//whether to show paths of enemies
|
||||
|
@ -13,6 +13,8 @@ public class DefenseBlocks{
|
||||
stonewall = new Wall("stonewall"){{
|
||||
health = 50;
|
||||
formalName = "stone wall";
|
||||
fullDescription =
|
||||
"A cheap defensive block. Useful for protecting the core and turrets in the first few waves.";
|
||||
}},
|
||||
|
||||
ironwall = new Wall("ironwall"){{
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user