Bugfixes / Tutorial cleanup
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user