Minor optimization

This commit is contained in:
Anuken 2020-09-13 14:30:31 -04:00
parent 48391219fd
commit f3921e3dcc
32 changed files with 111 additions and 116 deletions

View File

@ -1826,6 +1826,8 @@ public class Blocks implements ContentList{
size = 2;
range = 80f;
itemCapacity = 20;
ammoAmount = 5;
consumes.item(Items.copper, 1);
}};

View File

@ -36,7 +36,7 @@ public class Fx{
TextureRegion region = unit.icon(Cicon.full);
rect(region, e.x, e.y,
region.getWidth() * Draw.scl * scl, region.getHeight() * Draw.scl * scl, 180f);
region.width * Draw.scl * scl, region.height * Draw.scl * scl, 180f);
}),

View File

@ -1030,6 +1030,7 @@ public class UnitTypes implements ContentList{
mega = new UnitType("mega"){{
mineTier = 2;
health = 500;
speed = 1.8f;
accel = 0.06f;

View File

@ -193,7 +193,7 @@ public class Control implements ApplicationListener, Loadable{
@Override
public void loadAsync(){
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
Draw.scl = 1f / Core.atlas.find("scale_marker").width;
Core.input.setCatch(KeyCode.back, true);

View File

@ -28,6 +28,8 @@ public class Renderer implements ApplicationListener{
public PlanetRenderer planets;
public FrameBuffer effectBuffer = new FrameBuffer();
public float laserOpacity = 1f;
private Bloom bloom;
private FxProcessor fx = new FxProcessor();
private Color clearColor = new Color(0f, 0f, 0f, 1f);
@ -61,6 +63,7 @@ public class Renderer implements ApplicationListener{
Color.white.set(1f, 1f, 1f, 1f);
camerascale = Mathf.lerpDelta(camerascale, targetscale, 0.1f);
laserOpacity = Core.settings.getInt("lasersopacity") / 100f;
if(landTime > 0){
landTime -= Time.delta;
@ -273,7 +276,7 @@ public class Renderer implements ApplicationListener{
TextureRegion reg = entity.block.icon(Cicon.full);
float scl = Scl.scl(4f) / camerascale;
float s = reg.getWidth() * Draw.scl * scl * 4f * fract;
float s = reg.width * Draw.scl * scl * 4f * fract;
Draw.color(Pal.lightTrail);
Draw.rect("circle-shadow", entity.getX(), entity.getY(), s, s);
@ -285,7 +288,7 @@ public class Renderer implements ApplicationListener{
Draw.color();
Draw.mixcol(Color.white, fract);
Draw.rect(reg, entity.getX(), entity.getY(), reg.getWidth() * Draw.scl * scl, reg.getHeight() * Draw.scl * scl, fract * 135f);
Draw.rect(reg, entity.getX(), entity.getY(), reg.width * Draw.scl * scl, reg.height * Draw.scl * scl, fract * 135f);
Draw.reset();
}

View File

@ -110,7 +110,7 @@ public class MapRenderer implements Disposable{
if(wall != Blocks.air && wall.synthetic()){
region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon();
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
float width = region.width * Draw.scl, height = region.height * Draw.scl;
mesh.draw(idxWall, region,
wx * tilesize + wall.offset + (tilesize - width) / 2f,
@ -130,15 +130,15 @@ public class MapRenderer implements Disposable{
region = Core.atlas.find("block-border-editor");
}else if(!wall.synthetic() && wall != Blocks.air && center){
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl;
offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl;
offsetX = tilesize / 2f - region.width / 2f * Draw.scl;
offsetY = tilesize / 2f - region.height / 2f * Draw.scl;
}else if(wall == Blocks.air && !tile.overlay().isAir()){
region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
}else{
region = Core.atlas.find("clear-editor");
}
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
float width = region.width * Draw.scl, height = region.height * Draw.scl;
if(!wall.synthetic() && wall != Blocks.air && !wall.isMultiblock()){
offsetX = 0;
offsetY = 0;

View File

@ -27,7 +27,7 @@ abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
@Replace
public float clipSize(){
return region.getWidth()*2;
return region.width *2;
}
}

View File

@ -44,7 +44,7 @@ abstract class LaunchCoreComp implements Drawc, Timedc{
Draw.z(Layer.weather - 1);
TextureRegion region = block.icon(Cicon.full);
float rw = region.getWidth() * Draw.scl * scale, rh = region.getHeight() * Draw.scl * scale;
float rw = region.width * Draw.scl * scale, rh = region.height * Draw.scl * scale;
Draw.alpha(alpha);
Draw.rect(region, cx, cy, rw, rh, rotation - 45);

View File

@ -67,7 +67,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Replace
public float clipSize(){
return type.region.getWidth() * 2f;
return type.region.width * 2f;
}
@Override

View File

@ -152,8 +152,8 @@ public class Drawf{
public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float rotation, float scale){
Tmp.v1.trns(rotation, 8f * scale * Draw.scl);
Draw.rect(edge, x, y, edge.getWidth() * scale * Draw.scl, edge.getHeight() * scale * Draw.scl, rotation + 180);
Draw.rect(edge, x2, y2, edge.getWidth() * scale * Draw.scl, edge.getHeight() * scale * Draw.scl, rotation);
Draw.rect(edge, x, y, edge.width * scale * Draw.scl, edge.height * scale * Draw.scl, rotation + 180);
Draw.rect(edge, x2, y2, edge.width * scale * Draw.scl, edge.height * scale * Draw.scl, rotation);
Lines.stroke(12f * scale);
Lines.precise(true);

View File

@ -68,10 +68,10 @@ public class IndexedRenderer implements Disposable{
public void draw(int index, TextureRegion region, float x, float y, float w, float h){
float fx2 = x + w;
float fy2 = y + h;
float u = region.getU();
float v = region.getV2();
float u2 = region.getU2();
float v2 = region.getV();
float u = region.u;
float v = region.v2;
float u2 = region.u2;
float v2 = region.v;
float[] vertices = tmpVerts;
float color = this.color;
@ -118,10 +118,10 @@ public class IndexedRenderer implements Disposable{
}
public void draw(int index, TextureRegion region, float x, float y, float w, float h, float rotation){
float u = region.getU();
float v = region.getV2();
float u2 = region.getU2();
float v2 = region.getV();
float u = region.u;
float v = region.v2;
float u2 = region.u2;
float v2 = region.v;
float originX = w / 2, originY = h / 2;

View File

@ -58,10 +58,10 @@ public class LightRenderer{
TextureRegion ledge = Core.atlas.find("circle-end"), lmid = Core.atlas.find("circle-mid");
float color = Draw.getColor().toFloatBits();
float u = lmid.getU();
float v = lmid.getV2();
float u2 = lmid.getU2();
float v2 = lmid.getV();
float u = lmid.u;
float v = lmid.v2;
float u2 = lmid.u2;
float v2 = lmid.v;
Vec2 v1 = Tmp.v1.trnsExact(rot + 90f, stroke);
@ -103,10 +103,10 @@ public class LightRenderer{
Vec2 v3 = Tmp.v2.trnsExact(rot, stroke);
u = ledge.getU();
v = ledge.getV2();
u2 = ledge.getU2();
v2 = ledge.getV();
u = ledge.u;
v = ledge.v2;
u2 = ledge.u2;
v2 = ledge.v;
vertices[0] = lx4;
vertices[1] = ly4;

View File

@ -243,7 +243,7 @@ public class MenuRenderer implements Disposable{
TextureRegion icon = flyerType.icon(Cicon.full);
float size = Math.max(icon.getWidth(), icon.getHeight()) * Draw.scl * 1.6f;
float size = Math.max(icon.width, icon.height) * Draw.scl * 1.6f;
flyers((x, y) -> {
Draw.rect(flyerType.region, x - 12f, y - 13f, flyerRot - 90);

View File

@ -122,8 +122,8 @@ public class MinimapRenderer implements Disposable{
float dy = (Core.camera.position.y / tilesize);
dx = Mathf.clamp(dx, sz, world.width() - sz);
dy = Mathf.clamp(dy, sz, world.height() - sz);
float invTexWidth = 1f / texture.getWidth();
float invTexHeight = 1f / texture.getHeight();
float invTexWidth = 1f / texture.width;
float invTexHeight = 1f / texture.height;
float x = dx - sz, y = world.height() - dy - sz, width = sz * 2, height = sz * 2;
region.set(x * invTexWidth, y * invTexHeight, (x + width) * invTexWidth, (y + height) * invTexHeight);
return region;

View File

@ -152,9 +152,9 @@ public class Shaders{
setUniformf("u_time", time);
setUniformf("u_color", color);
setUniformf("u_progress", progress);
setUniformf("u_uv", region.getU(), region.getV());
setUniformf("u_uv2", region.getU2(), region.getV2());
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight());
setUniformf("u_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2);
setUniformf("u_texsize", region.getTexture().width, region.getTexture().height);
}
}
@ -171,10 +171,10 @@ public class Shaders{
public void apply(){
setUniformf("u_progress", progress);
setUniformf("u_color", color);
setUniformf("u_uv", region.getU(), region.getV());
setUniformf("u_uv2", region.getU2(), region.getV2());
setUniformf("u_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2);
setUniformf("u_time", Time.time());
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight());
setUniformf("u_texsize", region.getTexture().width, region.getTexture().height);
}
}

View File

@ -59,7 +59,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public int rotation;
public boolean droppingItem;
public Group uiGroup;
public boolean isBuilding = true, buildWasAutoPaused = false;
public boolean isBuilding = true, buildWasAutoPaused = false, wasShooting = false;
public @Nullable UnitType controlledType;
public @Nullable Schematic lastSchematic;
@ -353,6 +353,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
player.builder().updateBuilding(isBuilding);
}
if(player.shooting && !wasShooting && player.unit().hasWeapons()){
player.unit().type().weapons.first().noAmmoSound.at(player.unit());
}
wasShooting = player.shooting;
if(!player.dead()){
controlledType = player.unit().type();
}
@ -1068,15 +1074,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
Draw.rect(Core.atlas.find("place-arrow"),
x * tilesize + block.offset + dx*trns,
y * tilesize + block.offset - 1 + dy*trns,
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
Core.atlas.find("place-arrow").width * Draw.scl,
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90);
Draw.color(!valid ? Pal.remove : Pal.accent);
Draw.rect(Core.atlas.find("place-arrow"),
x * tilesize + block.offset + dx*trns,
y * tilesize + block.offset + dy*trns,
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
Core.atlas.find("place-arrow").width * Draw.scl,
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90);
}
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){

View File

@ -431,7 +431,7 @@ public class UnitType extends UnlockableContent{
public void drawOcclusion(Unit unit){
Draw.color(0, 0, 0, 0.4f);
float rad = 1.6f;
float size = Math.max(region.getWidth(), region.getHeight()) * Draw.scl;
float size = Math.max(region.width, region.height) * Draw.scl;
Draw.rect(occlusionRegion, unit, size * rad, size * rad);
Draw.color();
}
@ -503,7 +503,7 @@ public class UnitType extends UnlockableContent{
float rotation = unit.rotation - 90;
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
float width = weapon.region.getWidth();
float width = weapon.region.width;
float recoil = -((mount.reload) / weapon.reload * weapon.recoil);
float wx = unit.x + Angles.trnsx(rotation, weapon.x, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil),
wy = unit.y + Angles.trnsy(rotation, weapon.x, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil);
@ -514,7 +514,7 @@ public class UnitType extends UnlockableContent{
Draw.rect(weapon.region, wx, wy,
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
weapon.region.getHeight() * Draw.scl,
weapon.region.height * Draw.scl,
weaponRotation);
}
@ -552,7 +552,7 @@ public class UnitType extends UnlockableContent{
Leg[] legs = unit.legs();
float ssize = footRegion.getWidth() * Draw.scl * 1.5f;
float ssize = footRegion.width * Draw.scl * 1.5f;
float rotation = unit.baseRotation();
for(Leg leg : legs){
@ -586,10 +586,10 @@ public class UnitType extends UnlockableContent{
Draw.rect(footRegion, leg.base.x, leg.base.y, position.angleTo(leg.base));
Lines.stroke(legRegion.getHeight() * Draw.scl * flips);
Lines.stroke(legRegion.height * Draw.scl * flips);
Lines.line(legRegion, position.x, position.y, leg.joint.x, leg.joint.y, false, 0);
Lines.stroke(legBaseRegion.getHeight() * Draw.scl * flips);
Lines.stroke(legBaseRegion.height * Draw.scl * flips);
Lines.line(legBaseRegion, leg.joint.x + Tmp.v1.x, leg.joint.y + Tmp.v1.y, leg.base.x, leg.base.y, false, 0);
if(jointRegion.found()){
@ -627,8 +627,8 @@ public class UnitType extends UnlockableContent{
Draw.rect(legRegion,
unit.x + Angles.trnsx(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i),
unit.y + Angles.trnsy(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i),
legRegion.getWidth() * i * Draw.scl,
legRegion.getHeight() * Draw.scl - Math.max(-sin * i, 0) * legRegion.getHeight() * 0.5f * Draw.scl,
legRegion.width * i * Draw.scl,
legRegion.height * Draw.scl - Math.max(-sin * i, 0) * legRegion.height * 0.5f * Draw.scl,
mech.baseRotation() - 90 + 35f*i*e);
}

View File

@ -59,6 +59,8 @@ public class Weapon{
public int otherSide = -1;
/** sound used for shooting */
public Sound shootSound = Sounds.pew;
/** sound played when there is nothing to shoot */
public Sound noAmmoSound = Sounds.click;
/** displayed region (autoloaded) */
public TextureRegion region;

View File

@ -80,11 +80,11 @@ public class Bar extends Element{
Drawable top = Tex.barTop;
float topWidth = width * value;
if(topWidth > Core.atlas.find("bar-top").getWidth()){
if(topWidth > Core.atlas.find("bar-top").width){
top.draw(x, y, topWidth, height);
}else{
if(ScissorStack.push(scissor.set(x, y, topWidth, height))){
top.draw(x, y, Core.atlas.find("bar-top").getWidth(), height);
top.draw(x, y, Core.atlas.find("bar-top").width, height);
ScissorStack.pop();
}
}

View File

@ -98,10 +98,10 @@ public class Fonts{
glyph.srcY = 0;
glyph.width = size;
glyph.height = size;
glyph.u = region.getU();
glyph.v = region.getV2();
glyph.u2 = region.getU2();
glyph.v2 = region.getV();
glyph.u = region.u;
glyph.v = region.v2;
glyph.u2 = region.u2;
glyph.v2 = region.v;
glyph.xoffset = 0;
glyph.yoffset = -size;
glyph.xadvance = size;

View File

@ -78,8 +78,8 @@ public class MenuFragment extends Fragment{
parent.fill((x, y, w, h) -> {
TextureRegion logo = Core.atlas.find("logo");
float logoscl = Scl.scl(1);
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - Scl.scl(20));
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
float logow = Math.min(logo.width * logoscl, Core.graphics.getWidth() - Scl.scl(20));
float logoh = logow * (float)logo.height / logo.width;
float fx = (int)(Core.graphics.getWidth() / 2f);
float fy = (int)(Core.graphics.getHeight() - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? Scl.scl(30f) : 0f);

View File

@ -32,7 +32,7 @@ public class MinimapFragment extends Fragment{
if(renderer.minimap.getTexture() != null){
Draw.color();
float ratio = (float)renderer.minimap.getTexture().getHeight() / renderer.minimap.getTexture().getWidth();
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().width;
TextureRegion reg = Draw.wrap(renderer.minimap.getTexture());
Draw.rect(reg, w/2f + panx*zoom, h/2f + pany*zoom, size, size * ratio);
renderer.minimap.drawEntities(w/2f + panx*zoom - size/2f, h/2f + pany*zoom - size/2f * ratio, size, size * ratio, zoom, true);
@ -113,7 +113,7 @@ public class MinimapFragment extends Fragment{
public void toggle(){
if(Core.settings.getBool("mapcenter")){
float size = baseSize * zoom * world.width();
float ratio = (float)renderer.minimap.getTexture().getHeight() / renderer.minimap.getTexture().getWidth();
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().width;
panx = (size/2f - player.x() / (world.width() * tilesize) * size) / zoom;
pany = (size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio) / zoom;
}

View File

@ -31,14 +31,14 @@ public interface Autotiler{
default TextureRegion topHalf(TextureRegion input){
TextureRegion region = Tmp.tr1;
region.set(input);
region.setWidth(region.getWidth() / 2);
region.setWidth(region.width / 2);
return region;
}
default TextureRegion botHalf(TextureRegion input){
TextureRegion region = Tmp.tr1;
region.set(input);
int width = region.getWidth();
int width = region.width;
region.setWidth(width / 2);
region.setX(region.getX() + width);
return region;

View File

@ -142,7 +142,7 @@ public class LaunchPad extends Block{
Draw.z(Layer.weather - 1);
TextureRegion region = Core.atlas.find("launchpod");
float rw = region.getWidth() * Draw.scl * scale, rh = region.getHeight() * Draw.scl * scale;
float rw = region.width * Draw.scl * scale, rh = region.height * Draw.scl * scale;
Draw.alpha(alpha);
Draw.rect(region, cx, cy, rw, rh, rotation);

View File

@ -63,7 +63,7 @@ public class Conveyor extends Block implements Autotiler{
if(bits == null) return;
TextureRegion region = regions[bits[0]][0];
Draw.rect(region, req.drawx(), req.drawy(), region.getWidth() * bits[1] * Draw.scl, region.getHeight() * bits[2] * Draw.scl, req.rotation * 90);
Draw.rect(region, req.drawx(), req.drawy(), region.width * bits[1] * Draw.scl, region.height * bits[2] * Draw.scl, req.rotation * 90);
}
@Override

View File

@ -17,7 +17,7 @@ import mindustry.world.blocks.production.*;
import static mindustry.Vars.*;
public class PayloadConveyor extends Block{
public float moveTime = 60f;
public float moveTime = 50f;
public @Load("@-top") TextureRegion topRegion;
public @Load("@-edge") TextureRegion edgeRegion;
public Interp interp = Interp.pow5;
@ -155,20 +155,20 @@ public class PayloadConveyor extends Block{
float s = tilesize * size;
//next
Tmp.v1.set((s-clipped.getWidth()*Draw.scl) + clipped.getWidth()/2f*Draw.scl - s/2f, s-clipped.getHeight()*Draw.scl + clipped.getHeight()/2f*Draw.scl - s/2f).rotate(rot);
Tmp.v1.set((s- clipped.width *Draw.scl) + clipped.width /2f*Draw.scl - s/2f, s- clipped.height *Draw.scl + clipped.height /2f*Draw.scl - s/2f).rotate(rot);
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trprev, 0), topRegion);
//prev
Tmp.v1.set(- s/2f + clipped.getWidth()/2f*Draw.scl, - s/2f + clipped.getHeight()/2f*Draw.scl).rotate(rot);
Tmp.v1.set(- s/2f + clipped.width /2f*Draw.scl, - s/2f + clipped.height /2f*Draw.scl).rotate(rot);
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
for(int i = 0; i < 4; i++){
if(blends(i) && i != rotation){
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);
Tmp.v1.set(- s/2f + clipped.width /2f*Draw.scl, - s/2f + clipped.height /2f*Draw.scl).rotate(i * 90 + 180);
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, i * 90 + 180);
}
}
@ -268,9 +268,9 @@ public class PayloadConveyor extends Block{
out.set(region.getTexture());
if(overlaps){
float w = region.getU2() - region.getU();
float h = region.getV2() - region.getV();
float x = region.getU(), y = region.getV();
float w = region.u2 - region.u;
float h = region.v2 - region.v;
float x = region.u, y = region.v;
float newX = (over.x - sprite.x) / sprite.width * w + x;
float newY = (over.y - sprite.y) / sprite.height * h + y;
float newW = (over.width / sprite.width) * w, newH = (over.height / sprite.height) * h;

View File

@ -16,7 +16,7 @@ public class StaticTree extends StaticWall{
public void drawBase(Tile tile){
TextureRegion r = Tmp.tr1;
r.set(region);
int crop = (region.getWidth() - tilesize*4) / 2;
int crop = (region.width - tilesize*4) / 2;
float ox = 0;
float oy = 0;
@ -24,7 +24,7 @@ public class StaticTree extends StaticWall{
if(tile.getNearby(i) != null && tile.getNearby(i).block() instanceof StaticWall){
if(i == 0){
r.setWidth(r.getWidth() - crop);
r.setWidth(r.width - crop);
ox -= crop /2f;
}else if(i == 1){
r.setY(r.getY() + crop);
@ -33,7 +33,7 @@ public class StaticTree extends StaticWall{
r.setX(r.getX() + crop);
ox += crop /2f;
}else{
r.setHeight(r.getHeight() - crop);
r.setHeight(r.height - crop);
oy += crop /2f;
}
}

View File

@ -24,7 +24,7 @@ public class TreeBlock extends Block{
float x = tile.worldx(), y = tile.worldy();
float rot = Mathf.randomSeed(tile.pos(), 0, 4) * 90 + Mathf.sin(Time.time() + x, 50f, 0.5f) + Mathf.sin(Time.time() - y, 65f, 0.9f) + Mathf.sin(Time.time() + y - x, 85f, 0.9f);
float w = region.getWidth() * Draw.scl, h = region.getHeight() * Draw.scl;
float w = region.width * Draw.scl, h = region.height * Draw.scl;
float scl = 30f, mag = 0.2f;
if(shadow.found()){

View File

@ -146,9 +146,6 @@ public class PowerNode extends PowerBlock{
}
protected void drawLaser(Team team, float x1, float y1, float x2, float y2, float satisfaction, int size1, int size2){
float opacity = Core.settings.getInt("lasersopacity") / 100f;
if(Mathf.zero(opacity)) return;
float angle1 = Angles.angle(x1, y1, x2, y2);
t1.trns(angle1, size1 * tilesize / 2f - 1.5f);
t2.trns(angle1 + 180f, size2 * tilesize / 2f - 1.5f);
@ -161,7 +158,7 @@ public class PowerNode extends PowerBlock{
float fract = 1f - satisfaction;
Draw.color(laserColor1, laserColor2, fract * 0.86f + Mathf.absin(3f, 0.1f));
Draw.alpha(opacity);
Draw.alpha(renderer.laserOpacity);
Drawf.laser(team, laser, laserEnd, x1, y1, x2, y2, 0.25f);
Draw.color();
}
@ -386,7 +383,7 @@ public class PowerNode extends PowerBlock{
public void draw(){
super.draw();
if(Core.settings.getInt("lasersopacity") == 0) return;
if(Mathf.zero(renderer.laserOpacity)) return;
Draw.z(Layer.power);

View File

@ -172,7 +172,7 @@ public class Generators{
int radius = 4;
GenRegion region = (GenRegion)regions[regions.length - 1];
Image base = ImagePacker.get(region);
Image out = last = new Image(region.getWidth(), region.getHeight());
Image out = last = new Image(region.width, region.height);
for(int x = 0; x < out.width; x++){
for(int y = 0; y < out.height; y++){
@ -330,7 +330,7 @@ public class Generators{
image.save(type.name + "-cell");
}
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
Image cell = new Image(type.cellRegion.width, type.cellRegion.height);
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
image.draw(cell, image.width / 2 - cell.width / 2, image.height / 2 - cell.height / 2);
@ -339,8 +339,8 @@ public class Generators{
weapon.load();
image.draw(weapon.region,
(int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.getWidth() / 2f),
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
(int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.width / 2f),
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.height / 2f),
weapon.flipSprite, false);
}

View File

@ -81,12 +81,12 @@ class Image{
/** Draws a region at the center. */
void drawCenter(TextureRegion region){
draw(region, (width - region.getWidth()) / 2, (height - region.getHeight()) / 2, false, false);
draw(region, (width - region.width) / 2, (height - region.height) / 2, false, false);
}
/** Draws a region at the center. */
void drawCenter(TextureRegion region, boolean flipx, boolean flipy){
draw(region, (width - region.getWidth()) / 2, (height - region.getHeight()) / 2, flipx, flipy);
draw(region, (width - region.width) / 2, (height - region.height) / 2, flipx, flipy);
}
void drawScaled(Image image){
@ -114,12 +114,12 @@ class Image{
graphics.drawImage(ImagePacker.get(region).image,
x, y,
x + region.getWidth(),
y + region.getHeight(),
(flipx ? region.getWidth() : 0) + ofx,
(flipy ? region.getHeight() : 0) + ofy,
(flipx ? 0 : region.getWidth()) + ofx,
(flipy ? 0 : region.getHeight()) + ofy,
x + region.width,
y + region.height,
(flipx ? region.width : 0) + ofx,
(flipy ? region.height : 0) + ofy,
(flipx ? 0 : region.width) + ofx,
(flipy ? 0 : region.height) + ofy,
null);
}

View File

@ -42,28 +42,12 @@ public class ImagePacker{
BufferedImage image = ImageIO.read(path.file());
if(image == null) throw new IOException("image " + path.absolutePath() + " is null for terrible reasons");
GenRegion region = new GenRegion(fname, path){
@Override
public int getX(){
return 0;
}
@Override
public int getY(){
return 0;
}
@Override
public int getWidth(){
return image.getWidth();
}
@Override
public int getHeight(){
return image.getHeight();
}
};
GenRegion region = new GenRegion(fname, path){{
width = image.getWidth();
height = image.getHeight();
u2 = v2 = 1f;
u = v = 0f;
}};
regionCache.put(fname, region);
imageCache.put(fname, image);
@ -105,7 +89,7 @@ public class ImagePacker{
}
};
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
Draw.scl = 1f / Core.atlas.find("scale_marker").width;
Time.mark();
Generators.generate();