mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-07 14:01:51 +07:00
Delegate more methods into Planet (#9568)
This commit is contained in:
parent
4e24b31c0d
commit
2c3167e668
@ -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){
|
||||
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user