Merge branch 'master' into pr-readwrite

This commit is contained in:
WayZer
2024-02-21 15:39:33 +08:00
committed by GitHub
17 changed files with 62 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

View File

@@ -2372,7 +2372,7 @@ lglobal.@clientLocale = Locale of the client running the code. For example: en_U
lglobal.@clientUnit = Unit of client running the code
lglobal.@clientName = Player name of client running the code
lglobal.@clientTeam = Team ID of client running the code
lglobal.@clientMobile = True is the client running the code is on mobile, false otherwise
lglobal.@clientMobile = True if the client running the code is on mobile, false otherwise
logic.nounitbuild = [red]Unit building logic is not allowed here.
@@ -2532,4 +2532,4 @@ lenum.texturesize = Size of texture in tiles. Zero value scales marker width to
lenum.autoscale = Whether to scale marker corresponding to player's zoom level.
lenum.posi = Indexed position, used for line and quad markers with index zero being the first position.
lenum.uvi = Texture's position ranging from zero to one, used for quad markers.
lenum.colori = Indexed position, used for line and quad markers with index zero being the first color.
lenum.colori = Indexed color, used for line and quad markers with index zero being the first color.

View File

@@ -26,6 +26,7 @@ public class UnitGroup{
if(lastSpeedUpdate == Vars.state.updateId) return;
lastSpeedUpdate = Vars.state.updateId;
minSpeed = 999999f;
for(Unit unit : units){
//don't factor in the floor speed multiplier

View File

@@ -148,17 +148,20 @@ public class MinimapRenderer{
Tmp.m2.set(Draw.trans());
float scaleFactor;
var trans = Tmp.m1.idt();
trans.translate(lastX, lastY);
if(!worldSpace){
trans.scl(Tmp.v1.set(lastW / rect.width, lastH / rect.height));
trans.scl(Tmp.v1.set(scaleFactor = lastW / rect.width, lastH / rect.height));
trans.translate(-rect.x, -rect.y);
}else{
trans.scl(Tmp.v1.set(lastW / world.unitWidth(), lastH / world.unitHeight()));
trans.scl(Tmp.v1.set(scaleFactor = lastW / world.unitWidth(), lastH / world.unitHeight()));
}
trans.translate(tilesize / 2f, tilesize / 2f);
Draw.trans(trans);
scaleFactor = 1f / scaleFactor;
for(Unit unit : units){
if(unit.inFogTo(player.team()) || !unit.type.drawMinimap) continue;
@@ -198,7 +201,7 @@ public class MinimapRenderer{
dynamicTex.setFilter(TextureFilter.nearest);
Tmp.tr1.set(dynamicTex);
Tmp.tr1.set(0f, 0f, 1f, 1f);
Tmp.tr1.set(0f, 1f, 1f, 0f);
float wf = world.width() * tilesize;
float hf = world.height() * tilesize;
@@ -226,7 +229,7 @@ public class MinimapRenderer{
if(!mobile){
//draw bounds for camera - not drawn on mobile because you can't shift it by tapping anyway
Rect r = Core.camera.bounds(Tmp.r1);
Lines.stroke(Scl.scl(3f));
Lines.stroke(Scl.scl(3f) * scaleFactor);
Draw.color(Pal.accent);
Lines.rect(r.x, r.y, r.width, r.height);
Draw.reset();

View File

@@ -203,17 +203,7 @@ public class PlanetRenderer implements Disposable{
}
public void setPlane(Sector sector){
float rotation = -sector.planet.getRotation();
float length = 0.01f;
projector.setPlane(
//origin on sector position
Tmp.v33.set(sector.tile.v).setLength((outlineRad + length) * sector.planet.radius).rotate(Vec3.Y, rotation).add(sector.planet.position),
//face up
sector.plane.project(Tmp.v32.set(sector.tile.v).add(Vec3.Y)).sub(sector.tile.v, sector.planet.radius).rotate(Vec3.Y, rotation).nor(),
//right vector
Tmp.v31.set(Tmp.v32).rotate(Vec3.Y, -rotation).add(sector.tile.v).rotate(sector.tile.v, 90).sub(sector.tile.v).rotate(Vec3.Y, rotation).nor()
);
sector.planet.setPlane(sector, projector);
}
public void fill(Sector sector, Color color, float offset){

View File

@@ -84,8 +84,6 @@ public class Liquid extends UnlockableContent implements Senseable{
super.init();
if(gas){
//gases can't be coolants
coolant = false;
//always "boils", it's a gas
boilPoint = -1;
//ensure no accidental global mutation

View File

@@ -536,4 +536,26 @@ public class Planet extends UnlockableContent{
}
batch.flush(Gl.lineStrip);
}
public Vec3 lookAt(Sector sector, Vec3 out){
return out.set(sector.tile.v).rotate(Vec3.Y, -getRotation());
}
public Vec3 project(Sector sector, Camera3D cam, Vec3 out){
return cam.project(out.set(sector.tile.v).setLength(outlineRad * radius).rotate(Vec3.Y, -getRotation()).add(position));
}
public void setPlane(Sector sector, PlaneBatch3D projector){
float rotation = -getRotation();
float length = 0.01f;
projector.setPlane(
//origin on sector position
Tmp.v33.set(sector.tile.v).setLength((outlineRad + length) * radius).rotate(Vec3.Y, rotation).add(position),
//face up
sector.plane.project(Tmp.v32.set(sector.tile.v).add(Vec3.Y)).sub(sector.tile.v, radius).rotate(Vec3.Y, rotation).nor(),
//right vector
Tmp.v31.set(Tmp.v32).rotate(Vec3.Y, -rotation).add(sector.tile.v).rotate(sector.tile.v, 90).sub(sector.tile.v).rotate(Vec3.Y, rotation).nor()
);
}
}

View File

@@ -236,7 +236,7 @@ public class Sector{
/** Projects this sector onto a 4-corner square for use in map gen.
* Allocates a new object. Do not call in the main loop. */
private SectorRect makeRect(){
protected SectorRect makeRect(){
Vec3[] corners = new Vec3[tile.corners.length];
for(int i = 0; i < corners.length; i++){
corners[i] = tile.corners[i].v.cpy().setLength(planet.radius);

View File

@@ -167,7 +167,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//show selection of Erekir/Serpulo campaign if the user has no bases, and hasn't selected yet (essentially a "have they played campaign before" check)
shown(() -> {
if(!settings.getBool("campaignselect") && !content.planets().contains(p -> p.sectors.contains(s -> s.hasBase()))){
if(!settings.getBool("campaignselect") && !content.planets().contains(p -> p.sectors.contains(Sector::hasBase))){
var diag = new BaseDialog("@campaign.select");
Planet[] selected = {null};
@@ -214,7 +214,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
}
//unlock defaults for older campaign saves (TODO move? where to?)
if(content.planets().contains(p -> p.sectors.contains(s -> s.hasBase())) || Blocks.scatter.unlocked() || Blocks.router.unlocked()){
if(content.planets().contains(p -> p.sectors.contains(Sector::hasBase)) || Blocks.scatter.unlocked() || Blocks.router.unlocked()){
Seq.with(Blocks.junction, Blocks.mechanicalDrill, Blocks.conveyor, Blocks.duo, Items.copper, Items.lead).each(UnlockableContent::quietUnlock);
}
}
@@ -372,11 +372,17 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
super.show();
}
void lookAt(Sector sector){
public void lookAt(Sector sector){
if(sector.tile == Ptile.empty) return;
//TODO should this even set `state.planet`? the other lookAt() doesn't, so...
state.planet = sector.planet;
state.camPos.set(Tmp.v33.set(sector.tile.v).rotate(Vec3.Y, -sector.planet.getRotation()));
sector.planet.lookAt(sector, state.camPos);
}
public void lookAt(Sector sector, float alpha){
float len = state.camPos.len();
state.camPos.slerp(sector.planet.lookAt(sector, Tmp.v33).setLength(len), alpha);
}
boolean canSelect(Sector sector){
@@ -648,10 +654,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
}
}).visible(() -> mode != select),
new Table(c -> {
expandTable = c;
})).grow();
new Table(c -> expandTable = c)).grow();
rebuildExpand();
}
@@ -770,11 +773,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
}
}
public void lookAt(Sector sector, float alpha){
float len = state.camPos.len();
state.camPos.slerp(Tmp.v31.set(sector.tile.v).rotate(Vec3.Y, -sector.planet.getRotation()).setLength(len), alpha);
}
@Override
public void act(float delta){
super.act(delta);
@@ -801,7 +799,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
hoverLabel.touchable = Touchable.disabled;
hoverLabel.color.a = state.uiAlpha;
Vec3 pos = planets.cam.project(Tmp.v31.set(hovered.tile.v).setLength(PlanetRenderer.outlineRad * state.planet.radius).rotate(Vec3.Y, -state.planet.getRotation()).add(state.planet.position));
Vec3 pos = hovered.planet.project(hovered, planets.cam, Tmp.v31);
hoverLabel.setPosition(pos.x - Core.scene.marginLeft, pos.y - Core.scene.marginBottom, Align.center);
hoverLabel.getText().setLength(0);

View File

@@ -36,8 +36,6 @@ public class TraceDialog extends BaseDialog{
c.add(Core.bundle.format("trace.ip", info.ip)).row();
c.button(Icon.copySmall, style, () -> copy(info.uuid)).size(s).padRight(4f);
c.add(Core.bundle.format("trace.id", info.uuid)).row();
c.button(Icon.copySmall, style, () -> copy(player.locale)).size(s).padRight(4f);
c.add(Core.bundle.format("trace.language", player.locale)).row();
}).row();
table.add(Core.bundle.format("trace.modclient", info.modded)).row();

View File

@@ -50,6 +50,7 @@ public class Build{
if(tile.build != null){
prevBuild.add(tile.build);
tile.build.onDeconstructed(unit);
tile.build.dead = true;
}
tile.setBlock(sub, team, rotation);

View File

@@ -29,6 +29,7 @@ public class StackConveyor extends Block implements Autotiler{
public @Load("@-stack") TextureRegion stackRegion;
/** requires power to work properly */
public @Load(value = "@-glow") TextureRegion glowRegion;
public @Load(value = "@-edge-glow", fallback = "@-glow") TextureRegion edgeGlowRegion;
public float glowAlpha = 1f;
public Color glowColor = Pal.redLight;
@@ -154,7 +155,7 @@ public class StackConveyor extends Block implements Autotiler{
Draw.z(Layer.blockAdditive);
Draw.color(glowColor, glowAlpha * power.status);
Draw.blend(Blending.additive);
Draw.rect(glowRegion, x, y, rotation * 90);
Draw.rect(state == stateLoad ? edgeGlowRegion : glowRegion, x, y, rotation * 90);
Draw.blend();
Draw.color();
Draw.z(Layer.block - 0.1f);

View File

@@ -42,6 +42,11 @@ public class SwitchBlock extends Block{
if(privileged) return;
super.damage(damage);
}
@Override
public boolean canPickup(){
return !privileged;
}
@Override
public boolean collide(Bullet other){