Removed dependency on old BulletEntity/BaseBulletType classes
This commit is contained in:
@@ -110,7 +110,7 @@ public class Damage{
|
||||
rect.height += expand * 2;
|
||||
|
||||
Consumer<Unit> cons = e -> {
|
||||
e.getHitbox(hitrect);
|
||||
e.hitbox(hitrect);
|
||||
Rectangle other = hitrect;
|
||||
other.y -= expand;
|
||||
other.x -= expand;
|
||||
@@ -134,7 +134,7 @@ public class Damage{
|
||||
Consumer<Unit> cons = entity -> {
|
||||
if(!predicate.test(entity)) return;
|
||||
|
||||
entity.getHitbox(hitrect);
|
||||
entity.hitbox(hitrect);
|
||||
if(!hitrect.overlaps(rect)){
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class Damage{
|
||||
entity.damage(amount);
|
||||
//TODO better velocity displacement
|
||||
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);
|
||||
|
||||
@@ -100,17 +100,17 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitboxTile(Rectangle rectangle){
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDrag(){
|
||||
public float drag(){
|
||||
return mech.drag;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMass(){
|
||||
public float mass(){
|
||||
return mech.mass;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxVelocity(){
|
||||
public float maxVelocity(){
|
||||
return mech.maxSpeed;
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}else if(getCarry() != null){
|
||||
dropCarry();
|
||||
}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){
|
||||
carry(unit);
|
||||
@@ -675,7 +675,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
float expansion = 3f;
|
||||
|
||||
getHitbox(rect);
|
||||
hitbox(rect);
|
||||
rect.x -= expansion;
|
||||
rect.y -= expansion;
|
||||
rect.width += expansion * 2f;
|
||||
@@ -732,7 +732,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
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;
|
||||
pointerY = intercept.y;
|
||||
|
||||
@@ -257,7 +257,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 getVelocity(){
|
||||
public Vector2 velocity(){
|
||||
return Vector2.ZERO;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 getVelocity(){
|
||||
public Vector2 velocity(){
|
||||
return velocity;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
public void avoidOthers(float scaling){
|
||||
getHitbox(queryRect);
|
||||
hitbox(queryRect);
|
||||
queryRect.setSize(queryRect.getWidth() * scaling);
|
||||
|
||||
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
|
||||
set(carrier.getX(), carrier.getY());
|
||||
velocity.set(carrier.getVelocity());
|
||||
velocity.set(carrier.velocity());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
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()){
|
||||
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;
|
||||
}
|
||||
|
||||
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){
|
||||
@@ -355,7 +355,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
public abstract float getArmor();
|
||||
|
||||
public abstract float getMass();
|
||||
public abstract float mass();
|
||||
|
||||
public abstract boolean isFlying();
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Units{
|
||||
Units.getNearby(rect, unit -> {
|
||||
if(boolResult) return;
|
||||
if(!unit.isFlying()){
|
||||
unit.getHitbox(hitrect);
|
||||
unit.hitbox(hitrect);
|
||||
|
||||
if(hitrect.overlaps(rect)){
|
||||
boolResult = true;
|
||||
@@ -89,7 +89,7 @@ public class Units{
|
||||
Units.getNearby(rect, unit -> {
|
||||
if(value[0] || !pred.test(unit) || unit.isDead()) return;
|
||||
if(!unit.isFlying()){
|
||||
unit.getHitbox(hitrect);
|
||||
unit.hitbox(hitrect);
|
||||
|
||||
if(hitrect.overlaps(rect)){
|
||||
value[0] = true;
|
||||
|
||||
@@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||
|
||||
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.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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class BasicBulletType extends BulletType{
|
||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||
|
||||
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.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();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class BasicBulletType extends BulletType{
|
||||
if(homingPower > 0.0001f){
|
||||
TargetTrait target = Units.getClosestTarget(b.getTeam(), b.x, b.y, homingRange);
|
||||
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.Remote;
|
||||
import io.anuke.arc.entities.EntityGroup;
|
||||
import io.anuke.arc.entities.impl.BulletEntity;
|
||||
import io.anuke.arc.entities.trait.Entity;
|
||||
import io.anuke.arc.entities.trait.SolidTrait;
|
||||
import io.anuke.arc.entities.trait.VelocityTrait;
|
||||
import io.anuke.arc.entities.impl.SolidEntity;
|
||||
import io.anuke.arc.entities.trait.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Interval;
|
||||
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.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.effect.Lightning;
|
||||
@@ -26,14 +27,18 @@ import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
||||
private static Vector2 vector = new Vector2();
|
||||
public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Poolable, DrawTrait, VelocityTrait, TimeTrait, TeamTrait, SyncTrait, AbsorbTrait{
|
||||
public Interval timer = new Interval(3);
|
||||
|
||||
private float lifeScl;
|
||||
private Team team;
|
||||
private Object data;
|
||||
private boolean supressCollision, supressOnce, initialized;
|
||||
|
||||
protected BulletType type;
|
||||
protected Entity owner;
|
||||
protected float time;
|
||||
|
||||
/**Internal use only!*/
|
||||
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);
|
||||
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;
|
||||
@@ -83,6 +88,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
return create(type, parent.owner, parent.team, x, y, angle, velocityScl);
|
||||
}
|
||||
|
||||
/**Internal use only.*/
|
||||
@Remote(called = Loc.server)
|
||||
public static void createBullet(BulletType type, float x, float y, float angle){
|
||||
create(type, null, Team.none, x, y, angle);
|
||||
@@ -97,12 +103,6 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
supressOnce = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorb(){
|
||||
supressCollision = true;
|
||||
remove();
|
||||
}
|
||||
|
||||
public BulletType getBulletType(){
|
||||
return type;
|
||||
}
|
||||
@@ -124,22 +124,29 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorb(){
|
||||
supressCollision = true;
|
||||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float drawSize(){
|
||||
return type.drawSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamage(){
|
||||
public float damage(){
|
||||
//todo hacky way to get damage, refactor
|
||||
if(owner instanceof Unit){
|
||||
return super.getDamage() * ((Unit) owner).getDamageMultipler();
|
||||
return type.damage * ((Unit) owner).getDamageMultipler();
|
||||
}
|
||||
|
||||
if(owner instanceof Lightning && data instanceof Float){
|
||||
return (Float)data;
|
||||
}
|
||||
|
||||
return super.getDamage();
|
||||
return type.damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,35 +179,44 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
return team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
type.draw(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShieldDamage(){
|
||||
return Math.max(getDamage(), type.splashDamage);
|
||||
return Math.max(damage(), type.splashDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
public void reset(){
|
||||
super.reset();
|
||||
type = null;
|
||||
owner = null;
|
||||
velocity.setZero();
|
||||
time = 0f;
|
||||
timer.clear();
|
||||
lifeScl = 1f;
|
||||
team = null;
|
||||
@@ -257,6 +265,31 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
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
|
||||
public void removed(){
|
||||
Pools.free(this);
|
||||
@@ -266,4 +299,44 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
public EntityGroup targetGroup(){
|
||||
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.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.fx.BulletFx;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
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 speed;
|
||||
public float damage;
|
||||
public float hitsize = 4;
|
||||
public float drawSize = 20f;
|
||||
public float hitSize = 4;
|
||||
public float drawSize = 40f;
|
||||
public float drag = 0f;
|
||||
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;
|
||||
/**Knockback in velocity.*/
|
||||
@@ -45,14 +49,12 @@ public abstract class BulletType extends Content implements BaseBulletType<Bulle
|
||||
/**Whether velocity is inherited from the shooter.*/
|
||||
public boolean keepVelocity = true;
|
||||
|
||||
protected Vector2 vector = new Vector2();
|
||||
|
||||
public BulletType(float speed, float damage){
|
||||
this.speed = speed;
|
||||
this.damage = damage;
|
||||
lifetime = 40f;
|
||||
hiteffect = BulletFx.hitBulletSmall;
|
||||
despawneffect = BulletFx.hitBulletSmall;
|
||||
hitEffect = BulletFx.hitBulletSmall;
|
||||
despawnEffect = BulletFx.hitBulletSmall;
|
||||
}
|
||||
|
||||
public boolean collides(Bullet bullet, Tile tile){
|
||||
@@ -63,59 +65,25 @@ public abstract class BulletType extends Content implements BaseBulletType<Bulle
|
||||
hit(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float drawSize(){
|
||||
return 40;
|
||||
public void hit(Bullet b){
|
||||
hit(b, b.x, b.y);
|
||||
}
|
||||
|
||||
@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){
|
||||
Effects.effect(hiteffect, hitx, hity, b.angle());
|
||||
Effects.effect(hitEffect, hitx, hity, b.rot());
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -13,7 +13,7 @@ public abstract class FlakBulletType extends BasicBulletType{
|
||||
super(speed, damage, "shell");
|
||||
splashDamage = 15f;
|
||||
splashDamageRadius = 34f;
|
||||
hiteffect = BulletFx.flakExplosionBig;
|
||||
hitEffect = BulletFx.flakExplosionBig;
|
||||
bulletWidth = 8f;
|
||||
bulletHeight = 10f;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public class LiquidBulletType extends BulletType{
|
||||
this.liquid = liquid;
|
||||
|
||||
lifetime = 70f;
|
||||
despawneffect = Fx.none;
|
||||
hiteffect = BulletFx.hitLiquid;
|
||||
despawnEffect = Fx.none;
|
||||
hitEffect = BulletFx.hitLiquid;
|
||||
drag = 0.01f;
|
||||
knockback = 0.5f;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class LiquidBulletType extends BulletType{
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
||||
|
||||
@@ -156,12 +156,12 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setCenter(x, y).setSize(tilesize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitboxTile(Rectangle rectangle){
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
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 -> {
|
||||
if(unit.isFlying()) return;
|
||||
|
||||
unit.getHitbox(rect2);
|
||||
unit.hitbox(rect2);
|
||||
if(!rect.overlaps(rect2)) return;
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,6 +11,6 @@ public interface AbsorbTrait extends Entity, TeamTrait, DamageTrait{
|
||||
}
|
||||
|
||||
default float getShieldDamage(){
|
||||
return getDamage();
|
||||
return damage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ public interface TargetTrait extends Position, VelocityTrait{
|
||||
if(this instanceof SolidTrait){
|
||||
return ((SolidTrait) this).getDeltaX();
|
||||
}
|
||||
return getVelocity().x;
|
||||
return velocity().x;
|
||||
}
|
||||
|
||||
default float getTargetVelocityY(){
|
||||
if(this instanceof SolidTrait){
|
||||
return ((SolidTrait) this).getDeltaY();
|
||||
}
|
||||
return getVelocity().y;
|
||||
return velocity().y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDrag(){
|
||||
public float drag(){
|
||||
return type.drag;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMass(){
|
||||
public float mass(){
|
||||
return type.mass;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxVelocity(){
|
||||
public float maxVelocity(){
|
||||
return type.maxVelocity;
|
||||
}
|
||||
|
||||
@@ -357,12 +357,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitsize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHitboxTile(Rectangle rectangle){
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user