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{ public @interface OverrideCallSuper{
} }
/** Marks a class as serializable. */ /** Marks a class as serializable.
* @deprecated due to very sparse use and inflexibility. */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Deprecated
public @interface Serialize{ 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

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

View File

@@ -60,13 +60,13 @@ public class Fx{
color(Pal.accent); 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 x = Tmp.v1.x, y = Tmp.v1.y;
float size = 2.5f * e.fin(); float size = 2.5f * e.fin();
Fill.square(x, y, 1.5f * size, 45f); 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; x = Tmp.v1.x;
y = Tmp.v1.y; y = Tmp.v1.y;
@@ -76,7 +76,7 @@ public class Fx{
itemTransfer = new Effect(30f, e -> { itemTransfer = new Effect(30f, e -> {
if(!(e.data instanceof Position)) return; if(!(e.data instanceof Position)) return;
Position to = e.data(); 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)); .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 x = Tmp.v1.x, y = Tmp.v1.y;
float size = Math.min(0.8f + e.rotation / 5f, 2); float size = Math.min(0.8f + e.rotation / 5f, 2);
@@ -96,7 +96,7 @@ public class Fx{
Block block = l.block; Block block = l.block;
Position to = Tmp.v3.set(l.x * tilesize, l.y * tilesize).add(block.offset(), block.offset()); 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; float x = Tmp.v1.x, y = Tmp.v1.y;
Draw.rect(block.icon(Cicon.full), x, 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); 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 -> { healWaveMend = new Effect(40, e -> {
color(e.color); color(e.color);
stroke(e.fout() * 2f); stroke(e.fout() * 2f);

View File

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

View File

@@ -7,10 +7,10 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.core.GameState.*; import mindustry.core.GameState.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.game.Teams.*; import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.type.Weather.*; import mindustry.type.Weather.*;
import mindustry.world.*; 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. */ /** 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(Tilec entity : state.teams.playerCores()){
for(Item item : content.items()){ for(Item item : content.items()){
data.addItem(item, entity.items().get(item)); 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(); entity.tile().remove();
} }
@@ -245,6 +247,8 @@ public class Logic implements ApplicationListener{
} }
if(!state.isPaused()){ if(!state.isPaused()){
state.stats.update();
if(state.isCampaign()){ if(state.isCampaign()){
universe.update(); universe.update();
} }

View File

@@ -60,7 +60,7 @@ public class Renderer implements ApplicationListener{
if(landTime > 0){ if(landTime > 0){
landTime -= Time.delta(); 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; camerascale = landscale;
weatherAlpha = 0f; weatherAlpha = 0f;
}else{ }else{

View File

@@ -284,7 +284,7 @@ public class UI implements ApplicationListener, Loadable{
public void showInfoFade(String info){ public void showInfoFade(String info){
Table table = new Table(); Table table = new Table();
table.setFillParent(true); 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); table.top().add(info).style(Styles.outlineLabel).padTop(10);
Core.scene.add(table); Core.scene.add(table);
} }
@@ -297,7 +297,7 @@ public class UI implements ApplicationListener, Loadable{
table.update(() -> { table.update(() -> {
if(state.isMenu()) table.remove(); 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); table.top().table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).padTop(10);
Core.scene.add(table); Core.scene.add(table);
} }

View File

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

View File

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

View File

@@ -2,13 +2,19 @@ package mindustry.game;
import arc.math.*; import arc.math.*;
import arc.struct.*; import arc.struct.*;
import mindustry.annotations.Annotations.*; import arc.util.*;
import mindustry.type.*; import mindustry.type.*;
import java.util.*;
import static mindustry.Vars.content; import static mindustry.Vars.content;
@Serialize
public class Stats{ 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. */ /** Items delivered to global resoure counter. Zones only. */
public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>(); public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
/** Enemy (red team) units destroyed. */ /** Enemy (red team) units destroyed. */
@@ -24,8 +30,35 @@ public class Stats{
/** Friendly buildings destroyed. */ /** Friendly buildings destroyed. */
public int buildingsDestroyed; public int buildingsDestroyed;
/** Item production means. */ /** Item production means. Holds means per period. */
private transient WindowedMean[] itemProduction = new WindowedMean[content.items().size]; 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){ public RankResult calculateRank(Sector zone, boolean launched){
float score = 0; float score = 0;

View File

@@ -90,7 +90,11 @@ public class Drawf{
} }
public static void shadow(float x, float y, float rad){ 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.rect("circle-shadow", x, y, rad, rad);
Draw.color(); Draw.color();
} }

View File

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

View File

@@ -383,7 +383,7 @@ public class MobileInput extends InputHandler implements GestureListener{
Draw.color(Pal.remove); Draw.color(Pal.remove);
Lines.stroke(1f); 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.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); 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){ void showToast(String info){
Table table = new Table(); 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.top().add(info);
table.setName("toast"); table.setName("toast");
table.update(() -> { table.update(() -> {
@@ -238,7 +238,7 @@ public class TechTreeDialog extends FloatingDialog{
addAction(new RelativeTemporalAction(){ addAction(new RelativeTemporalAction(){
{ {
setDuration(0.1f); setDuration(0.1f);
setInterpolation(Interpolation.fade); setInterpolation(Interp.fade);
} }
@Override @Override

View File

@@ -7,7 +7,6 @@ import arc.scene.actions.*;
import arc.scene.ui.layout.*; import arc.scene.ui.layout.*;
import arc.util.*; import arc.util.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.gen.*; import mindustry.gen.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -52,7 +51,7 @@ public class BlockConfigFragment extends Fragment{
table.pack(); table.pack();
table.setTransform(true); table.setTransform(true);
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(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(() -> { table.update(() -> {
if(configTile != null && configTile.shouldHideConfigure(player)){ if(configTile != null && configTile.shouldHideConfigure(player)){
@@ -76,6 +75,6 @@ public class BlockConfigFragment extends Fragment{
public void hideConfig(){ public void hideConfig(){
configTile = null; 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(){ public void hide(){
if(table == null) return; 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.clearChildren();
table.clearListeners(); table.clearListeners();
table.update(null); table.update(null);
@@ -213,7 +213,7 @@ public class BlockInventoryFragment extends Fragment{
if(actions){ if(actions){
table.setScale(0f, 1f); 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{ }else{
table.setScale(1f, 1f); table.setScale(1f, 1f);
} }

View File

@@ -348,9 +348,9 @@ public class HudFragment extends Fragment{
Table container = Core.scene.table(); Table container = Core.scene.table();
container.top().add(table); container.top().add(table);
container.setTranslation(0, table.getPrefHeight()); 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 //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(); Table container = Core.scene.table();
container.top().add(table); container.top().add(table);
container.setTranslation(0, table.getPrefHeight()); 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 //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; lastUnlockTable = null;
lastUnlockLayout = null; lastUnlockLayout = null;
}), Actions.remove()))); }), Actions.remove())));

View File

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

View File

@@ -21,7 +21,7 @@ public class PayloadConveyor extends Block{
public float moveTime = 70f; public float moveTime = 70f;
public @Load("@-top") TextureRegion topRegion; public @Load("@-top") TextureRegion topRegion;
public @Load("@-edge") TextureRegion edgeRegion; public @Load("@-edge") TextureRegion edgeRegion;
public Interpolation interp = Interpolation.pow5; public Interp interp = Interp.pow5;
public PayloadConveyor(String name){ public PayloadConveyor(String name){
super(name); super(name);
@@ -140,7 +140,7 @@ public class PayloadConveyor extends Block{
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
if(blends(i) && i != rotation()){ if(blends(i) && i != rotation()){
Draw.alpha(1f - Interpolation.pow5In.apply(fract())); Draw.alpha(1f - Interp.pow5In.apply(fract()));
//prev from back //prev from back
Tmp.v1.set(- s/2f + clipped.getWidth()/2f*Draw.scl, - s/2f + clipped.getHeight()/2f*Draw.scl).rotate(i * 90 + 180); 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); 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); Tile from = world.tile(link);
Tmp.v1.set(from); Tmp.v1.set(from);
Tmp.v2.set(tile); Tmp.v2.set(tile);
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear); Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interp.linear);
//rotation //rotation
float a = (from.rotation()%4) * 90; 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; if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
//stack //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 //item
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f); 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(){ public float getPowerBalance(){
return powerBalance.getMean(); return powerBalance.mean();
} }
public float getLastPowerNeeded(){ public float getLastPowerNeeded(){
@@ -198,7 +198,7 @@ public class PowerGraph{
lastPowerNeeded = powerNeeded; lastPowerNeeded = powerNeeded;
lastPowerProduced = powerProduced; lastPowerProduced = powerProduced;
powerBalance.addValue((lastPowerProduced - lastPowerNeeded) / Time.delta()); powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta());
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){ if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){

View File

@@ -1,12 +1,18 @@
package mindustry.world.blocks.storage; package mindustry.world.blocks.storage;
import arc.*;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.math.*;
import arc.struct.*; import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.game.EventType.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
@@ -29,33 +35,19 @@ public class LaunchPad extends Block{
stats.add(BlockStat.launchTime, launchTime / 60f, StatUnit.seconds); 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{ public class LaunchPadEntity extends TileEntity{
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
//TODO
/*
//TODO broken Draw.rect("launchpod", x, y);
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();*/
} }
@Override @Override
@@ -68,45 +60,58 @@ public class LaunchPad extends Block{
//launch when full //launch when full
if(items.total() >= itemCapacity){ 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) @EntityDef(LaunchPayloadc.class)
@Component @Component
static abstract class LaunchPayloadComp implements Drawc{ static abstract class LaunchPayloadComp implements Drawc, Timedc, Teamc{
static final float speed = 1f; static final float speed = 1.6f;
@Import float x,y; @Import float x,y;
float height; float height;
transient TextureRegion region;
Array<ItemStack> stacks = new Array<>(); Array<ItemStack> stacks = new Array<>();
@Override @Override
public void draw(){ 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.z(Layer.weather - 1);
Draw.rect(region, x, y);
Draw.alpha(alpha);
Draw.rect("launchpod", cx, cy, rotation);
Tmp.v1.trns(225f, height); Tmp.v1.trns(225f, height);
Draw.z(Layer.flyingUnit + 1); Draw.z(Layer.flyingUnit + 1);
Draw.color(UnitType.shadowColor); Draw.color(0, 0, 0, 0.22f * alpha);
Draw.rect(region, x + Tmp.v1.x, y + Tmp.v1.y); Draw.rect("launchpod", cx + Tmp.v1.x, cy + Tmp.v1.y, rotation);
Draw.reset(); Draw.reset();
} }
@@ -115,5 +120,16 @@ public class LaunchPad extends Block{
public void update(){ public void update(){
height += Time.delta() * speed; 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); boolean updateFlow = flowTimer.get(30);
for(int i = 0; i < items.length; i++){ for(int i = 0; i < items.length; i++){
flow[i].addValue(cacheSums[i]); flow[i].add(cacheSums[i]);
if(cacheSums[i] > 0){ if(cacheSums[i] > 0){
cacheBits.set(i); cacheBits.set(i);
} }
cacheSums[i] = 0; cacheSums[i] = 0;
if(updateFlow){ if(updateFlow){
displayFlow[i] = flow[i].hasEnoughData() ? flow[i].getMean() : -1; displayFlow[i] = flow[i].hasEnoughData() ? flow[i].mean() : -1;
} }
} }
}else{ }else{
@@ -267,7 +267,7 @@ public class ItemModule extends BlockModule{
} }
public interface ItemConsumer{ public interface ItemConsumer{
void accept(Item item, float amount); void accept(Item item, int amount);
} }
public interface ItemCalculator{ public interface ItemCalculator{

View File

@@ -26,10 +26,10 @@ public class LiquidModule extends BlockModule{
smoothLiquid = Mathf.lerpDelta(smoothLiquid, currentAmount(), 0.1f); smoothLiquid = Mathf.lerpDelta(smoothLiquid, currentAmount(), 0.1f);
if(showFlow){ if(showFlow){
if(flow == null) flow = new WindowedMean(windowSize); if(flow == null) flow = new WindowedMean(windowSize);
flow.addValue(lastAdded); flow.add(lastAdded);
lastAdded = 0; lastAdded = 0;
if(currentFlowRate < 0 || flowTimer.get(updateInterval)){ if(currentFlowRate < 0 || flowTimer.get(updateInterval)){
currentFlowRate = flow.hasEnoughData() ? flow.getMean() : -1f; currentFlowRate = flow.hasEnoughData() ? flow.mean() : -1f;
} }
}else{ }else{
currentFlowRate = -1f; currentFlowRate = -1f;

View File

@@ -70,7 +70,7 @@ task run(dependsOn: classes, type: JavaExec){
task dist(type: Jar, dependsOn: classes){ task dist(type: Jar, dependsOn: classes){
from files(sourceSets.main.output.classesDirs) from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir) 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) from files(project.assetsDir)
archiveFileName = "${appName}.jar" archiveFileName = "${appName}.jar"

View File

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