Removed dependency on old BulletEntity/BaseBulletType classes
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,3 @@
|
|||||||
##Packr, build stuff
|
|
||||||
|
|
||||||
logs/
|
logs/
|
||||||
/core/assets/mindustry-saves/
|
/core/assets/mindustry-saves/
|
||||||
/core/assets/mindustry-maps/
|
/core/assets/mindustry-maps/
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public class Mechs implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void updateAlt(Player player){
|
public void updateAlt(Player player){
|
||||||
float scl = 1f - player.shootHeat/2f;
|
float scl = 1f - player.shootHeat/2f;
|
||||||
player.getVelocity().scl(scl);
|
player.velocity().scl(scl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -230,7 +230,7 @@ public class Mechs implements ContentList{
|
|||||||
if(Mathf.chance(Time.delta() * (0.15*scl))){
|
if(Mathf.chance(Time.delta() * (0.15*scl))){
|
||||||
Effects.effect(BulletFx.hitLancer, Palette.lancerLaser, player.x, player.y);
|
Effects.effect(BulletFx.hitLancer, Palette.lancerLaser, player.x, player.y);
|
||||||
Lightning.create(player.getTeam(), Palette.lancerLaser, 10f,
|
Lightning.create(player.getTeam(), Palette.lancerLaser, 10f,
|
||||||
player.x + player.getVelocity().x, player.y + player.getVelocity().y, player.rotation, 14);
|
player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ public class Mechs implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float scld(Player player){
|
float scld(Player player){
|
||||||
return Mathf.clamp((player.getVelocity().len() - minV) / (maxV - minV));
|
return Mathf.clamp((player.velocity().len() - minV) / (maxV - minV));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public class Mechs implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShoot(Player player){
|
public boolean canShoot(Player player){
|
||||||
return player.getVelocity().len() > 1.2f;
|
return player.velocity().len() > 1.2f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
dense = new ArtilleryBulletType(3f, 0, "shell"){
|
dense = new ArtilleryBulletType(3f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hitEffect = BulletFx.flakExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 50f;
|
lifetime = 50f;
|
||||||
bulletWidth = bulletHeight = 11f;
|
bulletWidth = bulletHeight = 11f;
|
||||||
@@ -34,13 +34,13 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
lifetime = 15f;
|
lifetime = 15f;
|
||||||
backColor = Palette.plastaniumBack;
|
backColor = Palette.plastaniumBack;
|
||||||
frontColor = Palette.plastaniumFront;
|
frontColor = Palette.plastaniumFront;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
plastic = new ArtilleryBulletType(3.3f, 0, "shell"){
|
plastic = new ArtilleryBulletType(3.3f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.plasticExplosion;
|
hitEffect = BulletFx.plasticExplosion;
|
||||||
knockback = 1f;
|
knockback = 1f;
|
||||||
lifetime = 55f;
|
lifetime = 55f;
|
||||||
bulletWidth = bulletHeight = 13f;
|
bulletWidth = bulletHeight = 13f;
|
||||||
@@ -56,7 +56,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
homing = new ArtilleryBulletType(3f, 0, "shell"){
|
homing = new ArtilleryBulletType(3f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hitEffect = BulletFx.flakExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 45f;
|
lifetime = 45f;
|
||||||
bulletWidth = bulletHeight = 11f;
|
bulletWidth = bulletHeight = 11f;
|
||||||
@@ -70,7 +70,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
incindiary = new ArtilleryBulletType(3f, 0, "shell"){
|
incindiary = new ArtilleryBulletType(3f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 60f;
|
lifetime = 60f;
|
||||||
bulletWidth = bulletHeight = 13f;
|
bulletWidth = bulletHeight = 13f;
|
||||||
@@ -87,7 +87,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
explosive = new ArtilleryBulletType(2f, 0, "shell"){
|
explosive = new ArtilleryBulletType(2f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 70f;
|
lifetime = 70f;
|
||||||
bulletWidth = bulletHeight = 14f;
|
bulletWidth = bulletHeight = 14f;
|
||||||
@@ -101,7 +101,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
unit = new ArtilleryBulletType(2f, 0, "shell"){
|
unit = new ArtilleryBulletType(2f, 0, "shell"){
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 90f;
|
lifetime = 90f;
|
||||||
bulletWidth = bulletHeight = 14f;
|
bulletWidth = bulletHeight = 14f;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class FlakBullets extends BulletList implements ContentList{
|
|||||||
splashDamageRadius = 40f;
|
splashDamageRadius = 40f;
|
||||||
fragBullet = ArtilleryBullets.plasticFrag;
|
fragBullet = ArtilleryBullets.plasticFrag;
|
||||||
fragBullets = 4;
|
fragBullets = 4;
|
||||||
hiteffect = BulletFx.plasticExplosion;
|
hitEffect = BulletFx.plasticExplosion;
|
||||||
frontColor = Palette.plastaniumFront;
|
frontColor = Palette.plastaniumFront;
|
||||||
backColor = Palette.plastaniumBack;
|
backColor = Palette.plastaniumBack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
splashDamageRadius = 30f;
|
splashDamageRadius = 30f;
|
||||||
splashDamage = 30f;
|
splashDamage = 30f;
|
||||||
lifetime = 150f;
|
lifetime = 150f;
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
despawneffect = BulletFx.blastExplosion;
|
despawnEffect = BulletFx.blastExplosion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
splashDamageRadius = 10f;
|
splashDamageRadius = 10f;
|
||||||
splashDamage = 10f;
|
splashDamage = 10f;
|
||||||
lifetime = 160f;
|
lifetime = 160f;
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
incendSpread = 10f;
|
incendSpread = 10f;
|
||||||
incendAmount = 3;
|
incendAmount = 3;
|
||||||
}
|
}
|
||||||
@@ -58,8 +58,8 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
splashDamageRadius = 30f;
|
splashDamageRadius = 30f;
|
||||||
splashDamage = 22f;
|
splashDamage = 22f;
|
||||||
lifetime = 150f;
|
lifetime = 150f;
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
despawneffect = BulletFx.blastExplosion;
|
despawnEffect = BulletFx.blastExplosion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,8 +83,8 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
splashDamage = 1f;
|
splashDamage = 1f;
|
||||||
lifetime = 90f;
|
lifetime = 90f;
|
||||||
trailColor = Color.valueOf("b6c6fd");
|
trailColor = Color.valueOf("b6c6fd");
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
despawneffect = BulletFx.blastExplosion;
|
despawnEffect = BulletFx.blastExplosion;
|
||||||
backColor = Palette.bulletYellowBack;
|
backColor = Palette.bulletYellowBack;
|
||||||
frontColor = Palette.bulletYellow;
|
frontColor = Palette.bulletYellow;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void update(Bullet b){
|
public void update(Bullet b){
|
||||||
super.update(b);
|
super.update(b);
|
||||||
b.getVelocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f));
|
b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,14 +110,14 @@ public class MissileBullets extends BulletList implements ContentList{
|
|||||||
trailColor = Color.GRAY;
|
trailColor = Color.GRAY;
|
||||||
backColor = Palette.bulletYellowBack;
|
backColor = Palette.bulletYellowBack;
|
||||||
frontColor = Palette.bulletYellow;
|
frontColor = Palette.bulletYellow;
|
||||||
hiteffect = BulletFx.blastExplosion;
|
hitEffect = BulletFx.blastExplosion;
|
||||||
despawneffect = BulletFx.blastExplosion;
|
despawnEffect = BulletFx.blastExplosion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Bullet b){
|
public void update(Bullet b){
|
||||||
super.update(b);
|
super.update(b);
|
||||||
b.getVelocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f));
|
b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class StandardBullets extends BulletList implements ContentList{
|
|||||||
bulletWidth = 11f;
|
bulletWidth = 11f;
|
||||||
bulletHeight = 14f;
|
bulletHeight = 14f;
|
||||||
lifetime = 40f;
|
lifetime = 40f;
|
||||||
despawneffect = BulletFx.hitBulletSmall;
|
despawnEffect = BulletFx.hitBulletSmall;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.anuke.arc.graphics.g2d.Lines;
|
|||||||
import io.anuke.arc.math.Angles;
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.arc.util.Tmp;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.content.fx.BlockFx;
|
import io.anuke.mindustry.content.fx.BlockFx;
|
||||||
@@ -41,8 +42,8 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
damageLightning = new BulletType(0.0001f, 0f){
|
damageLightning = new BulletType(0.0001f, 0f){
|
||||||
{
|
{
|
||||||
lifetime = Lightning.lifetime;
|
lifetime = Lightning.lifetime;
|
||||||
hiteffect = BulletFx.hitLancer;
|
hitEffect = BulletFx.hitLancer;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
status = StatusEffects.shocked;
|
status = StatusEffects.shocked;
|
||||||
statusIntensity = 1f;
|
statusIntensity = 1f;
|
||||||
}
|
}
|
||||||
@@ -52,8 +53,8 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float healPercent = 3f;
|
float healPercent = 3f;
|
||||||
|
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.hitLaser;
|
hitEffect = BulletFx.hitLaser;
|
||||||
despawneffect = BulletFx.hitLaser;
|
despawnEffect = BulletFx.hitLaser;
|
||||||
collidesTeam = true;
|
collidesTeam = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,9 +67,9 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
Draw.color(Palette.heal);
|
Draw.color(Palette.heal);
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
Lines.lineAngleCenter(b.x, b.y, b.angle(), 7f);
|
Lines.lineAngleCenter(b.x, b.y, b.rot(), 7f);
|
||||||
Draw.color(Color.WHITE);
|
Draw.color(Color.WHITE);
|
||||||
Lines.lineAngleCenter(b.x, b.y, b.angle(), 3f);
|
Lines.lineAngleCenter(b.x, b.y, b.rot(), 3f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,12 +92,12 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
collides = false;
|
collides = false;
|
||||||
collidesTiles = false;
|
collidesTiles = false;
|
||||||
drag = 0.03f;
|
drag = 0.03f;
|
||||||
hiteffect = despawneffect = Fx.none;
|
hitEffect = despawnEffect = Fx.none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
b.getVelocity().setLength(0.6f + Mathf.random(2f));
|
b.velocity().setLength(0.6f + Mathf.random(2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,12 +129,12 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
basicFlame = new BulletType(2.3f, 5){
|
basicFlame = new BulletType(2.3f, 5){
|
||||||
{
|
{
|
||||||
hitsize = 7f;
|
hitSize = 7f;
|
||||||
lifetime = 35f;
|
lifetime = 35f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
drag = 0.05f;
|
drag = 0.05f;
|
||||||
hiteffect = BulletFx.hitFlameSmall;
|
hitEffect = BulletFx.hitFlameSmall;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
status = StatusEffects.burning;
|
status = StatusEffects.burning;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,16 +150,16 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float length = 100f;
|
float length = 100f;
|
||||||
|
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.hitLancer;
|
hitEffect = BulletFx.hitLancer;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hitsize = 4;
|
hitSize = 4;
|
||||||
lifetime = 16f;
|
lifetime = 16f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length);
|
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,12 +167,12 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float f = Mathf.curve(b.fin(), 0f, 0.2f);
|
float f = Mathf.curve(b.fin(), 0f, 0.2f);
|
||||||
float baseLen = length * f;
|
float baseLen = length * f;
|
||||||
|
|
||||||
Lines.lineAngle(b.x, b.y, b.angle(), baseLen);
|
Lines.lineAngle(b.x, b.y, b.rot(), baseLen);
|
||||||
for(int s = 0; s < 3; s++){
|
for(int s = 0; s < 3; s++){
|
||||||
Draw.color(colors[s]);
|
Draw.color(colors[s]);
|
||||||
for(int i = 0; i < tscales.length; i++){
|
for(int i = 0; i < tscales.length; i++){
|
||||||
Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]);
|
Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]);
|
||||||
Lines.lineAngle(b.x, b.y, b.angle(), baseLen * lenscales[i]);
|
Lines.lineAngle(b.x, b.y, b.rot(), baseLen * lenscales[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -187,9 +188,9 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float length = 200f;
|
float length = 200f;
|
||||||
|
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.hitMeltdown;
|
hitEffect = BulletFx.hitMeltdown;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hitsize = 4;
|
hitSize = 4;
|
||||||
drawSize = 420f;
|
drawSize = 420f;
|
||||||
lifetime = 16f;
|
lifetime = 16f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
@@ -198,14 +199,14 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void update(Bullet b){
|
public void update(Bullet b){
|
||||||
if(b.timer.get(1, 5f)){
|
if(b.timer.get(1, 5f)){
|
||||||
Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length);
|
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length);
|
||||||
}
|
}
|
||||||
Effects.shake(1f, 1f, b.x, b.y);
|
Effects.shake(1f, 1f, b.x, b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hit(Bullet b, float hitx, float hity){
|
public void hit(Bullet b, float hitx, float hity){
|
||||||
Effects.effect(hiteffect, colors[2], hitx, hity);
|
Effects.effect(hitEffect, colors[2], hitx, hity);
|
||||||
if(Mathf.chance(0.4)){
|
if(Mathf.chance(0.4)){
|
||||||
Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f)));
|
Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f)));
|
||||||
}
|
}
|
||||||
@@ -215,13 +216,13 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
float baseLen = (length) * b.fout();
|
float baseLen = (length) * b.fout();
|
||||||
|
|
||||||
Lines.lineAngle(b.x, b.y, b.angle(), baseLen);
|
Lines.lineAngle(b.x, b.y, b.rot(), baseLen);
|
||||||
for(int s = 0; s < colors.length; s++){
|
for(int s = 0; s < colors.length; s++){
|
||||||
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
|
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
|
||||||
for(int i = 0; i < tscales.length; i++){
|
for(int i = 0; i < tscales.length; i++){
|
||||||
vector.trns(b.angle() + 180f, (lenscales[i] - 1f) * 35f);
|
Tmp.v1.trns(b.rot() + 180f, (lenscales[i] - 1f) * 35f);
|
||||||
Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
|
Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
|
||||||
Lines.lineAngle(b.x + vector.x, b.y + vector.y, b.angle(), baseLen * lenscales[i], CapStyle.none);
|
Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rot(), baseLen * lenscales[i], CapStyle.none);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -233,18 +234,16 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float raySpace = 2f;
|
float raySpace = 2f;
|
||||||
float rayLength = 80f;
|
float rayLength = 80f;
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.hitFuse;
|
hitEffect = BulletFx.hitFuse;
|
||||||
lifetime = 13f;
|
lifetime = 13f;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b) {
|
public void init(Bullet b) {
|
||||||
for (int i = 0; i < rays; i++) {
|
for (int i = 0; i < rays; i++) {
|
||||||
float offset = (i-rays/2)*raySpace;
|
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays/2))*20f);
|
||||||
vector.trns(b.angle(), 0.01f, offset);
|
|
||||||
Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), rayLength - Math.abs(i - (rays/2))*20f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,17 +252,15 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
super.draw(b);
|
super.draw(b);
|
||||||
Draw.color(Color.WHITE, Palette.surge, b.fin());
|
Draw.color(Color.WHITE, Palette.surge, b.fin());
|
||||||
for(int i = 0; i < 7; i++){
|
for(int i = 0; i < 7; i++){
|
||||||
vector.trns(b.angle(), i * 8f);
|
Tmp.v1.trns(b.rot(), i * 8f);
|
||||||
float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10);
|
float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10);
|
||||||
Shapes.tri(b.x + vector.x, b.y + vector.y, 4f, sl, b.angle() + 90);
|
Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90);
|
||||||
Shapes.tri(b.x + vector.x, b.y + vector.y, 4f, sl, b.angle() - 90);
|
Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90);
|
||||||
}
|
}
|
||||||
Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.angle());
|
Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.rot());
|
||||||
Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.angle() + 180f);
|
Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.rot() + 180f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
|
||||||
};
|
};
|
||||||
|
|
||||||
waterShot = new LiquidBulletType(Liquids.water){
|
waterShot = new LiquidBulletType(Liquids.water){
|
||||||
@@ -300,8 +297,8 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
lightning = new BulletType(0.001f, 12f){
|
lightning = new BulletType(0.001f, 12f){
|
||||||
{
|
{
|
||||||
lifetime = 1f;
|
lifetime = 1f;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hiteffect = BulletFx.hitLancer;
|
hitEffect = BulletFx.hitLancer;
|
||||||
keepVelocity = false;
|
keepVelocity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,15 +308,15 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.angle(), 30);
|
Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 30);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
arc = new BulletType(0.001f, 26){
|
arc = new BulletType(0.001f, 26){
|
||||||
{
|
{
|
||||||
lifetime = 1;
|
lifetime = 1;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hiteffect = BulletFx.hitLancer;
|
hitEffect = BulletFx.hitLancer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -328,7 +325,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.angle(), 36);
|
Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 36);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -336,8 +333,8 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
{
|
{
|
||||||
collidesTiles = false;
|
collidesTiles = false;
|
||||||
lifetime = 200f;
|
lifetime = 200f;
|
||||||
despawneffect = BlockFx.smeltsmoke;
|
despawnEffect = BlockFx.smeltsmoke;
|
||||||
hiteffect = BulletFx.hitBulletBig;
|
hitEffect = BulletFx.hitBulletBig;
|
||||||
drag = 0.005f;
|
drag = 0.005f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,10 +343,10 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
float w = 11f, h = 13f;
|
float w = 11f, h = 13f;
|
||||||
|
|
||||||
Draw.color(Palette.bulletYellowBack);
|
Draw.color(Palette.bulletYellowBack);
|
||||||
Draw.rect("shell-back", b.x, b.y, w, h, b.angle() + 90);
|
Draw.rect("shell-back", b.x, b.y, w, h, b.rot() + 90);
|
||||||
|
|
||||||
Draw.color(Palette.bulletYellow);
|
Draw.color(Palette.bulletYellow);
|
||||||
Draw.rect("shell", b.x, b.y, w, h, b.angle() + 90);
|
Draw.rect("shell", b.x, b.y, w, h, b.rot() + 90);
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
@@ -412,7 +409,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
for(int i = 0; i < data.items.length; i++){
|
for(int i = 0; i < data.items.length; i++){
|
||||||
int amountDropped = Mathf.random(0, data.items[i]);
|
int amountDropped = Mathf.random(0, data.items[i]);
|
||||||
if(amountDropped > 0){
|
if(amountDropped > 0){
|
||||||
float angle = b.angle() + Mathf.range(100f);
|
float angle = b.rot() + Mathf.range(100f);
|
||||||
Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i));
|
Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class WeaponBullets extends BulletList{
|
|||||||
{
|
{
|
||||||
bulletWidth = 9f;
|
bulletWidth = 9f;
|
||||||
bulletHeight = 13f;
|
bulletHeight = 13f;
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hitEffect = BulletFx.flakExplosion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class WeaponBullets extends BulletList{
|
|||||||
{
|
{
|
||||||
bulletWidth = 8f;
|
bulletWidth = 8f;
|
||||||
bulletHeight = 12f;
|
bulletHeight = 12f;
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hitEffect = BulletFx.flakExplosion;
|
||||||
backColor = Palette.lightOrange;
|
backColor = Palette.lightOrange;
|
||||||
frontColor = Palette.lightishOrange;
|
frontColor = Palette.lightishOrange;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ public class WeaponBullets extends BulletList{
|
|||||||
{
|
{
|
||||||
bulletWidth = 8f;
|
bulletWidth = 8f;
|
||||||
bulletHeight = 12f;
|
bulletHeight = 12f;
|
||||||
hiteffect = BlockFx.pulverize;
|
hitEffect = BlockFx.pulverize;
|
||||||
backColor = new Color(0x4f4f4fff);
|
backColor = new Color(0x4f4f4fff);
|
||||||
frontColor = Color.GRAY;
|
frontColor = Color.GRAY;
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ public class WeaponBullets extends BulletList{
|
|||||||
lifetime = 40f;
|
lifetime = 40f;
|
||||||
drag = 0.025f;
|
drag = 0.025f;
|
||||||
fragBullets = 5;
|
fragBullets = 5;
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hitEffect = BulletFx.flakExplosion;
|
||||||
fragBullet = tungstenShotgun;
|
fragBullet = tungstenShotgun;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
Call.onClientShapshot(lastSent++, Time.millis(), player.x, player.y,
|
Call.onClientShapshot(lastSent++, Time.millis(), player.x, player.y,
|
||||||
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
||||||
player.getVelocity().x, player.getVelocity().y,
|
player.velocity().x, player.velocity().y,
|
||||||
player.getMineTile(),
|
player.getMineTile(),
|
||||||
player.isBoosting, player.isShooting, requests,
|
player.isBoosting, player.isShooting, requests,
|
||||||
Core.camera.position.x, Core.camera.position.y,
|
Core.camera.position.x, Core.camera.position.y,
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
//set interpolator target to *new* position so it moves toward it
|
//set interpolator target to *new* position so it moves toward it
|
||||||
player.getInterpolator().read(player.x, player.y, newx, newy, sent, rotation, baseRotation);
|
player.getInterpolator().read(player.x, player.y, newx, newy, sent, rotation, baseRotation);
|
||||||
player.getVelocity().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player
|
player.velocity().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player
|
||||||
|
|
||||||
connection.lastRecievedClientSnapshot = snapshotID;
|
connection.lastRecievedClientSnapshot = snapshotID;
|
||||||
connection.lastRecievedClientTime = Time.millis();
|
connection.lastRecievedClientTime = Time.millis();
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class Damage{
|
|||||||
rect.height += expand * 2;
|
rect.height += expand * 2;
|
||||||
|
|
||||||
Consumer<Unit> cons = e -> {
|
Consumer<Unit> cons = e -> {
|
||||||
e.getHitbox(hitrect);
|
e.hitbox(hitrect);
|
||||||
Rectangle other = hitrect;
|
Rectangle other = hitrect;
|
||||||
other.y -= expand;
|
other.y -= expand;
|
||||||
other.x -= expand;
|
other.x -= expand;
|
||||||
@@ -134,7 +134,7 @@ public class Damage{
|
|||||||
Consumer<Unit> cons = entity -> {
|
Consumer<Unit> cons = entity -> {
|
||||||
if(!predicate.test(entity)) return;
|
if(!predicate.test(entity)) return;
|
||||||
|
|
||||||
entity.getHitbox(hitrect);
|
entity.hitbox(hitrect);
|
||||||
if(!hitrect.overlaps(rect)){
|
if(!hitrect.overlaps(rect)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ public class Damage{
|
|||||||
entity.damage(amount);
|
entity.damage(amount);
|
||||||
//TODO better velocity displacement
|
//TODO better velocity displacement
|
||||||
float dst = tr.set(entity.x - x, entity.y - y).len();
|
float dst = tr.set(entity.x - x, entity.y - y).len();
|
||||||
entity.getVelocity().add(tr.setLength((1f - dst / radius) * 2f));
|
entity.velocity().add(tr.setLength((1f - dst / radius) * 2f));
|
||||||
};
|
};
|
||||||
|
|
||||||
rect.setSize(radius * 2).setCenter(x, y);
|
rect.setSize(radius * 2).setCenter(x, y);
|
||||||
|
|||||||
@@ -100,17 +100,17 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitbox(Rectangle rectangle){
|
public void hitbox(Rectangle rectangle){
|
||||||
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rectangle rectangle){
|
||||||
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDrag(){
|
public float drag(){
|
||||||
return mech.drag;
|
return mech.drag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMass(){
|
public float mass(){
|
||||||
return mech.mass;
|
return mech.mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxVelocity(){
|
public float maxVelocity(){
|
||||||
return mech.maxSpeed;
|
return mech.maxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}else if(getCarry() != null){
|
}else if(getCarry() != null){
|
||||||
dropCarry();
|
dropCarry();
|
||||||
}else{
|
}else{
|
||||||
Unit unit = Units.getClosest(team, x, y, 8f, u -> !u.isFlying() && u.getMass() <= mech.carryWeight);
|
Unit unit = Units.getClosest(team, x, y, 8f, u -> !u.isFlying() && u.mass() <= mech.carryWeight);
|
||||||
|
|
||||||
if(unit != null){
|
if(unit != null){
|
||||||
carry(unit);
|
carry(unit);
|
||||||
@@ -675,7 +675,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
float expansion = 3f;
|
float expansion = 3f;
|
||||||
|
|
||||||
getHitbox(rect);
|
hitbox(rect);
|
||||||
rect.x -= expansion;
|
rect.x -= expansion;
|
||||||
rect.y -= expansion;
|
rect.y -= expansion;
|
||||||
rect.width += expansion * 2f;
|
rect.width += expansion * 2f;
|
||||||
@@ -732,7 +732,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector2 intercept =
|
Vector2 intercept =
|
||||||
Predict.intercept(x, y, target.getX(), target.getY(), target.getVelocity().x - velocity.x, target.getVelocity().y - velocity.y, getWeapon().getAmmo().bullet.speed);
|
Predict.intercept(x, y, target.getX(), target.getY(), target.velocity().x - velocity.x, target.velocity().y - velocity.y, getWeapon().getAmmo().bullet.speed);
|
||||||
|
|
||||||
pointerX = intercept.x;
|
pointerX = intercept.x;
|
||||||
pointerY = intercept.y;
|
pointerY = intercept.y;
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getVelocity(){
|
public Vector2 velocity(){
|
||||||
return Vector2.ZERO;
|
return Vector2.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getVelocity(){
|
public Vector2 velocity(){
|
||||||
return velocity;
|
return velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void avoidOthers(float scaling){
|
public void avoidOthers(float scaling){
|
||||||
getHitbox(queryRect);
|
hitbox(queryRect);
|
||||||
queryRect.setSize(queryRect.getWidth() * scaling);
|
queryRect.setSize(queryRect.getWidth() * scaling);
|
||||||
|
|
||||||
Units.getNearby(queryRect, t -> {
|
Units.getNearby(queryRect, t -> {
|
||||||
@@ -228,7 +228,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
|
|
||||||
if(isCarried()){ //carried units do not take into account velocity normally
|
if(isCarried()){ //carried units do not take into account velocity normally
|
||||||
set(carrier.getX(), carrier.getY());
|
set(carrier.getX(), carrier.getY());
|
||||||
velocity.set(carrier.getVelocity());
|
velocity.set(carrier.velocity());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
|
|
||||||
status.update(this);
|
status.update(this);
|
||||||
|
|
||||||
velocity.limit(getMaxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta());
|
velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta());
|
||||||
|
|
||||||
if(isFlying()){
|
if(isFlying()){
|
||||||
x += velocity.x * Time.delta();
|
x += velocity.x * Time.delta();
|
||||||
@@ -289,7 +289,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
if(Math.abs(py - y) <= 0.0001f) velocity.y = 0f;
|
if(Math.abs(py - y) <= 0.0001f) velocity.y = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
velocity.scl(Mathf.clamp(1f - getDrag() * (isFlying() ? 1f : floor.dragMultiplier) * Time.delta()));
|
velocity.scl(Mathf.clamp(1f - drag() * (isFlying() ? 1f : floor.dragMultiplier) * Time.delta()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyEffect(StatusEffect effect, float intensity){
|
public void applyEffect(StatusEffect effect, float intensity){
|
||||||
@@ -355,7 +355,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
|
|
||||||
public abstract float getArmor();
|
public abstract float getArmor();
|
||||||
|
|
||||||
public abstract float getMass();
|
public abstract float mass();
|
||||||
|
|
||||||
public abstract boolean isFlying();
|
public abstract boolean isFlying();
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class Units{
|
|||||||
Units.getNearby(rect, unit -> {
|
Units.getNearby(rect, unit -> {
|
||||||
if(boolResult) return;
|
if(boolResult) return;
|
||||||
if(!unit.isFlying()){
|
if(!unit.isFlying()){
|
||||||
unit.getHitbox(hitrect);
|
unit.hitbox(hitrect);
|
||||||
|
|
||||||
if(hitrect.overlaps(rect)){
|
if(hitrect.overlaps(rect)){
|
||||||
boolResult = true;
|
boolResult = true;
|
||||||
@@ -89,7 +89,7 @@ public class Units{
|
|||||||
Units.getNearby(rect, unit -> {
|
Units.getNearby(rect, unit -> {
|
||||||
if(value[0] || !pred.test(unit) || unit.isDead()) return;
|
if(value[0] || !pred.test(unit) || unit.isDead()) return;
|
||||||
if(!unit.isFlying()){
|
if(!unit.isFlying()){
|
||||||
unit.getHitbox(hitrect);
|
unit.hitbox(hitrect);
|
||||||
|
|
||||||
if(hitrect.overlaps(rect)){
|
if(hitrect.overlaps(rect)){
|
||||||
value[0] = true;
|
value[0] = true;
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{
|
|||||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
Draw.color(backColor);
|
||||||
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90);
|
||||||
Draw.color(frontColor);
|
Draw.color(frontColor);
|
||||||
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ public class BasicBulletType extends BulletType{
|
|||||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
Draw.color(backColor);
|
||||||
Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
|
Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.rot() - 90);
|
||||||
Draw.color(frontColor);
|
Draw.color(frontColor);
|
||||||
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
|
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.rot() - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class BasicBulletType extends BulletType{
|
|||||||
if(homingPower > 0.0001f){
|
if(homingPower > 0.0001f){
|
||||||
TargetTrait target = Units.getClosestTarget(b.getTeam(), b.x, b.y, homingRange);
|
TargetTrait target = Units.getClosestTarget(b.getTeam(), b.x, b.y, homingRange);
|
||||||
if(target != null){
|
if(target != null){
|
||||||
b.getVelocity().setAngle(Angles.moveToward(b.getVelocity().angle(), b.angleTo(target), homingPower * Time.delta()));
|
b.velocity().setAngle(Angles.moveToward(b.velocity().angle(), b.angleTo(target), homingPower * Time.delta()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ package io.anuke.mindustry.entities.bullet;
|
|||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
import io.anuke.arc.entities.impl.BulletEntity;
|
import io.anuke.arc.entities.impl.SolidEntity;
|
||||||
import io.anuke.arc.entities.trait.Entity;
|
import io.anuke.arc.entities.trait.*;
|
||||||
import io.anuke.arc.entities.trait.SolidTrait;
|
|
||||||
import io.anuke.arc.entities.trait.VelocityTrait;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Interval;
|
import io.anuke.arc.util.Interval;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.arc.util.Tmp;
|
||||||
|
import io.anuke.arc.util.pooling.Pool.Poolable;
|
||||||
import io.anuke.arc.util.pooling.Pools;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.entities.effect.Lightning;
|
import io.anuke.mindustry.entities.effect.Lightning;
|
||||||
@@ -26,14 +27,18 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Poolable, DrawTrait, VelocityTrait, TimeTrait, TeamTrait, SyncTrait, AbsorbTrait{
|
||||||
private static Vector2 vector = new Vector2();
|
|
||||||
public Interval timer = new Interval(3);
|
public Interval timer = new Interval(3);
|
||||||
|
|
||||||
private float lifeScl;
|
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;
|
||||||
|
|
||||||
|
protected BulletType type;
|
||||||
|
protected Entity owner;
|
||||||
|
protected float time;
|
||||||
|
|
||||||
/**Internal use only!*/
|
/**Internal use only!*/
|
||||||
public Bullet(){
|
public Bullet(){
|
||||||
}
|
}
|
||||||
@@ -62,7 +67,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
|
|
||||||
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
|
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
|
||||||
if(type.keepVelocity){
|
if(type.keepVelocity){
|
||||||
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).getVelocity() : Vector2.ZERO);
|
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).velocity() : Vector2.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bullet.team = team;
|
bullet.team = team;
|
||||||
@@ -83,6 +88,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
return create(type, parent.owner, parent.team, x, y, angle, velocityScl);
|
return create(type, parent.owner, parent.team, x, y, angle, velocityScl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Internal use only.*/
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void createBullet(BulletType type, float x, float y, float angle){
|
public static void createBullet(BulletType type, float x, float y, float angle){
|
||||||
create(type, null, Team.none, x, y, angle);
|
create(type, null, Team.none, x, y, angle);
|
||||||
@@ -97,12 +103,6 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
supressOnce = true;
|
supressOnce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void absorb(){
|
|
||||||
supressCollision = true;
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BulletType getBulletType(){
|
public BulletType getBulletType(){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -124,22 +124,29 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void absorb(){
|
||||||
|
supressCollision = true;
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float drawSize(){
|
public float drawSize(){
|
||||||
return type.drawSize;
|
return type.drawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDamage(){
|
public float damage(){
|
||||||
|
//todo hacky way to get damage, refactor
|
||||||
if(owner instanceof Unit){
|
if(owner instanceof Unit){
|
||||||
return super.getDamage() * ((Unit) owner).getDamageMultipler();
|
return type.damage * ((Unit) owner).getDamageMultipler();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(owner instanceof Lightning && data instanceof Float){
|
if(owner instanceof Lightning && data instanceof Float){
|
||||||
return (Float)data;
|
return (Float)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getDamage();
|
return type.damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,35 +179,44 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
type.draw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getShieldDamage(){
|
public float getShieldDamage(){
|
||||||
return Math.max(getDamage(), type.splashDamage);
|
return Math.max(damage(), type.splashDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean collides(SolidTrait other){
|
public boolean collides(SolidTrait other){
|
||||||
return type.collides && super.collides(other) && !supressCollision && !(other instanceof Unit && ((Unit) other).isFlying() && !type.collidesAir);
|
return type.collides && (other != owner && !(other instanceof DamageTrait)) && !supressCollision && !(other instanceof Unit && ((Unit) other).isFlying() && !type.collidesAir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collision(SolidTrait other, float x, float y){
|
public void collision(SolidTrait other, float x, float y){
|
||||||
super.collision(other, x, y);
|
if(!type.pierce) remove();
|
||||||
|
type.hit(this, x, y);
|
||||||
|
|
||||||
if(other instanceof Unit){
|
if(other instanceof Unit){
|
||||||
Unit unit = (Unit) other;
|
Unit unit = (Unit) other;
|
||||||
unit.getVelocity().add(vector.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.getMass()));
|
unit.velocity().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.mass()));
|
||||||
unit.applyEffect(type.status, type.statusIntensity);
|
unit.applyEffect(type.status, type.statusIntensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
super.update();
|
type.update(this);
|
||||||
|
|
||||||
|
x += velocity.x * Time.delta();
|
||||||
|
y += velocity.y * Time.delta();
|
||||||
|
|
||||||
|
velocity.scl(Mathf.clamp(1f - type.drag * Time.delta()));
|
||||||
|
|
||||||
|
time += Time.delta() * 1f/(lifeScl);
|
||||||
|
time = Mathf.clamp(time, 0, type.lifetime);
|
||||||
|
|
||||||
|
if(time >= type.lifetime){
|
||||||
|
if(!supressCollision) type.despawned(this);
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
if(type.hitTiles && collidesTiles() && !supressCollision && initialized){
|
if(type.hitTiles && collidesTiles() && !supressCollision && initialized){
|
||||||
world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> {
|
world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> {
|
||||||
@@ -234,20 +250,12 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateLife(){
|
|
||||||
time += Time.delta() * 1f/(lifeScl);
|
|
||||||
time = Mathf.clamp(time, 0, type.lifetime());
|
|
||||||
|
|
||||||
if(time >= type.lifetime){
|
|
||||||
if(!supressCollision) type.despawned(this);
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(){
|
public void reset(){
|
||||||
super.reset();
|
type = null;
|
||||||
|
owner = null;
|
||||||
|
velocity.setZero();
|
||||||
|
time = 0f;
|
||||||
timer.clear();
|
timer.clear();
|
||||||
lifeScl = 1f;
|
lifeScl = 1f;
|
||||||
team = null;
|
team = null;
|
||||||
@@ -257,6 +265,31 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hitbox(Rectangle rectangle){
|
||||||
|
rectangle.setSize(type.hitSize).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hitboxTile(Rectangle rectangle){
|
||||||
|
rectangle.setSize(type.hitSize).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float lifetime(){
|
||||||
|
return type.lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void time(float time){
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float time(){
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(){
|
public void removed(){
|
||||||
Pools.free(this);
|
Pools.free(this);
|
||||||
@@ -266,4 +299,44 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
public EntityGroup targetGroup(){
|
public EntityGroup targetGroup(){
|
||||||
return bulletGroup;
|
return bulletGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void added(){
|
||||||
|
type.init(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
type.draw(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float fin(){
|
||||||
|
return time / type.lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector2 velocity(){
|
||||||
|
return velocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void velocity(float speed, float angle){
|
||||||
|
velocity.set(0, speed).setAngle(angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void limit(float f){
|
||||||
|
velocity.limit(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the bullet's rotation in degrees.*/
|
||||||
|
public void rot(float angle){
|
||||||
|
velocity.setAngle(angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return the bullet's rotation.*/
|
||||||
|
public float rot(){
|
||||||
|
float angle = Mathf.atan2(velocity.x, velocity.y) * Mathf.radiansToDegrees;
|
||||||
|
if(angle < 0) angle += 360;
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,28 @@ package io.anuke.mindustry.entities.bullet;
|
|||||||
|
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.entities.Effects.Effect;
|
import io.anuke.arc.entities.Effects.Effect;
|
||||||
import io.anuke.arc.entities.impl.BaseBulletType;
|
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.StatusEffect;
|
import io.anuke.mindustry.type.StatusEffect;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
|
public abstract class BulletType extends Content{
|
||||||
public float lifetime;
|
public float lifetime;
|
||||||
public float speed;
|
public float speed;
|
||||||
public float damage;
|
public float damage;
|
||||||
public float hitsize = 4;
|
public float hitSize = 4;
|
||||||
public float drawSize = 20f;
|
public float drawSize = 40f;
|
||||||
public float drag = 0f;
|
public float drag = 0f;
|
||||||
public boolean pierce;
|
public boolean pierce;
|
||||||
public Effect hiteffect, despawneffect;
|
public Effect hitEffect, despawnEffect;
|
||||||
|
|
||||||
|
/**Effect created when shooting.*/
|
||||||
|
public Effect shootEffect = Fx.none;
|
||||||
|
/**Extra smoke effect created when shooting.*/
|
||||||
|
public Effect smokeEffect = Fx.none;
|
||||||
|
|
||||||
public float splashDamage = 0f;
|
public float splashDamage = 0f;
|
||||||
/**Knockback in velocity.*/
|
/**Knockback in velocity.*/
|
||||||
@@ -45,14 +49,12 @@ public abstract class BulletType extends Content implements BaseBulletType<Bulle
|
|||||||
/**Whether velocity is inherited from the shooter.*/
|
/**Whether velocity is inherited from the shooter.*/
|
||||||
public boolean keepVelocity = true;
|
public boolean keepVelocity = true;
|
||||||
|
|
||||||
protected Vector2 vector = new Vector2();
|
|
||||||
|
|
||||||
public BulletType(float speed, float damage){
|
public BulletType(float speed, float damage){
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
lifetime = 40f;
|
lifetime = 40f;
|
||||||
hiteffect = BulletFx.hitBulletSmall;
|
hitEffect = BulletFx.hitBulletSmall;
|
||||||
despawneffect = BulletFx.hitBulletSmall;
|
despawnEffect = BulletFx.hitBulletSmall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean collides(Bullet bullet, Tile tile){
|
public boolean collides(Bullet bullet, Tile tile){
|
||||||
@@ -63,59 +65,25 @@ public abstract class BulletType extends Content implements BaseBulletType<Bulle
|
|||||||
hit(b);
|
hit(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void hit(Bullet b){
|
||||||
public float drawSize(){
|
hit(b, b.x, b.y);
|
||||||
return 40;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float lifetime(){
|
|
||||||
return lifetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float speed(){
|
|
||||||
return speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float damage(){
|
|
||||||
return damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float hitSize(){
|
|
||||||
return hitsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float drag(){
|
|
||||||
return drag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean pierce(){
|
|
||||||
return pierce;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Effect hitEffect(){
|
|
||||||
return hiteffect;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Effect despawnEffect(){
|
|
||||||
return despawneffect;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hit(Bullet b, float hitx, float hity){
|
public void hit(Bullet b, float hitx, float hity){
|
||||||
Effects.effect(hiteffect, hitx, hity, b.angle());
|
Effects.effect(hitEffect, hitx, hity, b.rot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void despawned(Bullet b){
|
public void despawned(Bullet b){
|
||||||
Effects.effect(despawneffect, b.x, b.y, b.angle());
|
Effects.effect(despawnEffect, b.x, b.y, b.rot());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Bullet b){
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(Bullet b){
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Bullet b){
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public abstract class FlakBulletType extends BasicBulletType{
|
|||||||
super(speed, damage, "shell");
|
super(speed, damage, "shell");
|
||||||
splashDamage = 15f;
|
splashDamage = 15f;
|
||||||
splashDamageRadius = 34f;
|
splashDamageRadius = 34f;
|
||||||
hiteffect = BulletFx.flakExplosionBig;
|
hitEffect = BulletFx.flakExplosionBig;
|
||||||
bulletWidth = 8f;
|
bulletWidth = 8f;
|
||||||
bulletHeight = 10f;
|
bulletHeight = 10f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class LiquidBulletType extends BulletType{
|
|||||||
this.liquid = liquid;
|
this.liquid = liquid;
|
||||||
|
|
||||||
lifetime = 70f;
|
lifetime = 70f;
|
||||||
despawneffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hiteffect = BulletFx.hitLiquid;
|
hitEffect = BulletFx.hitLiquid;
|
||||||
drag = 0.01f;
|
drag = 0.01f;
|
||||||
knockback = 0.5f;
|
knockback = 0.5f;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public class LiquidBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hit(Bullet b, float hitx, float hity){
|
public void hit(Bullet b, float hitx, float hity){
|
||||||
Effects.effect(hiteffect, liquid.color, hitx, hity);
|
Effects.effect(hitEffect, liquid.color, hitx, hity);
|
||||||
Puddle.deposit(world.tileWorld(hitx, hity), liquid, 5f);
|
Puddle.deposit(world.tileWorld(hitx, hity), liquid, 5f);
|
||||||
|
|
||||||
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
||||||
|
|||||||
@@ -156,12 +156,12 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitbox(Rectangle rectangle){
|
public void hitbox(Rectangle rectangle){
|
||||||
rectangle.setCenter(x, y).setSize(tilesize);
|
rectangle.setCenter(x, y).setSize(tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rectangle rectangle){
|
||||||
rectangle.setCenter(x, y).setSize(0f);
|
rectangle.setCenter(x, y).setSize(0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,12 +203,12 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
Units.getNearby(rect.setSize(Mathf.clamp(amount / (maxLiquid / 1.5f)) * 10f).setCenter(x, y), unit -> {
|
Units.getNearby(rect.setSize(Mathf.clamp(amount / (maxLiquid / 1.5f)) * 10f).setCenter(x, y), unit -> {
|
||||||
if(unit.isFlying()) return;
|
if(unit.isFlying()) return;
|
||||||
|
|
||||||
unit.getHitbox(rect2);
|
unit.hitbox(rect2);
|
||||||
if(!rect.overlaps(rect2)) return;
|
if(!rect.overlaps(rect2)) return;
|
||||||
|
|
||||||
unit.applyEffect(liquid.effect, 0.5f);
|
unit.applyEffect(liquid.effect, 0.5f);
|
||||||
|
|
||||||
if(unit.getVelocity().len() > 0.1){
|
if(unit.velocity().len() > 0.1){
|
||||||
Effects.effect(BlockFx.ripple, liquid.color, unit.x, unit.y);
|
Effects.effect(BlockFx.ripple, liquid.color, unit.x, unit.y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ public interface AbsorbTrait extends Entity, TeamTrait, DamageTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
default float getShieldDamage(){
|
default float getShieldDamage(){
|
||||||
return getDamage();
|
return damage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ public interface TargetTrait extends Position, VelocityTrait{
|
|||||||
if(this instanceof SolidTrait){
|
if(this instanceof SolidTrait){
|
||||||
return ((SolidTrait) this).getDeltaX();
|
return ((SolidTrait) this).getDeltaX();
|
||||||
}
|
}
|
||||||
return getVelocity().x;
|
return velocity().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
default float getTargetVelocityY(){
|
default float getTargetVelocityY(){
|
||||||
if(this instanceof SolidTrait){
|
if(this instanceof SolidTrait){
|
||||||
return ((SolidTrait) this).getDeltaY();
|
return ((SolidTrait) this).getDeltaY();
|
||||||
}
|
}
|
||||||
return getVelocity().y;
|
return velocity().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDrag(){
|
public float drag(){
|
||||||
return type.drag;
|
return type.drag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMass(){
|
public float mass(){
|
||||||
return type.mass;
|
return type.mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxVelocity(){
|
public float maxVelocity(){
|
||||||
return type.maxVelocity;
|
return type.maxVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,12 +357,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitbox(Rectangle rectangle){
|
public void hitbox(Rectangle rectangle){
|
||||||
rectangle.setSize(type.hitsize).setCenter(x, y);
|
rectangle.setSize(type.hitsize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rectangle rectangle){
|
||||||
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -559,7 +559,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
player.dropCarry(); //drop off unit
|
player.dropCarry(); //drop off unit
|
||||||
}else{
|
}else{
|
||||||
Unit unit = Units.getClosest(player.getTeam(), Core.input.mouseWorld(x, y).x, Core.input.mouseWorld(x, y).y, 4f, u -> !u.isFlying() && u.getMass() <= player.mech.carryWeight);
|
Unit unit = Units.getClosest(player.getTeam(), Core.input.mouseWorld(x, y).x, Core.input.mouseWorld(x, y).y, 4f, u -> !u.isFlying() && u.mass() <= player.mech.carryWeight);
|
||||||
|
|
||||||
if(unit != null){
|
if(unit != null){
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.type;
|
package io.anuke.mindustry.type;
|
||||||
|
|
||||||
/**Used to store ammo amounts in turrets.*/
|
/**Used to store ammo amounts in turrets.
|
||||||
|
* TODO move inside turret class?*/
|
||||||
public class AmmoEntry{
|
public class AmmoEntry{
|
||||||
public AmmoType type;
|
public AmmoType type;
|
||||||
public int amount;
|
public int amount;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class Weapon extends Content{
|
|||||||
|
|
||||||
weapon.tr.trns(rotation + 180f, ammo.recoil);
|
weapon.tr.trns(rotation + 180f, ammo.recoil);
|
||||||
|
|
||||||
shooter.getVelocity().add(weapon.tr);
|
shooter.velocity().add(weapon.tr);
|
||||||
|
|
||||||
weapon.tr.trns(rotation, 3f);
|
weapon.tr.trns(rotation, 3f);
|
||||||
|
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ public class Block extends BaseBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleBulletHit(TileEntity entity, Bullet bullet){
|
public void handleBulletHit(TileEntity entity, Bullet bullet){
|
||||||
entity.damage(bullet.getDamage());
|
entity.damage(bullet.damage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getVelocity(){
|
public Vector2 velocity(){
|
||||||
return Vector2.ZERO;
|
return Vector2.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ public class DeflectorWall extends Wall{
|
|||||||
super.handleBulletHit(entity, bullet);
|
super.handleBulletHit(entity, bullet);
|
||||||
|
|
||||||
//doesn't reflect powerful bullets
|
//doesn't reflect powerful bullets
|
||||||
if(bullet.getDamage() > maxDamageDeflect) return;
|
if(bullet.damage() > maxDamageDeflect) return;
|
||||||
|
|
||||||
float penX = Math.abs(entity.x - bullet.x), penY = Math.abs(entity.y - bullet.y);
|
float penX = Math.abs(entity.x - bullet.x), penY = Math.abs(entity.y - bullet.y);
|
||||||
|
|
||||||
bullet.getHitbox(rect2);
|
bullet.hitbox(rect2);
|
||||||
|
|
||||||
Vector2 position = Geometry.raycastRect(bullet.x, bullet.y, bullet.x + bullet.getVelocity().x, bullet.y + bullet.getVelocity().y,
|
Vector2 position = Geometry.raycastRect(bullet.x, bullet.y, bullet.x + bullet.velocity().x, bullet.y + bullet.velocity().y,
|
||||||
rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height));
|
rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height));
|
||||||
|
|
||||||
if(position != null){
|
if(position != null){
|
||||||
@@ -63,9 +63,9 @@ public class DeflectorWall extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(penX > penY){
|
if(penX > penY){
|
||||||
bullet.getVelocity().x *= -1;
|
bullet.velocity().x *= -1;
|
||||||
}else{
|
}else{
|
||||||
bullet.getVelocity().y *= -1;
|
bullet.velocity().y *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bullet.updateVelocity();
|
bullet.updateVelocity();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class SurgeWall extends Wall{
|
|||||||
public void handleBulletHit(TileEntity entity, Bullet bullet){
|
public void handleBulletHit(TileEntity entity, Bullet bullet){
|
||||||
super.handleBulletHit(entity, bullet);
|
super.handleBulletHit(entity, bullet);
|
||||||
if(Mathf.chance(lightningChance)){
|
if(Mathf.chance(lightningChance)){
|
||||||
Lightning.create(entity.getTeam(), Palette.surge, lightningDamage, bullet.x, bullet.y, bullet.angle() + 180f, lightningLength);
|
Lightning.create(entity.getTeam(), Palette.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public class LaserTurret extends PowerTurret{
|
|||||||
LaserTurretEntity entity = tile.entity();
|
LaserTurretEntity entity = tile.entity();
|
||||||
|
|
||||||
if(entity.bulletLife > 0 && entity.bullet != null){
|
if(entity.bulletLife > 0 && entity.bullet != null){
|
||||||
tr.trns(entity.rotation, size * tilesize / 2, 0f);
|
tr.trns(entity.rotation, size * tilesize / 2f, 0f);
|
||||||
entity.bullet.setRotation(entity.rotation);
|
entity.bullet.rot(entity.rotation);
|
||||||
entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y);
|
entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y);
|
||||||
entity.bullet.time(0f);
|
entity.bullet.time(0f);
|
||||||
entity.heat = 1f;
|
entity.heat = 1f;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class Conveyor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(entity.convey.size * itemSpace < 0.9f){
|
if(entity.convey.size * itemSpace < 0.9f){
|
||||||
unit.getVelocity().add((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta());
|
unit.velocity().add((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class UnitFactory extends Block{
|
|||||||
unit.setSpawner(tile);
|
unit.setSpawner(tile);
|
||||||
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
||||||
unit.add();
|
unit.add();
|
||||||
unit.getVelocity().y = factory.launchVelocity;
|
unit.velocity().y = factory.launchVelocity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user