This commit is contained in:
Anuken
2020-06-07 09:58:29 -04:00
parent bf125c92d3
commit 737e32e447
8 changed files with 117 additions and 55 deletions

View File

@@ -476,60 +476,15 @@ public class Bullets implements ContentList{
drawSize = 400f; drawSize = 400f;
}}; }};
meltdownLaser = new BulletType(0.001f, 70){ meltdownLaser = new ContinuousLaserBulletType(70){{
Color tmpColor = new Color(); length = 220f;
Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.white}; hitEffect = Fx.hitMeltdown;
float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; drawSize = 420f;
float[] strokes = {2f, 1.5f, 1f, 0.3f};
float[] lenscales = {1f, 1.12f, 1.15f, 1.17f};
float length = 220f;
{ incendChance = 0.4f;
hitEffect = Fx.hitMeltdown; incendSpread = 5f;
despawnEffect = Fx.none; incendAmount = 1;
hitSize = 4; }};
drawSize = 420f;
lifetime = 16f;
pierce = true;
hittable = false;
}
@Override
public void update(Bulletc b){
if(b.timer(1, 5f)){
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length, true);
}
Effects.shake(1f, 1f, b.x(), b.y());
}
@Override
public void hit(Bulletc b, float hitx, float hity){
hitEffect.at(hitx, hity, colors[2]);
if(Mathf.chance(0.4)){
Fires.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f)));
}
}
@Override
public void draw(Bulletc b){
float baseLen = (length) * b.fout();
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen);
for(int s = 0; s < colors.length; s++){
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
for(int i = 0; i < tscales.length; i++){
Tmp.v1.trns(b.rotation() + 180f, (lenscales[i] - 1f) * 35f);
Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
Lines.lineAngle(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, b.rotation(), baseLen * lenscales[i], CapStyle.none);
}
}
Tmp.v1.trns(b.rotation(), baseLen * 1.1f);
Drawf.light(b.x(), b.y(), b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 40, Color.orange, 0.7f);
Draw.reset();
}
};
waterShot = new LiquidBulletType(Liquids.water){{ waterShot = new LiquidBulletType(Liquids.water){{
knockback = 0.7f; knockback = 0.7f;

View File

@@ -1,6 +1,7 @@
package mindustry.entities.bullet; package mindustry.entities.bullet;
import arc.audio.*; import arc.audio.*;
import arc.graphics.*;
import arc.math.*; import arc.math.*;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
import arc.util.*; import arc.util.*;
@@ -74,6 +75,7 @@ public abstract class BulletType extends Content{
public int fragBullets = 9; public int fragBullets = 9;
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f; public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
public BulletType fragBullet = null; public BulletType fragBullet = null;
public Color hitColor = Color.white;
/** Use a negative value to disable splash damage. */ /** Use a negative value to disable splash damage. */
public float splashDamageRadius = -1f; public float splashDamageRadius = -1f;
@@ -119,7 +121,7 @@ public abstract class BulletType extends Content{
} }
public void hit(Bulletc b, float x, float y){ public void hit(Bulletc b, float x, float y){
hitEffect.at(x, y, b.rotation()); hitEffect.at(x, y, b.rotation(), hitColor);
hitSound.at(b); hitSound.at(b);
Effects.shake(hitShake, hitShake, b); Effects.shake(hitShake, hitShake, b);

View File

@@ -0,0 +1,85 @@
package mindustry.entities.bullet;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
public class ContinuousLaserBulletType extends BulletType{
public float length = 220f;
public float shake = 1f;
public Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.white};
public float[] tscales = {1f, 0.7f, 0.5f, 0.2f};
public float[] strokes = {2f, 1.5f, 1f, 0.3f};
public float[] lenscales = {1f, 1.12f, 1.15f, 1.17f};
public ContinuousLaserBulletType(float damage){
super(0.001f, damage);
hitEffect = Fx.hitMeltdown;
despawnEffect = Fx.none;
hitSize = 4;
drawSize = 420f;
lifetime = 16f;
pierce = true;
hittable = false;
hitColor = colors[2];
}
protected ContinuousLaserBulletType(){
this(0);
}
@Override
public float range(){
return length;
}
@Override
public void update(Bulletc b){
//TODO possible laser absorption from blocks
//damage every 5 ticks
if(b.timer(1, 5f)){
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length, true);
}
if(shake > 0){
Effects.shake(shake, shake, b);
}
}
/*
@Override
public void hit(Bulletc b, float hitx, float hity){
hitEffect.at(hitx, hity, colors[2]);
if(Mathf.chance(0.4)){
Fires.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f)));
}
}*/
@Override
public void draw(Bulletc b){
float baseLen = length * b.fout();
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen);
for(int s = 0; s < colors.length; s++){
Draw.color(Tmp.c1.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
for(int i = 0; i < tscales.length; i++){
Tmp.v1.trns(b.rotation() + 180f, (lenscales[i] - 1f) * 35f);
Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
Lines.lineAngle(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, b.rotation(), baseLen * lenscales[i], CapStyle.none);
}
}
Tmp.v1.trns(b.rotation(), baseLen * 1.1f);
Drawf.light(b.x(), b.y(), b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 40, Color.orange, 0.7f);
Draw.reset();
}
}

View File

@@ -44,6 +44,11 @@ public class LaserTurret extends PowerTurret{
Bulletc bullet; Bulletc bullet;
float bulletLife; float bulletLife;
@Override
protected void updateCooling(){
//do nothing, cooling is irrelevant here
}
@Override @Override
public void updateTile(){ public void updateTile(){
super.updateTile(); super.updateTile();

View File

@@ -174,7 +174,7 @@ public class PayloadConveyor extends Block{
@Override @Override
public boolean acceptPayload(Tilec source, Payload payload){ public boolean acceptPayload(Tilec source, Payload payload){
//accepting payloads from units isn't supported //accepting payloads from units isn't supported
return this.item == null && progress <= 5f && source != this; return this.item == null && progress <= 5f && source != this && payload.fits();
} }
@Override @Override

View File

@@ -33,6 +33,11 @@ public class BlockPayload implements Payload{
tile.setBlock(entity.block(), entity.team(), rotation, () -> entity); tile.setBlock(entity.block(), entity.team(), rotation, () -> entity);
} }
@Override
public boolean fits(){
return entity.block().size < 3;
}
@Override @Override
public void write(Writes write){ public void write(Writes write){
write.b(payloadBlock); write.b(payloadBlock);

View File

@@ -22,6 +22,11 @@ public interface Payload{
return false; return false;
} }
/** @return whether this payload fits on a standard 3x3 conveyor. */
default boolean fits(){
return true;
}
/** writes the payload for saving. */ /** writes the payload for saving. */
void write(Writes write); void write(Writes write);

View File

@@ -15,6 +15,11 @@ public class UnitPayload implements Payload{
this.unit = unit; this.unit = unit;
} }
@Override
public boolean fits(){
return unit.hitSize() <= 16f;
}
@Override @Override
public void write(Writes write){ public void write(Writes write){
write.b(payloadUnit); write.b(payloadUnit);