Bugfixes / Builder changes / Planning layer changes
This commit is contained in:
@@ -20,6 +20,6 @@ void main(){
|
||||
float shinyness = (1.0 - a_color.a) * pow(shinedot, shinefalloff);
|
||||
vec4 baseCol = vec4(a_color.rgb, 1.0);
|
||||
|
||||
v_col = lerp(baseCol * vec4(norc, 1.0), vec4(1.0), shinyness * norc.r);
|
||||
v_col = mix(baseCol * vec4(norc, 1.0), vec4(1.0), shinyness * norc.r);
|
||||
gl_Position = u_proj * u_trans * a_position;
|
||||
}
|
||||
|
||||
@@ -224,11 +224,13 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
blocks.drawBlocks(Layer.turret);
|
||||
|
||||
Groups.drawFlyingShadows();
|
||||
|
||||
blocks.drawBlocks(Layer.power);
|
||||
blocks.drawBlocks(Layer.lights);
|
||||
|
||||
overlays.drawBottom();
|
||||
|
||||
Groups.drawFlyingShadows();
|
||||
|
||||
Groups.drawFlying();
|
||||
|
||||
Draw.flush();
|
||||
@@ -244,11 +246,6 @@ public class Renderer implements ApplicationListener{
|
||||
bloom.render();
|
||||
}
|
||||
|
||||
overlays.drawBottom();
|
||||
if(player.isBuilder()){
|
||||
player.builder().drawBuildRequests();
|
||||
}
|
||||
|
||||
Groups.drawOverlays();
|
||||
|
||||
overlays.drawTop();
|
||||
|
||||
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||
static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||
|
||||
@Import float x, y, rotation;
|
||||
|
||||
@@ -67,9 +67,19 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
|
||||
Tile tile = world.tile(current.x, current.y);
|
||||
|
||||
if(dst(tile) <= finalPlaceDst){
|
||||
rotation = Mathf.slerpDelta(rotation, angleTo(tile), 0.4f);
|
||||
}
|
||||
|
||||
if(!(tile.block() instanceof BuildBlock)){
|
||||
if(!current.initialized && !current.breaking && Build.validPlace(team(), current.x, current.y, current.block, current.rotation)){
|
||||
Build.beginPlace(team(), current.x, current.y, current.block, current.rotation);
|
||||
boolean hasAll = !Structs.contains(current.block.requirements, i -> !core.items().has(i.item));
|
||||
|
||||
if(hasAll){
|
||||
Build.beginPlace(team(), current.x, current.y, current.block, current.rotation);
|
||||
}else{
|
||||
current.stuck = true;
|
||||
}
|
||||
}else if(!current.initialized && current.breaking && Build.validBreak(team(), current.x, current.y)){
|
||||
Build.beginBreak(team(), current.x, current.y);
|
||||
}else{
|
||||
@@ -94,10 +104,6 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
//otherwise, update it.
|
||||
BuildEntity entity = tile.ent();
|
||||
|
||||
if(dst(tile) <= finalPlaceDst){
|
||||
rotation = Mathf.slerpDelta(rotation, angleTo(entity), 0.4f);
|
||||
}
|
||||
|
||||
if(current.breaking){
|
||||
entity.deconstruct(this, core, 1f / entity.buildCost * Time.delta() * buildSpeed * state.rules.buildSpeedMultiplier);
|
||||
}else{
|
||||
@@ -134,8 +140,9 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
/** @return whether this request should be skipped, in favor of the next one. */
|
||||
boolean shouldSkip(BuildRequest request, @Nullable Tilec core){
|
||||
//requests that you have at least *started* are considered
|
||||
if(state.rules.infiniteResources || request.breaking || !request.initialized || core == null) return false;
|
||||
return request.stuck && !core.items().has(request.block.requirements);
|
||||
if(state.rules.infiniteResources || request.breaking || core == null) return false;
|
||||
//TODO these are bad criteria
|
||||
return (request.stuck && !core.items().has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items().has(i.item)) && !request.initialized);
|
||||
}
|
||||
|
||||
void removeBuild(int x, int y, boolean breaking){
|
||||
@@ -199,23 +206,26 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
return;
|
||||
}
|
||||
|
||||
int size = request.breaking ? tile.block().size : request.block.size;
|
||||
float tx = request.drawx(), ty = request.drawy();
|
||||
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
float focusLen = 3.8f + Mathf.absin(Time.time(), 1.1f, 0.6f);
|
||||
float px = x + Angles.trnsx(rotation, focusLen);
|
||||
float py = y + Angles.trnsy(rotation, focusLen);
|
||||
|
||||
float sz = Vars.tilesize * tile.block().size / 2f;
|
||||
float ang = angleTo(tile);
|
||||
float sz = Vars.tilesize * size / 2f;
|
||||
float ang = angleTo(tx, ty);
|
||||
|
||||
tmptr[0].set(tile.drawx() - sz, tile.drawy() - sz);
|
||||
tmptr[1].set(tile.drawx() + sz, tile.drawy() - sz);
|
||||
tmptr[2].set(tile.drawx() - sz, tile.drawy() + sz);
|
||||
tmptr[3].set(tile.drawx() + sz, tile.drawy() + sz);
|
||||
vecs[0].set(tx - sz, ty - sz);
|
||||
vecs[1].set(tx + sz, ty - sz);
|
||||
vecs[2].set(tx - sz, ty + sz);
|
||||
vecs[3].set(tx + sz, ty + sz);
|
||||
|
||||
Arrays.sort(tmptr, Structs.comparingFloat(vec -> -Angles.angleDist(angleTo(vec), ang)));
|
||||
Arrays.sort(vecs, Structs.comparingFloat(vec -> -Angles.angleDist(angleTo(vec), ang)));
|
||||
|
||||
float x1 = tmptr[0].x, y1 = tmptr[0].y,
|
||||
x3 = tmptr[1].x, y3 = tmptr[1].y;
|
||||
float x1 = vecs[0].x, y1 = vecs[0].y,
|
||||
x3 = vecs[1].x, y3 = vecs[1].y;
|
||||
|
||||
Draw.alpha(1f);
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ public class OverlayRenderer{
|
||||
|
||||
if(player.dead()) return;
|
||||
|
||||
if(player.isBuilder()){
|
||||
player.builder().drawBuildRequests();
|
||||
}
|
||||
|
||||
input.drawBottom();
|
||||
}
|
||||
|
||||
@@ -54,23 +58,6 @@ public class OverlayRenderer{
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
|
||||
//mech pads are gone
|
||||
/*
|
||||
if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){
|
||||
for(Tile mechpad : indexer.getAllied(player.team(), BlockFlag.mechPad)){
|
||||
if(!(mechpad.block() instanceof MechPad)) continue;
|
||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(mechpad.drawx(), mechpad.drawy())){
|
||||
|
||||
Tmp.v1.set(mechpad.drawx(), mechpad.drawy()).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
|
||||
Lines.stroke(2f, ((MechPad) mechpad.block()).mech.engineColor);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 0.5f);
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(player.dead()) return; //dead players don't draw
|
||||
|
||||
@@ -81,26 +81,36 @@ public class DesktopInput extends InputHandler{
|
||||
int cursorX = tileX(Core.input.mouseX());
|
||||
int cursorY = tileY(Core.input.mouseY());
|
||||
|
||||
//draw selection(s)
|
||||
if(mode == placing && block != null){
|
||||
for(int i = 0; i < lineRequests.size; i++){
|
||||
BuildRequest req = lineRequests.get(i);
|
||||
if(i == lineRequests.size - 1 && req.block.rotate){
|
||||
drawArrow(block, req.x, req.y, req.rotation);
|
||||
}
|
||||
drawRequest(lineRequests.get(i));
|
||||
}
|
||||
}else if(mode == breaking){
|
||||
//draw break selection
|
||||
if(mode == breaking){
|
||||
drawBreakSelection(selectX, selectY, cursorX, cursorY);
|
||||
}else if(isPlacing()){
|
||||
if(block.rotate){
|
||||
drawArrow(block, cursorX, cursorY, rotation);
|
||||
}
|
||||
Draw.color();
|
||||
drawRequest(cursorX, cursorY, block, rotation);
|
||||
block.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, block, rotation));
|
||||
}
|
||||
|
||||
if(Core.input.keyDown(Binding.schematic_select) && !Core.scene.hasKeyboard()){
|
||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBottom(){
|
||||
int cursorX = tileX(Core.input.mouseX());
|
||||
int cursorY = tileY(Core.input.mouseY());
|
||||
|
||||
//draw request being moved
|
||||
if(sreq != null){
|
||||
boolean valid = validPlace(sreq.x, sreq.y, sreq.block, sreq.rotation, sreq);
|
||||
if(sreq.block.rotate){
|
||||
drawArrow(sreq.block, sreq.x, sreq.y, sreq.rotation, valid);
|
||||
}
|
||||
|
||||
sreq.block.drawRequest(sreq, allRequests(), valid);
|
||||
|
||||
drawSelected(sreq.x, sreq.y, sreq.block, getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null ? Pal.remove : Pal.accent);
|
||||
}
|
||||
|
||||
//draw hover request
|
||||
if(mode == none && !isPlacing()){
|
||||
BuildRequest req = getRequest(cursorX, cursorY);
|
||||
if(req != null){
|
||||
@@ -118,19 +128,22 @@ public class DesktopInput extends InputHandler{
|
||||
drawOverRequest(request);
|
||||
}
|
||||
|
||||
if(sreq != null){
|
||||
boolean valid = validPlace(sreq.x, sreq.y, sreq.block, sreq.rotation, sreq);
|
||||
if(sreq.block.rotate){
|
||||
drawArrow(sreq.block, sreq.x, sreq.y, sreq.rotation, valid);
|
||||
//draw things that may be placed soon
|
||||
if(mode == placing && block != null){
|
||||
for(int i = 0; i < lineRequests.size; i++){
|
||||
BuildRequest req = lineRequests.get(i);
|
||||
if(i == lineRequests.size - 1 && req.block.rotate){
|
||||
drawArrow(block, req.x, req.y, req.rotation);
|
||||
}
|
||||
drawRequest(lineRequests.get(i));
|
||||
}
|
||||
|
||||
sreq.block.drawRequest(sreq, allRequests(), valid);
|
||||
|
||||
drawSelected(sreq.x, sreq.y, sreq.block, getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null ? Pal.remove : Pal.accent);
|
||||
}
|
||||
|
||||
if(Core.input.keyDown(Binding.schematic_select) && !Core.scene.hasKeyboard()){
|
||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
||||
}else if(isPlacing()){
|
||||
if(block.rotate){
|
||||
drawArrow(block, cursorX, cursorY, rotation);
|
||||
}
|
||||
Draw.color();
|
||||
drawRequest(cursorX, cursorY, block, rotation);
|
||||
block.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, block, rotation));
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
@@ -47,7 +47,6 @@ public class PlanetDialog extends FloatingDialog{
|
||||
|
||||
private Bloom bloom;
|
||||
private Planet planet = Planets.starter;
|
||||
private float lastX, lastY;
|
||||
private @Nullable Sector selected, hovered;
|
||||
private Table stable;
|
||||
private Mesh atmosphere = MeshBuilder.buildHex(new HexMesher(){
|
||||
@@ -104,35 +103,31 @@ public class PlanetDialog extends FloatingDialog{
|
||||
camRelative.set(0, 0f, camLength);
|
||||
projector.setScaling(1f / 150f);
|
||||
|
||||
update(() -> {
|
||||
Vec3 v = Tmp.v33.set(Core.input.mouseX(), Core.input.mouseY(), 0);
|
||||
dragged((cx, cy) -> {
|
||||
float upV = camRelative.angle(Vec3.Y);
|
||||
float xscale = 9f, yscale = 10f;
|
||||
float margin = 1;
|
||||
|
||||
//scale X speed depending on polar coordinate
|
||||
float speed = 1f - Math.abs(upV - 90) / 90f;
|
||||
|
||||
camRelative.rotate(cam.up, cx / xscale * speed);
|
||||
|
||||
//prevent user from scrolling all the way up and glitching it out
|
||||
float amount = cy / yscale;
|
||||
amount = Mathf.clamp(upV + amount, margin, 180f - margin) - upV;
|
||||
|
||||
camRelative.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount);
|
||||
});
|
||||
|
||||
update(() -> {
|
||||
if(planet.isLandable()){
|
||||
hovered = planet.getSector(cam.getMouseRay(), outlineRad);
|
||||
|
||||
if(Core.input.keyDown(KeyCode.MOUSE_LEFT)){
|
||||
float upV = camRelative.angle(Vec3.Y);
|
||||
float xscale = 9f, yscale = 10f;
|
||||
float margin = 1;
|
||||
|
||||
//scale X speed depending on polar coordinate
|
||||
float speed = 1f - Math.abs(upV - 90) / 90f;
|
||||
|
||||
camRelative.rotate(cam.up, (v.x - lastX) / xscale * speed);
|
||||
|
||||
//prevent user from scrolling all the way up and glitching it out
|
||||
float amount = (v.y - lastY) / yscale;
|
||||
amount = Mathf.clamp(upV + amount, margin, 180f - margin) - upV;
|
||||
|
||||
camRelative.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount);
|
||||
}
|
||||
|
||||
}else{
|
||||
hovered = selected = null;
|
||||
}
|
||||
|
||||
lastX = v.x;
|
||||
lastY = v.y;
|
||||
|
||||
});
|
||||
|
||||
addListener(new ElementGestureListener(){
|
||||
@@ -382,6 +377,17 @@ public class PlanetDialog extends FloatingDialog{
|
||||
|
||||
stable.pack();
|
||||
stable.setPosition(x, y, Align.center);
|
||||
|
||||
stable.update(() -> {
|
||||
if(selected != null){
|
||||
//fade out UI when not facing selected sector
|
||||
Tmp.v31.set(selected.tile.v).rotate(Vec3.Y, -planet.getRotation()).scl(-1f).nor();
|
||||
float dot = cam.direction.dot(Tmp.v31);
|
||||
stable.getColor().a = Math.max(dot, 0f)*2f;
|
||||
}
|
||||
});
|
||||
|
||||
stable.act(0f);
|
||||
}
|
||||
|
||||
private void setPlane(Sector sector){
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
Throwable steamError;
|
||||
|
||||
public static void main(String[] arg){
|
||||
|
||||
try{
|
||||
Vars.loadLogger();
|
||||
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=83917377f451543c8d747e8cf35a5e09b8bad2b8
|
||||
archash=b45eff56366057e331c8ffc97eb28161b0f01bf0
|
||||
|
||||
Reference in New Issue
Block a user