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