Cleanup
This commit is contained in:
1
annotations/src/main/resources/revisions/Bullet/6.json
Normal file
1
annotations/src/main/resources/revisions/Bullet/6.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{version:6,fields:[{name:collided,type:arc.struct.IntSeq,size:-1},{name:damage,type:float,size:4},{name:data,type:java.lang.Object,size:-1},{name:fdata,type:float,size:4},{name:lifetime,type:float,size:4},{name:owner,type:mindustry.gen.Entityc,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:type,type:mindustry.entities.bullet.BulletType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
@@ -1808,6 +1808,7 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
upgrades = new UnitType[][]{
|
upgrades = new UnitType[][]{
|
||||||
{UnitTypes.antumbra, UnitTypes.eclipse},
|
{UnitTypes.antumbra, UnitTypes.eclipse},
|
||||||
|
{UnitTypes.arkyid, UnitTypes.toxopid},
|
||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
/** Utility class for damaging in an area. */
|
/** Utility class for damaging in an area. */
|
||||||
public class Damage{
|
public class Damage{
|
||||||
|
private static Tile furthest;
|
||||||
private static Rect rect = new Rect();
|
private static Rect rect = new Rect();
|
||||||
private static Rect hitrect = new Rect();
|
private static Rect hitrect = new Rect();
|
||||||
private static Vec2 tr = new Vec2();
|
private static Vec2 tr = new Vec2();
|
||||||
@@ -76,6 +77,23 @@ public class Damage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Collides a bullet with blocks in a laser, taking into account absorption blocks. Resulting length is stored in the bullet's fdata. */
|
||||||
|
public static float collideLaser(Bullet b, float length){
|
||||||
|
Tmp.v1.trns(b.rotation(), length);
|
||||||
|
|
||||||
|
furthest = null;
|
||||||
|
|
||||||
|
world.raycast(b.tileX(), b.tileY(), world.toTile(b.x + Tmp.v1.x), world.toTile(b.y + Tmp.v1.y),
|
||||||
|
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team && furthest.block().absorbLasers);
|
||||||
|
|
||||||
|
float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length;
|
||||||
|
|
||||||
|
Damage.collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), resultLength);
|
||||||
|
b.fdata = furthest != null ? resultLength : length;
|
||||||
|
|
||||||
|
return resultLength;
|
||||||
|
}
|
||||||
|
|
||||||
public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length){
|
public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length){
|
||||||
collideLine(hitter, team, effect, x, y, angle, length, false);
|
collideLine(hitter, team, effect, x, y, angle, length, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class LaserBulletType extends BulletType{
|
public class LaserBulletType extends BulletType{
|
||||||
protected static Tile furthest;
|
protected static Tile furthest;
|
||||||
|
|
||||||
@@ -49,24 +47,13 @@ public class LaserBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
Tmp.v1.trns(b.rotation(), length);
|
float resultLength = Damage.collideLaser(b, length);
|
||||||
|
|
||||||
furthest = null;
|
|
||||||
|
|
||||||
world.raycast(b.tileX(), b.tileY(), world.toTile(b.x + Tmp.v1.x), world.toTile(b.y + Tmp.v1.y),
|
|
||||||
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team && furthest.block().absorbLasers);
|
|
||||||
|
|
||||||
float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length;
|
|
||||||
|
|
||||||
Damage.collideLine(b, b.team, hitEffect, b.x, b.y, b.rotation(), resultLength);
|
|
||||||
if(furthest != null) b.data(resultLength);
|
|
||||||
|
|
||||||
laserEffect.at(b.x, b.y, b.rotation(), resultLength * 0.75f);
|
laserEffect.at(b.x, b.y, b.rotation(), resultLength * 0.75f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
float realLength = b.data() == null ? length : (Float)b.data();
|
float realLength = b.fdata;
|
||||||
|
|
||||||
float f = Mathf.curve(b.fin(), 0f, 0.2f);
|
float f = Mathf.curve(b.fin(), 0f, 0.2f);
|
||||||
float baseLen = realLength * f;
|
float baseLen = realLength * f;
|
||||||
|
|||||||
@@ -29,19 +29,21 @@ public class ShrapnelBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bullet b){
|
public void init(Bullet b){
|
||||||
Damage.collideLine(b, b.team, hitEffect, b.x, b.y, b.rotation(), length);
|
Damage.collideLaser(b, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
|
float realLength = b.fdata;
|
||||||
|
|
||||||
Draw.color(fromColor, toColor, b.fin());
|
Draw.color(fromColor, toColor, b.fin());
|
||||||
for(int i = 0; i < serrations; i++){
|
for(int i = 0; i < (int)(serrations * realLength / length); i++){
|
||||||
Tmp.v1.trns(b.rotation(), i * serrationSpacing);
|
Tmp.v1.trns(b.rotation(), i * serrationSpacing);
|
||||||
float sl = Mathf.clamp(b.fout() - serrationFadeOffset) * (serrationSpaceOffset - i * serrationLenScl);
|
float sl = Mathf.clamp(b.fout() - serrationFadeOffset) * (serrationSpaceOffset - i * serrationLenScl);
|
||||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() + 90);
|
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() + 90);
|
||||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() - 90);
|
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() - 90);
|
||||||
}
|
}
|
||||||
Drawf.tri(b.x, b.y, width * b.fout(), (length + 50), b.rotation());
|
Drawf.tri(b.x, b.y, width * b.fout(), (realLength + 50), b.rotation());
|
||||||
Drawf.tri(b.x, b.y, width * b.fout(), 10f, b.rotation() + 180f);
|
Drawf.tri(b.x, b.y, width * b.fout(), 10f, b.rotation() + 180f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
|||||||
Object data;
|
Object data;
|
||||||
BulletType type;
|
BulletType type;
|
||||||
float damage;
|
float damage;
|
||||||
|
float fdata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getCollisions(Cons<QuadTree> consumer){
|
public void getCollisions(Cons<QuadTree> consumer){
|
||||||
|
|||||||
Reference in New Issue
Block a user