Bugfixes / Tutorial cleanup

This commit is contained in:
Anuken
2020-11-21 15:50:44 -05:00
parent 96b55c6b1c
commit b09dc47aad
8 changed files with 110 additions and 80 deletions

View File

@@ -1694,8 +1694,8 @@ public class UnitTypes implements ContentList{
bullet = new RailBulletType(){{
shootEffect = Fx.railShoot;
speed = 67f;
lifetime = 8f;
length = 500;
updateEffectSeg = 60f;
pierceEffect = Fx.railHit;
updateEffect = Fx.railTrail;
hitEffect = Fx.massiveExplosion;

View File

@@ -25,6 +25,7 @@ public class Damage{
private static Rect rect = new Rect();
private static Rect hitrect = new Rect();
private static Vec2 tr = new Vec2();
private static Seq<Unit> units = new Seq<>();
private static GridBits bits = new GridBits(30, 30);
private static IntQueue propagation = new IntQueue();
private static IntSet collidedBlocks = new IntSet();
@@ -117,14 +118,16 @@ public class Damage{
Building tile = world.build(cx, cy);
boolean collide = tile != null && collidedBlocks.add(tile.pos());
if(collide && tile.team != team && tile.collide(hitter)){
tile.collision(hitter);
hitter.type.hit(hitter, tile.x, tile.y);
}
if(hitter.damage > 0){
if(collide && tile.team != team && tile.collide(hitter)){
tile.collision(hitter);
hitter.type.hit(hitter, tile.x, tile.y);
}
//try to heal the tile
if(collide && hitter.type.collides(hitter, tile)){
hitter.type.hitTile(hitter, tile, 0f, false);
//try to heal the tile
if(collide && hitter.type.collides(hitter, tile)){
hitter.type.hitTile(hitter, tile, tile.health, false);
}
}
};
@@ -161,20 +164,27 @@ public class Damage{
rect.height += expand * 2;
Cons<Unit> cons = e -> {
if(!e.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround)) return;
e.hitbox(hitrect);
Vec2 vec = Geometry.raycastRect(x, y, x2, y2, hitrect.grow(expand * 2));
if(vec != null){
if(vec != null && hitter.damage > 0){
effect.at(vec.x, vec.y);
e.collision(hitter, vec.x, vec.y);
hitter.collision(e, vec.x, vec.y);
}
};
Units.nearbyEnemies(team, rect, cons);
units.clear();
Units.nearbyEnemies(team, rect, u -> {
if(u.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround)){
units.add(u);
}
});
units.sort(u -> u.dst2(hitter));
units.each(cons);
}
/**

View File

@@ -1,5 +1,7 @@
package mindustry.entities.bullet;
import arc.math.geom.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
@@ -15,36 +17,54 @@ public class RailBulletType extends BulletType{
/** Multiplier of damage decreased per health pierced. */
public float pierceDamageFactor = 1f;
public float length = 100f;
public float updateEffectSeg = 20f;
public RailBulletType(){
pierceBuilding = true;
pierce = true;
reflectable = false;
hitEffect = Fx.none;
despawnEffect = Fx.none;
collides = false;
lifetime = 1f;
}
@Override
public float range(){
return length;
}
void handle(Bullet b, Posc pos, float initialHealth){
float sub = initialHealth*pierceDamageFactor;
if(sub >= b.damage){
//cause a despawn
b.remove();
if(b.damage <= 0){
b.fdata = Math.min(b.fdata, b.dst(pos));
return;
}
if(b.damage > 0){
pierceEffect.at(pos.getX(), pos.getY(), b.rotation());
hitEffect.at(pos.getX(), pos.getY());
}
//subtract health from each consecutive pierce
b.damage -= Math.min(b.damage, sub);
if(b.damage > 0){
pierceEffect.at(pos.getX(), pos.getY(), b.rotation());
}
hitEffect.at(pos.getX(), pos.getY());
}
@Override
public void update(Bullet b){
if(b.timer(1, 0.9f)){
updateEffect.at(b.x, b.y, b.rotation());
public void init(Bullet b){
super.init(b);
b.fdata = length;
Damage.collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), length, false);
float resultLen = b.fdata;
Vec2 nor = Tmp.v1.set(b.vel).nor();
for(float i = 0; i <= resultLen; i += updateEffectSeg){
updateEffect.at(b.x + nor.x * i, b.y + nor.y * i, b.rotation());
}
}

View File

@@ -698,19 +698,15 @@ public class HudFragment extends Fragment{
float bw = 40f;
float pad = -20;
t.margin(0);
t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad);
t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f).with(i -> {
if(mobile){
//on mobile, cause a respawn on tap
i.clicked(() -> {
if(!player.unit().spawnedByCore && !player.dead()){
Call.unitClear(player);
control.input.controlledType = null;
}
});
t.clicked(() -> {
if(!player.dead() && mobile){
Call.unitClear(player);
control.input.controlledType = null;
}
});
t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad);
t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f);
t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> {
b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type.ammoType.color : Pal.health);
});
@@ -760,8 +756,6 @@ public class HudFragment extends Fragment{
return builder;
}).growX().pad(8f);
table.touchable(() -> state.rules.waves ? Touchable.enabled : Touchable.disabled);
return table;
}