No timers for driver payloads
This commit is contained in:
@@ -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,26 +281,22 @@ 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, () -> {
|
//transfer payload
|
||||||
receiveEffect.at(other.x - cx/2f, other.y - cy/2f, other.turretRotation);
|
other.handlePayload(this, pay);
|
||||||
Effect.shake(shake, shake, this);
|
other.lastOther = this;
|
||||||
|
other.payVector.set(-cx, -cy);
|
||||||
|
other.payRotation = turretRotation;
|
||||||
|
other.payLength = length;
|
||||||
|
other.loaded = true;
|
||||||
|
other.updatePayload();
|
||||||
|
other.recPayload = null;
|
||||||
|
|
||||||
//transfer payload
|
if(other.waitingShooters.size != 0 && other.waitingShooters.first() == this){
|
||||||
other.reload = 1f;
|
other.waitingShooters.removeFirst();
|
||||||
other.handlePayload(this, pay);
|
}
|
||||||
other.payVector.set(-cx, -cy);
|
other.state = idle;
|
||||||
other.payRotation = turretRotation;
|
|
||||||
other.payLength = length;
|
|
||||||
other.loaded = true;
|
|
||||||
other.updatePayload();
|
|
||||||
other.recPayload = null;
|
|
||||||
|
|
||||||
if(other.waitingShooters.size != 0 && other.waitingShooters.first() == this){
|
|
||||||
other.waitingShooters.removeFirst();
|
|
||||||
}
|
|
||||||
other.state = idle;
|
|
||||||
});
|
|
||||||
|
|
||||||
//reset state after shooting immediately
|
//reset state after shooting immediately
|
||||||
payload = null;
|
payload = null;
|
||||||
@@ -341,8 +348,10 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||||||
if(payload != null){
|
if(payload != null){
|
||||||
updatePayload();
|
updatePayload();
|
||||||
|
|
||||||
Draw.z(loaded ? Layer.blockOver + 0.2f : Layer.blockOver);
|
if(effectDelayTimer <= 0){
|
||||||
payload.draw();
|
Draw.z(loaded ? Layer.blockOver + 0.2f : Layer.blockOver);
|
||||||
|
payload.draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.z(Layer.blockOver + 0.1f);
|
Draw.z(Layer.blockOver + 0.1f);
|
||||||
|
|||||||
Reference in New Issue
Block a user