mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Fixed high sound memory usage / Basic drill output speed display
This commit is contained in:
parent
b1980a17ac
commit
01efb59d25
@ -132,12 +132,23 @@ public class UI implements ApplicationListener{
|
||||
|
||||
void generateFonts(Skin skin){
|
||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||
param.size = (int)(9 * 2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
||||
param.shadowColor = Color.DARK_GRAY;
|
||||
param.shadowOffsetY = 2;
|
||||
param.incremental = true;
|
||||
|
||||
FreeTypeFontParameter param = new FreeTypeFontParameter(){{
|
||||
size = (int)(9 * 2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
||||
shadowColor = Color.DARK_GRAY;
|
||||
shadowOffsetY = 2;
|
||||
incremental = true;
|
||||
}};
|
||||
|
||||
FreeTypeFontParameter outlined = new FreeTypeFontParameter(){{
|
||||
size = param.size;
|
||||
borderColor = Color.DARK_GRAY;
|
||||
borderWidth = 2f;
|
||||
spaceX -= borderWidth;
|
||||
incremental = true;
|
||||
}};
|
||||
|
||||
skin.add("outlined-font", generator.generateFont(outlined));
|
||||
skin.add("default-font", generator.generateFont(param));
|
||||
skin.add("default-font-chat", generator.generateFont(param));
|
||||
skin.getFont("default-font").getData().markupEnabled = true;
|
||||
|
@ -478,8 +478,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
for(int i = 0; i < 4; i++){
|
||||
Point2 p = Geometry.d8edge[i];
|
||||
float offset = -Math.max(request.block.size - 1, 0) / 2f * tilesize;
|
||||
if(i % 2 == 0)
|
||||
Draw.rect("block-select", request.x * tilesize + request.block.offset() + offset * p.x, request.y * tilesize + request.block.offset() + offset * p.y, i * 90);
|
||||
Draw.rect("block-select", request.x * tilesize + request.block.offset() + offset * p.x, request.y * tilesize + request.block.offset() + offset * p.y, i * 90);
|
||||
}
|
||||
Draw.color();
|
||||
|
||||
|
@ -1,22 +1,19 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Graphics.Cursor;
|
||||
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.scene.ui.TextField;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Graphics.*;
|
||||
import io.anuke.arc.Graphics.Cursor.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.PlaceUtils.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.arc.Core.scene;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@ -41,6 +38,7 @@ public class DesktopInput extends InputHandler{
|
||||
block.getPlaceDraw(placeDraw, rotation, prevX, prevY, prevRotation);
|
||||
|
||||
Draw.color();
|
||||
Draw.mixcol(Pal.accent, 0.12f + Mathf.absin(Time.time(), 8f, 0.35f));
|
||||
Draw.rect(placeDraw.region, x * tilesize + block.offset(), y * tilesize + block.offset(),
|
||||
placeDraw.region.getWidth() * selectScale * Draw.scl * placeDraw.scalex,
|
||||
placeDraw.region.getHeight() * selectScale * Draw.scl * placeDraw.scaley,
|
||||
@ -54,6 +52,7 @@ public class DesktopInput extends InputHandler{
|
||||
Draw.rect("block-select", x * tilesize + block.offset() + offset * p.x, y * tilesize + block.offset() + offset * p.y, i * 90);
|
||||
}
|
||||
Draw.color();
|
||||
Draw.mixcol();
|
||||
}else{
|
||||
Draw.color(Pal.removeBack);
|
||||
Lines.square(x * tilesize + block.offset(), y * tilesize + block.offset() - 1, block.size * tilesize / 2f - 1);
|
||||
|
@ -215,13 +215,13 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
float offset = request.block.offset();
|
||||
TextureRegion region = placeDraw.region;
|
||||
|
||||
Draw.mixcol(Pal.accent, Mathf.clamp((1f - request.scale) / 0.5f));
|
||||
Draw.mixcol(Pal.accent, Mathf.clamp((1f - request.scale) / 0.5f + 0.12f + Mathf.absin(Time.time(), 8f, 0.35f)));
|
||||
Draw.tint(Color.WHITE, Pal.breakInvalid, request.redness);
|
||||
|
||||
Draw.rect(region, tile.worldx() + offset, tile.worldy() + offset,
|
||||
region.getWidth() * request.scale * Draw.scl * placeDraw.scalex,
|
||||
region.getHeight() * request.scale * Draw.scl * placeDraw.scaley,
|
||||
request.block.rotate ? placeDraw.rotation * 90 : 0);
|
||||
region.getWidth() * request.scale * Draw.scl * placeDraw.scalex,
|
||||
region.getHeight() * request.scale * Draw.scl * placeDraw.scaley,
|
||||
request.block.rotate ? placeDraw.rotation * 90 : 0);
|
||||
|
||||
Draw.mixcol(Pal.accent, 1f);
|
||||
for(int i = 0; i < 4; i++){
|
||||
|
@ -228,7 +228,7 @@ public class Block extends BlockStorage{
|
||||
if(renderer.pixelator.enabled()) return;
|
||||
|
||||
Color color = valid ? Pal.accent : Pal.remove;
|
||||
BitmapFont font = Core.scene.skin.getFont("default-font");
|
||||
BitmapFont font = Core.scene.skin.getFont("outlined-font");
|
||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
boolean ints = font.usesIntegerPositions();
|
||||
font.setUseIntegerPositions(false);
|
||||
@ -236,10 +236,13 @@ public class Block extends BlockStorage{
|
||||
layout.setText(font, text);
|
||||
|
||||
font.setColor(color);
|
||||
float dx = x * tilesize + offset(), dy = y * tilesize + offset() + size * tilesize / 2f + 2;
|
||||
float dx = x * tilesize + offset(), dy = y * tilesize + offset() + size * tilesize / 2f + 3;
|
||||
font.draw(text, dx, dy + layout.height + 1, Align.center);
|
||||
Lines.stroke(1f, color);
|
||||
dy -= 1f;
|
||||
Lines.stroke(2f, Color.DARK_GRAY);
|
||||
Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 2f, dy);
|
||||
Lines.stroke(1f, color);
|
||||
Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 1.5f, dy);
|
||||
|
||||
font.setUseIntegerPositions(ints);
|
||||
font.setColor(Color.WHITE);
|
||||
|
@ -22,7 +22,7 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Drill extends Block{
|
||||
protected final static float hardnessDrillMultiplier = 50f;
|
||||
@ -39,6 +39,10 @@ public class Drill extends Block{
|
||||
/** Speed at which the drill speeds up. */
|
||||
protected float warmupSpeed = 0.02f;
|
||||
|
||||
//return variables for countOre
|
||||
protected Item returnItem;
|
||||
protected int returnCount;
|
||||
|
||||
/** Whether to draw the item this drill is mining. */
|
||||
protected boolean drawMineItem = false;
|
||||
/** Effect played when an item is produced. This is colored. */
|
||||
@ -130,6 +134,14 @@ public class Drill extends Block{
|
||||
return tile.entity.items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile == null) return;
|
||||
countOre(tile);
|
||||
drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / (drillTime + hardnessDrillMultiplier * returnItem.hardness) * returnCount, 2), x, y, valid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
@ -158,40 +170,44 @@ public class Drill extends Block{
|
||||
stats.add(BlockStat.boostEffect, liquidBoostIntensity, StatUnit.timesSpeed);
|
||||
}
|
||||
|
||||
void countOre(Tile tile){
|
||||
oreCount.clear();
|
||||
itemArray.clear();
|
||||
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
if(isValid(other)){
|
||||
oreCount.getAndIncrement(getDrop(other), 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for(Item item : oreCount.keys()){
|
||||
itemArray.add(item);
|
||||
}
|
||||
|
||||
itemArray.sort((item1, item2) -> {
|
||||
int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material);
|
||||
if(type != 0) return type;
|
||||
return Integer.compare(item1.id, item2.id);
|
||||
});
|
||||
|
||||
if(itemArray.size == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
returnItem = itemArray.peek();
|
||||
returnCount = oreCount.get(itemArray.peek(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
DrillEntity entity = tile.entity();
|
||||
|
||||
if(entity.dominantItem == null){
|
||||
oreCount.clear();
|
||||
itemArray.clear();
|
||||
|
||||
for(Tile other : tile.getLinkedTiles(tempTiles)){
|
||||
if(isValid(other)){
|
||||
oreCount.getAndIncrement(getDrop(other), 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for(Item item : oreCount.keys()){
|
||||
itemArray.add(item);
|
||||
}
|
||||
|
||||
itemArray.sort((item1, item2) -> {
|
||||
int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material);
|
||||
if(type != 0) return type;
|
||||
return Integer.compare(item1.id, item2.id);
|
||||
});
|
||||
|
||||
if(itemArray.size == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
entity.dominantItem = itemArray.peek();
|
||||
entity.dominantItems = oreCount.get(itemArray.peek(), 0);
|
||||
countOre(tile);
|
||||
entity.dominantItem = returnItem;
|
||||
entity.dominantItems = returnCount;
|
||||
}
|
||||
|
||||
float totalHardness = entity.dominantItems * entity.dominantItem.hardness;
|
||||
|
||||
if(entity.timer.get(timerDump, dumpTime)){
|
||||
tryDump(tile, entity.dominantItem);
|
||||
}
|
||||
@ -210,7 +226,7 @@ public class Drill extends Block{
|
||||
speed *= entity.power.satisfaction; // Drill slower when not at full power
|
||||
}
|
||||
|
||||
entity.lastDrillSpeed = (speed * entity.dominantItems * entity.warmup) / (drillTime + hardnessDrillMultiplier * Math.max(totalHardness, 1f) / entity.dominantItems);
|
||||
entity.lastDrillSpeed = (speed * entity.dominantItems * entity.warmup) / (drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness);
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, speed, warmupSpeed);
|
||||
entity.progress += entity.delta()
|
||||
* entity.dominantItems * speed * entity.warmup;
|
||||
@ -223,8 +239,7 @@ public class Drill extends Block{
|
||||
return;
|
||||
}
|
||||
|
||||
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * Math.max(totalHardness, 1f) / entity.dominantItems
|
||||
&& tile.entity.items.total() < itemCapacity){
|
||||
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.items.total() < itemCapacity){
|
||||
|
||||
offloadNear(tile, entity.dominantItem);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user