Point defense blocks
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -239,3 +239,4 @@
|
|||||||
63505=data-processor|block-data-processor-medium
|
63505=data-processor|block-data-processor-medium
|
||||||
63504=payload-router|block-payload-router-medium
|
63504=payload-router|block-payload-router-medium
|
||||||
63503=silicon-crucible|block-silicon-crucible-medium
|
63503=silicon-crucible|block-silicon-crucible-medium
|
||||||
|
63502=segment|block-segment-medium
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 746 B |
|
Before Width: | Height: | Size: 835 KiB After Width: | Height: | Size: 836 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 271 KiB |
|
Before Width: | Height: | Size: 907 KiB After Width: | Height: | Size: 905 KiB |
@@ -74,7 +74,7 @@ public class Blocks implements ContentList{
|
|||||||
coreShard, coreFoundation, coreNucleus, vault, container, unloader,
|
coreShard, coreFoundation, coreNucleus, vault, container, unloader,
|
||||||
|
|
||||||
//turrets
|
//turrets
|
||||||
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
|
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown, segment,
|
||||||
|
|
||||||
//units
|
//units
|
||||||
groundFactory, airFactory, navalFactory, basicReconstructor, repairPoint,
|
groundFactory, airFactory, navalFactory, basicReconstructor, repairPoint,
|
||||||
@@ -83,7 +83,7 @@ public class Blocks implements ContentList{
|
|||||||
launchPad, launchPadLarge, coreSilo, dataProcessor,
|
launchPad, launchPadLarge, coreSilo, dataProcessor,
|
||||||
|
|
||||||
//misc experimental
|
//misc experimental
|
||||||
blockForge, blockLauncher, blockLoader, blockUnloader;
|
blockForge, blockLoader, blockUnloader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
@@ -1674,6 +1674,18 @@ public class Blocks implements ContentList{
|
|||||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
|
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
segment = new PointDefenseTurret("segment"){{
|
||||||
|
requirements(Category.turret, ItemStack.with(Items.silicon, 80, Items.thorium, 80, Items.surgealloy, 50));
|
||||||
|
|
||||||
|
hasPower = true;
|
||||||
|
consumes.power(1.1f);
|
||||||
|
size = 2;
|
||||||
|
shootLength = 5f;
|
||||||
|
bulletDamage = 12f;
|
||||||
|
reloadTime = 25f;
|
||||||
|
health = 190 * size * size;
|
||||||
|
}};
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
//region units
|
//region units
|
||||||
|
|
||||||
@@ -1835,13 +1847,6 @@ public class Blocks implements ContentList{
|
|||||||
size = 3;
|
size = 3;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
blockLauncher = new BlockLauncher("block-launcher"){{
|
|
||||||
requirements(Category.production, BuildVisibility.debugOnly, ItemStack.with(Items.thorium, 100));
|
|
||||||
size = 3;
|
|
||||||
hasPower = true;
|
|
||||||
consumes.power(2f);
|
|
||||||
}};
|
|
||||||
|
|
||||||
blockLoader = new BlockLoader("block-loader"){{
|
blockLoader = new BlockLoader("block-loader"){{
|
||||||
requirements(Category.production, BuildVisibility.debugOnly, ItemStack.with(Items.thorium, 100));
|
requirements(Category.production, BuildVisibility.debugOnly, ItemStack.with(Items.thorium, 100));
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ public class Bullets implements ContentList{
|
|||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
status = StatusEffects.shocked;
|
status = StatusEffects.shocked;
|
||||||
statusDuration = 10f;
|
statusDuration = 10f;
|
||||||
|
hittable = false;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
healBullet = new HealBulletType(5.2f, 13){{
|
healBullet = new HealBulletType(5.2f, 13){{
|
||||||
@@ -431,6 +432,7 @@ public class Bullets implements ContentList{
|
|||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
status = StatusEffects.burning;
|
status = StatusEffects.burning;
|
||||||
keepVelocity = false;
|
keepVelocity = false;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -455,6 +457,7 @@ public class Bullets implements ContentList{
|
|||||||
hitEffect = Fx.hitFlameSmall;
|
hitEffect = Fx.hitFlameSmall;
|
||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
status = StatusEffects.burning;
|
status = StatusEffects.burning;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -486,6 +489,7 @@ public class Bullets implements ContentList{
|
|||||||
drawSize = 420f;
|
drawSize = 420f;
|
||||||
lifetime = 16f;
|
lifetime = 16f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,13 +12,12 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
|
||||||
import mindustry.world.blocks.experimental.BlockLauncher.*;
|
|
||||||
|
|
||||||
|
import static arc.graphics.g2d.Draw.rect;
|
||||||
import static arc.graphics.g2d.Draw.*;
|
import static arc.graphics.g2d.Draw.*;
|
||||||
import static arc.graphics.g2d.Lines.*;
|
import static arc.graphics.g2d.Lines.*;
|
||||||
import static arc.math.Angles.*;
|
import static arc.math.Angles.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class Fx{
|
public class Fx{
|
||||||
public static final Effect
|
public static final Effect
|
||||||
@@ -103,18 +102,21 @@ public class Fx{
|
|||||||
Fill.circle(x, y, e.fslope() * 1.5f * size);
|
Fill.circle(x, y, e.fslope() * 1.5f * size);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
blockTransfer = new Effect(25f, e -> {
|
pointBeam = new Effect(25f, e -> {
|
||||||
if(!(e.data instanceof LaunchedBlock)) return;
|
if(!(e.data instanceof Position)) return;
|
||||||
|
|
||||||
LaunchedBlock l = e.data();
|
Position pos = e.data();
|
||||||
|
|
||||||
Block block = l.block;
|
Draw.color(e.color);
|
||||||
Position to = Tmp.v3.set(l.x * tilesize, l.y * tilesize).add(block.offset(), block.offset());
|
Draw.alpha(e.fout());
|
||||||
|
Lines.stroke(1.5f);
|
||||||
|
Lines.line(e.x, e.y, pos.getX(), pos.getY());
|
||||||
|
}),
|
||||||
|
|
||||||
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interp.linear);
|
pointHit = new Effect(8f, e -> {
|
||||||
float x = Tmp.v1.x, y = Tmp.v1.y;
|
color(Color.white, e.color, e.fin());
|
||||||
|
stroke(e.fout() * 1f + 0.2f);
|
||||||
Draw.rect(block.icon(Cicon.full), x, y);
|
Lines.circle(e.x, e.y, e.fin() * 6f);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
lightning = new Effect(10f, 500f, e -> {
|
lightning = new Effect(10f, 500f, e -> {
|
||||||
@@ -915,6 +917,16 @@ public class Fx{
|
|||||||
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
sparkShoot = new Effect(12f, e -> {
|
||||||
|
color(Color.white, e.color, e.fin());
|
||||||
|
stroke(e.fout() * 1.2f + 0.6f);
|
||||||
|
|
||||||
|
randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 3f, (x, y) -> {
|
||||||
|
lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 5f + 0.5f);
|
||||||
|
});
|
||||||
|
|
||||||
|
}),
|
||||||
|
|
||||||
lightningShoot = new Effect(12f, e -> {
|
lightningShoot = new Effect(12f, e -> {
|
||||||
color(Color.white, Pal.lancerLaser, e.fin());
|
color(Color.white, Pal.lancerLaser, e.fin());
|
||||||
stroke(e.fout() * 1.2f + 0.5f);
|
stroke(e.fout() * 1.2f + 0.5f);
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public abstract class BulletType extends Content{
|
|||||||
public boolean keepVelocity = true;
|
public boolean keepVelocity = true;
|
||||||
/** Whether to scale velocity to disappear at the target position. Used for artillery. */
|
/** Whether to scale velocity to disappear at the target position. Used for artillery. */
|
||||||
public boolean scaleVelocity;
|
public boolean scaleVelocity;
|
||||||
|
/** Whether this bullet can be hit by point defense. */
|
||||||
|
public boolean hittable = true;
|
||||||
|
|
||||||
//additional effects
|
//additional effects
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class HealBulletType extends BulletType{
|
|||||||
hitEffect = Fx.hitLaser;
|
hitEffect = Fx.hitLaser;
|
||||||
despawnEffect = Fx.hitLaser;
|
despawnEffect = Fx.hitLaser;
|
||||||
collidesTeam = true;
|
collidesTeam = true;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HealBulletType(){
|
public HealBulletType(){
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class LaserBulletType extends BulletType{
|
|||||||
hitSize = 4;
|
hitSize = 4;
|
||||||
lifetime = 16f;
|
lifetime = 16f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LaserBulletType(){
|
public LaserBulletType(){
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class LightningBulletType extends BulletType{
|
|||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
hitEffect = Fx.hitLancer;
|
hitEffect = Fx.hitLancer;
|
||||||
keepVelocity = false;
|
keepVelocity = false;
|
||||||
|
hittable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ public class Block extends UnlockableContent{
|
|||||||
|
|
||||||
public Block(String name){
|
public Block(String name){
|
||||||
super(name);
|
super(name);
|
||||||
this.solid = false;
|
|
||||||
initEntity();
|
initEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
118
core/src/mindustry/world/blocks/defense/PointDefenseTurret.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package mindustry.world.blocks.defense;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
public class PointDefenseTurret extends Block{
|
||||||
|
public final int timerTarget = timers++;
|
||||||
|
public float retargetTime = 5f;
|
||||||
|
|
||||||
|
public @Load("block-$size") TextureRegion baseRegion;
|
||||||
|
|
||||||
|
public Color color = Color.white;
|
||||||
|
public Effect beamEffect = Fx.pointBeam;
|
||||||
|
public Effect hitEffect = Fx.pointHit;
|
||||||
|
public Effect shootEffect = Fx.sparkShoot;
|
||||||
|
|
||||||
|
public float range = 80f;
|
||||||
|
public float reloadTime = 30f;
|
||||||
|
public float rotateSpeed = 20;
|
||||||
|
public float shootCone = 5f;
|
||||||
|
public float bulletDamage = 10f;
|
||||||
|
public float shootLength = 3f;
|
||||||
|
|
||||||
|
public PointDefenseTurret(String name){
|
||||||
|
super(name);
|
||||||
|
|
||||||
|
outlineIcon = true;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
|
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] generateIcons(){
|
||||||
|
return new TextureRegion[]{Core.atlas.find("block-" + size), Core.atlas.find(name)};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PointDefenseEntity extends TileEntity{
|
||||||
|
public float rotation = 90, reload;
|
||||||
|
public @Nullable Bulletc target;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
|
||||||
|
//retarget
|
||||||
|
if(timer(timerTarget, retargetTime)){
|
||||||
|
target = Groups.bullet.intersect(x - range, y - range, range*2, range*2).min(b -> b.team() == team || !b.type().hittable ? Float.MAX_VALUE : b.dst2(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
//look at target
|
||||||
|
if(target != null && target.within(this, range) && target.team() != team && target.type().hittable){
|
||||||
|
float dest = angleTo(target);
|
||||||
|
rotation = Angles.moveToward(rotation,dest, rotateSpeed * edelta());
|
||||||
|
reload -= edelta();
|
||||||
|
|
||||||
|
//shoot when possible
|
||||||
|
if(Angles.within(rotation, dest, shootCone) && reload <= 0f){
|
||||||
|
if(target.damage() > bulletDamage){
|
||||||
|
target.damage(target.damage() - bulletDamage);
|
||||||
|
}else{
|
||||||
|
target.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
Tmp.v1.trns(rotation, shootLength);
|
||||||
|
|
||||||
|
beamEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color, new Vec2().set(target));
|
||||||
|
shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color);
|
||||||
|
hitEffect.at(target.x(), target.y(), color);
|
||||||
|
reload = reloadTime;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawSelect(){
|
||||||
|
Drawf.dashCircle(x, y, range, Pal.accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
Draw.rect(baseRegion, x, y);
|
||||||
|
Draw.rect(region, x, y, rotation - 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Writes write){
|
||||||
|
super.write(write);
|
||||||
|
|
||||||
|
write.f(rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
super.read(read, revision);
|
||||||
|
|
||||||
|
rotation = read.f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package mindustry.world.blocks.experimental;
|
|
||||||
|
|
||||||
import arc.math.geom.*;
|
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.content.*;
|
|
||||||
import mindustry.entities.*;
|
|
||||||
import mindustry.game.*;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.world.*;
|
|
||||||
import mindustry.world.blocks.payloads.*;
|
|
||||||
import mindustry.world.blocks.production.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
|
||||||
|
|
||||||
//pointless, will definitely be removed eventually
|
|
||||||
public class BlockLauncher extends PayloadAcceptor{
|
|
||||||
static final IntArray positions = new IntArray();
|
|
||||||
|
|
||||||
public float range = 150;
|
|
||||||
|
|
||||||
public BlockLauncher(String name){
|
|
||||||
super(name);
|
|
||||||
|
|
||||||
update = true;
|
|
||||||
size = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BlockLauncherEntity extends PayloadAcceptorEntity<BlockPayload>{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
super.draw();
|
|
||||||
|
|
||||||
drawPayload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptPayload(Tilec source, Payload payload){
|
|
||||||
return this.payload == null && payload instanceof BlockPayload;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTile(){
|
|
||||||
if(moveInPayload() && efficiency() >= 0.99f){
|
|
||||||
Effects.shake(4f, 4f, this);
|
|
||||||
Fx.producesmoke.at(this);
|
|
||||||
|
|
||||||
positions.clear();
|
|
||||||
|
|
||||||
Geometry.circle(tileX(), tileY(), world.width(), world.height(), (int)(range / tilesize), (cx, cy) -> {
|
|
||||||
if(Build.validPlace(team, cx, cy, payload.entity.block(), 0)){
|
|
||||||
positions.add(Point2.pack(cx, cy));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(positions.isEmpty()) return;
|
|
||||||
|
|
||||||
int pick = positions.random();
|
|
||||||
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), payload.entity.block(), team);
|
|
||||||
Fx.blockTransfer.at(x, y, 0, launch);
|
|
||||||
Time.run(Fx.blockTransfer.lifetime, () -> {
|
|
||||||
float ex = launch.x * tilesize + launch.block.offset(), ey = launch.y * tilesize + launch.block.offset();
|
|
||||||
if(Build.validPlace(launch.team, launch.x, launch.y, launch.block, 0)){
|
|
||||||
world.tile(launch.x, launch.y).setBlock(launch.block, launch.team);
|
|
||||||
Fx.placeBlock.at(ex, ey, launch.block.size);
|
|
||||||
}else{
|
|
||||||
Fx.breakBlock.at(ex, ey, launch.block.size);
|
|
||||||
Fx.explosion.at(ex, ey);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
payload = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LaunchedBlock{
|
|
||||||
public final int x, y;
|
|
||||||
public final Block block;
|
|
||||||
public final Team team;
|
|
||||||
|
|
||||||
public LaunchedBlock(int x, int y, Block block, Team team){
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.block = block;
|
|
||||||
this.team = team;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,7 @@ public class AttributeSmelter extends GenericSmelter{
|
|||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
|
|
||||||
stats.add(BlockStat.tiles, attribute, boostScale);
|
stats.add(BlockStat.affinities, attribute, boostScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttributeSmelterEntity extends SmelterEntity{
|
public class AttributeSmelterEntity extends SmelterEntity{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class RepairPoint extends Block{
|
public class RepairPoint extends Block{
|
||||||
private static Rect rect = new Rect();
|
private static final Rect rect = new Rect();
|
||||||
|
|
||||||
public int timerTarget = timers++;
|
public int timerTarget = timers++;
|
||||||
|
|
||||||
|
|||||||