This commit is contained in:
Anuken
2020-09-24 14:26:24 -04:00
parent a914bd77f6
commit 1682e3b996
5 changed files with 53 additions and 6 deletions
@@ -51,7 +51,6 @@ public class GroundAI extends AIController{
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type().rotateShooting){ if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type().rotateShooting){
if(unit.type().hasWeapons()){ if(unit.type().hasWeapons()){
//TODO certain units should not look at the target, e.g. ships
unit.lookAt(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed)); unit.lookAt(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
} }
}else if(unit.moving()){ }else if(unit.moving()){
+2 -2
View File
@@ -1148,7 +1148,7 @@ public class Blocks implements ContentList{
requirements(Category.power, with(Items.copper, 35, Items.graphite, 25, Items.lead, 40, Items.silicon, 30)); requirements(Category.power, with(Items.copper, 35, Items.graphite, 25, Items.lead, 40, Items.silicon, 30));
powerProduction = 5.5f; powerProduction = 5.5f;
itemDuration = 90f; itemDuration = 90f;
consumes.liquid(Liquids.water, 0.09f); consumes.liquid(Liquids.water, 0.1f);
hasLiquids = true; hasLiquids = true;
size = 2; size = 2;
}}; }};
@@ -1268,7 +1268,7 @@ public class Blocks implements ContentList{
rotateSpeed = 1.4f; rotateSpeed = 1.4f;
attribute = Attribute.water; attribute = Attribute.water;
consumes.power(1.25f); consumes.power(1.5f);
}}; }};
cultivator = new Cultivator("cultivator"){{ cultivator = new Cultivator("cultivator"){{
@@ -156,6 +156,7 @@ public class UnitTypes implements ContentList{
mechStepParticles = true; mechStepParticles = true;
mechStepShake = 0.15f; mechStepShake = 0.15f;
singleTarget = true;
weapons.add( weapons.add(
new Weapon("scepter-weapon"){{ new Weapon("scepter-weapon"){{
@@ -0,0 +1,48 @@
package mindustry.entities;
import arc.math.geom.*;
import arc.math.geom.QuadTree.*;
import arc.struct.*;
public class PhysicsWorld{
private QuadTree<PhysicsBody> tree;
private Seq<PhysicsBody> bodies = new Seq<>(false, 16, PhysicsBody.class);
private Rect rect = new Rect();
public PhysicsWorld(Rect bounds){
tree = new QuadTree<>(new Rect(bounds));
}
public void add(PhysicsBody body){
bodies.add(body);
}
public void remove(PhysicsBody body){
bodies.remove(body);
}
public void update(){
tree.clear();
for(int i = 0; i < bodies.size; i++){
tree.insert(bodies.items[i]);
}
for(int i = 0; i < bodies.size; i++){
PhysicsBody body = bodies.items[i];
body.hitbox(rect);
tree.intersect(rect, other -> {
});
}
}
public static class PhysicsBody implements QuadTreeObject{
public float x, y, xv, yv, radius, mass;
public int flag = 0;
@Override
public void hitbox(Rect out){
out.setCentered(x, y, radius * 2, radius * 2);
}
}
}
@@ -4,11 +4,10 @@ import arc.graphics.*;
import arc.graphics.VertexAttributes.*; import arc.graphics.VertexAttributes.*;
import arc.graphics.gl.*; import arc.graphics.gl.*;
import arc.math.geom.*; import arc.math.geom.*;
import arc.util.*;
import mindustry.graphics.g3d.PlanetGrid.*; import mindustry.graphics.g3d.PlanetGrid.*;
public class MeshBuilder{ public class MeshBuilder{
private static final Vec3 v1 = new Vec3(), v2 = new Vec3(), v3 = new Vec3(); private static final Vec3 v1 = new Vec3(), v2 = new Vec3(), v3 = new Vec3(), v4 = new Vec3();
private static final float[] floats = new float[3 + 3 + 1]; private static final float[] floats = new float[3 + 3 + 1];
private static Mesh mesh; private static Mesh mesh;
@@ -111,7 +110,7 @@ public class MeshBuilder{
} }
private static Vec3 normal(Vec3 v1, Vec3 v2, Vec3 v3){ private static Vec3 normal(Vec3 v1, Vec3 v2, Vec3 v3){
return Tmp.v32.set(v2).sub(v1).crs(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).nor(); return v4.set(v2).sub(v1).crs(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).nor();
} }
private static void verts(Vec3 a, Vec3 b, Vec3 c, Vec3 normal, Color color){ private static void verts(Vec3 a, Vec3 b, Vec3 c, Vec3 normal, Color color){