Merge
This commit is contained in:
@@ -134,7 +134,7 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
if(brokenFade > 0.001f){
|
||||
for(BrokenBlock block : state.teams.get(player.getTeam()).brokenBlocks){
|
||||
for(BrokenBlock block : state.teams.get(player.team()).brokenBlocks){
|
||||
Block b = content.block(block.block);
|
||||
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class BlockRenderer implements Disposable{
|
||||
addRequest(tile, block.layer2);
|
||||
}
|
||||
|
||||
if(tile.entity != null && tile.entity.power != null && tile.entity.power.links.size > 0){
|
||||
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
|
||||
for(Tile other : block.getPowerConnections(tile, outArray)){
|
||||
if(other.block().layer == Layer.power){
|
||||
addRequest(other, Layer.power);
|
||||
@@ -275,7 +275,7 @@ public class BlockRenderer implements Disposable{
|
||||
if(request.tile.entity != null && request.tile.entity.damaged()){
|
||||
block.drawCracks(request.tile);
|
||||
}
|
||||
if(block.synthetic() && request.tile.getTeam() != player.getTeam()){
|
||||
if(block.synthetic() && request.tile.team() != player.team()){
|
||||
block.drawTeam(request.tile);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,382 +0,0 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.Core;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Pixmap.Format;
|
||||
import arc.graphics.VertexAttributes.Usage;
|
||||
import arc.graphics.gl.FrameBuffer;
|
||||
import arc.graphics.gl.Shader;
|
||||
|
||||
/**
|
||||
* Bloomlib allow easy but efficient way to add bloom effect as post process
|
||||
* effect
|
||||
*
|
||||
* @author kalle_h
|
||||
*/
|
||||
public class Bloom{
|
||||
/**
|
||||
* To use implement bloom more like a glow. Texture alpha channel can be
|
||||
* used as mask which part are glowing and which are not. see more info at:
|
||||
* http://www.gamasutra.com/view/feature/2107/realtime_glow.php
|
||||
* <p>
|
||||
* NOTE: need to be set before bloom instance is created. After that this
|
||||
* does nothing.
|
||||
*/
|
||||
public static boolean useAlphaChannelAsMask = false;
|
||||
|
||||
/** how many blur pass */
|
||||
public int blurPasses = 1;
|
||||
|
||||
private Shader tresholdShader;
|
||||
private Shader bloomShader;
|
||||
|
||||
private Mesh fullScreenQuad;
|
||||
|
||||
private Texture pingPongTex1;
|
||||
private Texture pingPongTex2;
|
||||
private Texture original;
|
||||
|
||||
private FrameBuffer frameBuffer;
|
||||
private FrameBuffer pingPongBuffer1;
|
||||
private FrameBuffer pingPongBuffer2;
|
||||
|
||||
private Shader blurShader;
|
||||
|
||||
private float bloomIntensity;
|
||||
private float originalIntensity;
|
||||
private float threshold;
|
||||
private int w;
|
||||
private int h;
|
||||
private boolean blending = false;
|
||||
private boolean capturing = false;
|
||||
private float r = 0f;
|
||||
private float g = 0f;
|
||||
private float b = 0f;
|
||||
private float a = 1f;
|
||||
private boolean disposeFBO = true;
|
||||
|
||||
/**
|
||||
* IMPORTANT NOTE CALL THIS WHEN RESUMING
|
||||
*/
|
||||
public void resume(){
|
||||
bloomShader.begin();
|
||||
bloomShader.setUniformi("u_texture0", 0);
|
||||
bloomShader.setUniformi("u_texture1", 1);
|
||||
bloomShader.end();
|
||||
|
||||
setSize(w, h);
|
||||
setThreshold(threshold);
|
||||
setBloomIntesity(bloomIntensity);
|
||||
setOriginalIntesity(originalIntensity);
|
||||
|
||||
original = frameBuffer.getTexture();
|
||||
pingPongTex1 = pingPongBuffer1.getTexture();
|
||||
pingPongTex2 = pingPongBuffer2.getTexture();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize bloom class that capsulate original scene capturate,
|
||||
* tresholding, gaussian blurring and blending. Default values: depth = true
|
||||
* blending = false 32bits = true
|
||||
*/
|
||||
public Bloom(){
|
||||
initialize(Core.graphics.getWidth() / 4, Core.graphics.getHeight() / 4, null, false, false, true);
|
||||
}
|
||||
|
||||
public Bloom(boolean useBlending){
|
||||
initialize(Core.graphics.getWidth() / 4, Core.graphics.getHeight() / 4, null, false, useBlending, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize bloom class that capsulate original scene capturate,
|
||||
* tresholding, gaussian blurring and blending.
|
||||
*
|
||||
* @param FBO_W
|
||||
* @param FBO_H how big fbo is used for bloom texture, smaller = more blur and
|
||||
* lot faster but aliasing can be problem
|
||||
* @param hasDepth do rendering need depth buffer
|
||||
* @param useBlending does fbo need alpha channel and is blending enabled when final
|
||||
* image is rendered. This allow to combine background graphics
|
||||
* and only do blooming on certain objects param use32bitFBO does
|
||||
* fbo use higher precision than 16bits.
|
||||
*/
|
||||
public Bloom(int FBO_W, int FBO_H, boolean hasDepth, boolean useBlending, boolean use32bitFBO){
|
||||
initialize(FBO_W, FBO_H, null, hasDepth, useBlending, use32bitFBO);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* EXPERT FUNCTIONALITY. no error checking. Use this only if you know what
|
||||
* you are doing. Remember that bloom.capture() clear the screen so use
|
||||
* continue instead if that is a problem.
|
||||
* <p>
|
||||
* Initialize bloom class that capsulate original scene capturate,
|
||||
* tresholding, gaussian blurring and blending.
|
||||
* <p>
|
||||
* * @param sceneIsCapturedHere diposing is user responsibility.
|
||||
*
|
||||
* @param FBO_W
|
||||
* @param FBO_H how big fbo is used for bloom texture, smaller = more blur and
|
||||
* lot faster but aliasing can be problem
|
||||
* @param useBlending does fbo need alpha channel and is blending enabled when final
|
||||
* image is rendered. This allow to combine background graphics
|
||||
* and only do blooming on certain objects param use32bitFBO does
|
||||
* fbo use higher precision than 16bits.
|
||||
*/
|
||||
public Bloom(int FBO_W, int FBO_H, FrameBuffer sceneIsCapturedHere, boolean useBlending, boolean use32bitFBO){
|
||||
initialize(FBO_W, FBO_H, sceneIsCapturedHere, false, useBlending, use32bitFBO);
|
||||
disposeFBO = false;
|
||||
}
|
||||
|
||||
private void initialize(int FBO_W, int FBO_H, FrameBuffer fbo, boolean hasDepth, boolean useBlending, boolean use32bitFBO){
|
||||
blending = useBlending;
|
||||
Format format;
|
||||
|
||||
if(use32bitFBO){
|
||||
if(useBlending){
|
||||
format = Format.RGBA8888;
|
||||
}else{
|
||||
format = Format.RGB888;
|
||||
}
|
||||
|
||||
}else{
|
||||
if(useBlending){
|
||||
format = Format.RGBA4444;
|
||||
}else{
|
||||
format = Format.RGB565;
|
||||
}
|
||||
}
|
||||
if(fbo == null){
|
||||
frameBuffer = new FrameBuffer(format, Core.graphics.getWidth(), Core.graphics.getHeight(), hasDepth);
|
||||
}else{
|
||||
frameBuffer = fbo;
|
||||
}
|
||||
|
||||
pingPongBuffer1 = new FrameBuffer(format, FBO_W, FBO_H, false);
|
||||
|
||||
pingPongBuffer2 = new FrameBuffer(format, FBO_W, FBO_H, false);
|
||||
|
||||
original = frameBuffer.getTexture();
|
||||
pingPongTex1 = pingPongBuffer1.getTexture();
|
||||
pingPongTex2 = pingPongBuffer2.getTexture();
|
||||
|
||||
fullScreenQuad = createFullScreenQuad();
|
||||
final String alpha = useBlending ? "alpha_" : "";
|
||||
|
||||
bloomShader = createShader("screenspace", alpha + "bloom");
|
||||
|
||||
if(useAlphaChannelAsMask){
|
||||
tresholdShader = createShader("screenspace", "maskedtreshold");
|
||||
}else{
|
||||
tresholdShader = createShader("screenspace", alpha + "threshold");
|
||||
}
|
||||
|
||||
blurShader = createShader("blurspace", alpha + "gaussian");
|
||||
|
||||
setSize(FBO_W, FBO_H);
|
||||
setBloomIntesity(2.5f);
|
||||
setOriginalIntesity(0.8f);
|
||||
setThreshold(0.5f);
|
||||
|
||||
bloomShader.begin();
|
||||
bloomShader.setUniformi("u_texture0", 0);
|
||||
bloomShader.setUniformi("u_texture1", 1);
|
||||
bloomShader.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set clearing color for capturing buffer
|
||||
*
|
||||
* @param r
|
||||
* @param g
|
||||
* @param b
|
||||
* @param a
|
||||
*/
|
||||
public void setClearColor(float r, float g, float b, float a){
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this before rendering scene.
|
||||
*/
|
||||
public void capture(){
|
||||
if(!capturing){
|
||||
capturing = true;
|
||||
frameBuffer.begin();
|
||||
Gl.clearColor(r, g, b, a);
|
||||
Gl.clear(Gl.colorBufferBit);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause capturing to fbo.
|
||||
*/
|
||||
public void capturePause(){
|
||||
if(capturing){
|
||||
capturing = false;
|
||||
frameBuffer.end();
|
||||
}
|
||||
}
|
||||
|
||||
/** Start capturing again after pause, no clearing is done to framebuffer */
|
||||
public void captureContinue(){
|
||||
if(!capturing){
|
||||
capturing = true;
|
||||
frameBuffer.begin();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after scene. Renders the bloomed scene.
|
||||
*/
|
||||
public void render(){
|
||||
if(capturing){
|
||||
capturing = false;
|
||||
frameBuffer.end();
|
||||
}
|
||||
|
||||
Gl.disable(Gl.blend);
|
||||
Gl.disable(Gl.depthTest);
|
||||
Gl.depthMask(false);
|
||||
|
||||
gaussianBlur();
|
||||
|
||||
if(blending){
|
||||
Gl.enable(Gl.blend);
|
||||
Gl.blendFunc(Gl.srcAlpha, Gl.oneMinusSrcAlpha);
|
||||
}
|
||||
|
||||
pingPongTex1.bind(1);
|
||||
original.bind(0);
|
||||
|
||||
bloomShader.begin();
|
||||
fullScreenQuad.render(bloomShader, Gl.triangleFan);
|
||||
bloomShader.end();
|
||||
|
||||
}
|
||||
|
||||
private void gaussianBlur(){
|
||||
|
||||
// cut bright areas of the picture and blit to smaller fbo
|
||||
|
||||
original.bind(0);
|
||||
pingPongBuffer1.begin();
|
||||
tresholdShader.begin();
|
||||
fullScreenQuad.render(tresholdShader, Gl.triangleFan, 0, 4);
|
||||
tresholdShader.end();
|
||||
pingPongBuffer1.end();
|
||||
|
||||
for(int i = 0; i < blurPasses; i++){
|
||||
|
||||
pingPongTex1.bind(0);
|
||||
|
||||
// horizontal
|
||||
pingPongBuffer2.begin();
|
||||
blurShader.begin();
|
||||
blurShader.setUniformf("dir", 1f, 0f);
|
||||
fullScreenQuad.render(blurShader, Gl.triangleFan, 0, 4);
|
||||
blurShader.end();
|
||||
pingPongBuffer2.end();
|
||||
|
||||
pingPongTex2.bind(0);
|
||||
// vertical
|
||||
pingPongBuffer1.begin();
|
||||
blurShader.begin();
|
||||
blurShader.setUniformf("dir", 0f, 1f);
|
||||
fullScreenQuad.render(blurShader, Gl.triangleFan, 0, 4);
|
||||
blurShader.end();
|
||||
pingPongBuffer1.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set intensity for bloom. higher mean more brightening for spots that are
|
||||
* over threshold
|
||||
*
|
||||
* @param intensity multiplier for blurred texture in combining phase. must be
|
||||
* positive.
|
||||
*/
|
||||
public void setBloomIntesity(float intensity){
|
||||
bloomIntensity = intensity;
|
||||
bloomShader.begin();
|
||||
bloomShader.setUniformf("BloomIntensity", intensity);
|
||||
bloomShader.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* set intensity for original scene. under 1 mean darkening and over 1 means
|
||||
* lightening
|
||||
*
|
||||
* @param intensity multiplier for captured texture in combining phase. must be
|
||||
* positive.
|
||||
*/
|
||||
public void setOriginalIntesity(float intensity){
|
||||
originalIntensity = intensity;
|
||||
bloomShader.begin();
|
||||
bloomShader.setUniformf("OriginalIntensity", intensity);
|
||||
bloomShader.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Treshold for bright parts. everything under threshold is clamped to 0
|
||||
*
|
||||
* @param threshold must be in range 0..1
|
||||
*/
|
||||
public void setThreshold(float threshold){
|
||||
this.threshold = threshold;
|
||||
tresholdShader.begin();
|
||||
tresholdShader.setUniformf("threshold", threshold, 1f / (1 - threshold));
|
||||
tresholdShader.end();
|
||||
}
|
||||
|
||||
private void setSize(int FBO_W, int FBO_H){
|
||||
w = FBO_W;
|
||||
h = FBO_H;
|
||||
blurShader.begin();
|
||||
blurShader.setUniformf("size", FBO_W, FBO_H);
|
||||
blurShader.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this when application is exiting.
|
||||
*/
|
||||
public void dispose(){
|
||||
try{
|
||||
if(disposeFBO) frameBuffer.dispose();
|
||||
|
||||
fullScreenQuad.dispose();
|
||||
|
||||
pingPongBuffer1.dispose();
|
||||
pingPongBuffer2.dispose();
|
||||
|
||||
blurShader.dispose();
|
||||
bloomShader.dispose();
|
||||
tresholdShader.dispose();
|
||||
}catch(Throwable ignored){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static Mesh createFullScreenQuad(){
|
||||
float[] verts = {-1, -1, 0, 0, 1, -1, 1, 0, 1, 1, 1, 1, -1, 1, 0, 1};
|
||||
Mesh tmpMesh = new Mesh(true, 4, 0,
|
||||
new VertexAttribute(Usage.position, 2, "a_position"),
|
||||
new VertexAttribute(Usage.textureCoordinates, 2, "a_texCoord0")
|
||||
);
|
||||
|
||||
tmpMesh.setVertices(verts);
|
||||
return tmpMesh;
|
||||
|
||||
}
|
||||
|
||||
private static Shader createShader(String vertexName, String fragmentName){
|
||||
String vertexShader = Core.files.internal("bloomshaders/" + vertexName + ".vertex.glsl").readString();
|
||||
String fragmentShader = Core.files.internal("bloomshaders/" + fragmentName + ".fragment.glsl").readString();
|
||||
return new Shader(vertexShader, fragmentShader);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public enum CacheLayer{
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
|
||||
renderer.blocks.floor.endc();
|
||||
renderer.shieldBuffer.begin();
|
||||
renderer.effectBuffer.begin();
|
||||
Core.graphics.clear(Color.clear);
|
||||
renderer.blocks.floor.beginc();
|
||||
}
|
||||
@@ -66,10 +66,10 @@ public enum CacheLayer{
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
|
||||
renderer.blocks.floor.endc();
|
||||
renderer.shieldBuffer.end();
|
||||
renderer.effectBuffer.end();
|
||||
|
||||
Draw.shader(shader);
|
||||
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.rect(Draw.wrap(renderer.effectBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.shader();
|
||||
|
||||
renderer.blocks.floor.beginc();
|
||||
|
||||
@@ -43,6 +43,10 @@ public class Drawf{
|
||||
}
|
||||
|
||||
public static void arrow(float x, float y, float x2, float y2, float length, float radius){
|
||||
arrow(x, y, x2, y2, length, radius, Pal.accent);
|
||||
}
|
||||
|
||||
public static void arrow(float x, float y, float x2, float y2, float length, float radius, Color color){
|
||||
float angle = Angles.angle(x, y, x2, y2);
|
||||
float space = 2f;
|
||||
Tmp.v1.set(x2, y2).sub(x, y).limit(length);
|
||||
@@ -50,7 +54,7 @@ public class Drawf{
|
||||
|
||||
Draw.color(Pal.gray);
|
||||
Fill.poly(vx, vy, 3, radius + space, angle);
|
||||
Draw.color(Pal.accent);
|
||||
Draw.color(color);
|
||||
Fill.poly(vx, vy, 3, radius, angle);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public class LightRenderer{
|
||||
lights.add(run);
|
||||
}
|
||||
|
||||
public void add(Position pos, float radius, Color color, float opacity){
|
||||
add(pos.getX(), pos.getY(), radius, color, opacity);
|
||||
}
|
||||
|
||||
public void add(float x, float y, float radius, Color color, float opacity){
|
||||
if(!enabled()) return;
|
||||
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.Core;
|
||||
import arc.struct.Array;
|
||||
import arc.func.Floatc2;
|
||||
import arc.graphics.Camera;
|
||||
import arc.graphics.Color;
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.FrameBuffer;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.noise.RidgedPerlin;
|
||||
import arc.util.noise.Simplex;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.content.UnitTypes;
|
||||
import mindustry.type.UnitType;
|
||||
import mindustry.ui.Cicon;
|
||||
import arc.util.noise.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.Floor;
|
||||
import mindustry.world.blocks.OreBlock;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -34,7 +30,7 @@ public class MenuRenderer implements Disposable{
|
||||
private float time = 0f;
|
||||
private float flyerRot = 45f;
|
||||
private int flyers = Mathf.chance(0.2) ? Mathf.random(35) : Mathf.random(15);
|
||||
private UnitType flyerType = Structs.select(UnitTypes.wraith, UnitTypes.wraith, UnitTypes.ghoul, UnitTypes.phantom, UnitTypes.phantom, UnitTypes.revenant);
|
||||
private UnitDef flyerType = Structs.select(UnitTypes.wraith, UnitTypes.wraith, UnitTypes.ghoul, UnitTypes.phantom, UnitTypes.phantom, UnitTypes.revenant);
|
||||
|
||||
public MenuRenderer(){
|
||||
Time.mark();
|
||||
@@ -251,6 +247,8 @@ public class MenuRenderer implements Disposable{
|
||||
}
|
||||
|
||||
private void drawFlyers(){
|
||||
//TODO fix
|
||||
if(true) return;
|
||||
Draw.color(0f, 0f, 0f, 0.4f);
|
||||
|
||||
TextureRegion icon = flyerType.icon(Cicon.full);
|
||||
|
||||
@@ -12,7 +12,7 @@ import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -22,7 +22,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class MinimapRenderer implements Disposable{
|
||||
private static final float baseSize = 16f;
|
||||
private final Array<Unit> units = new Array<>();
|
||||
private final Array<Unitc> units = new Array<>();
|
||||
private Pixmap pixmap;
|
||||
private Texture texture;
|
||||
private TextureRegion region;
|
||||
@@ -76,7 +76,7 @@ public class MinimapRenderer implements Disposable{
|
||||
updateUnitArray();
|
||||
}else{
|
||||
units.clear();
|
||||
Units.all(units::add);
|
||||
Groups.unit.each(units::add);
|
||||
}
|
||||
|
||||
float sz = baseSize * zoom;
|
||||
@@ -87,21 +87,20 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
rect.set((dx - sz) * tilesize, (dy - sz) * tilesize, sz * 2 * tilesize, sz * 2 * tilesize);
|
||||
|
||||
for(Unit unit : units){
|
||||
if(unit.isDead()) continue;
|
||||
float rx = !withLabels ? (unit.x - rect.x) / rect.width * w : unit.x / (world.width() * tilesize) * w;
|
||||
float ry = !withLabels ? (unit.y - rect.y) / rect.width * h : unit.y / (world.height() * tilesize) * h;
|
||||
for(Unitc unit : units){
|
||||
float rx = !withLabels ? (unit.x() - rect.x) / rect.width * w : unit.x() / (world.width() * tilesize) * w;
|
||||
float ry = !withLabels ? (unit.y() - rect.y) / rect.width * h : unit.y() / (world.height() * tilesize) * h;
|
||||
|
||||
Draw.mixcol(unit.getTeam().color, 1f);
|
||||
Draw.mixcol(unit.team().color, 1f);
|
||||
float scale = Scl.scl(1f) / 2f * scaling * 32f;
|
||||
Draw.rect(unit.getIconRegion(), x + rx, y + ry, scale, scale, unit.rotation - 90);
|
||||
Draw.rect(unit.type().region, x + rx, y + ry, scale, scale, unit.rotation() - 90);
|
||||
Draw.reset();
|
||||
|
||||
if(withLabels && unit instanceof Player){
|
||||
Player pl = (Player) unit;
|
||||
if(!pl.isLocal){
|
||||
if(withLabels && unit instanceof Playerc){
|
||||
Playerc pl = (Playerc) unit;
|
||||
if(!pl.isLocal()){
|
||||
// Only display names for other players.
|
||||
drawLabel(x + rx, y + ry, pl.name, unit.getTeam().color);
|
||||
drawLabel(x + rx, y + ry, pl.name(), unit.team().color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,7 +161,7 @@ public class MinimapRenderer implements Disposable{
|
||||
if(bc != 0){
|
||||
return bc;
|
||||
}
|
||||
return Tmp.c1.set(MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.getTeam())).mul(tile.block().cacheLayer == CacheLayer.walls ? 1f - tile.rotation() / 4f : 1f).rgba();
|
||||
return Tmp.c1.set(MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.team())).mul(tile.block().cacheLayer == CacheLayer.walls ? 1f - tile.rotation() / 4f : 1f).rgba();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,7 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -28,7 +27,7 @@ public class OverlayRenderer{
|
||||
public void drawBottom(){
|
||||
InputHandler input = control.input;
|
||||
|
||||
if(player.isDead()) return;
|
||||
if(player.dead()) return;
|
||||
|
||||
input.drawBottom();
|
||||
}
|
||||
@@ -36,32 +35,32 @@ public class OverlayRenderer{
|
||||
public void drawTop(){
|
||||
|
||||
if(Core.settings.getBool("indicators")){
|
||||
for(Player player : playerGroup.all()){
|
||||
if(Vars.player != player && Vars.player.getTeam() == player.getTeam()){
|
||||
for(Playerc player : Groups.player){
|
||||
if(Vars.player != player && Vars.player.team() == player.team()){
|
||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x(), player.y())){
|
||||
|
||||
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
Tmp.v1.set(player.x(), player.y()).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
|
||||
Lines.stroke(2f, player.getTeam().color);
|
||||
Lines.stroke(2f, player.team().color);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 4f);
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Units.all(unit -> {
|
||||
if(unit != player && unit.getTeam() != player.getTeam() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
|
||||
Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
Groups.unit.each(unit -> {
|
||||
if(unit != player && unit.team() != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x(), unit.y())){
|
||||
Tmp.v1.set(unit.x(), unit.y()).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
|
||||
Lines.stroke(1f, unit.getTeam().color);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
Lines.stroke(1f, unit.team().color);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
|
||||
if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){
|
||||
for(Tile mechpad : indexer.getAllied(player.getTeam(), BlockFlag.mechPad)){
|
||||
for(Tile mechpad : indexer.getAllied(player.team(), BlockFlag.mechPad)){
|
||||
if(!(mechpad.block() instanceof MechPad)) continue;
|
||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(mechpad.drawx(), mechpad.drawy())){
|
||||
@@ -76,7 +75,7 @@ public class OverlayRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
if(player.isDead()) return; //dead players don't draw
|
||||
if(player.dead()) return; //dead players don't draw
|
||||
|
||||
InputHandler input = control.input;
|
||||
|
||||
@@ -94,13 +93,13 @@ public class OverlayRenderer{
|
||||
Lines.stroke(buildFadeTime * 2f);
|
||||
|
||||
if(buildFadeTime > 0.005f){
|
||||
state.teams.eachEnemyCore(player.getTeam(), core -> {
|
||||
state.teams.eachEnemyCore(player.team(), core -> {
|
||||
float dst = core.dst(player);
|
||||
if(dst < state.rules.enemyCoreBuildRadius * 2.2f){
|
||||
Draw.color(Color.darkGray);
|
||||
Lines.circle(core.x, core.y - 2, state.rules.enemyCoreBuildRadius);
|
||||
Draw.color(Pal.accent, core.getTeam().color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
|
||||
Lines.circle(core.x, core.y, state.rules.enemyCoreBuildRadius);
|
||||
Lines.circle(core.x(), core.y() - 2, state.rules.enemyCoreBuildRadius);
|
||||
Draw.color(Pal.accent, core.team().color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
|
||||
Lines.circle(core.x(), core.y(), state.rules.enemyCoreBuildRadius);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,7 +108,7 @@ public class OverlayRenderer{
|
||||
Draw.color(Color.gray, Color.lightGray, Mathf.absin(Time.time(), 8f, 1f));
|
||||
|
||||
for(Tile tile : spawner.getGroundSpawns()){
|
||||
if(tile.withinDst(player.x, player.y, state.rules.dropZoneRadius + spawnerMargin)){
|
||||
if(tile.withinDst(player.x(), player.y(), state.rules.dropZoneRadius + spawnerMargin)){
|
||||
Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin));
|
||||
Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius);
|
||||
}
|
||||
@@ -122,10 +121,10 @@ public class OverlayRenderer{
|
||||
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
Tile tile = world.ltileWorld(vec.x, vec.y);
|
||||
|
||||
if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){
|
||||
if(tile != null && tile.block() != Blocks.air && tile.team() == player.team()){
|
||||
tile.block().drawSelect(tile);
|
||||
|
||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate){
|
||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
|
||||
control.input.drawArrow(tile.block(), tile.x, tile.y, tile.rotation(), true);
|
||||
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
||||
Fill.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize/2f);
|
||||
@@ -138,13 +137,13 @@ public class OverlayRenderer{
|
||||
if(input.isDroppingItem()){
|
||||
Vec2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
float size = 8;
|
||||
Draw.rect(player.item().item.icon(Cicon.medium), v.x, v.y, size, size);
|
||||
Draw.rect(player.unit().item().icon(Cicon.medium), v.x, v.y, size, size);
|
||||
Draw.color(Pal.accent);
|
||||
Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Draw.reset();
|
||||
|
||||
Tile tile = world.ltileWorld(v.x, v.y);
|
||||
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
||||
if(tile != null && tile.interactable(player.team()) && tile.block().acceptStack(player.unit().item(), player.unit().stack().amount, tile, player.unit()) > 0){
|
||||
Lines.stroke(3f, Pal.gray);
|
||||
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Lines.stroke(1f, Pal.place);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.Core;
|
||||
import arc.graphics.Blending;
|
||||
import arc.graphics.Texture.TextureFilter;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.gl.FrameBuffer;
|
||||
import arc.util.Disposable;
|
||||
import mindustry.entities.type.Player;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static arc.Core.camera;
|
||||
import static arc.Core.graphics;
|
||||
import static mindustry.Vars.playerGroup;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.renderer;
|
||||
|
||||
public class Pixelator implements Disposable{
|
||||
@@ -55,7 +53,7 @@ public class Pixelator implements Disposable{
|
||||
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
|
||||
Draw.blend();
|
||||
|
||||
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
||||
Groups.drawNames();
|
||||
|
||||
Core.camera.position.set(px, py);
|
||||
Core.settings.put("animatedwater", hadWater);
|
||||
|
||||
33
core/src/mindustry/graphics/ScorchGenerator.java
Normal file
33
core/src/mindustry/graphics/ScorchGenerator.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.util.noise.*;
|
||||
|
||||
/** Generates a scorch pixmap based on parameters. Thread safe, unless multiple scorch generators are running in parallel. */
|
||||
public class ScorchGenerator{
|
||||
private static final Simplex sim = new Simplex();
|
||||
|
||||
public int size = 80, seed = 0, color = Color.white.rgba();
|
||||
public double scale = 18, pow = 2, octaves = 4, pers = 0.4, add = 2, nscl = 4.5f;
|
||||
|
||||
public Pixmap generate(){
|
||||
Pixmap pix = new Pixmap(size, size);
|
||||
sim.setSeed(seed);
|
||||
|
||||
pix.each((x, y) -> {
|
||||
double dst = Mathf.dst(x, y, size/2, size/2) / (size / 2f);
|
||||
double scaled = Math.abs(dst - 0.5f) * 5f + add;
|
||||
scaled -= noise(Angles.angle(x, y, size/2, size/2))*nscl;
|
||||
boolean present = scaled < 1.5f;
|
||||
|
||||
if(present) pix.draw(x, y, color);
|
||||
});
|
||||
|
||||
return pix;
|
||||
}
|
||||
|
||||
private double noise(float angle){
|
||||
return Math.pow(sim.octaveNoise2D(octaves, pers, 1 / scale, Angles.trnsx(angle, size/2f) + size/2f, Angles.trnsy(angle, size/2f) + size/2f), pow);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user