Fixed artillery bullet not respecting range properly
This commit is contained in:
@@ -27,7 +27,7 @@ allprojects {
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
uCoreVersion = '39d511523f61b8464d7187a3bcd93ea17550712d'
|
uCoreVersion = '99b7a3af00a1fa7e48a494515bf6b137774e114b'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.anuke.ucore.entities.impl.BulletEntity;
|
|||||||
import io.anuke.ucore.entities.trait.Entity;
|
import io.anuke.ucore.entities.trait.Entity;
|
||||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||||
import io.anuke.ucore.entities.trait.VelocityTrait;
|
import io.anuke.ucore.entities.trait.VelocityTrait;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Pooling;
|
import io.anuke.ucore.util.Pooling;
|
||||||
import io.anuke.ucore.util.Timer;
|
import io.anuke.ucore.util.Timer;
|
||||||
|
|
||||||
@@ -23,13 +24,12 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.bulletGroup;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.mindustry.Vars.content;
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
||||||
private static Vector2 vector = new Vector2();
|
private static Vector2 vector = new Vector2();
|
||||||
public Timer timer = new Timer(3);
|
public Timer timer = new Timer(3);
|
||||||
|
private float lifeScl;
|
||||||
private Team team;
|
private Team team;
|
||||||
private Object data;
|
private Object data;
|
||||||
private boolean supressCollision, supressOnce, initialized;
|
private boolean supressCollision, supressOnce, initialized;
|
||||||
@@ -68,7 +68,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
|
|
||||||
bullet.team = team;
|
bullet.team = team;
|
||||||
bullet.type = type;
|
bullet.type = type;
|
||||||
bullet.time(type.lifetime() * (1f - lifetimeScl));
|
bullet.lifeScl = lifetimeScl;
|
||||||
|
|
||||||
//translate bullets backwards, purely for visual reasons
|
//translate bullets backwards, purely for visual reasons
|
||||||
float backDelta = Timers.delta();
|
float backDelta = Timers.delta();
|
||||||
@@ -95,10 +95,6 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
create(type, null, Team.none, x, y, angle);
|
create(type, null, Team.none, x, y, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BulletType getBulletType(){
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean collidesTiles(){
|
public boolean collidesTiles(){
|
||||||
return type.collidesTiles;
|
return type.collidesTiles;
|
||||||
}
|
}
|
||||||
@@ -231,6 +227,9 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateLife(){
|
protected void updateLife(){
|
||||||
|
time += Timers.delta() * 1f/(lifeScl);
|
||||||
|
time = Mathf.clamp(time, 0, type.lifetime());
|
||||||
|
|
||||||
if(time >= type.lifetime){
|
if(time >= type.lifetime){
|
||||||
if(!supressCollision) type.despawned(this);
|
if(!supressCollision) type.despawned(this);
|
||||||
remove();
|
remove();
|
||||||
@@ -241,6 +240,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
public void reset(){
|
public void reset(){
|
||||||
super.reset();
|
super.reset();
|
||||||
timer.clear();
|
timer.clear();
|
||||||
|
lifeScl = 1f;
|
||||||
team = null;
|
team = null;
|
||||||
data = null;
|
data = null;
|
||||||
supressCollision = false;
|
supressCollision = false;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class ArtilleryTurret extends ItemTurret{
|
|||||||
|
|
||||||
for(int i = 0; i < shots; i++){
|
for(int i = 0; i < shots; i++){
|
||||||
Bullet.create(ammo.bullet, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y,
|
Bullet.create(ammo.bullet, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y,
|
||||||
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), 1f + Mathf.range(velocityInaccuracy), Mathf.clamp(dst / maxTraveled));
|
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), 1f + Mathf.range(velocityInaccuracy), (dst / maxTraveled));
|
||||||
}
|
}
|
||||||
|
|
||||||
effects(tile);
|
effects(tile);
|
||||||
|
|||||||
Reference in New Issue
Block a user