Plastanium laser blocking

This commit is contained in:
Anuken
2020-06-06 17:15:08 -04:00
parent 182d8e2daf
commit b4cecbc3b9
4 changed files with 30 additions and 5 deletions

View File

@@ -795,6 +795,7 @@ public class Blocks implements ContentList{
requirements(Category.defense, ItemStack.with(Items.plastanium, 5, Items.metaglass, 2)); requirements(Category.defense, ItemStack.with(Items.plastanium, 5, Items.metaglass, 2));
health = 190 * wallHealthMultiplier; health = 190 * wallHealthMultiplier;
insulated = true; insulated = true;
absorbLasers = true;
}}; }};
plastaniumWallLarge = new Wall("plastanium-wall-large"){{ plastaniumWallLarge = new Wall("plastanium-wall-large"){{
@@ -802,6 +803,7 @@ public class Blocks implements ContentList{
health = 190 * wallHealthMultiplier * 4; health = 190 * wallHealthMultiplier * 4;
size = 2; size = 2;
insulated = true; insulated = true;
absorbLasers = true;
}}; }};
thoriumWall = new Wall("thorium-wall"){{ thoriumWall = new Wall("thorium-wall"){{
@@ -1484,7 +1486,7 @@ public class Blocks implements ContentList{
powerUse = 2.5f; powerUse = 2.5f;
shootShake = 2f; shootShake = 2f;
shootEffect = Fx.lancerLaserShoot; shootEffect = Fx.lancerLaserShoot;
smokeEffect = Fx.lancerLaserShootSmoke; smokeEffect = Fx.none;
chargeEffect = Fx.lancerLaserCharge; chargeEffect = Fx.lancerLaserCharge;
chargeBeginEffect = Fx.lancerLaserChargeBegin; chargeBeginEffect = Fx.lancerLaserChargeBegin;
heatColor = Color.red; heatColor = Color.red;

View File

@@ -884,8 +884,9 @@ public class Fx{
lancerLaserShootSmoke = new Effect(26f, e -> { lancerLaserShootSmoke = new Effect(26f, e -> {
color(Color.white); color(Color.white);
float length = e.data == null ? 70f : (Float)e.data;
randLenVectors(e.id, 7, 70f, e.rotation, 0f, (x, y) -> { randLenVectors(e.id, 7, length, e.rotation, 0f, (x, y) -> {
lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f);
}); });

View File

@@ -8,9 +8,15 @@ import mindustry.content.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.world.*;
import static mindustry.Vars.world;
public class LaserBulletType extends BulletType{ public class LaserBulletType extends BulletType{
protected static Tile furthest;
protected Color[] colors = {Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white}; protected Color[] colors = {Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white};
protected Effect laserEffect = Fx.lancerLaserShootSmoke;
protected float length = 160f; protected float length = 160f;
protected float width = 15f; protected float width = 15f;
protected float lengthFalloff = 0.5f; protected float lengthFalloff = 0.5f;
@@ -24,7 +30,7 @@ public class LaserBulletType extends BulletType{
hitEffect = Fx.hitLancer; hitEffect = Fx.hitLancer;
despawnEffect = Fx.none; despawnEffect = Fx.none;
shootEffect = Fx.hitLancer; shootEffect = Fx.hitLancer;
smokeEffect = Fx.lancerLaserShootSmoke; smokeEffect = Fx.none;
hitSize = 4; hitSize = 4;
lifetime = 16f; lifetime = 16f;
pierce = true; pierce = true;
@@ -42,13 +48,27 @@ public class LaserBulletType extends BulletType{
@Override @Override
public void init(Bulletc b){ public void init(Bulletc b){
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), 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.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);
} }
@Override @Override
public void draw(Bulletc b){ public void draw(Bulletc b){
float realLength = b.data() == null ? length : (Float)b.data();
float f = Mathf.curve(b.fin(), 0f, 0.2f); float f = Mathf.curve(b.fin(), 0f, 0.2f);
float baseLen = length * f; float baseLen = realLength * f;
float cwidth = width; float cwidth = width;
float compound = 1f; float compound = 1f;

View File

@@ -86,6 +86,8 @@ public class Block extends UnlockableContent{
public boolean insulated = false; public boolean insulated = false;
/** whether the sprite is a full square. */ /** whether the sprite is a full square. */
public boolean squareSprite = true; public boolean squareSprite = true;
/** whether this block absorbs laser attacks. */
public boolean absorbLasers = false;
/** tile entity health */ /** tile entity health */
public int health = -1; public int health = -1;
/** base block explosiveness */ /** base block explosiveness */