More cleanup
This commit is contained in:
@@ -3,7 +3,6 @@ package mindustry.entities.bullet;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
|
||||
//TODO scale velocity depending on fslope()
|
||||
@@ -24,7 +23,7 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
public void update(Bulletc b){
|
||||
super.update(b);
|
||||
|
||||
if(b.timer.get(0, 3 + b.fslope() * 2f)){
|
||||
@@ -33,7 +32,7 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
float baseScale = 0.7f;
|
||||
float scale = (baseScale + b.fslope() * (1f - baseScale));
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
/** An extended BulletType for most ammo-based bullets shot from turrets and units. */
|
||||
@@ -34,7 +34,7 @@ public class BasicBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||
|
||||
Draw.color(backColor);
|
||||
|
||||
@@ -2,13 +2,16 @@ package mindustry.entities.bullet;
|
||||
|
||||
import arc.audio.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@@ -97,20 +100,20 @@ public abstract class BulletType extends Content{
|
||||
return speed * lifetime * (1f - drag);
|
||||
}
|
||||
|
||||
public boolean collides(Bullet bullet, Tile tile){
|
||||
public boolean collides(Bulletc bullet, Tile tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
public void hitTile(Bullet b, Tile tile){
|
||||
public void hitTile(Bulletc b, Tile tile){
|
||||
hit(b);
|
||||
}
|
||||
|
||||
public void hit(Bullet b){
|
||||
hit(b, b.x, b.y);
|
||||
public void hit(Bulletc b){
|
||||
hit(b, b.getX(), b.getY());
|
||||
}
|
||||
|
||||
public void hit(Bullet b, float x, float y){
|
||||
hitEffect.at(x, y, b.rot());
|
||||
public void hit(Bulletc b, float x, float y){
|
||||
hitEffect.at(x, y, b.getRotation());
|
||||
hitSound.at(b);
|
||||
|
||||
Effects.shake(hitShake, hitShake, b);
|
||||
@@ -119,7 +122,7 @@ public abstract class BulletType extends Content{
|
||||
for(int i = 0; i < fragBullets; i++){
|
||||
float len = Mathf.random(1f, 7f);
|
||||
float a = Mathf.random(360f);
|
||||
Bullet.create(fragBullet, b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax));
|
||||
fragBullet.create(b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,8 +135,8 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
}
|
||||
|
||||
public void despawned(Bullet b){
|
||||
despawnEffect.at(b.x, b.y, b.rot());
|
||||
public void despawned(Bulletc b){
|
||||
despawnEffect.at(b.getX(), b.getY(), b.getRotation());
|
||||
hitSound.at(b);
|
||||
|
||||
if(fragBullet != null || splashDamageRadius > 0){
|
||||
@@ -145,23 +148,23 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
}
|
||||
|
||||
public void init(Bullet b){
|
||||
if(killShooter && b.getOwner() instanceof HealthTrait){
|
||||
((HealthTrait)b.getOwner()).kill();
|
||||
public void init(Bulletc b){
|
||||
if(killShooter && b.getOwner() instanceof Healthc){
|
||||
((Healthc)b.getOwner()).kill();
|
||||
}
|
||||
|
||||
if(instantDisappear){
|
||||
b.time(lifetime);
|
||||
b.setTime(lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(Bullet b){
|
||||
public void update(Bulletc b){
|
||||
|
||||
if(homingPower > 0.0001f){
|
||||
TargetTrait target = Units.closestTarget(b.getTeam(), b.x, b.y, homingRange, e -> !e.isFlying() || collidesAir);
|
||||
Teamc target = Units.closestTarget(b.getTeam(), b.x, b.y, homingRange, e -> !e.isFlying() || collidesAir);
|
||||
if(target != null){
|
||||
b.velocity().setAngle(Mathf.slerpDelta(b.velocity().angle(), b.angleTo(target), 0.08f));
|
||||
}
|
||||
@@ -172,4 +175,61 @@ public abstract class BulletType extends Content{
|
||||
public ContentType getContentType(){
|
||||
return ContentType.bullet;
|
||||
}
|
||||
|
||||
//TODO change 'create' to 'at'
|
||||
|
||||
public Bulletc create(Teamc owner, float x, float y, float angle){
|
||||
return create(owner, owner.getTeam(), x, y, angle);
|
||||
}
|
||||
|
||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle){
|
||||
return create(owner, team, x, y, angle, 1f);
|
||||
}
|
||||
|
||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl){
|
||||
return create(owner, team, x, y, angle, velocityScl, 1f, null);
|
||||
}
|
||||
|
||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
|
||||
return create(owner, team, x, y, angle, velocityScl, lifetimeScl, null);
|
||||
}
|
||||
|
||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
||||
|
||||
|
||||
//TODO implement
|
||||
return null;
|
||||
/*
|
||||
Bullet bullet = Pools.obtain(Bullet.class, Bullet::new);
|
||||
bullet.type = type;
|
||||
bullet.owner = owner;
|
||||
bullet.data = data;
|
||||
|
||||
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
|
||||
if(type.keepVelocity){
|
||||
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).velocity() : Vec2.ZERO);
|
||||
}
|
||||
|
||||
bullet.team = team;
|
||||
bullet.type = type;
|
||||
bullet.lifeScl = lifetimeScl;
|
||||
|
||||
bullet.set(x - bullet.velocity.x * Time.delta(), y - bullet.velocity.y * Time.delta());
|
||||
bullet.add();
|
||||
|
||||
return bullet;*/
|
||||
}
|
||||
|
||||
public Bulletc create(Bulletc parent, float x, float y, float angle){
|
||||
return create(parent.getOwner(), parent.getTeam(), x, y, angle);
|
||||
}
|
||||
|
||||
public Bulletc create(Bulletc parent, float x, float y, float angle, float velocityScl){
|
||||
return create(parent.getOwner(), parent.getTeam(), x, y, angle, velocityScl);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void createBullet(BulletType type, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
|
||||
type.create(null, team, x, y, angle, velocityScl, lifetimeScl, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class FlakBulletType extends BasicBulletType{
|
||||
protected static Rect rect = new Rect();
|
||||
@@ -24,7 +24,7 @@ public class FlakBulletType extends BasicBulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
public void update(Bulletc b){
|
||||
super.update(b);
|
||||
if(b.getData() instanceof Integer) return;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mindustry.entities.bullet;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
@@ -28,12 +28,12 @@ public class HealBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collides(Bullet b, Tile tile){
|
||||
public boolean collides(Bulletc b, Tile tile){
|
||||
return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
Draw.color(backColor);
|
||||
Lines.stroke(bulletWidth);
|
||||
Lines.lineAngleCenter(b.x, b.y, b.rot(), bulletHeight);
|
||||
@@ -43,7 +43,7 @@ public class HealBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitTile(Bullet b, Tile tile){
|
||||
public void hitTile(Bulletc b, Tile tile){
|
||||
super.hit(b);
|
||||
tile = tile.link();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class LaserBulletType extends BulletType{
|
||||
@@ -40,12 +40,12 @@ public class LaserBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Bullet b){
|
||||
public void init(Bulletc b){
|
||||
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
float f = Mathf.curve(b.fin(), 0f, 0.2f);
|
||||
float baseLen = length * f;
|
||||
float cwidth = width;
|
||||
|
||||
@@ -3,7 +3,7 @@ package mindustry.entities.bullet;
|
||||
import arc.graphics.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class LightningBulletType extends BulletType{
|
||||
@@ -20,11 +20,11 @@ public class LightningBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Bullet b){
|
||||
public void init(Bulletc b){
|
||||
Lightning.create(b.getTeam(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class LiquidBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
public void update(Bulletc b){
|
||||
super.update(b);
|
||||
|
||||
if(liquid.canExtinguish()){
|
||||
@@ -59,14 +58,14 @@ public class LiquidBulletType extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
Draw.color(liquid.color, Color.white, b.fout() / 100f);
|
||||
|
||||
Fill.circle(b.x, b.y, 0.5f + b.fout() * 2.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hit(Bullet b, float hitx, float hity){
|
||||
public void hit(Bulletc b, float hitx, float hity){
|
||||
hitEffect.at(liquid.color, hitx, hity);
|
||||
Puddle.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import arc.graphics.g2d.Draw;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(mindustry.entities.type.Bullet b){
|
||||
public void draw(Bulletc b){
|
||||
float w = 11f, h = 13f;
|
||||
|
||||
Draw.color(Pal.bulletYellowBack);
|
||||
@@ -36,7 +36,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(mindustry.entities.type.Bullet b){
|
||||
public void update(Bulletc b){
|
||||
//data MUST be an instance of DriverBulletData
|
||||
if(!(b.getData() instanceof DriverBulletData)){
|
||||
hit(b);
|
||||
@@ -82,7 +82,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void despawned(mindustry.entities.type.Bullet b){
|
||||
public void despawned(Bulletc b){
|
||||
super.despawned(b);
|
||||
|
||||
if(!(b.getData() instanceof DriverBulletData)) return;
|
||||
@@ -99,7 +99,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hit(Bullet b, float hitx, float hity){
|
||||
public void hit(Bulletc b, float hitx, float hity){
|
||||
super.hit(b, hitx, hity);
|
||||
despawned(b);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import arc.graphics.Color;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
@@ -27,7 +26,7 @@ public class MissileBulletType extends BasicBulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
public void update(Bulletc b){
|
||||
super.update(b);
|
||||
|
||||
if(Mathf.chance(Time.delta() * 0.2)){
|
||||
|
||||
Reference in New Issue
Block a user