Fixed #2066
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
package mindustry.async;
|
package mindustry.async;
|
||||||
|
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Teams.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/** Creates quadtrees per unit team. */
|
/** Creates quadtrees per unit team. */
|
||||||
public class TeamIndexProcess implements AsyncProcess{
|
public class TeamIndexProcess implements AsyncProcess{
|
||||||
private QuadTree<Unitc>[] trees = new QuadTree[Team.all().length];
|
private QuadTree<Unitc>[] trees = new QuadTree[Team.all().length];
|
||||||
private Array<Team> active = new Array<>();
|
|
||||||
private int[] counts = new int[Team.all().length];
|
private int[] counts = new int[Team.all().length];
|
||||||
|
|
||||||
public QuadTree<Unitc> tree(Team team){
|
public QuadTree<Unitc> tree(Team team){
|
||||||
@@ -29,28 +28,20 @@ public class TeamIndexProcess implements AsyncProcess{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(){
|
public void reset(){
|
||||||
active.clear();
|
|
||||||
counts = new int[Team.all().length];
|
counts = new int[Team.all().length];
|
||||||
trees = new QuadTree[Team.all().length];
|
trees = new QuadTree[Team.all().length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void begin(){
|
public void begin(){
|
||||||
for(TeamData data : Vars.state.teams.getActive()){
|
|
||||||
if(!active.contains(data.team)){
|
|
||||||
active.add(data.team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Team team : active){
|
for(Team team : Team.all()){
|
||||||
if(trees[team.uid] != null){
|
if(trees[team.uid] != null){
|
||||||
trees[team.uid].clear();
|
trees[team.uid].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Team team : active){
|
Arrays.fill(counts, 0);
|
||||||
counts[team.id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Unitc unit : Groups.unit){
|
for(Unitc unit : Groups.unit){
|
||||||
tree(unit.team()).insert(unit);
|
tree(unit.team()).insert(unit);
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ public class Bullets implements ContentList{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
basicFlame = new BulletType(3f, 6f){
|
basicFlame = new BulletType(3f, 30f){
|
||||||
{
|
{
|
||||||
ammoMultiplier = 3f;
|
ammoMultiplier = 3f;
|
||||||
hitSize = 7f;
|
hitSize = 7f;
|
||||||
@@ -464,7 +464,7 @@ public class Bullets implements ContentList{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pyraFlame = new BulletType(3.3f, 9f){
|
pyraFlame = new BulletType(3.3f, 45f){
|
||||||
{
|
{
|
||||||
ammoMultiplier = 4f;
|
ammoMultiplier = 4f;
|
||||||
hitSize = 7f;
|
hitSize = 7f;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.func.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
@@ -18,6 +19,7 @@ import static mindustry.Vars.*;
|
|||||||
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{
|
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{
|
||||||
@Import Team team;
|
@Import Team team;
|
||||||
|
|
||||||
|
IntArray collided = new IntArray(6);
|
||||||
Object data;
|
Object data;
|
||||||
BulletType type;
|
BulletType type;
|
||||||
float damage;
|
float damage;
|
||||||
@@ -42,6 +44,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
|||||||
@Override
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
type.despawned(this);
|
type.despawned(this);
|
||||||
|
collided.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +75,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
|||||||
@Override
|
@Override
|
||||||
public boolean collides(Hitboxc other){
|
public boolean collides(Hitboxc other){
|
||||||
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team())
|
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team())
|
||||||
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)));
|
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)))
|
||||||
|
&& !(type.pierce && collided.contains(other.id())); //prevent multiple collisions
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodPriority(100)
|
@MethodPriority(100)
|
||||||
@@ -92,7 +96,11 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
|||||||
}
|
}
|
||||||
|
|
||||||
//must be last.
|
//must be last.
|
||||||
if(!type.pierce) remove();
|
if(!type.pierce){
|
||||||
|
remove();
|
||||||
|
}else{
|
||||||
|
collided.add(other.id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
return relativeTo(tile.x, tile.y);
|
return relativeTo(tile.x, tile.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte relativeTo(Tilec tile){
|
||||||
|
return relativeTo(tile.tile());
|
||||||
|
}
|
||||||
|
|
||||||
public byte relativeTo(int cx, int cy){
|
public byte relativeTo(int cx, int cy){
|
||||||
return tile.absoluteRelativeTo(cx, cy);
|
return tile.absoluteRelativeTo(cx, cy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.struct.ObjectFloatMap.*;
|
import arc.struct.ObjectFloatMap.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -70,26 +71,37 @@ public class Universe{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTurn(){
|
public int[] getTotalExports(){
|
||||||
//TODO run waves on hostile sectors, damage them
|
int[] exports = new int[Vars.content.items().size];
|
||||||
|
|
||||||
//calculate passive items
|
|
||||||
for(Planet planet : content.planets()){
|
for(Planet planet : content.planets()){
|
||||||
for(Sector sector : planet.sectors){
|
for(Sector sector : planet.sectors){
|
||||||
//make sure this is a different sector
|
|
||||||
if(sector.hasSave() && sector != state.rules.sector){
|
//ignore the current sector if the player is in it right now
|
||||||
|
if(sector.hasSave() && (state.isMenu() || sector != state.rules.sector)){
|
||||||
SaveMeta meta = sector.save.meta;
|
SaveMeta meta = sector.save.meta;
|
||||||
|
|
||||||
for(Entry<Item> entry : meta.exportRates){
|
for(Entry<Item> entry : meta.exportRates){
|
||||||
//total is calculated by items/sec (value) * turn duration in seconds
|
//total is calculated by items/sec (value) * turn duration in seconds
|
||||||
int total = (int)(entry.value * turnDuration / 60f);
|
int total = (int)(entry.value * turnDuration / 60f);
|
||||||
|
|
||||||
//add the items to global data
|
exports[entry.key.id] += total;
|
||||||
data.addItem(entry.key, total);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onTurn(){
|
||||||
|
//TODO run waves on hostile sectors, damage them
|
||||||
|
|
||||||
|
//calculate passive item generation
|
||||||
|
int[] exports = getTotalExports();
|
||||||
|
for(int i = 0; i < exports.length; i++){
|
||||||
|
data.addItem(content.item(i), exports[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float secondsMod(float mod, float scale){
|
public float secondsMod(float mod, float scale){
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
borderColor = Pal.accent.cpy().a(0.3f),
|
borderColor = Pal.accent.cpy().a(0.3f),
|
||||||
shadowColor = new Color(0, 0, 0, 0.7f);
|
shadowColor = new Color(0, 0, 0, 0.7f);
|
||||||
private static final float camLength = 4f;
|
private static final float camLength = 4f;
|
||||||
float outlineRad = 1.16f;
|
private static final float outlineRad = 1.16f;
|
||||||
|
|
||||||
//the base planet that's being rendered
|
//the base planet that's being rendered
|
||||||
private final Planet solarSystem = Planets.sun;
|
private final Planet solarSystem = Planets.sun;
|
||||||
@@ -44,7 +44,9 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
private final PlaneBatch3D projector = new PlaneBatch3D();
|
private final PlaneBatch3D projector = new PlaneBatch3D();
|
||||||
private final Mat3D mat = new Mat3D();
|
private final Mat3D mat = new Mat3D();
|
||||||
private final Vec3 camRelative = new Vec3();
|
private final Vec3 camRelative = new Vec3();
|
||||||
|
private final ResourcesDialog resources = new ResourcesDialog();
|
||||||
|
|
||||||
|
private float zoom = 1f, smoothZoom = 1f;
|
||||||
private Bloom bloom;
|
private Bloom bloom;
|
||||||
private Planet planet = Planets.starter;
|
private Planet planet = Planets.starter;
|
||||||
private @Nullable Sector selected, hovered;
|
private @Nullable Sector selected, hovered;
|
||||||
@@ -73,18 +75,17 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
|
|
||||||
Events.on(ResizeEvent.class, e -> makeBloom());
|
Events.on(ResizeEvent.class, e -> makeBloom());
|
||||||
|
|
||||||
|
|
||||||
buttons.defaults().size(220f, 64f).pad(0f);
|
|
||||||
|
|
||||||
TextButtonStyle style = Styles.cleart;
|
TextButtonStyle style = Styles.cleart;
|
||||||
float bmargin = 6f;
|
float bmargin = 6f;
|
||||||
|
|
||||||
//TODO names
|
getCell(buttons).padBottom(-4);
|
||||||
//buttons.button("$back", Icon.left, style, this::hide).margin(bmargin);
|
buttons.background(Styles.black).defaults().growX().height(64f).pad(0);
|
||||||
//buttons.addImageTextButton("Tech", Icon.tree, style, () -> ui.tech.show()).margin(bmargin);
|
|
||||||
//buttons.addImageTextButton("Launch", Icon.upOpen, style, this::hide).margin(bmargin);
|
//TODO
|
||||||
//buttons.addImageTextButton("Database", Icon.book, style, () -> ui.database.show()).margin(bmargin);
|
buttons.button("$back", Icon.left, style, this::hide).margin(bmargin);
|
||||||
//buttons.addImageTextButton("Resources", Icon.file, style, this::hide).margin(bmargin);
|
buttons.button("Research", Icon.tree, style, () -> ui.tech.show()).margin(bmargin);
|
||||||
|
//buttons.button("Database", Icon.book, style, () -> ui.database.show()).margin(bmargin);
|
||||||
|
buttons.button("Resources", Icon.file, style, resources::show).margin(bmargin);
|
||||||
|
|
||||||
cam.fov = 60f;
|
cam.fov = 60f;
|
||||||
|
|
||||||
@@ -108,6 +109,10 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
camRelative.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount);
|
camRelative.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scrolled(value -> {
|
||||||
|
zoom = Mathf.clamp(zoom + value / 10f, 0.5f, 2f);
|
||||||
|
});
|
||||||
|
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(planet.isLandable()){
|
if(planet.isLandable()){
|
||||||
hovered = planet.getSector(cam.getMouseRay(), outlineRad);
|
hovered = planet.getSector(cam.getMouseRay(), outlineRad);
|
||||||
@@ -115,7 +120,7 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
hovered = selected = null;
|
hovered = selected = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smoothZoom = Mathf.lerpDelta(smoothZoom, zoom, 0.4f);
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener(new ElementGestureListener(){
|
addListener(new ElementGestureListener(){
|
||||||
@@ -166,7 +171,7 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
cam.up.set(Vec3.Y);
|
cam.up.set(Vec3.Y);
|
||||||
|
|
||||||
cam.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
cam.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||||
camRelative.setLength(planet.radius * camLength);
|
camRelative.setLength(planet.radius * camLength + (smoothZoom-1f) * planet.radius * 2);
|
||||||
cam.position.set(planet.position).add(camRelative);
|
cam.position.set(planet.position).add(camRelative);
|
||||||
cam.lookAt(planet.position);
|
cam.lookAt(planet.position);
|
||||||
cam.update();
|
cam.update();
|
||||||
@@ -372,8 +377,6 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stable.row();
|
stable.row();
|
||||||
|
|
||||||
stable.button("Launch", Styles.transt, () -> {
|
stable.button("Launch", Styles.transt, () -> {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import arc.graphics.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
public class ResourcesDialog extends FloatingDialog{
|
||||||
|
|
||||||
|
public ResourcesDialog(){
|
||||||
|
super("//TODO resources");
|
||||||
|
shown(this::setup);
|
||||||
|
addCloseButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
cont.clear();
|
||||||
|
|
||||||
|
cont.table(Tex.button, t -> {
|
||||||
|
t.left();
|
||||||
|
t.margin(10f);
|
||||||
|
int[] exports = universe.getTotalExports();
|
||||||
|
for(Item item : content.items()){
|
||||||
|
if(exports[item.id] > 0 || data.getItem(item) > 0){
|
||||||
|
t.image(item.icon(Cicon.small)).padRight(4);
|
||||||
|
t.add(ui.formatAmount(data.getItem(item))).color(Color.lightGray);
|
||||||
|
if(exports[item.id] > 0){
|
||||||
|
t.add("+ [accent]" + ui.formatAmount(exports[item.id]) + " [lightgray]/T");
|
||||||
|
}else{
|
||||||
|
t.add();
|
||||||
|
}
|
||||||
|
t.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -275,8 +275,8 @@ public class ItemBridge extends Block{
|
|||||||
Tile other = world.tile(link);
|
Tile other = world.tile(link);
|
||||||
|
|
||||||
if(linkValid(tile, other)){
|
if(linkValid(tile, other)){
|
||||||
int rel = relativeTo(other.x, other.y);
|
int rel = relativeTo(other);
|
||||||
int rel2 = relativeTo(source.tileX(), source.tileY());
|
int rel2 = relativeTo(Edges.getFacingEdge(source.tile(), tile));
|
||||||
|
|
||||||
if(rel == rel2) return false;
|
if(rel == rel2) return false;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user