Refactoring / Launch pad tweaks
This commit is contained in:
@@ -21,7 +21,7 @@ public class PayloadConveyor extends Block{
|
||||
public float moveTime = 70f;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
public @Load("@-edge") TextureRegion edgeRegion;
|
||||
public Interpolation interp = Interpolation.pow5;
|
||||
public Interp interp = Interp.pow5;
|
||||
|
||||
public PayloadConveyor(String name){
|
||||
super(name);
|
||||
@@ -140,7 +140,7 @@ public class PayloadConveyor extends Block{
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(i) && i != rotation()){
|
||||
Draw.alpha(1f - Interpolation.pow5In.apply(fract()));
|
||||
Draw.alpha(1f - Interp.pow5In.apply(fract()));
|
||||
//prev from back
|
||||
Tmp.v1.set(- s/2f + clipped.getWidth()/2f*Draw.scl, - s/2f + clipped.getHeight()/2f*Draw.scl).rotate(i * 90 + 180);
|
||||
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, i * 90 + 180);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
Tile from = world.tile(link);
|
||||
Tmp.v1.set(from);
|
||||
Tmp.v2.set(tile);
|
||||
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear);
|
||||
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interp.linear);
|
||||
|
||||
//rotation
|
||||
float a = (from.rotation()%4) * 90;
|
||||
@@ -126,7 +126,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
|
||||
|
||||
//stack
|
||||
Draw.rect(stackRegion, Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interpolation.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
|
||||
Draw.rect(stackRegion, Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interp.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
|
||||
|
||||
//item
|
||||
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PowerGraph{
|
||||
}
|
||||
|
||||
public float getPowerBalance(){
|
||||
return powerBalance.getMean();
|
||||
return powerBalance.mean();
|
||||
}
|
||||
|
||||
public float getLastPowerNeeded(){
|
||||
@@ -198,7 +198,7 @@ public class PowerGraph{
|
||||
lastPowerNeeded = powerNeeded;
|
||||
lastPowerProduced = powerProduced;
|
||||
|
||||
powerBalance.addValue((lastPowerProduced - lastPowerNeeded) / Time.delta());
|
||||
powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta());
|
||||
|
||||
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package mindustry.world.blocks.storage;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@@ -29,33 +35,19 @@ public class LaunchPad extends Block{
|
||||
stats.add(BlockStat.launchTime, launchTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity));
|
||||
}
|
||||
|
||||
public class LaunchPadEntity extends TileEntity{
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
//TODO
|
||||
/*
|
||||
|
||||
//TODO broken
|
||||
float progress = Mathf.clamp(Mathf.clamp((items.total() / (float)itemCapacity)) * ((timer().getTime(timerLaunch) / (launchTime / timeScale()))));
|
||||
float scale = size / 3f;
|
||||
|
||||
Lines.stroke(2f);
|
||||
Draw.color(Pal.accentBack);
|
||||
Lines.poly(x, y, 4, scale * 10f * (1f - progress), 45 + 360f * progress);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
|
||||
if(cons.valid()){
|
||||
for(int i = 0; i < 3; i++){
|
||||
float f = (Time.time() / 200f + i * 0.5f) % 1f;
|
||||
|
||||
Lines.stroke(((2f * (2f - Math.abs(0.5f - f) * 2f)) - 2f + 0.2f));
|
||||
Lines.poly(x, y, 4, (1f - f) * 10f * scale);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();*/
|
||||
Draw.rect("launchpod", x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,45 +60,58 @@ public class LaunchPad extends Block{
|
||||
|
||||
//launch when full
|
||||
if(items.total() >= itemCapacity){
|
||||
|
||||
LaunchPayloadc entity = LaunchPayloadEntity.create();
|
||||
items.each((item, amount) -> entity.stacks().add(new ItemStack(item, amount)));
|
||||
entity.set(this);
|
||||
entity.lifetime(120f);
|
||||
entity.team(team);
|
||||
entity.add();
|
||||
Fx.launchPod.at(this);
|
||||
items.clear();
|
||||
}
|
||||
/*
|
||||
|
||||
if(state.isCampaign() && consValid() && items.total() >= itemCapacity && timer(timerLaunch, launchTime / timeScale())){
|
||||
for(Item item : Vars.content.items()){
|
||||
Events.fire(Trigger.itemLaunch);
|
||||
Fx.padlaunch.at(tile);
|
||||
int used = Math.min(items.get(item), itemCapacity);
|
||||
data.addItem(item, used);
|
||||
items.remove(item, used);
|
||||
Events.fire(new LaunchItemEvent(item, used));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@EntityDef(LaunchPayloadc.class)
|
||||
@Component
|
||||
static abstract class LaunchPayloadComp implements Drawc{
|
||||
static final float speed = 1f;
|
||||
static abstract class LaunchPayloadComp implements Drawc, Timedc, Teamc{
|
||||
static final float speed = 1.6f;
|
||||
|
||||
@Import float x,y;
|
||||
|
||||
float height;
|
||||
transient TextureRegion region;
|
||||
|
||||
Array<ItemStack> stacks = new Array<>();
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
float alpha = fout(Interp.pow5Out);
|
||||
float cx = x + fin(Interp.pow2In) * 90f, cy = y + height;
|
||||
float rotation = fin() * 120f;
|
||||
|
||||
Draw.z(Layer.effect);
|
||||
|
||||
Draw.color(Pal.engine);
|
||||
|
||||
float rad = 0.2f + fslope();
|
||||
|
||||
Fill.light(cx, cy, 10, 25f * rad, Pal.engine, Tmp.c1.set(Pal.engine).a(0f));
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
Drawf.tri(cx, cy, 6f, 40f * rad, i * 90f + rotation);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
Draw.z(Layer.weather - 1);
|
||||
Draw.rect(region, x, y);
|
||||
|
||||
Draw.alpha(alpha);
|
||||
Draw.rect("launchpod", cx, cy, rotation);
|
||||
|
||||
Tmp.v1.trns(225f, height);
|
||||
|
||||
Draw.z(Layer.flyingUnit + 1);
|
||||
Draw.color(UnitType.shadowColor);
|
||||
Draw.rect(region, x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
Draw.color(0, 0, 0, 0.22f * alpha);
|
||||
Draw.rect("launchpod", cx + Tmp.v1.x, cy + Tmp.v1.y, rotation);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -115,5 +120,16 @@ public class LaunchPad extends Block{
|
||||
public void update(){
|
||||
height += Time.delta() * speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
if(team() == Vars.state.rules.defaultTeam){
|
||||
for(ItemStack stack : stacks){
|
||||
Vars.data.addItem(stack.item, stack.amount);
|
||||
Events.fire(new LaunchItemEvent(stack));
|
||||
Vars.state.stats.handleItemExport(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ public class ItemModule extends BlockModule{
|
||||
boolean updateFlow = flowTimer.get(30);
|
||||
|
||||
for(int i = 0; i < items.length; i++){
|
||||
flow[i].addValue(cacheSums[i]);
|
||||
flow[i].add(cacheSums[i]);
|
||||
if(cacheSums[i] > 0){
|
||||
cacheBits.set(i);
|
||||
}
|
||||
cacheSums[i] = 0;
|
||||
|
||||
if(updateFlow){
|
||||
displayFlow[i] = flow[i].hasEnoughData() ? flow[i].getMean() : -1;
|
||||
displayFlow[i] = flow[i].hasEnoughData() ? flow[i].mean() : -1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@@ -267,7 +267,7 @@ public class ItemModule extends BlockModule{
|
||||
}
|
||||
|
||||
public interface ItemConsumer{
|
||||
void accept(Item item, float amount);
|
||||
void accept(Item item, int amount);
|
||||
}
|
||||
|
||||
public interface ItemCalculator{
|
||||
|
||||
@@ -26,10 +26,10 @@ public class LiquidModule extends BlockModule{
|
||||
smoothLiquid = Mathf.lerpDelta(smoothLiquid, currentAmount(), 0.1f);
|
||||
if(showFlow){
|
||||
if(flow == null) flow = new WindowedMean(windowSize);
|
||||
flow.addValue(lastAdded);
|
||||
flow.add(lastAdded);
|
||||
lastAdded = 0;
|
||||
if(currentFlowRate < 0 || flowTimer.get(updateInterval)){
|
||||
currentFlowRate = flow.hasEnoughData() ? flow.getMean() : -1f;
|
||||
currentFlowRate = flow.hasEnoughData() ? flow.mean() : -1f;
|
||||
}
|
||||
}else{
|
||||
currentFlowRate = -1f;
|
||||
|
||||
Reference in New Issue
Block a user