Networked unit control / Mimic AI prototype
This commit is contained in:
@@ -12,6 +12,8 @@ import static mindustry.Vars.net;
|
||||
|
||||
@Component
|
||||
abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
private static final Vec2 tmp1 = new Vec2(), tmp2 = new Vec2();
|
||||
|
||||
@Import float x, y, drag;
|
||||
@Import Vec2 vel;
|
||||
|
||||
@@ -37,9 +39,9 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
}
|
||||
|
||||
void moveAt(Vec2 vector, float acceleration){
|
||||
Vec2 t = Tmp.v3.set(vector).scl(floorSpeedMultiplier()); //target vector
|
||||
Tmp.v1.set(t).sub(vel).limit(acceleration * vector.len()); //delta vector
|
||||
vel.add(Tmp.v1);
|
||||
Vec2 t = tmp1.set(vector).scl(floorSpeedMultiplier()); //target vector
|
||||
tmp2.set(t).sub(vel).limit(acceleration * vector.len()); //delta vector
|
||||
vel.add(tmp2);
|
||||
}
|
||||
|
||||
float floorSpeedMultiplier(){
|
||||
|
||||
@@ -956,6 +956,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
Events.fire(new BlockDestroyEvent(tile));
|
||||
block.breakSound.at(tile);
|
||||
onDestroyed();
|
||||
tile.remove();
|
||||
remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
lookAt(pos);
|
||||
}
|
||||
|
||||
public void aimLook(float x, float y){
|
||||
aim(x, y);
|
||||
lookAt(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float clipSize(){
|
||||
return type.region.getWidth() * 2f;
|
||||
@@ -109,6 +114,14 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
lookAt(angleTo(pos));
|
||||
}
|
||||
|
||||
public void lookAt(float x, float y){
|
||||
lookAt(angleTo(x, y));
|
||||
}
|
||||
|
||||
public boolean isAI(){
|
||||
return controller instanceof AIController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRead(){
|
||||
//set up type info after reading
|
||||
|
||||
@@ -21,7 +21,8 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
|
||||
/** weapon mount array, never null */
|
||||
@ReadOnly WeaponMount[] mounts = {};
|
||||
@ReadOnly float range;
|
||||
@ReadOnly transient float range, aimX, aimY;
|
||||
@ReadOnly transient boolean isRotate, isShooting;
|
||||
|
||||
boolean inRange(Position other){
|
||||
return within(other, range);
|
||||
@@ -41,6 +42,8 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
mount.rotate = rotate;
|
||||
mount.shoot = shoot;
|
||||
}
|
||||
isRotate = rotate;
|
||||
isShooting = shoot;
|
||||
}
|
||||
|
||||
void aim(Position pos){
|
||||
@@ -59,6 +62,9 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
mount.aimX = x;
|
||||
mount.aimY = y;
|
||||
}
|
||||
|
||||
aimX = x;
|
||||
aimY = y;
|
||||
}
|
||||
|
||||
/** Update shooting and rotation for this unit. */
|
||||
|
||||
Reference in New Issue
Block a user