Support of mods with textures in different resolution (HD or low-res) (#7602)

* HDustry - scl() & private map

Co-Authored-By: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com>

* MEEP stop doing stuff when i work

<3 <3

* Replaced Draw.scl

Co-authored-by: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com>
Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
hortiSquash
2022-09-23 16:21:53 -04:00
committed by GitHub
co-authored by citrusMarmelade Anuken
parent 0e9e3de11f
commit 1d971231ca
19 changed files with 79 additions and 54 deletions
+3 -3
View File
@@ -54,10 +54,10 @@ public class Fx{
unitSpawn = new Effect(30f, e -> { unitSpawn = new Effect(30f, e -> {
if(!(e.data instanceof UnitType unit)) return; if(!(e.data instanceof UnitType unit)) return;
float scl = 1f + e.fout() * 2f;
TextureRegion region = unit.fullIcon; TextureRegion region = unit.fullIcon;
float scl = (1f + e.fout() * 2f) * region.scl();
alpha(e.fout()); alpha(e.fout());
mixcol(Color.white, e.fin()); mixcol(Color.white, e.fin());
@@ -67,7 +67,7 @@ public class Fx{
alpha(e.fin()); alpha(e.fin());
rect(region, e.x, e.y, region.width * Draw.scl * scl, region.height * Draw.scl * scl, e.rotation - 90); rect(region, e.x, e.y, region.width * scl, region.height * scl, e.rotation - 90);
}), }),
unitCapKill = new Effect(80f, e -> { unitCapKill = new Effect(80f, e -> {
+1 -1
View File
@@ -484,7 +484,7 @@ public class Renderer implements ApplicationListener{
TextureRegion reg = block.fullIcon; TextureRegion reg = block.fullIcon;
float scl = Scl.scl(4f) / camerascale; float scl = Scl.scl(4f) / camerascale;
float shake = 0f; float shake = 0f;
float s = reg.width * Draw.scl * scl * 3.6f * Interp.pow2Out.apply(fout); float s = reg.width * reg.scl() * scl * 3.6f * Interp.pow2Out.apply(fout);
float rotation = Interp.pow2In.apply(fout) * 135f, x = build.x + Mathf.range(shake), y = build.y + Mathf.range(shake); float rotation = Interp.pow2In.apply(fout) * 135f, x = build.x + Mathf.range(shake), y = build.y + Mathf.range(shake);
float thrustOpen = 0.25f; float thrustOpen = 0.25f;
float thrusterFrame = fin >= thrustOpen ? 1f : fin / thrustOpen; float thrusterFrame = fin >= thrustOpen ? 1f : fin / thrustOpen;
+4 -4
View File
@@ -119,7 +119,7 @@ public class MapRenderer implements Disposable{
if(wall != Blocks.air && useSyntheticWall){ if(wall != Blocks.air && useSyntheticWall){
region = !center ? clearEditor : getIcon(wall, idxWall); region = !center ? clearEditor : getIcon(wall, idxWall);
float width = region.width * Draw.scl, height = region.height * Draw.scl, ox = wall.offset + (tilesize - width) / 2f, oy = wall.offset + (tilesize - height) / 2f; float width = region.width * region.scl(), height = region.height * region.scl(), ox = wall.offset + (tilesize - width) / 2f, oy = wall.offset + (tilesize - height) / 2f;
//force fit to tile //force fit to tile
if(overlay.wallOre && !wall.synthetic()){ if(overlay.wallOre && !wall.synthetic()){
@@ -152,8 +152,8 @@ public class MapRenderer implements Disposable{
region = ((Cliff)Blocks.cliff).editorCliffs[tile.data & 0xff]; region = ((Cliff)Blocks.cliff).editorCliffs[tile.data & 0xff];
} }
offsetX = tilesize / 2f - region.width / 2f * Draw.scl; offsetX = tilesize / 2f - region.width * region.scl() / 2f;
offsetY = tilesize / 2f - region.height / 2f * Draw.scl; offsetY = tilesize / 2f - region.height * region.scl() / 2f;
}else if((wall == Blocks.air || overlay.wallOre) && !overlay.isAir()){ }else if((wall == Blocks.air || overlay.wallOre) && !overlay.isAir()){
if(floor.isLiquid){ if(floor.isLiquid){
mesh.setColor(Tmp.c1.set(1f, 1f, 1f, floor.overlayAlpha)); mesh.setColor(Tmp.c1.set(1f, 1f, 1f, floor.overlayAlpha));
@@ -163,7 +163,7 @@ public class MapRenderer implements Disposable{
region = clearEditor; region = clearEditor;
} }
float width = region.width * Draw.scl, height = region.height * Draw.scl; float width = region.width * region.scl(), height = region.height * region.scl();
if(!wall.synthetic() && wall != Blocks.air && !wall.isMultiblock()){ if(!wall.synthetic() && wall != Blocks.air && !wall.isMultiblock()){
offsetX = offsetY = 0f; offsetX = offsetY = 0f;
width = height = tilesize; width = height = tilesize;
@@ -43,7 +43,8 @@ abstract class LaunchCoreComp implements Drawc, Timedc{
Draw.z(Layer.weather - 1); Draw.z(Layer.weather - 1);
TextureRegion region = block.fullIcon; TextureRegion region = block.fullIcon;
float rw = region.width * Draw.scl * scale, rh = region.height * Draw.scl * scale; scale *= region.scl();
float rw = region.width * scale, rh = region.height * scale;
Draw.alpha(alpha); Draw.alpha(alpha);
Draw.rect(region, cx, cy, rw, rh, rotation - 45); Draw.rect(region, cx, cy, rw, rh, rotation - 45);
+2 -2
View File
@@ -402,8 +402,8 @@ public class Drawf{
float scl = 8f * scale * Draw.scl, rot = Mathf.angle(x2 - x, y2 - y); float scl = 8f * scale * Draw.scl, rot = Mathf.angle(x2 - x, y2 - y);
float vx = Mathf.cosDeg(rot) * scl, vy = Mathf.sinDeg(rot) * scl; float vx = Mathf.cosDeg(rot) * scl, vy = Mathf.sinDeg(rot) * scl;
Draw.rect(start, x, y, start.width * scale * Draw.scl, start.height * scale * Draw.scl, rot + 180); Draw.rect(start, x, y, start.width * scale * start.scl(), start.height * scale * start.scl(), rot + 180);
Draw.rect(end, x2, y2, end.width * scale * Draw.scl, end.height * scale * Draw.scl, rot); Draw.rect(end, x2, y2, end.width * scale * end.scl(), end.height * scale * end.scl(), rot);
Lines.stroke(12f * scale); Lines.stroke(12f * scale);
Lines.line(line, x + vx, y + vy, x2 - vx, y2 - vy, false); Lines.line(line, x + vx, y + vy, x2 - vx, y2 - vy, false);
@@ -243,12 +243,12 @@ public class MenuRenderer implements Disposable{
TextureRegion icon = flyerType.fullIcon; TextureRegion icon = flyerType.fullIcon;
float size = Math.max(icon.width, icon.height) * Draw.scl * 1.6f;
flyers((x, y) -> { flyers((x, y) -> {
Draw.rect(icon, x - 12f, y - 13f, flyerRot - 90); Draw.rect(icon, x - 12f, y - 13f, flyerRot - 90);
}); });
float size = Math.max(icon.width, icon.height) * icon.scl() * 1.6f;
flyers((x, y) -> { flyers((x, y) -> {
Draw.rect("circle-shadow", x, y, size, size); Draw.rect("circle-shadow", x, y, size, size);
}); });
+16 -10
View File
@@ -1653,20 +1653,26 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public void drawArrow(Block block, int x, int y, int rotation, boolean valid){ public void drawArrow(Block block, int x, int y, int rotation, boolean valid){
float trns = (block.size / 2) * tilesize; float trns = (block.size / 2) * tilesize;
int dx = Geometry.d4(rotation).x, dy = Geometry.d4(rotation).y; int dx = Geometry.d4(rotation).x, dy = Geometry.d4(rotation).y;
float offsetx = x * tilesize + block.offset + dx*trns;
float offsety = y * tilesize + block.offset + dy*trns;
Draw.color(!valid ? Pal.removeBack : Pal.accentBack); Draw.color(!valid ? Pal.removeBack : Pal.accentBack);
Draw.rect(Core.atlas.find("place-arrow"), TextureRegion regionArrow = Core.atlas.find("place-arrow");
x * tilesize + block.offset + dx*trns,
y * tilesize + block.offset - 1 + dy*trns, Draw.rect(regionArrow,
Core.atlas.find("place-arrow").width * Draw.scl, offsetx,
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90); offsety - 1,
regionArrow.width * regionArrow.scl(),
regionArrow.height * regionArrow.scl(),
rotation * 90 - 90);
Draw.color(!valid ? Pal.remove : Pal.accent); Draw.color(!valid ? Pal.remove : Pal.accent);
Draw.rect(Core.atlas.find("place-arrow"), Draw.rect(regionArrow,
x * tilesize + block.offset + dx*trns, offsetx,
y * tilesize + block.offset + dy*trns, offsety,
Core.atlas.find("place-arrow").width * Draw.scl, regionArrow.width * regionArrow.scl(),
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90); regionArrow.height * regionArrow.scl(),
rotation * 90 - 90);
} }
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){ void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){
+16 -3
View File
@@ -40,6 +40,7 @@ public class Mods implements Loadable{
private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites", "sprites-override"); private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites", "sprites-override");
private int totalSprites; private int totalSprites;
private static ObjectFloatMap<String> textureResize = new ObjectFloatMap<>();
private MultiPacker packer; private MultiPacker packer;
private ModClassLoader mainLoader = new ModClassLoader(getClass().getClassLoader()); private ModClassLoader mainLoader = new ModClassLoader(getClass().getClassLoader());
@@ -181,6 +182,7 @@ public class Mods implements Loadable{
private void packSprites(Seq<Fi> sprites, LoadedMod mod, boolean prefix, Seq<Future<Runnable>> tasks){ private void packSprites(Seq<Fi> sprites, LoadedMod mod, boolean prefix, Seq<Future<Runnable>> tasks){
boolean bleed = Core.settings.getBool("linear", true) && !mod.meta.pregenerated; boolean bleed = Core.settings.getBool("linear", true) && !mod.meta.pregenerated;
float textureScale = mod.meta.texturescale;
for(Fi file : sprites){ for(Fi file : sprites){
String name = file.nameWithoutExtension(); String name = file.nameWithoutExtension();
@@ -209,7 +211,11 @@ public class Mods implements Loadable{
} }
//this returns a *runnable* which actually packs the resulting pixmap; this has to be done synchronously outside the method //this returns a *runnable* which actually packs the resulting pixmap; this has to be done synchronously outside the method
return () -> { return () -> {
packer.add(getPage(file), (prefix ? mod.name + "-" : "") + name, new PixmapRegion(pix)); String fullName = (prefix ? mod.name + "-" : "") + name;
packer.add(getPage(file), fullName, new PixmapRegion(pix));
if(textureScale != 1.0f){
textureResize.put(fullName, textureScale);
}
pix.dispose(); pix.dispose();
}; };
}catch(Exception e){ }catch(Exception e){
@@ -344,13 +350,17 @@ public class Mods implements Loadable{
} }
Log.debug("Time to generate icons: @", Time.elapsed()); Log.debug("Time to generate icons: @", Time.elapsed());
packer.printStats();
//dispose old atlas data //dispose old atlas data
Core.atlas = packer.flush(filter, new TextureAtlas()); Core.atlas = packer.flush(filter, new TextureAtlas());
Time.mark();
textureResize.each(e -> { Core.atlas.find(e.key).scale = e.value; });
Log.debug("Time to rescale textures: @", Time.elapsed());
Core.atlas.setErrorRegion("error"); Core.atlas.setErrorRegion("error");
Log.debug("Total pages: @", Core.atlas.getTextures().size); Log.debug("Total pages: @", Core.atlas.getTextures().size);
packer.printStats();
} }
packer.dispose(); packer.dispose();
@@ -1141,6 +1151,8 @@ public class Mods implements Loadable{
public boolean java; public boolean java;
/** If true, -outline regions for units are kept when packing. Only use if you know exactly what you are doing. */ /** If true, -outline regions for units are kept when packing. Only use if you know exactly what you are doing. */
public boolean keepOutlines; public boolean keepOutlines;
/** To rescale textures with a different size. Represents the size in pixels of the sprite of a 1x1 block. */
public float texturescale = 1.0f;
/** If true, bleeding is skipped and no content icons are generated. */ /** If true, bleeding is skipped and no content icons are generated. */
public boolean pregenerated; public boolean pregenerated;
@@ -1176,6 +1188,7 @@ public class Mods implements Loadable{
", minGameVersion='" + minGameVersion + '\'' + ", minGameVersion='" + minGameVersion + '\'' +
", hidden=" + hidden + ", hidden=" + hidden +
", repo=" + repo + ", repo=" + repo +
", texturescale=" + texturescale +
'}'; '}';
} }
} }
+10 -9
View File
@@ -1274,7 +1274,7 @@ public class UnitType extends UnlockableContent{
public void drawSoftShadow(float x, float y, float rotation, float alpha){ public void drawSoftShadow(float x, float y, float rotation, float alpha){
Draw.color(0, 0, 0, 0.4f * alpha); Draw.color(0, 0, 0, 0.4f * alpha);
float rad = 1.6f; float rad = 1.6f;
float size = Math.max(region.width, region.height) * Draw.scl; float size = Math.max(region.width, region.height) * region.scl();
Draw.rect(softShadowRegion, x, y, size * rad * Draw.xscl, size * rad * Draw.yscl, rotation - 90); Draw.rect(softShadowRegion, x, y, size * rad * Draw.xscl, size * rad * Draw.yscl, rotation - 90);
Draw.color(); Draw.color();
} }
@@ -1293,11 +1293,12 @@ public class UnitType extends UnlockableContent{
size, size, unit.rotation); size, size, unit.rotation);
Draw.mixcol(); Draw.mixcol();
size = (3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime + 0.5f; size = ((3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime + 0.5f) * 2;
Draw.color(Pal.accent); Draw.color(Pal.accent);
Draw.rect(itemCircleRegion, Draw.rect(itemCircleRegion,
unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY), unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY), size * 2, size * 2); unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY),
size, size);
if(unit.isLocal() && !renderer.pixelator.enabled()){ if(unit.isLocal() && !renderer.pixelator.enabled()){
Fonts.outline.draw(unit.stack.amount + "", Fonts.outline.draw(unit.stack.amount + "",
@@ -1409,7 +1410,7 @@ public class UnitType extends UnlockableContent{
for(int side : Mathf.signs){ for(int side : Mathf.signs){
Tmp.v1.set(xOffset * side, yOffset).rotate(unit.rotation - 90); Tmp.v1.set(xOffset * side, yOffset).rotate(unit.rotation - 90);
Draw.rect(region, unit.x + Tmp.v1.x / 4f, unit.y + Tmp.v1.y / 4f, treadRect.width / 4f, region.height / 4f, unit.rotation - 90); Draw.rect(region, unit.x + Tmp.v1.x / 4f, unit.y + Tmp.v1.y / 4f, treadRect.width / 4f, region.height * region.scale / 4f, unit.rotation - 90);
} }
} }
} }
@@ -1421,7 +1422,7 @@ public class UnitType extends UnlockableContent{
Leg[] legs = unit.legs(); Leg[] legs = unit.legs();
float ssize = footRegion.width * Draw.scl * 1.5f; float ssize = footRegion.width * footRegion.scl() * 1.5f;
float rotation = unit.baseRotation(); float rotation = unit.baseRotation();
float invDrown = 1f - unit.drownTime; float invDrown = 1f - unit.drownTime;
@@ -1456,10 +1457,10 @@ public class UnitType extends UnlockableContent{
Draw.rect(footRegion, leg.base.x, leg.base.y, position.angleTo(leg.base)); Draw.rect(footRegion, leg.base.x, leg.base.y, position.angleTo(leg.base));
} }
Lines.stroke(legRegion.height * Draw.scl * flips); Lines.stroke(legRegion.height * legRegion.scl() * flips);
Lines.line(legRegion, position.x, position.y, leg.joint.x, leg.joint.y, false); Lines.line(legRegion, position.x, position.y, leg.joint.x, leg.joint.y, false);
Lines.stroke(legBaseRegion.height * Draw.scl * flips); Lines.stroke(legBaseRegion.height * legRegion.scl() * flips);
Lines.line(legBaseRegion, leg.joint.x + Tmp.v1.x, leg.joint.y + Tmp.v1.y, leg.base.x, leg.base.y, false); Lines.line(legBaseRegion, leg.joint.x + Tmp.v1.x, leg.joint.y + Tmp.v1.y, leg.base.x, leg.base.y, false);
if(jointRegion.found()){ if(jointRegion.found()){
@@ -1534,8 +1535,8 @@ public class UnitType extends UnlockableContent{
Draw.rect(legRegion, Draw.rect(legRegion,
unit.x + Angles.trnsx(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i), unit.x + Angles.trnsx(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i),
unit.y + Angles.trnsy(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i), unit.y + Angles.trnsy(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i),
legRegion.width * i * Draw.scl, legRegion.width * legRegion.scl() * i,
legRegion.height * Draw.scl - Math.max(-sin * i, 0) * legRegion.height * 0.5f * Draw.scl, legRegion.height * legRegion.scl() * (1 - Math.max(-sin * i, 0) * 0.5f),
mech.baseRotation() - 90 + 35f*i*e); mech.baseRotation() - 90 + 35f*i*e);
} }
@@ -88,7 +88,7 @@ public class MenuFragment{
parent.fill((x, y, w, h) -> { parent.fill((x, y, w, h) -> {
TextureRegion logo = Core.atlas.find("logo"); TextureRegion logo = Core.atlas.find("logo");
float width = Core.graphics.getWidth(), height = Core.graphics.getHeight() - Core.scene.marginTop; float width = Core.graphics.getWidth(), height = Core.graphics.getHeight() - Core.scene.marginTop;
float logoscl = Scl.scl(1); float logoscl = Scl.scl(1) * logo.scale;
float logow = Math.min(logo.width * logoscl, Core.graphics.getWidth() - Scl.scl(20)); float logow = Math.min(logo.width * logoscl, Core.graphics.getWidth() - Scl.scl(20));
float logoh = logow * (float)logo.height / logo.width; float logoh = logow * (float)logo.height / logo.width;
@@ -229,7 +229,8 @@ public class LaunchPad extends Block{
Draw.z(Layer.weather - 1); Draw.z(Layer.weather - 1);
TextureRegion region = blockOn() instanceof mindustry.world.blocks.campaign.LaunchPad p ? p.podRegion : Core.atlas.find("launchpod"); TextureRegion region = blockOn() instanceof mindustry.world.blocks.campaign.LaunchPad p ? p.podRegion : Core.atlas.find("launchpod");
float rw = region.width * Draw.scl * scale, rh = region.height * Draw.scl * scale; scale *= region.scl();
float rw = region.width * scale, rh = region.height * scale;
Draw.alpha(alpha); Draw.alpha(alpha);
Draw.rect(region, cx, cy, rw, rh, rotation); Draw.rect(region, cx, cy, rw, rh, rotation);
@@ -73,7 +73,7 @@ public class Conveyor extends Block implements Autotiler{
if(bits == null) return; if(bits == null) return;
TextureRegion region = regions[bits[0]][0]; TextureRegion region = regions[bits[0]][0];
Draw.rect(region, plan.drawx(), plan.drawy(), region.width * bits[1] * Draw.scl, region.height * bits[2] * Draw.scl, plan.rotation * 90); Draw.rect(region, plan.drawx(), plan.drawy(), region.width * bits[1] * region.scl(), region.height * bits[2] * region.scl(), plan.rotation * 90);
} }
@Override @Override
@@ -134,16 +134,16 @@ public class DirectionBridge extends Block{
cy = (y1 + y2)/2f, cy = (y1 + y2)/2f,
len = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)) - size * tilesize; len = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)) - size * tilesize;
Draw.rect(bridgeRegion, cx, cy, len, bridgeRegion.height * Draw.scl, angle); Draw.rect(bridgeRegion, cx, cy, len, bridgeRegion.height * bridgeRegion.scl(), angle);
if(liquidColor != null){ if(liquidColor != null){
Draw.color(liquidColor, liquidColor.a * Renderer.bridgeOpacity); Draw.color(liquidColor, liquidColor.a * Renderer.bridgeOpacity);
Draw.rect(bridgeLiquidRegion, cx, cy, len, bridgeLiquidRegion.height * Draw.scl, angle); Draw.rect(bridgeLiquidRegion, cx, cy, len, bridgeLiquidRegion.height * bridgeLiquidRegion.scl(), angle);
Draw.color(); Draw.color();
Draw.alpha(Renderer.bridgeOpacity); Draw.alpha(Renderer.bridgeOpacity);
} }
if(bridgeBotRegion.found()){ if(bridgeBotRegion.found()){
Draw.color(0.4f, 0.4f, 0.4f, 0.4f * Renderer.bridgeOpacity); Draw.color(0.4f, 0.4f, 0.4f, 0.4f * Renderer.bridgeOpacity);
Draw.rect(bridgeBotRegion, cx, cy, len, bridgeBotRegion.height * Draw.scl, angle); Draw.rect(bridgeBotRegion, cx, cy, len, bridgeBotRegion.height * bridgeBotRegion.scl(), angle);
Draw.reset(); Draw.reset();
} }
Draw.alpha(Renderer.bridgeOpacity); Draw.alpha(Renderer.bridgeOpacity);
@@ -28,7 +28,7 @@ public class SeaBush extends Prop{
int lobes = rand.random(lobesMin, lobesMax); int lobes = rand.random(lobesMin, lobesMax);
for(int i = 0; i < lobes; i++){ for(int i = 0; i < lobes; i++){
float ba = i / (float)lobes * 360f + offset + rand.range(spread), angle = ba + Mathf.sin(Time.time + rand.random(0, timeRange), rand.random(sclMin, sclMax), rand.random(magMin, magMax)); float ba = i / (float)lobes * 360f + offset + rand.range(spread), angle = ba + Mathf.sin(Time.time + rand.random(0, timeRange), rand.random(sclMin, sclMax), rand.random(magMin, magMax));
float w = region.width * Draw.scl, h = region.height * Draw.scl; float w = region.width * region.scl(), h = region.height * region.scl();
var region = Angles.angleDist(ba, 225f) <= botAngle ? botRegion : this.region; var region = Angles.angleDist(ba, 225f) <= botAngle ? botRegion : this.region;
Draw.rect(region, Draw.rect(region,
@@ -19,7 +19,7 @@ public class Seaweed extends Prop{
x = tile.worldx(), y = tile.worldy(), x = tile.worldx(), y = tile.worldy(),
rotmag = 3f, rotscl = 0.5f, rotmag = 3f, rotscl = 0.5f,
rot = Mathf.randomSeedRange(tile.pos(), 20f) - 45 + Mathf.sin(Time.time + x, 50f * rotscl, 0.5f * rotmag) + Mathf.sin(Time.time - y, 65f * rotscl, 0.9f* rotmag) + Mathf.sin(Time.time + y - x, 85f * rotscl, 0.9f* rotmag), rot = Mathf.randomSeedRange(tile.pos(), 20f) - 45 + Mathf.sin(Time.time + x, 50f * rotscl, 0.5f * rotmag) + Mathf.sin(Time.time - y, 65f * rotscl, 0.9f* rotmag) + Mathf.sin(Time.time + y - x, 85f * rotscl, 0.9f* rotmag),
w = region.width * Draw.scl, h = region.height * Draw.scl, w = region.width * region.scl(), h = region.height * region.scl(),
scl = 30f, mag = 0.3f; scl = 30f, mag = 0.3f;
Draw.rectv(region, x, y, w, h, rot, vec -> vec.add( Draw.rectv(region, x, y, w, h, rot, vec -> vec.add(
@@ -23,7 +23,7 @@ public class TreeBlock extends Block{
float float
x = tile.worldx(), y = tile.worldy(), x = tile.worldx(), y = tile.worldy(),
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), 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),
w = region.width * Draw.scl, h = region.height * Draw.scl, w = region.width * region.scl(), h = region.height * region.scl(),
scl = 30f, mag = 0.2f; scl = 30f, mag = 0.2f;
if(shadow.found()){ if(shadow.found()){
@@ -18,7 +18,7 @@ public class WobbleProp extends Prop{
public void drawBase(Tile tile){ public void drawBase(Tile tile){
var region = variants > 0 ? variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))] : this.region; var region = variants > 0 ? variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))] : this.region;
Draw.rectv(region, tile.worldx(), tile.worldy(), region.width * Draw.scl, region.height * Draw.scl, 0, vec -> vec.add( Draw.rectv(region, tile.worldx(), tile.worldy(), region.width * region.scl(), region.height * region.scl(), 0, vec -> vec.add(
Mathf.sin(vec.y*3 + Time.time, wscl, wmag) + Mathf.sin(vec.x*3 - Time.time, 70 * wtscl, 0.8f * wmag2), Mathf.sin(vec.y*3 + Time.time, wscl, wmag) + Mathf.sin(vec.x*3 - Time.time, 70 * wtscl, 0.8f * wmag2),
Mathf.cos(vec.x*3 + Time.time + 8, wscl + 6f, wmag * 1.1f) + Mathf.sin(vec.y*3 - Time.time, 50 * wtscl, 0.2f * wmag2) Mathf.cos(vec.x*3 + Time.time + 8, wscl + 6f, wmag * 1.1f) + Mathf.sin(vec.y*3 - Time.time, 50 * wtscl, 0.2f * wmag2)
)); ));
@@ -197,26 +197,28 @@ public class PayloadConveyor extends Block{
float glow = Math.max((dst - (Math.abs(fract() - 0.5f) * 2)) / dst, 0); float glow = Math.max((dst - (Math.abs(fract() - 0.5f) * 2)) / dst, 0);
Draw.mixcol(team.color, glow); Draw.mixcol(team.color, glow);
float trnext = fract() * size * tilesize, trprev = size * tilesize * (fract() - 1), rot = rotdeg();
TextureRegion clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trnext, 0), topRegion);
float s = tilesize * size; float s = tilesize * size;
float trnext = s * fract(), trprev = s * (fract() - 1), rot = rotdeg();
//next //next
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); TextureRegion clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trnext, 0), topRegion);
float widthNext = (s - clipped.width * clipped.scl()) * 0.5f;
float heightNext = (s - clipped.height * clipped.scl()) * 0.5f;
Tmp.v1.set(widthNext, heightNext).rotate(rot);
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, 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 //prev
Tmp.v1.set(- s/2f + clipped.width /2f*Draw.scl, - s/2f + clipped.height /2f*Draw.scl).rotate(rot); clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trprev, 0), topRegion);
float widthPrev = (clipped.width * clipped.scl() - s) * 0.5f;
float heightPrev = (clipped.height * clipped.scl() - s) * 0.5f;
Tmp.v1.set(widthPrev, heightPrev).rotate(rot);
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot); Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
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 - Interp.pow5In.apply(fract())); Draw.alpha(1f - Interp.pow5In.apply(fract()));
//prev from back //prev from back
Tmp.v1.set(- s/2f + clipped.width /2f*Draw.scl, - s/2f + clipped.height /2f*Draw.scl).rotate(i * 90 + 180); Tmp.v1.set(widthPrev, heightPrev).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);
} }
} }
@@ -331,6 +333,7 @@ public class PayloadConveyor extends Block{
TextureRegion out = Tmp.tr1; TextureRegion out = Tmp.tr1;
out.set(region.texture); out.set(region.texture);
out.scale = region.scale;
if(overlaps){ if(overlaps){
float w = region.u2 - region.u; float w = region.u2 - region.u;
@@ -33,7 +33,7 @@ public class DrawPlasma extends DrawFlame{
public void draw(Building build){ public void draw(Building build){
Draw.blend(Blending.additive); Draw.blend(Blending.additive);
for(int i = 0; i < regions.length; i++){ for(int i = 0; i < regions.length; i++){
float r = ((float)regions[i].width * Draw.scl - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f)); float r = ((float)regions[i].width * regions[i].scl() - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f));
Draw.color(plasma1, plasma2, (float)i / regions.length); Draw.color(plasma1, plasma2, (float)i / regions.length);
Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * build.warmup()); Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * build.warmup());