1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-10-06 12:57:17 +03:00

Let bullets have speed = 0

This commit is contained in:
Anuken 2021-06-04 08:53:39 -04:00
parent 6ceb1d5058
commit 1bbb52877f
7 changed files with 23 additions and 13 deletions

View File

@ -0,0 +1 @@
{version:1,fields:[{name:collided,type:arc.struct.IntSeq},{name:damage,type:float},{name:data,type:java.lang.Object},{name:fdata,type:float},{name:lifetime,type:float},{name:owner,type:mindustry.gen.Entityc},{name:rotation,type:float},{name:team,type:mindustry.game.Team},{name:time,type:float},{name:type,type:mindustry.entities.bullet.BulletType},{name:x,type:float},{name:y,type:float}]}

View File

@ -445,7 +445,7 @@ public class BulletType extends Content implements Cloneable{
bullet.owner = owner;
bullet.team = team;
bullet.time = 0f;
bullet.vel.trns(angle, speed * velocityScl);
bullet.initVel(angle, speed * velocityScl);
if(backMove){
bullet.set(x - bullet.vel.x * Time.delta, y - bullet.vel.y * Time.delta);
}else{
@ -462,7 +462,7 @@ public class BulletType extends Content implements Cloneable{
}
bullet.add();
if(keepVelocity && owner instanceof Velc v) bullet.vel.add(v.vel().x, v.vel().y);
if(keepVelocity && owner instanceof Velc v) bullet.vel.add(v.vel());
return bullet;
}

View File

@ -23,7 +23,8 @@ public class ContinuousLaserBulletType extends BulletType{
public boolean largeHit = true;
public ContinuousLaserBulletType(float damage){
super(0.001f, damage);
this.damage = damage;
this.speed = 0f;
hitEffect = Fx.hitBeam;
despawnEffect = Fx.none;

View File

@ -21,7 +21,8 @@ public class LaserBulletType extends BulletType{
public boolean largeHit = false;
public LaserBulletType(float damage){
super(0.01f, damage);
this.damage = damage;
this.speed = 0f;
hitEffect = Fx.hitLaserBlast;
hitColor = colors[2];

View File

@ -12,8 +12,8 @@ public class LightningBulletType extends BulletType{
public int lightningLength = 25, lightningLengthRand = 0;
public LightningBulletType(){
super(0.0001f, 1f);
damage = 1f;
speed = 0f;
lifetime = 1;
despawnEffect = Fx.none;
hitEffect = Fx.hitLancer;

View File

@ -16,6 +16,7 @@ public class RailBulletType extends BulletType{
public float updateEffectSeg = 20f;
public RailBulletType(){
speed = 0f;
pierceBuilding = true;
pierce = true;
reflectable = false;
@ -23,7 +24,6 @@ public class RailBulletType extends BulletType{
despawnEffect = Fx.none;
collides = false;
lifetime = 1f;
speed = 0.01f;
}
@Override
@ -57,7 +57,7 @@ public class RailBulletType extends BulletType{
Damage.collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), length, false, false);
float resultLen = b.fdata;
Vec2 nor = Tmp.v1.set(b.vel).nor();
Vec2 nor = Tmp.v1.trns(b.rotation(), 1f).nor();
for(float i = 0; i <= resultLen; i += updateEffectSeg){
updateEffect.at(b.x + nor.x * i, b.y + nor.y * i, b.rotation());
}

View File

@ -2,7 +2,6 @@ package mindustry.entities.comp;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
@ -22,11 +21,16 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Import Team team;
@Import Entityc owner;
@Import float x, y, damage;
@Import Vec2 vel;
IntSeq collided = new IntSeq(6);
Object data;
BulletType type;
float fdata;
@ReadOnly
private float rotation;
transient boolean absorbed, hit;
transient @Nullable Trail trail;
@ -149,17 +153,20 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
type.drawLight(self());
}
public void initVel(float angle, float amount){
vel.trns(angle, amount);
rotation = angle;
}
/** Sets the bullet's rotation in degrees. */
@Override
public void rotation(float angle){
vel().setAngle(angle);
vel.setAngle(rotation = angle);
}
/** @return the bullet's rotation. */
@Override
public float rotation(){
float angle = Mathf.atan2(vel().x, vel().y) * Mathf.radiansToDegrees;
if(angle < 0) angle += 360;
return angle;
return vel.isZero(0.001f) ? rotation : vel.angle();
}
}