No timers for driver payloads

This commit is contained in:
Anuken
2021-06-04 11:52:27 -04:00
parent 944b9ae2cf
commit a1cae3bc29
@@ -122,7 +122,8 @@ public class PayloadMassDriver extends PayloadBlock{
public float turretRotation = 90; public float turretRotation = 90;
public float reload = 0f, charge = 0f; public float reload = 0f, charge = 0f;
public float targetSize = grabWidth*2f, curSize = targetSize; public float targetSize = grabWidth*2f, curSize = targetSize;
public float payLength = 0f; public float payLength = 0f, effectDelayTimer = -1f;
public PayloadDriverBuild lastOther;
public boolean loaded; public boolean loaded;
public boolean charging; public boolean charging;
public PayloadDriverState state = idle; public PayloadDriverState state = idle;
@@ -151,6 +152,16 @@ public class PayloadMassDriver extends PayloadBlock{
targetSize = payload.size(); targetSize = payload.size();
} }
boolean pos = effectDelayTimer > 0;
effectDelayTimer -= Time.delta;
if(effectDelayTimer <= 0 && pos && lastOther != null){
var other = lastOther;
float cx = Angles.trnsx(other.turretRotation, length), cy = Angles.trnsy(other.turretRotation, length);
receiveEffect.at(x - cx/2f, y - cy/2f, turretRotation);
reload = 1f;
Effect.shake(shake, shake, this);
}
charging = false; charging = false;
if(hasLink){ if(hasLink){
@@ -192,7 +203,7 @@ public class PayloadMassDriver extends PayloadBlock{
payVector.setZero(); payVector.setZero();
payRotation = Angles.moveToward(payRotation, turretRotation + 180f, payloadRotateSpeed * delta()); payRotation = Angles.moveToward(payRotation, turretRotation + 180f, payloadRotateSpeed * delta());
} }
}else{ }else if(effectDelayTimer <= 0){
moveOutPayload(); moveOutPayload();
} }
} }
@@ -270,14 +281,11 @@ public class PayloadMassDriver extends PayloadBlock{
transferEffect.at(x + cx, y + cy, turretRotation, new PayloadMassDriverData(x + cx, y + cy, other.x - cx, other.y - cy, payload)); transferEffect.at(x + cx, y + cy, turretRotation, new PayloadMassDriverData(x + cx, y + cy, other.x - cx, other.y - cy, payload));
Payload pay = payload; Payload pay = payload;
other.recPayload = payload; other.recPayload = payload;
other.effectDelayTimer = transferEffect.lifetime;
Time.run(transferEffect.lifetime, () -> {
receiveEffect.at(other.x - cx/2f, other.y - cy/2f, other.turretRotation);
Effect.shake(shake, shake, this);
//transfer payload //transfer payload
other.reload = 1f;
other.handlePayload(this, pay); other.handlePayload(this, pay);
other.lastOther = this;
other.payVector.set(-cx, -cy); other.payVector.set(-cx, -cy);
other.payRotation = turretRotation; other.payRotation = turretRotation;
other.payLength = length; other.payLength = length;
@@ -289,7 +297,6 @@ public class PayloadMassDriver extends PayloadBlock{
other.waitingShooters.removeFirst(); other.waitingShooters.removeFirst();
} }
other.state = idle; other.state = idle;
});
//reset state after shooting immediately //reset state after shooting immediately
payload = null; payload = null;
@@ -341,9 +348,11 @@ public class PayloadMassDriver extends PayloadBlock{
if(payload != null){ if(payload != null){
updatePayload(); updatePayload();
if(effectDelayTimer <= 0){
Draw.z(loaded ? Layer.blockOver + 0.2f : Layer.blockOver); Draw.z(loaded ? Layer.blockOver + 0.2f : Layer.blockOver);
payload.draw(); payload.draw();
} }
}
Draw.z(Layer.blockOver + 0.1f); Draw.z(Layer.blockOver + 0.1f);
Draw.rect(topRegion, x, y); Draw.rect(topRegion, x, y);