Mass driver reloadTime -> reload

This commit is contained in:
Anuken
2022-05-10 21:56:34 -04:00
parent 2e4037451f
commit 8c98f8f9bf
4 changed files with 32 additions and 31 deletions

View File

@@ -493,6 +493,7 @@ toolmode.fillteams = Fill Teams
toolmode.fillteams.description = Fill teams instead of blocks. toolmode.fillteams.description = Fill teams instead of blocks.
toolmode.drawteams = Draw Teams toolmode.drawteams = Draw Teams
toolmode.drawteams.description = Draw teams instead of blocks. toolmode.drawteams.description = Draw teams instead of blocks.
#unused
toolmode.underliquid = Under Liquids toolmode.underliquid = Under Liquids
toolmode.underliquid.description = Draw floors under liquid tiles. toolmode.underliquid.description = Draw floors under liquid tiles.

View File

@@ -1910,7 +1910,7 @@ public class Blocks{
requirements(Category.distribution, with(Items.titanium, 125, Items.silicon, 75, Items.lead, 125, Items.thorium, 50)); requirements(Category.distribution, with(Items.titanium, 125, Items.silicon, 75, Items.lead, 125, Items.thorium, 50));
size = 3; size = 3;
itemCapacity = 120; itemCapacity = 120;
reloadTime = 200f; reload = 200f;
range = 440f; range = 440f;
consumePower(1.75f); consumePower(1.75f);
}}; }};
@@ -4399,7 +4399,7 @@ public class Blocks{
requirements(Category.units, with(Items.tungsten, 120, Items.silicon, 120, Items.oxide, 25)); requirements(Category.units, with(Items.tungsten, 120, Items.silicon, 120, Items.oxide, 25));
regionSuffix = "-dark"; regionSuffix = "-dark";
size = 3; size = 3;
reloadTime = 130f; reload = 130f;
chargeTime = 90f; chargeTime = 90f;
range = 700f; range = 700f;
maxPayloadSize = 2.5f; maxPayloadSize = 2.5f;
@@ -4411,7 +4411,7 @@ public class Blocks{
requirements(Category.units, with(Items.thorium, 300, Items.silicon, 200, Items.plastanium, 200, Items.phaseFabric, 50)); requirements(Category.units, with(Items.thorium, 300, Items.silicon, 200, Items.plastanium, 200, Items.phaseFabric, 50));
regionSuffix = "-dark"; regionSuffix = "-dark";
size = 5; size = 5;
reloadTime = 130f; reload = 130f;
chargeTime = 100f; chargeTime = 100f;
range = 1100f; range = 1100f;
maxPayloadSize = 3.5f; maxPayloadSize = 3.5f;

View File

@@ -28,7 +28,7 @@ public class MassDriver extends Block{
public float translation = 7f; public float translation = 7f;
public int minDistribute = 10; public int minDistribute = 10;
public float knockback = 4f; public float knockback = 4f;
public float reloadTime = 100f; public float reload = 100f;
public MassDriverBolt bullet = new MassDriverBolt(); public MassDriverBolt bullet = new MassDriverBolt();
public float bulletSpeed = 5.5f; public float bulletSpeed = 5.5f;
public float bulletLifetime = 200f; public float bulletLifetime = 200f;
@@ -60,7 +60,7 @@ public class MassDriver extends Block{
super.setStats(); super.setStats();
stats.add(Stat.shootRange, range / tilesize, StatUnit.blocks); stats.add(Stat.shootRange, range / tilesize, StatUnit.blocks);
stats.add(Stat.reload, 60f / reloadTime, StatUnit.perSecond); stats.add(Stat.reload, 60f / reload, StatUnit.perSecond);
} }
@Override @Override
@@ -107,7 +107,7 @@ public class MassDriver extends Block{
public class MassDriverBuild extends Building{ public class MassDriverBuild extends Building{
public int link = -1; public int link = -1;
public float rotation = 90; public float rotation = 90;
public float reload = 0f; public float reloadCounter = 0f;
public DriverState state = DriverState.idle; public DriverState state = DriverState.idle;
//TODO use queue? this array usually holds about 3 shooters max anyway //TODO use queue? this array usually holds about 3 shooters max anyway
public OrderedSet<Building> waitingShooters = new OrderedSet<>(); public OrderedSet<Building> waitingShooters = new OrderedSet<>();
@@ -126,8 +126,8 @@ public class MassDriver extends Block{
} }
//reload regardless of state //reload regardless of state
if(reload > 0f){ if(reloadCounter > 0f){
reload = Mathf.clamp(reload - edelta() / reloadTime); reloadCounter = Mathf.clamp(reloadCounter - edelta() / reload);
} }
var current = currentShooter(); var current = currentShooter();
@@ -182,7 +182,7 @@ public class MassDriver extends Block{
MassDriverBuild other = (MassDriverBuild)link; MassDriverBuild other = (MassDriverBuild)link;
other.waitingShooters.add(this); other.waitingShooters.add(this);
if(reload <= 0.0001f){ if(reloadCounter <= 0.0001f){
//align to target location //align to target location
rotation = Angles.moveToward(rotation, targetRotation, rotateSpeed * efficiency); rotation = Angles.moveToward(rotation, targetRotation, rotateSpeed * efficiency);
@@ -209,7 +209,7 @@ public class MassDriver extends Block{
@Override @Override
public double sense(LAccess sensor){ public double sense(LAccess sensor){
if(sensor == LAccess.progress) return Mathf.clamp(1f - reload / reloadTime); if(sensor == LAccess.progress) return Mathf.clamp(1f - reloadCounter / reload);
return super.sense(sensor); return super.sense(sensor);
} }
@@ -220,11 +220,11 @@ public class MassDriver extends Block{
Draw.z(Layer.turret); Draw.z(Layer.turret);
Drawf.shadow(region, Drawf.shadow(region,
x + Angles.trnsx(rotation + 180f, reload * knockback) - (size / 2), x + Angles.trnsx(rotation + 180f, reloadCounter * knockback) - (size / 2),
y + Angles.trnsy(rotation + 180f, reload * knockback) - (size / 2), rotation - 90); y + Angles.trnsy(rotation + 180f, reloadCounter * knockback) - (size / 2), rotation - 90);
Draw.rect(region, Draw.rect(region,
x + Angles.trnsx(rotation + 180f, reload * knockback), x + Angles.trnsx(rotation + 180f, reloadCounter * knockback),
y + Angles.trnsy(rotation + 180f, reload * knockback), rotation - 90); y + Angles.trnsy(rotation + 180f, reloadCounter * knockback), rotation - 90);
} }
@Override @Override
@@ -276,7 +276,7 @@ public class MassDriver extends Block{
protected void fire(MassDriverBuild target){ protected void fire(MassDriverBuild target){
//reset reload, use power. //reset reload, use power.
reload = 1f; reloadCounter = 1f;
DriverBulletData data = Pools.obtain(DriverBulletData.class, DriverBulletData::new); DriverBulletData data = Pools.obtain(DriverBulletData.class, DriverBulletData::new);
data.from = this; data.from = this;
@@ -321,7 +321,7 @@ public class MassDriver extends Block{
Effect.shake(shake, shake, this); Effect.shake(shake, shake, this);
receiveEffect.at(bullet); receiveEffect.at(bullet);
reload = 1f; reloadCounter = 1f;
bullet.remove(); bullet.remove();
} }

View File

@@ -24,7 +24,7 @@ public class PayloadMassDriver extends PayloadBlock{
public float rotateSpeed = 2f; public float rotateSpeed = 2f;
public float length = 89 / 8f; public float length = 89 / 8f;
public float knockback = 5f; public float knockback = 5f;
public float reloadTime = 30f; public float reload = 30f;
public float chargeTime = 100f; public float chargeTime = 100f;
public float maxPayloadSize = 3; public float maxPayloadSize = 3;
public float grabWidth = 8f, grabHeight = 11/4f; public float grabWidth = 8f, grabHeight = 11/4f;
@@ -79,7 +79,7 @@ public class PayloadMassDriver extends PayloadBlock{
super.setStats(); super.setStats();
stats.add(Stat.payloadCapacity, StatValues.squared(maxPayloadSize, StatUnit.blocksSquared)); stats.add(Stat.payloadCapacity, StatValues.squared(maxPayloadSize, StatUnit.blocksSquared));
stats.add(Stat.reload, 60f / (chargeTime + reloadTime), StatUnit.seconds); stats.add(Stat.reload, 60f / (chargeTime + reload), StatUnit.seconds);
} }
@Override @Override
@@ -128,7 +128,7 @@ public class PayloadMassDriver extends PayloadBlock{
public class PayloadDriverBuild extends PayloadBlockBuild<Payload>{ public class PayloadDriverBuild extends PayloadBlockBuild<Payload>{
public int link = -1; public int link = -1;
public float turretRotation = 90; public float turretRotation = 90;
public float reload = 0f, charge = 0f; public float reloadCounter = 0f, charge = 0f;
public float targetSize = grabWidth*2f, curSize = targetSize; public float targetSize = grabWidth*2f, curSize = targetSize;
public float payLength = 0f, effectDelayTimer = -1f; public float payLength = 0f, effectDelayTimer = -1f;
public PayloadDriverBuild lastOther; public PayloadDriverBuild lastOther;
@@ -167,7 +167,7 @@ public class PayloadMassDriver extends PayloadBlock{
var other = lastOther; var other = lastOther;
float cx = Angles.trnsx(other.turretRotation, length), cy = Angles.trnsy(other.turretRotation, length); float cx = Angles.trnsx(other.turretRotation, length), cy = Angles.trnsy(other.turretRotation, length);
receiveEffect.at(x - cx/2f, y - cy/2f, turretRotation); receiveEffect.at(x - cx/2f, y - cy/2f, turretRotation);
reload = 1f; reloadCounter = 1f;
Effect.shake(shake, shake, this); Effect.shake(shake, shake, this);
} }
@@ -178,8 +178,8 @@ public class PayloadMassDriver extends PayloadBlock{
} }
//reload regardless of state //reload regardless of state
reload -= edelta() / reloadTime; reloadCounter -= edelta() / reload;
if(reload < 0) reload = 0f; if(reloadCounter < 0) reloadCounter = 0f;
var current = currentShooter(); var current = currentShooter();
@@ -248,7 +248,7 @@ public class PayloadMassDriver extends PayloadBlock{
payRotation = Angles.moveToward(payRotation, turretRotation, payloadRotateSpeed * delta()); payRotation = Angles.moveToward(payRotation, turretRotation, payloadRotateSpeed * delta());
if(loaded){ if(loaded){
float loadLength = length - reload*knockback; float loadLength = length - reloadCounter *knockback;
payLength += payloadSpeed * delta(); payLength += payloadSpeed * delta();
if(payLength >= loadLength){ if(payLength >= loadLength){
payLength = loadLength; payLength = loadLength;
@@ -267,14 +267,14 @@ public class PayloadMassDriver extends PayloadBlock{
other.waitingShooters.addLast(this); other.waitingShooters.addLast(this);
} }
if(reload <= 0){ if(reloadCounter <= 0){
//align to target location //align to target location
turretRotation = Angles.moveToward(turretRotation, targetRotation, rotateSpeed * efficiency); turretRotation = Angles.moveToward(turretRotation, targetRotation, rotateSpeed * efficiency);
//fire when it's the first in the queue and angles are ready. //fire when it's the first in the queue and angles are ready.
if(other.currentShooter() == this && if(other.currentShooter() == this &&
other.state == accepting && other.state == accepting &&
other.reload <= 0f && other.reloadCounter <= 0f &&
Angles.within(turretRotation, targetRotation, 1f) && Angles.within(other.turretRotation, targetRotation + 180f, 1f)){ Angles.within(turretRotation, targetRotation, 1f) && Angles.within(other.turretRotation, targetRotation + 180f, 1f)){
charge += edelta(); charge += edelta();
charging = true; charging = true;
@@ -313,7 +313,7 @@ public class PayloadMassDriver extends PayloadBlock{
payLength = 0f; payLength = 0f;
loaded = false; loaded = false;
state = idle; state = idle;
reload = 1f; reloadCounter = 1f;
} }
} }
} }
@@ -323,7 +323,7 @@ public class PayloadMassDriver extends PayloadBlock{
@Override @Override
public double sense(LAccess sensor){ public double sense(LAccess sensor){
if(sensor == LAccess.progress) return Mathf.clamp(1f - reload / reloadTime); if(sensor == LAccess.progress) return Mathf.clamp(1f - reloadCounter / reload);
return super.sense(sensor); return super.sense(sensor);
} }
@@ -341,8 +341,8 @@ public class PayloadMassDriver extends PayloadBlock{
@Override @Override
public void draw(){ public void draw(){
float float
tx = x + Angles.trnsx(turretRotation + 180f, reload * knockback), tx = x + Angles.trnsx(turretRotation + 180f, reloadCounter * knockback),
ty = y + Angles.trnsy(turretRotation + 180f, reload * knockback), r = turretRotation - 90; ty = y + Angles.trnsy(turretRotation + 180f, reloadCounter * knockback), r = turretRotation - 90;
Draw.rect(baseRegion, x, y); Draw.rect(baseRegion, x, y);
@@ -476,7 +476,7 @@ public class PayloadMassDriver extends PayloadBlock{
write.f(turretRotation); write.f(turretRotation);
write.b((byte)state.ordinal()); write.b((byte)state.ordinal());
write.f(reload); write.f(reloadCounter);
write.f(charge); write.f(charge);
write.bool(loaded); write.bool(loaded);
write.bool(charging); write.bool(charging);
@@ -490,7 +490,7 @@ public class PayloadMassDriver extends PayloadBlock{
state = PayloadDriverState.all[read.b()]; state = PayloadDriverState.all[read.b()];
if(revision >= 1){ if(revision >= 1){
reload = read.f(); reloadCounter = read.f();
charge = read.f(); charge = read.f();
loaded = read.bool(); loaded = read.bool();
charging = read.bool(); charging = read.bool();