Refactoring / Launch pad tweaks

This commit is contained in:
Anuken 2020-05-14 22:00:04 -04:00
parent 3fd677b3e6
commit a4987f864f
31 changed files with 761 additions and 679 deletions

View file

@ -124,9 +124,11 @@ public class Annotations{
public @interface OverrideCallSuper{
}
/** Marks a class as serializable. */
/** Marks a class as serializable.
* @deprecated due to very sparse use and inflexibility. */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
@Deprecated
public @interface Serialize{
}

View file

@ -0,0 +1 @@
{version:1,fields:[{name:height,type:float,size:4},{name:lifetime,type:float,size:4},{name:stacks,type:arc.struct.Array<mindustry.type.ItemStack>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 KiB

After

Width:  |  Height:  |  Size: 711 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Before After
Before After

View file

@ -295,7 +295,7 @@ public class Vars implements Loadable{
Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false);
LogHandler log = Log.getLogger();
Log.setLogger(((level, text) -> {
Log.setLogger((level, text) -> {
log.log(level, text);
try{
@ -305,7 +305,7 @@ public class Vars implements Loadable{
e.printStackTrace();
//ignore it
}
}));
});
loadedFileLogger = true;
}

View file

@ -60,13 +60,13 @@ public class Fx{
color(Pal.accent);
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.pow2In);
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interp.pow2In);
float x = Tmp.v1.x, y = Tmp.v1.y;
float size = 2.5f * e.fin();
Fill.square(x, y, 1.5f * size, 45f);
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.pow5In);
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interp.pow5In);
x = Tmp.v1.x;
y = Tmp.v1.y;
@ -76,7 +76,7 @@ public class Fx{
itemTransfer = new Effect(30f, e -> {
if(!(e.data instanceof Position)) return;
Position to = e.data();
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.pow3)
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interp.pow3)
.add(Tmp.v2.sub(e.x, e.y).nor().rotate90(1).scl(Mathf.randomSeedRange(e.id, 1f) * e.fslope() * 10f));
float x = Tmp.v1.x, y = Tmp.v1.y;
float size = Math.min(0.8f + e.rotation / 5f, 2);
@ -96,7 +96,7 @@ public class Fx{
Block block = l.block;
Position to = Tmp.v3.set(l.x * tilesize, l.y * tilesize).add(block.offset(), block.offset());
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.linear);
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interp.linear);
float x = Tmp.v1.x, y = Tmp.v1.y;
Draw.rect(block.icon(Cicon.full), x, y);
@ -1153,6 +1153,22 @@ public class Fx{
Lines.circle(e.x, e.y, 4f + e.finpow() * 120f);
}),
launchPod = new Effect(40, e -> {
color(Pal.engine);
e.scaled(20f, f -> {
stroke(f.fout() * 2f);
Lines.circle(e.x, e.y, 4f + f.finpow() * 30f);
});
stroke(e.fout() * 2f);
randLenVectors(e.id, 24, e.finpow() * 50f, (x, y) -> {
float ang = Mathf.angle(x, y);
lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f);
});
}),
healWaveMend = new Effect(40, e -> {
color(e.color);
stroke(e.fout() * 2f);

View file

@ -9,7 +9,7 @@ import arc.math.*;
import arc.scene.ui.*;
import arc.struct.*;
import arc.util.*;
import mindustry.audio.MusicControl;
import mindustry.audio.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
@ -18,6 +18,7 @@ import mindustry.game.*;
import mindustry.game.Saves.*;
import mindustry.gen.*;
import mindustry.input.*;
import mindustry.io.*;
import mindustry.io.SaveIO.*;
import mindustry.maps.Map;
import mindustry.type.*;
@ -354,9 +355,9 @@ public class Control implements ApplicationListener, Loadable{
@Override
public void dispose(){
//try to save when exiting
if(saves != null && saves.getCurrent() != null && saves.getCurrent().isAutosave() && !net.client()){
if(saves != null && saves.getCurrent() != null && saves.getCurrent().isAutosave() && !net.client() && !state.isMenu()){
try{
control.saves.getCurrent().save();
SaveIO.save(control.saves.getCurrent().file);
Log.info("Saved on exit.");
}catch(Throwable e){
e.printStackTrace();

View file

@ -7,10 +7,10 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.type.Weather.*;
import mindustry.world.*;
@ -92,6 +92,8 @@ public class Logic implements ApplicationListener{
}
}
});
Events.on(LaunchItemEvent.class, e -> state.stats.handleItemExport(e.stack));
}
/** Handles the event of content being used by either the player or some block. */
@ -215,7 +217,7 @@ public class Logic implements ApplicationListener{
for(Tilec entity : state.teams.playerCores()){
for(Item item : content.items()){
data.addItem(item, entity.items().get(item));
Events.fire(new LaunchItemEvent(item, entity.items().get(item)));
Events.fire(new LaunchItemEvent(new ItemStack(item, entity.items().get(item))));
}
entity.tile().remove();
}
@ -245,6 +247,8 @@ public class Logic implements ApplicationListener{
}
if(!state.isPaused()){
state.stats.update();
if(state.isCampaign()){
universe.update();
}

View file

@ -60,7 +60,7 @@ public class Renderer implements ApplicationListener{
if(landTime > 0){
landTime -= Time.delta();
landscale = Interpolation.pow5In.apply(minZoomScl, Scl.scl(4f), 1f - landTime / Fx.coreLand.lifetime);
landscale = Interp.pow5In.apply(minZoomScl, Scl.scl(4f), 1f - landTime / Fx.coreLand.lifetime);
camerascale = landscale;
weatherAlpha = 0f;
}else{

View file

@ -284,7 +284,7 @@ public class UI implements ApplicationListener, Loadable{
public void showInfoFade(String info){
Table table = new Table();
table.setFillParent(true);
table.actions(Actions.fadeOut(7f, Interpolation.fade), Actions.remove());
table.actions(Actions.fadeOut(7f, Interp.fade), Actions.remove());
table.top().add(info).style(Styles.outlineLabel).padTop(10);
Core.scene.add(table);
}
@ -297,7 +297,7 @@ public class UI implements ApplicationListener, Loadable{
table.update(() -> {
if(state.isMenu()) table.remove();
});
table.actions(Actions.delay(duration * 0.9f), Actions.fadeOut(duration * 0.1f, Interpolation.fade), Actions.remove());
table.actions(Actions.delay(duration * 0.9f), Actions.fadeOut(duration * 0.1f, Interp.fade), Actions.remove());
table.top().table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).padTop(10);
Core.scene.add(table);
}

View file

@ -62,8 +62,8 @@ public class EventType{
public static class LaunchItemEvent{
public final ItemStack stack;
public LaunchItemEvent(Item item, int amount){
this.stack = new ItemStack(item, amount);
public LaunchItemEvent(ItemStack stack){
this.stack = stack;
}
}

View file

@ -14,7 +14,6 @@ import mindustry.world.*;
* Defines current rules on how the game should function.
* Does not store game state, just configuration.
*/
@Serialize
public class Rules{
/** Whether the player has infinite resources. */
public boolean infiniteResources;

View file

@ -2,13 +2,19 @@ package mindustry.game;
import arc.math.*;
import arc.struct.*;
import mindustry.annotations.Annotations.*;
import arc.util.*;
import mindustry.type.*;
import java.util.*;
import static mindustry.Vars.content;
@Serialize
public class Stats{
/** export window size in seconds */
private static final int exportWindow = 60;
/** refresh period of export in ticks */
private static final float refreshPeriod = 60;
/** Items delivered to global resoure counter. Zones only. */
public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
/** Enemy (red team) units destroyed. */
@ -24,8 +30,35 @@ public class Stats{
/** Friendly buildings destroyed. */
public int buildingsDestroyed;
/** Item production means. */
private transient WindowedMean[] itemProduction = new WindowedMean[content.items().size];
/** Item production means. Holds means per period. */
private transient WindowedMean[] itemExport = new WindowedMean[content.items().size];
/** Counters of items recieved this period. */
private transient float[] itemCounters = new float[content.items().size];
/** Counter refresh state. */
private transient Interval time = new Interval();
public Stats(){
for(int i = 0; i < itemExport.length; i++){
itemExport[i] = new WindowedMean(exportWindow);
}
}
/** Updates export statistics. */
public void handleItemExport(ItemStack stack){
itemCounters[stack.item.id] += stack.amount;
}
public void update(){
//refresh throughput
if(time.get(refreshPeriod)){
for(int i = 0; i < itemCounters.length; i++){
itemExport[i].add(itemCounters[i]);
}
Arrays.fill(itemCounters, 0);
}
}
public RankResult calculateRank(Sector zone, boolean launched){
float score = 0;

View file

@ -90,7 +90,11 @@ public class Drawf{
}
public static void shadow(float x, float y, float rad){
Draw.color(0, 0, 0, 0.4f);
shadow(x, y, rad, 1f);
}
public static void shadow(float x, float y, float rad, float alpha){
Draw.color(0, 0, 0, 0.4f * alpha);
Draw.rect("circle-shadow", x, y, rad, rad);
Draw.color();
}

View file

@ -71,7 +71,7 @@ public class LoadRenderer implements Disposable{
}
float timespace = Time.timeSinceMillis(lastFrameTime) / 1000f;
renderTimes.addValue(timespace);
renderTimes.add(timespace);
lastFrameTime = Time.millis();
}
@ -278,8 +278,8 @@ public class LoadRenderer implements Disposable{
for(int i = 0; i < bars; i++){
int index = i % renderTimes.getWindowSize();
float val = renderTimes.getValue(index);
float scale = Mathf.clamp(!renderTimes.hasEnoughData() ? Mathf.randomSeed(i) : (val / renderTimes.getMean() - 0.5f));
float val = renderTimes.get(index);
float scale = Mathf.clamp(!renderTimes.hasEnoughData() ? Mathf.randomSeed(i) : (val / renderTimes.mean() - 0.5f));
Color dst = scale > 0.8f ? colorRed : color;
Draw.color(dst);

View file

@ -383,7 +383,7 @@ public class MobileInput extends InputHandler implements GestureListener{
Draw.color(Pal.remove);
Lines.stroke(1f);
float radius = Interpolation.swingIn.apply(crosshairScale);
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);

View file

@ -169,7 +169,7 @@ public class TechTreeDialog extends FloatingDialog{
void showToast(String info){
Table table = new Table();
table.actions(Actions.fadeOut(0.5f, Interpolation.fade), Actions.remove());
table.actions(Actions.fadeOut(0.5f, Interp.fade), Actions.remove());
table.top().add(info);
table.setName("toast");
table.update(() -> {
@ -238,7 +238,7 @@ public class TechTreeDialog extends FloatingDialog{
addAction(new RelativeTemporalAction(){
{
setDuration(0.1f);
setInterpolation(Interpolation.fade);
setInterpolation(Interp.fade);
}
@Override

View file

@ -7,7 +7,6 @@ import arc.scene.actions.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.gen.*;
import static mindustry.Vars.*;
@ -52,7 +51,7 @@ public class BlockConfigFragment extends Fragment{
table.pack();
table.setTransform(true);
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out));
table.update(() -> {
if(configTile != null && configTile.shouldHideConfigure(player)){
@ -76,6 +75,6 @@ public class BlockConfigFragment extends Fragment{
public void hideConfig(){
configTile = null;
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false));
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false));
}
}

View file

@ -85,7 +85,7 @@ public class BlockInventoryFragment extends Fragment{
public void hide(){
if(table == null) return;
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.run(() -> {
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.run(() -> {
table.clearChildren();
table.clearListeners();
table.update(null);
@ -213,7 +213,7 @@ public class BlockInventoryFragment extends Fragment{
if(actions){
table.setScale(0f, 1f);
table.actions(Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
table.actions(Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out));
}else{
table.setScale(1f, 1f);
}

View file

@ -348,9 +348,9 @@ public class HudFragment extends Fragment{
Table container = Core.scene.table();
container.top().add(table);
container.setTranslation(0, table.getPrefHeight());
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interpolation.fade), Actions.delay(2.5f),
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interp.fade), Actions.delay(2.5f),
//nesting actions() calls is necessary so the right prefHeight() is used
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interpolation.fade), Actions.remove())));
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interp.fade), Actions.remove())));
});
}
@ -396,9 +396,9 @@ public class HudFragment extends Fragment{
Table container = Core.scene.table();
container.top().add(table);
container.setTranslation(0, table.getPrefHeight());
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interpolation.fade), Actions.delay(2.5f),
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interp.fade), Actions.delay(2.5f),
//nesting actions() calls is necessary so the right prefHeight() is used
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interpolation.fade), Actions.run(() -> {
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interp.fade), Actions.run(() -> {
lastUnlockTable = null;
lastUnlockLayout = null;
}), Actions.remove())));

View file

@ -202,7 +202,7 @@ public class MenuFragment extends Fragment{
private void fadeInMenu(){
submenu.clearActions();
submenu.actions(Actions.alpha(1f, 0.15f, Interpolation.fade));
submenu.actions(Actions.alpha(1f, 0.15f, Interp.fade));
}
private void fadeOutMenu(){
@ -212,7 +212,7 @@ public class MenuFragment extends Fragment{
}
submenu.clearActions();
submenu.actions(Actions.alpha(1f), Actions.alpha(0f, 0.2f, Interpolation.fade), Actions.run(() -> submenu.clearChildren()));
submenu.actions(Actions.alpha(1f), Actions.alpha(0f, 0.2f, Interp.fade), Actions.run(() -> submenu.clearChildren()));
}
private void buttons(Table t, Buttoni... buttons){

View file

@ -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);

View file

@ -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);

View file

@ -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)){

View file

@ -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);
}
}
}
}
}

View file

@ -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{

View file

@ -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;

View file

@ -70,7 +70,7 @@ task run(dependsOn: classes, type: JavaExec){
task dist(type: Jar, dependsOn: classes){
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compileClasspath.collect{ !it.exists() ? null : it.isDirectory() ? it : zipTree(it) }}
from {configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }}
from files(project.assetsDir)
archiveFileName = "${appName}.jar"

View file

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=3e73cf89218478a660d45b11b7ba273ad0f66fbc
archash=23565d2b458dbdccd676a9094538bc784e076cca