Mobile manual aiming / Mobile control changes [UNSTABLE]
This commit is contained in:
@@ -36,15 +36,13 @@ public class MassDriverBolt extends BulletType{
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
//data MUST be an instance of DriverBulletData
|
||||
if(!(b.data() instanceof DriverBulletData)){
|
||||
if(!(b.data() instanceof DriverBulletData data)){
|
||||
hit(b);
|
||||
return;
|
||||
}
|
||||
|
||||
float hitDst = 7f;
|
||||
|
||||
DriverBulletData data = (DriverBulletData)b.data();
|
||||
|
||||
//if the target is dead, just keep flying until the bullet explodes
|
||||
if(data.to.dead()){
|
||||
return;
|
||||
@@ -83,9 +81,7 @@ public class MassDriverBolt extends BulletType{
|
||||
public void despawned(Bullet b){
|
||||
super.despawned(b);
|
||||
|
||||
if(!(b.data() instanceof DriverBulletData)) return;
|
||||
|
||||
DriverBulletData data = (DriverBulletData)b.data();
|
||||
if(!(b.data() instanceof DriverBulletData data)) return;
|
||||
|
||||
for(int i = 0; i < data.items.length; i++){
|
||||
int amountDropped = Mathf.random(0, data.items[i]);
|
||||
|
||||
@@ -29,8 +29,7 @@ public class SapBulletType extends BulletType{
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
if(b.data instanceof Position){
|
||||
Position data = (Position)b.data;
|
||||
if(b.data instanceof Position data){
|
||||
Tmp.v1.set(data).lerp(b, b.fin());
|
||||
|
||||
Draw.color(color);
|
||||
@@ -68,13 +67,11 @@ public class SapBulletType extends BulletType{
|
||||
}
|
||||
}
|
||||
|
||||
if(target instanceof Hitboxc){
|
||||
Hitboxc hit = (Hitboxc)target;
|
||||
if(target instanceof Hitboxc hit){
|
||||
|
||||
hit.collision(b, hit.x(), hit.y());
|
||||
b.collision(hit, hit.x(), hit.y());
|
||||
}else if(target instanceof Building){
|
||||
Building tile = (Building)target;
|
||||
}else if(target instanceof Building tile){
|
||||
|
||||
if(tile.collide(b)){
|
||||
tile.collision(b);
|
||||
|
||||
@@ -1249,7 +1249,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
case type -> block;
|
||||
case firstItem -> items == null ? null : items.first();
|
||||
case config -> block.configurations.containsKey(Item.class) || block.configurations.containsKey(Liquid.class) ? config() : null;
|
||||
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type() : getPayload() instanceof BlockPayload p2 ? p2.block() : null;
|
||||
case payloadType -> getPayload() instanceof UnitPayload p1 ? p1.unit.type() : getPayload() instanceof BuildPayload p2 ? p2.block() : null;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
||||
@@ -95,14 +95,12 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
type.hit(self(), x, y);
|
||||
float health = 0f;
|
||||
|
||||
if(other instanceof Healthc){
|
||||
Healthc h = (Healthc)other;
|
||||
if(other instanceof Healthc h){
|
||||
health = h.health();
|
||||
h.damage(damage);
|
||||
}
|
||||
|
||||
if(other instanceof Unit){
|
||||
Unit unit = (Unit)other;
|
||||
if(other instanceof Unit unit){
|
||||
unit.impulse(Tmp.v3.set(unit).sub(this.x, this.y).nor().scl(type.knockback * 80f));
|
||||
unit.apply(type.status, type.statusDuration);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
}
|
||||
|
||||
boolean canPickup(Unit unit){
|
||||
return payloadUsed() + unit.hitSize * unit.hitSize <= type.payloadCapacity + 0.001f;
|
||||
return payloadUsed() + unit.hitSize * unit.hitSize <= type.payloadCapacity + 0.001f && unit.team == team() && unit.isAI();
|
||||
}
|
||||
|
||||
boolean canPickup(Building build){
|
||||
return payloadUsed() + build.block.size * build.block.size * Vars.tilesize * Vars.tilesize <= type.payloadCapacity + 0.001f;
|
||||
return payloadUsed() + build.block.size * build.block.size * Vars.tilesize * Vars.tilesize <= type.payloadCapacity + 0.001f && build.canPickup();
|
||||
}
|
||||
|
||||
boolean canPickupPayload(Payload pay){
|
||||
@@ -55,7 +55,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
|
||||
void pickup(Building tile){
|
||||
tile.tile.remove();
|
||||
payloads.add(new BlockPayload(tile));
|
||||
payloads.add(new BuildPayload(tile));
|
||||
Fx.unitPickup.at(tile);
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(payload instanceof BlockPayload){
|
||||
return dropBlock((BlockPayload)payload);
|
||||
if(payload instanceof BuildPayload){
|
||||
return dropBlock((BuildPayload)payload);
|
||||
}else if(payload instanceof UnitPayload){
|
||||
return dropUnit((UnitPayload)payload);
|
||||
}
|
||||
@@ -118,8 +118,8 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
}
|
||||
|
||||
/** @return whether the tile has been successfully placed. */
|
||||
boolean dropBlock(BlockPayload payload){
|
||||
Building tile = payload.entity;
|
||||
boolean dropBlock(BuildPayload payload){
|
||||
Building tile = payload.build;
|
||||
int tx = Vars.world.toTile(x - tile.block.offset), ty = Vars.world.toTile(y - tile.block.offset);
|
||||
Tile on = Vars.world.tile(tx, ty);
|
||||
if(on != null && Build.validPlace(tile.block, tile.team, tx, ty, tile.rotation, false)){
|
||||
|
||||
@@ -109,7 +109,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
case payloadType -> self() instanceof Payloadc pay ?
|
||||
(pay.payloads().isEmpty() ? null :
|
||||
pay.payloads().peek() instanceof UnitPayload p1 ? p1.unit.type() :
|
||||
pay.payloads().peek() instanceof BlockPayload p2 ? p2.block() : null) : null;
|
||||
pay.payloads().peek() instanceof BuildPayload p2 ? p2.block() : null) : null;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user