Building / Fixed some tests
This commit is contained in:
@@ -10,7 +10,7 @@ class AllDefs{
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(Playerc.class)
|
||||
@GroupDef(value = Playerc.class, mapping = true)
|
||||
class player{
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class AllDefs{
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(value = Unitc.class, spatial = true, collide = {unit.class})
|
||||
@GroupDef(value = Unitc.class, spatial = true, collide = {unit.class}, mapping = true)
|
||||
class unit{
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class AllDefs{
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(Syncc.class)
|
||||
@GroupDef(value = Syncc.class, mapping = true)
|
||||
class sync{
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class BuilderComp implements Unitc{
|
||||
abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||
|
||||
@Import float x, y, rotation;
|
||||
@@ -32,7 +32,8 @@ abstract class BuilderComp implements Unitc{
|
||||
transient float buildSpeed = 1f;
|
||||
//boolean building;
|
||||
|
||||
void updateBuilding(){
|
||||
@Override
|
||||
public void update(){
|
||||
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange;
|
||||
|
||||
Iterator<BuildRequest> it = requests.iterator();
|
||||
@@ -189,7 +190,8 @@ abstract class BuilderComp implements Unitc{
|
||||
return requests.size == 0 ? null : requests.first();
|
||||
}
|
||||
|
||||
void drawOver(){
|
||||
@Override
|
||||
public void drawFlying(){
|
||||
if(!isBuilding()) return;
|
||||
BuildRequest request = buildRequest();
|
||||
Tile tile = world.tile(request.x, request.y);
|
||||
@@ -211,7 +213,7 @@ abstract class BuilderComp implements Unitc{
|
||||
tmptr[2].set(tile.drawx() - sz, tile.drawy() + sz);
|
||||
tmptr[3].set(tile.drawx() + sz, tile.drawy() + sz);
|
||||
|
||||
Arrays.sort(tmptr, Structs.comparingFloat(vec -> Angles.angleDist(angleTo(vec), ang)));
|
||||
Arrays.sort(tmptr, 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;
|
||||
|
||||
@@ -33,7 +33,8 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
return mineTile != null;
|
||||
}
|
||||
|
||||
void updateMining(){
|
||||
@Override
|
||||
public void update(){
|
||||
Tilec core = closestCore();
|
||||
|
||||
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
|
||||
@@ -47,6 +48,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
|
||||
}
|
||||
|
||||
if(mineTile == null || core == null || mineTile.block() != Blocks.air || dst(mineTile.worldx(), mineTile.worldy()) > miningRange
|
||||
|| (((Object)this) instanceof Builderc && ((Builderc)(Object)this).isBuilding())
|
||||
|| mineTile.drop() == null || !acceptsItem(mineTile.drop()) || !canMine(mineTile.drop())){
|
||||
mineTile = null;
|
||||
mineTimer = 0f;
|
||||
|
||||
@@ -20,7 +20,7 @@ import static mindustry.Vars.*;
|
||||
@Component
|
||||
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc,
|
||||
DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc, Syncc{
|
||||
@Import float x, y, rotation;
|
||||
@Import float x, y, rotation, elevation;
|
||||
|
||||
private UnitController controller;
|
||||
private UnitType type;
|
||||
@@ -83,6 +83,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
hitSize(type.hitsize);
|
||||
controller(type.createController());
|
||||
setupWeapons(type);
|
||||
|
||||
elevation = type.flying ? 1f : 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,4 +188,22 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
Events.fire(Trigger.suicideBomb);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO this is bad
|
||||
|
||||
public boolean isPlayer(){
|
||||
return controller instanceof Playerc;
|
||||
}
|
||||
|
||||
public boolean canMine(Item item){
|
||||
return type.drillTier >= item.hardness;
|
||||
}
|
||||
|
||||
public float miningSpeed(){
|
||||
return type.mineSpeed;
|
||||
}
|
||||
|
||||
public boolean offloadImmediately(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.entities.units;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class AIController implements UnitController{
|
||||
@@ -21,11 +20,12 @@ public class AIController implements UnitController{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
rot += Mathf.range(3f) * Time.delta();
|
||||
//TODO implement
|
||||
//rot += Mathf.range(3f) * Time.delta();
|
||||
|
||||
unit.moveAt(Tmp.v1.trns(rot, unit.type().speed));
|
||||
if(!unit.vel().isZero()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
//unit.moveAt(Tmp.v1.trns(rot, unit.type().speed));
|
||||
//if(!unit.vel().isZero()){
|
||||
// unit.lookAt(unit.vel().angle());
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user