Misc cleanup & fixes
This commit is contained in:
@@ -33,7 +33,7 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
public @Nullable Bloom bloom;
|
||||
public FrameBuffer effectBuffer = new FrameBuffer();
|
||||
public boolean animateShields, drawWeather = true;
|
||||
public boolean animateShields, drawWeather = true, drawStatus;
|
||||
/** minZoom = zooming out, maxZoom = zooming in */
|
||||
public float minZoom = 1.5f, maxZoom = 6f;
|
||||
|
||||
@@ -81,6 +81,7 @@ public class Renderer implements ApplicationListener{
|
||||
laserOpacity = settings.getInt("lasersopacity") / 100f;
|
||||
bridgeOpacity = settings.getInt("bridgeopacity") / 100f;
|
||||
animateShields = settings.getBool("animatedshields");
|
||||
drawStatus = Core.settings.getBool("blockstatus");
|
||||
|
||||
if(landTime > 0){
|
||||
landTime -= Time.delta;
|
||||
|
||||
@@ -39,7 +39,6 @@ public class BlockRenderer implements Disposable{
|
||||
private Seq<Building> outArray2 = new Seq<>();
|
||||
private Seq<Tile> shadowEvents = new Seq<>();
|
||||
private IntSet procEntities = new IntSet(), procLinks = new IntSet(), procLights = new IntSet();
|
||||
private boolean displayStatus = false;
|
||||
|
||||
public BlockRenderer(){
|
||||
|
||||
@@ -177,7 +176,6 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
/** Process all blocks to draw. */
|
||||
public void processBlocks(){
|
||||
displayStatus = Core.settings.getBool("blockstatus");
|
||||
|
||||
int avgx = (int)(camera.position.x / tilesize);
|
||||
int avgy = (int)(camera.position.y / tilesize);
|
||||
@@ -275,7 +273,7 @@ public class BlockRenderer implements Disposable{
|
||||
Draw.z(Layer.block);
|
||||
}
|
||||
|
||||
if(displayStatus && block.consumes.any()){
|
||||
if(renderer.drawStatus && block.consumes.any()){
|
||||
entity.drawStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,22 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class Drawf{
|
||||
|
||||
public static void target(float x, float y, float rad, Color color){
|
||||
target(x, y, rad, 1, color);
|
||||
}
|
||||
|
||||
public static void target(float x, float y, float rad, float alpha, Color color){
|
||||
Lines.stroke(3f);
|
||||
Draw.color(Pal.gray, alpha);
|
||||
Lines.poly(x, y, 4, rad, Time.time * 1.5f);
|
||||
Lines.spikes(x, y, 3f/7f * rad, 6f/7f * rad, 4, Time.time * 1.5f);
|
||||
Lines.stroke(1f);
|
||||
Draw.color(color, alpha);
|
||||
Lines.poly(x, y, 4, rad, Time.time * 1.5f);
|
||||
Lines.spikes(x, y, 3f/7f * rad, 6f/7f * rad, 4, Time.time * 1.5f);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public static float text(){
|
||||
float z = Draw.z();
|
||||
if(renderer.pixelator.enabled()){
|
||||
|
||||
@@ -374,13 +374,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
crosshairScale = Mathf.lerpDelta(crosshairScale, 1f, 0.2f);
|
||||
|
||||
Draw.color(Pal.remove);
|
||||
Lines.stroke(1f);
|
||||
|
||||
float radius = Interp.swingIn.apply(crosshairScale);
|
||||
|
||||
Lines.poly(target.getX(), target.getY(), 4, 7f * radius, Time.time * 1.5f);
|
||||
Lines.spikes(target.getX(), target.getY(), 3f * radius, 6f * radius, 4, Time.time * 1.5f);
|
||||
Drawf.target(target.getX(), target.getY(), 7f * Interp.swingIn.apply(crosshairScale), Pal.remove);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
@@ -80,6 +80,10 @@ public class Scripts implements Disposable{
|
||||
|
||||
//region utility mod functions
|
||||
|
||||
public float[] newFloats(int capacity){
|
||||
return new float[capacity];
|
||||
}
|
||||
|
||||
public String readString(String path){
|
||||
return Vars.tree.get(path, true).readString();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public interface Payload{
|
||||
return size() / tilesize <= s;
|
||||
}
|
||||
|
||||
/** @return rotation of this payload. */
|
||||
default float rotation(){
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/** writes the payload for saving. */
|
||||
void write(Writes write);
|
||||
|
||||
|
||||
@@ -35,7 +35,12 @@ public class UnitPayload implements Payload{
|
||||
@Override
|
||||
public void set(float x, float y, float rotation){
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotation);
|
||||
unit.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float rotation(){
|
||||
return unit.rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import mindustry.world.blocks.payloads.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PayloadAcceptor extends Block{
|
||||
public float payloadSpeed = 0.5f;
|
||||
public float payloadSpeed = 0.5f, payloadRotateSpeed = 5f;
|
||||
|
||||
public @Load(value = "@-top", fallback = "factory-top-@size") TextureRegion topRegion;
|
||||
public @Load(value = "@-out", fallback = "factory-out-@size") TextureRegion outRegion;
|
||||
@@ -66,7 +66,7 @@ public class PayloadAcceptor extends Block{
|
||||
public void handlePayload(Building source, Payload payload){
|
||||
this.payload = (T)payload;
|
||||
this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f, size * tilesize / 2f);
|
||||
this.payRotation = source.angleTo(this);
|
||||
this.payRotation = payload.rotation();
|
||||
|
||||
updatePayload();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class PayloadAcceptor extends Block{
|
||||
|
||||
updatePayload();
|
||||
|
||||
payRotation = Mathf.slerpDelta(payRotation, rotate ? rotdeg() : 90f, 0.3f);
|
||||
payRotation = Angles.moveToward(payRotation, rotate ? rotdeg() : 90f, payloadRotateSpeed * edelta());
|
||||
payVector.approach(Vec2.ZERO, payloadSpeed * delta());
|
||||
|
||||
return hasArrived();
|
||||
@@ -126,10 +126,12 @@ public class PayloadAcceptor extends Block{
|
||||
|
||||
updatePayload();
|
||||
|
||||
payVector.trns(rotdeg(), payVector.len() + delta() * payloadSpeed);
|
||||
payRotation = rotdeg();
|
||||
Vec2 dest = Tmp.v1.trns(rotdeg(), size* tilesize/2f);
|
||||
|
||||
if(payVector.len() >= size * tilesize/2f){
|
||||
payRotation = Angles.moveToward(payRotation, rotdeg(), payloadRotateSpeed * edelta());
|
||||
payVector.approach(dest, payloadSpeed * delta());
|
||||
|
||||
if(payVector.within(dest, 0.001f)){
|
||||
payVector.clamp(-size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f, size * tilesize / 2f);
|
||||
|
||||
Building front = front();
|
||||
@@ -155,7 +157,7 @@ public class PayloadAcceptor extends Block{
|
||||
|
||||
public void drawPayload(){
|
||||
if(payload != null){
|
||||
payload.set(x + payVector.x, y + payVector.y, payRotation);
|
||||
updatePayload();
|
||||
|
||||
Draw.z(Layer.blockOver);
|
||||
payload.draw();
|
||||
|
||||
@@ -142,13 +142,12 @@ public class Reconstructor extends UnitBlock{
|
||||
if(constructing() && hasArrived()){
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
Draw.alpha(1f - progress/ constructTime);
|
||||
Draw.rect(payload.unit.type.icon(Cicon.full), x, y, rotdeg() - 90);
|
||||
Draw.rect(payload.unit.type.icon(Cicon.full), x, y, payload.rotation() - 90);
|
||||
Draw.reset();
|
||||
Drawf.construct(this, upgrade(payload.unit.type), rotdeg() - 90f, progress / constructTime, speedScl, time);
|
||||
Drawf.construct(this, upgrade(payload.unit.type), payload.rotation() - 90f, progress / constructTime, speedScl, time);
|
||||
});
|
||||
}else{
|
||||
Draw.z(Layer.blockOver);
|
||||
payRotation = rotdeg();
|
||||
|
||||
drawPayload();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user