Unit production limit tweaks
This commit is contained in:
@@ -1422,6 +1422,7 @@ public class UnitTypes implements ContentList{
|
||||
reload = 17f;
|
||||
x = 2.75f;
|
||||
y = 1f;
|
||||
top = false;
|
||||
|
||||
bullet = new BasicBulletType(2.5f, 9){{
|
||||
width = 7f;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.*;
|
||||
@@ -11,7 +13,10 @@ import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class UnitPayload implements Payload{
|
||||
public static final float deactiveDuration = 40f;
|
||||
|
||||
public Unit unit;
|
||||
public float deactiveTime = 0f;
|
||||
|
||||
public UnitPayload(Unit unit){
|
||||
this.unit = unit;
|
||||
@@ -37,6 +42,11 @@ public class UnitPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public boolean dump(){
|
||||
if(!Units.canCreate(unit.team, unit.type())){
|
||||
deactiveTime = 1f;
|
||||
return false;
|
||||
}
|
||||
|
||||
//naval units need water.
|
||||
if(unit instanceof WaterMovec){
|
||||
int tx = unit.tileX(), ty = unit.tileY();
|
||||
@@ -63,5 +73,18 @@ public class UnitPayload implements Payload{
|
||||
public void draw(){
|
||||
Drawf.shadow(unit.x, unit.y, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), unit.x, unit.y, unit.rotation - 90);
|
||||
|
||||
//draw warning
|
||||
if(deactiveTime > 0){
|
||||
Draw.color(Color.scarlet);
|
||||
Draw.alpha(0.8f * Interp.exp5Out.apply(deactiveTime));
|
||||
|
||||
float size = 8f;
|
||||
Draw.rect(Icon.warning.getRegion(), unit.x, unit.y, size, size);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
deactiveTime = Math.max(deactiveTime - Time.delta/deactiveDuration, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,11 +161,7 @@ public class Reconstructor extends UnitBlock{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(){
|
||||
//do not consume when cap reached
|
||||
if(constructing()){
|
||||
return Units.canCreate(team, upgrade(payload.unit.type()));
|
||||
}
|
||||
return false;
|
||||
return constructing();
|
||||
}
|
||||
|
||||
public UnitType unit(){
|
||||
|
||||
@@ -55,7 +55,9 @@ public class UnitBlock extends PayloadAcceptor{
|
||||
|
||||
@Override
|
||||
public void dumpPayload(){
|
||||
Call.unitBlockSpawn(tile);
|
||||
if(payload.dump()){
|
||||
Call.unitBlockSpawn(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,10 +219,7 @@ public class UnitFactory extends UnitBlock{
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(){
|
||||
//do not consume when cap reached
|
||||
if(currentPlan != -1 && !Units.canCreate(team, plans[currentPlan].unit)){
|
||||
return false;
|
||||
}
|
||||
if(currentPlan == -1) return false;
|
||||
return enabled && payload == null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user