mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-21 21:28:28 +07:00
RailBulletType collision fixes
This commit is contained in:
@ -7,10 +7,6 @@ import mindustry.entities.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
public class RailBulletType extends BulletType{
|
public class RailBulletType extends BulletType{
|
||||||
//for calculating the furthest point
|
|
||||||
static float furthest = 0;
|
|
||||||
static boolean any = false;
|
|
||||||
|
|
||||||
public Effect pierceEffect = Fx.hitBulletSmall, pointEffect = Fx.none, lineEffect = Fx.none;
|
public Effect pierceEffect = Fx.hitBulletSmall, pointEffect = Fx.none, lineEffect = Fx.none;
|
||||||
public Effect endEffect = Fx.none;
|
public Effect endEffect = Fx.none;
|
||||||
|
|
||||||
@ -55,10 +51,8 @@ public class RailBulletType extends BulletType{
|
|||||||
|
|
||||||
//bullet was stopped, decrease furthest distance
|
//bullet was stopped, decrease furthest distance
|
||||||
if(b.damage <= 0f){
|
if(b.damage <= 0f){
|
||||||
furthest = Math.min(furthest, b.dst(x, y));
|
b.fdata = Math.min(b.fdata, b.dst(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
any = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,10 +60,8 @@ public class RailBulletType extends BulletType{
|
|||||||
super.init(b);
|
super.init(b);
|
||||||
|
|
||||||
b.fdata = length;
|
b.fdata = length;
|
||||||
furthest = length;
|
|
||||||
any = false;
|
|
||||||
Damage.collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), length, false, false);
|
Damage.collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), length, false, false);
|
||||||
float resultLen = furthest;
|
float resultLen = b.fdata;
|
||||||
|
|
||||||
Vec2 nor = Tmp.v1.trns(b.rotation(), 1f).nor();
|
Vec2 nor = Tmp.v1.trns(b.rotation(), 1f).nor();
|
||||||
if(pointEffect != Fx.none){
|
if(pointEffect != Fx.none){
|
||||||
@ -78,6 +70,8 @@ public class RailBulletType extends BulletType{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean any = b.collided.size > 0;
|
||||||
|
|
||||||
if(!any && endEffect != Fx.none){
|
if(!any && endEffect != Fx.none){
|
||||||
endEffect.at(b.x + nor.x * resultLen, b.y + nor.y * resultLen, b.rotation(), hitColor);
|
endEffect.at(b.x + nor.x * resultLen, b.y + nor.y * resultLen, b.rotation(), hitColor);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user