mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-25 22:58:47 +07:00
Shield optimization
This commit is contained in:
parent
67a12eecad
commit
d9692004cc
@ -420,6 +420,7 @@ category.optional = Optional Enhancements
|
||||
setting.landscape.name = Lock Landscape
|
||||
setting.shadows.name = Shadows
|
||||
setting.animatedwater.name = Animated Water
|
||||
setting.animatedshields.name = Animated Shields
|
||||
setting.antialias.name = Antialias[LIGHT_GRAY] (requires restart)[]
|
||||
setting.indicators.name = Enemy/Ally Indicators
|
||||
setting.autotarget.name = Auto-Target
|
||||
|
@ -163,8 +163,9 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
graphics.clear(clearColor);
|
||||
|
||||
if(graphics.getWidth() >= 2 && graphics.getHeight() >= 2 && (shieldBuffer.getWidth() != graphics.getWidth() || shieldBuffer.getHeight() != graphics.getHeight())){
|
||||
if(!graphics.isHidden() && (shieldBuffer.getWidth() != graphics.getWidth() || shieldBuffer.getHeight() != graphics.getHeight())){
|
||||
shieldBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
pixelator.rebind();
|
||||
}
|
||||
|
||||
Draw.proj(camera.projection());
|
||||
@ -211,18 +212,22 @@ public class Renderer implements ApplicationListener{
|
||||
drawAndInterpolate(playerGroup, p -> true, Player::drawBuildRequests);
|
||||
|
||||
if(EntityDraw.countInBounds(shieldGroup) > 0){
|
||||
Draw.flush();
|
||||
shieldBuffer.begin();
|
||||
graphics.clear(Color.CLEAR);
|
||||
EntityDraw.draw(shieldGroup);
|
||||
EntityDraw.drawWith(shieldGroup, shield -> true, shield -> ((ShieldEntity)shield).drawOver());
|
||||
Draw.flush();
|
||||
shieldBuffer.end();
|
||||
Draw.shader(Shaders.shield);
|
||||
Draw.color(Pal.accent);
|
||||
Draw.rect(Draw.wrap(shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.color();
|
||||
Draw.shader();
|
||||
if(settings.getBool("animatedshields") && !pixelator.enabled()){
|
||||
Draw.flush();
|
||||
shieldBuffer.begin();
|
||||
graphics.clear(Color.CLEAR);
|
||||
EntityDraw.draw(shieldGroup);
|
||||
EntityDraw.drawWith(shieldGroup, shield -> true, shield -> ((ShieldEntity)shield).drawOver());
|
||||
Draw.flush();
|
||||
shieldBuffer.end();
|
||||
Draw.shader(Shaders.shield);
|
||||
Draw.color(Pal.accent);
|
||||
Draw.rect(Draw.wrap(shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||
Draw.color();
|
||||
Draw.shader();
|
||||
}else{
|
||||
EntityDraw.drawWith(shieldGroup, shield -> true, shield -> ((ShieldEntity)shield).drawSimple());
|
||||
}
|
||||
}
|
||||
|
||||
overlays.drawTop();
|
||||
|
@ -121,6 +121,7 @@ public class BlockRenderer{
|
||||
public void drawShadows(){
|
||||
if(!shadowEvents.isEmpty()){
|
||||
Draw.flush();
|
||||
|
||||
shadows.begin();
|
||||
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
|
||||
|
||||
|
@ -1,32 +1,41 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.arc.Core.camera;
|
||||
import static io.anuke.arc.Core.graphics;
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class Pixelator implements Disposable{
|
||||
private FrameBuffer buffer = new FrameBuffer(2, 2);
|
||||
|
||||
public void drawPixelate(){
|
||||
graphics.clear(0f, 0f, 0f, 1f);
|
||||
|
||||
float px = Core.camera.position.x, py = Core.camera.position.y;
|
||||
Core.camera.position.set((int)px, (int)py + (Core.graphics.getHeight() % 2 == 0 ? 0 : 0.5f));
|
||||
Core.camera.position.set((int)px, (int)py + ((int)(camera.height) % 2 == 0 ? 0 : 0.5f));
|
||||
|
||||
int w = (int)(Core.camera.width);
|
||||
int h = (int)(Core.camera.height);
|
||||
|
||||
if(buffer.getWidth() != w || buffer.getHeight() != h){
|
||||
if(!graphics.isHidden() && (buffer.getWidth() != w || buffer.getHeight() != h)){
|
||||
buffer.resize(w, h);
|
||||
}
|
||||
|
||||
Draw.flush();
|
||||
buffer.begin();
|
||||
renderer.draw();
|
||||
|
||||
Draw.flush();
|
||||
buffer.end();
|
||||
|
||||
Draw.blend(Blending.disabled);
|
||||
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
|
||||
Draw.blend();
|
||||
|
||||
Core.camera.position.set(px, py);
|
||||
}
|
||||
|
@ -213,6 +213,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
graphics.checkPref("fps", false);
|
||||
graphics.checkPref("indicators", true);
|
||||
graphics.checkPref("animatedwater", false);
|
||||
graphics.checkPref("animatedshields", false);
|
||||
graphics.checkPref("lasers", true);
|
||||
graphics.checkPref("pixelate", false);
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
package io.anuke.mindustry.world.blocks.defense;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.EntityQuery;
|
||||
import io.anuke.mindustry.entities.impl.BaseEntity;
|
||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||
import io.anuke.arc.graphics.Blending;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.EntityQuery;
|
||||
import io.anuke.mindustry.entities.impl.BaseEntity;
|
||||
import io.anuke.mindustry.entities.traits.AbsorbTrait;
|
||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@ -36,7 +37,7 @@ public class ForceProjector extends Block {
|
||||
protected float phaseUseTime = 350f;
|
||||
|
||||
protected float phaseRadiusBoost = 80f;
|
||||
protected float radius = 100f;
|
||||
protected float radius = 101.7f;
|
||||
protected float breakage = 550f;
|
||||
protected float cooldownNormal = 1.75f;
|
||||
protected float cooldownLiquid = 1.5f;
|
||||
@ -46,7 +47,6 @@ public class ForceProjector extends Block {
|
||||
protected final ConsumeForceProjectorPower consumePower;
|
||||
protected TextureRegion topRegion;
|
||||
|
||||
|
||||
public ForceProjector(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
@ -76,6 +76,16 @@ public class ForceProjector extends Block {
|
||||
stats.add(BlockStat.boostEffect, phaseRadiusBoost/tilesize, StatUnit.blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(1f);
|
||||
Lines.poly(x * tilesize, y * tilesize, 6, radius);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ForceEntity entity = tile.entity();
|
||||
@ -112,13 +122,13 @@ public class ForceProjector extends Block {
|
||||
|
||||
if(entity.power.satisfaction < relativePowerDraw){
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.15f);
|
||||
entity.power.satisfaction = .0f;
|
||||
entity.power.satisfaction = 0f;
|
||||
if(entity.warmup <= 0.09f){
|
||||
entity.broken = true;
|
||||
}
|
||||
}else{
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.1f);
|
||||
entity.power.satisfaction -= Math.min(entity.power.satisfaction, relativePowerDraw);
|
||||
entity.power.satisfaction -= Math.min(entity.power.satisfaction, relativePowerDraw*Time.delta());
|
||||
}
|
||||
|
||||
if(entity.buildup > 0){
|
||||
@ -261,6 +271,19 @@ public class ForceProjector extends Block {
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public void drawSimple(){
|
||||
if(realRadius(entity) < 0.5f) return;;
|
||||
|
||||
float rad = realRadius(entity);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(0.09f + 0.08f * entity.hit);
|
||||
Fill.poly(x, y, 6, rad);
|
||||
Draw.alpha(1f);
|
||||
Lines.poly(x, y, 6, rad);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityGroup targetGroup(){
|
||||
return shieldGroup;
|
||||
|
@ -39,7 +39,7 @@ public class Separator extends Block{
|
||||
hasItems = true;
|
||||
hasLiquids = true;
|
||||
|
||||
liquidRegion = reg("liquid");
|
||||
liquidRegion = reg("-liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user