Cleanup, re-implementations

This commit is contained in:
Anuken
2020-04-24 11:01:17 -04:00
parent 018fe5dea2
commit 1b2e10d355
7 changed files with 63 additions and 97 deletions

View File

@@ -29,14 +29,14 @@ void main() {
vec4 color = texture2D(u_texture, T); vec4 color = texture2D(u_texture, T);
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y); vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
if(texture2D(u_texture, T).a < 0.1 && if(texture2D(u_texture, T).a < 0.2 &&
(texture2D(u_texture, T + vec2(0, step) * v).a > 0.1 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.1 || (texture2D(u_texture, T + vec2(0, step) * v).a > 0.0 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.0 ||
texture2D(u_texture, T + vec2(step, 0) * v).a > 0.1 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.1)){ texture2D(u_texture, T + vec2(step, 0) * v).a > 0.0 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.0)){
gl_FragColor = mix(v_color, vec4(1.0), si); gl_FragColor = mix(v_color, vec4(1.0), si);
}else{ }else{
if(color.a > 0.1){ if(color.a > 0.0){
if(mod(coords.x / u_dp + coords.y / u_dp + sin(floor(coords.x / u_dp) / 5.0) * 3.0 + sin(floor(coords.y / u_dp) / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){ if(mod(coords.x / u_dp + coords.y / u_dp + sin(floor(coords.x / u_dp) / 5.0) * 3.0 + sin(floor(coords.y / u_dp) / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){
color *= 1.65; color *= 1.65;
} }

View File

@@ -221,6 +221,19 @@ public class Renderer implements ApplicationListener{
} }
Draw.draw(Layer.plans, overlays::drawBottom); Draw.draw(Layer.plans, overlays::drawBottom);
if(settings.getBool("animatedshields")){
Draw.drawRange(Layer.shields, 1f, () -> effectBuffer.begin(Color.clear), () -> {
effectBuffer.end();
Draw.shader(Shaders.shield);
Draw.color(Pal.accent);
Draw.rect(effectBuffer);
Draw.color();
Draw.shader();
});
}
Draw.draw(Layer.overlayUI, overlays::drawTop); Draw.draw(Layer.overlayUI, overlays::drawTop);
Draw.draw(Layer.space, this::drawLanding); Draw.draw(Layer.space, this::drawLanding);

View File

@@ -11,7 +11,6 @@ public enum Gamemode{
survival(rules -> { survival(rules -> {
rules.waveTimer = true; rules.waveTimer = true;
rules.waves = true; rules.waves = true;
rules.unitDrops = true;
}, map -> map.spawns > 0), }, map -> map.spawns > 0),
sandbox(rules -> { sandbox(rules -> {
rules.infiniteResources = true; rules.infiniteResources = true;
@@ -20,7 +19,6 @@ public enum Gamemode{
rules.respawnTime = 0f; rules.respawnTime = 0f;
}), }),
attack(rules -> { attack(rules -> {
rules.unitDrops = true;
rules.attackMode = true; rules.attackMode = true;
}, map -> map.teams.contains((int)state.rules.waveTeam.id)), }, map -> map.teams.contains((int)state.rules.waveTeam.id)),
pvp(rules -> { pvp(rules -> {

View File

@@ -25,8 +25,6 @@ public class Rules{
public boolean enemyCheat; public boolean enemyCheat;
/** Whether the game objective is PvP. Note that this enables automatic hosting. */ /** Whether the game objective is PvP. Note that this enables automatic hosting. */
public boolean pvp; public boolean pvp;
/** Whether enemy units drop random items on death. */
public boolean unitDrops = true;
/** Whether reactors can explode and damage other blocks. */ /** Whether reactors can explode and damage other blocks. */
public boolean reactorExplosions = true; public boolean reactorExplosions = true;
/** How fast unit pads build units. */ /** How fast unit pads build units. */

View File

@@ -53,6 +53,9 @@ public class Layer{
//overlaied UI, like block config guides //overlaied UI, like block config guides
overlayUI = 120, overlayUI = 120,
//shield effects
shields = 125,
//weather effects, e.g. rain and snow TODO draw before overlay UI? //weather effects, e.g. rain and snow TODO draw before overlay UI?
weather = 130, weather = 130,

View File

@@ -162,7 +162,6 @@ public class CustomRulesDialog extends FloatingDialog{
number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier); number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier);
title("$rules.title.unit"); title("$rules.title.unit");
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, () -> true);
number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier); number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier);
number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier); number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier);
number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier); number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier);

View File

@@ -5,6 +5,7 @@ import arc.func.*;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.math.*; import arc.math.*;
import arc.math.geom.*;
import arc.util.*; import arc.util.*;
import arc.util.io.*; import arc.util.io.*;
import mindustry.content.*; import mindustry.content.*;
@@ -29,18 +30,14 @@ public class ForceProjector extends Block{
public float basePowerDraw = 0.2f; public float basePowerDraw = 0.2f;
public TextureRegion topRegion; public TextureRegion topRegion;
private static Tile paramTile;
private static ForceProjector paramBlock;
private static ForceProjectorEntity paramEntity; private static ForceProjectorEntity paramEntity;
private static Cons<Shielderc> shieldConsumer = trait -> { private static Cons<Shielderc> shieldConsumer = trait -> {
//TODO implement if(trait.team() != paramEntity.team() && Intersector.isInsideHexagon(paramEntity.x(), paramEntity.y(), paramEntity.realRadius() * 2f, trait.x(), trait.y())){
/*
if(trait.team() != paramteam && Intersector.isInsideHexagon(trait.x(), trait.y(), paramEntity.realRadius() * 2f, paramx, paramy)){
trait.absorb(); trait.absorb();
Fx.absorb.at(trait); Fx.absorb.at(trait);
paramhit = 1f; paramEntity.hit = 1f;
parambuildup += trait.damage() * paramwarmup; paramEntity.buildup += trait.damage() * paramEntity.warmup;
}*/ }
}; };
public ForceProjector(String name){ public ForceProjector(String name){
@@ -84,7 +81,6 @@ public class ForceProjector extends Block{
} }
public class ForceProjectorEntity extends TileEntity{ public class ForceProjectorEntity extends TileEntity{
ShieldEntity shield;
boolean broken = true; boolean broken = true;
float buildup = 0f; float buildup = 0f;
float radscl = 0f; float radscl = 0f;
@@ -94,12 +90,6 @@ public class ForceProjector extends Block{
@Override @Override
public void updateTile(){ public void updateTile(){
if(shield == null){
//TODO implement
//shield = new ShieldEntity(tile);
//shield.add();
}
boolean phaseValid = consumes.get(ConsumeType.item).valid(tile.entity); boolean phaseValid = consumes.get(ConsumeType.item).valid(tile.entity);
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(phaseValid), 0.1f); phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(phaseValid), 0.1f);
@@ -143,11 +133,11 @@ public class ForceProjector extends Block{
float realRadius = realRadius(); float realRadius = realRadius();
paramTile = tile; if(realRadius > 0 && !broken){
paramEntity = this; paramEntity = this;
paramBlock = ForceProjector.this;
Groups.bullet.intersect(x - realRadius, y - realRadius, realRadius * 2f, realRadius * 2f, shieldConsumer); Groups.bullet.intersect(x - realRadius, y - realRadius, realRadius * 2f, realRadius * 2f, shieldConsumer);
} }
}
float realRadius(){ float realRadius(){
return (radius + phaseHeat * phaseRadiusBoost) * radscl; return (radius + phaseHeat * phaseRadiusBoost) * radscl;
@@ -157,7 +147,7 @@ public class ForceProjector extends Block{
public void draw(){ public void draw(){
super.draw(); super.draw();
if(buildup <= 0f) return; if(buildup > 0f){
Draw.alpha(buildup / breakage * 0.75f); Draw.alpha(buildup / breakage * 0.75f);
Draw.blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(topRegion, x, y); Draw.rect(topRegion, x, y);
@@ -165,6 +155,35 @@ public class ForceProjector extends Block{
Draw.reset(); Draw.reset();
} }
if(!broken){
float radius = realRadius();
Draw.z(Layer.shields);
Draw.color(Pal.accent);
if(Core.settings.getBool("animatedshields")){
Fill.poly(x, y, 6, radius);
Draw.z(Layer.shields + 0.1f);
Draw.color(Color.white);
Draw.alpha(hit);
Fill.poly(x, y, 6, radius);
Draw.color();
}else{
Lines.stroke(1.5f);
Draw.alpha(0.09f + 0.08f * hit);
Fill.poly(x, y, 6, radius);
Draw.alpha(1f);
Lines.poly(x, y, 6, radius);
Draw.reset();
}
}
Draw.reset();
}
@Override @Override
public void write(Writes write){ public void write(Writes write){
super.write(write); super.write(write);
@@ -185,68 +204,4 @@ public class ForceProjector extends Block{
phaseHeat = read.f(); phaseHeat = read.f();
} }
} }
//TODO fix
class ShieldEntity{
}
/*
//@EntityDef({Drawc.class})
//class ShieldDef{}
public class ShieldEntity extends BaseEntity implements DrawTrait{
final ForceEntity entity;
public ShieldEntity(){
this.entity = tile.ent();
set(x, y);
}
@Override
public void update(){
if(isDead() || !isAdded()){
remove();
}
}
@Override
public float drawSize(){
return realRadius(entity) * 2f + 2f;
}
@Override
public void draw(){
Draw.color(Pal.accent);
Fill.poly(x, y, 6, realRadius(entity));
Draw.color();
}
public void drawOver(){
if(hit <= 0f) return;
Draw.color(Color.white);
Draw.alpha(hit);
Fill.poly(x, y, 6, realRadius(entity));
Draw.color();
}
public void drawSimple(){
if(realRadius(entity) < 0.5f) return;
float rad = realRadius(entity);
Draw.color(Pal.accent);
Lines.stroke(1.5f);
Draw.alpha(0.09f + 0.08f * hit);
Fill.poly(x, y, 6, rad);
Draw.alpha(1f);
Lines.poly(x, y, 6, rad);
Draw.reset();
}
@Override
public EntityGroup targetGroup(){
return shieldGroup;
}
}*/
} }