🚮Upgrade cleanup
This commit is contained in:
@@ -1701,6 +1701,12 @@ public class Blocks implements ContentList{
|
|||||||
itemCapacity = 30;
|
itemCapacity = 30;
|
||||||
|
|
||||||
constructTime = 60f * 5f;
|
constructTime = 60f * 5f;
|
||||||
|
|
||||||
|
upgrades = new UnitType[][]{
|
||||||
|
{UnitTypes.dagger, UnitTypes.titan},
|
||||||
|
{UnitTypes.crawler, UnitTypes.eruptor},
|
||||||
|
{UnitTypes.wraith, UnitTypes.ghoul},
|
||||||
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
repairPoint = new RepairPoint("repair-point"){{
|
repairPoint = new RepairPoint("repair-point"){{
|
||||||
|
|||||||
@@ -99,9 +99,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
titan = new UnitType("titan"){{
|
titan = new UnitType("titan"){{
|
||||||
dagger.upgrade = this;
|
|
||||||
tier = 2;
|
|
||||||
|
|
||||||
speed = 0.4f;
|
speed = 0.4f;
|
||||||
hitsize = 9f;
|
hitsize = 9f;
|
||||||
range = 10f;
|
range = 10f;
|
||||||
@@ -193,9 +190,6 @@ public class UnitTypes implements ContentList{
|
|||||||
};
|
};
|
||||||
|
|
||||||
fortress = new UnitType("fortress"){{
|
fortress = new UnitType("fortress"){{
|
||||||
titan.upgrade = this;
|
|
||||||
tier = 3;
|
|
||||||
|
|
||||||
speed = 0.38f;
|
speed = 0.38f;
|
||||||
hitsize = 13f;
|
hitsize = 13f;
|
||||||
rotateSpeed = 3f;
|
rotateSpeed = 3f;
|
||||||
@@ -226,9 +220,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
eruptor = new UnitType("eruptor"){{
|
eruptor = new UnitType("eruptor"){{
|
||||||
crawler.upgrade = this;
|
|
||||||
tier = 2;
|
|
||||||
|
|
||||||
speed = 0.4f;
|
speed = 0.4f;
|
||||||
drag = 0.4f;
|
drag = 0.4f;
|
||||||
hitsize = 10f;
|
hitsize = 10f;
|
||||||
@@ -269,9 +260,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
ghoul = new UnitType("ghoul"){{
|
ghoul = new UnitType("ghoul"){{
|
||||||
wraith.upgrade = this;
|
|
||||||
tier = 2;
|
|
||||||
|
|
||||||
health = 220;
|
health = 220;
|
||||||
speed = 2f;
|
speed = 2f;
|
||||||
accel = 0.08f;
|
accel = 0.08f;
|
||||||
@@ -297,9 +285,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
revenant = new UnitType("revenant"){{
|
revenant = new UnitType("revenant"){{
|
||||||
ghoul.upgrade = this;
|
|
||||||
tier = 3;
|
|
||||||
|
|
||||||
health = 220;
|
health = 220;
|
||||||
speed = 1.9f;
|
speed = 1.9f;
|
||||||
accel = 0.04f;
|
accel = 0.04f;
|
||||||
@@ -459,8 +444,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
oculon = new UnitType("oculon"){{
|
oculon = new UnitType("oculon"){{
|
||||||
tier = 2;
|
|
||||||
|
|
||||||
drillTier = -1;
|
drillTier = -1;
|
||||||
speed = 0.6f;
|
speed = 0.6f;
|
||||||
hitsize = 9f;
|
hitsize = 9f;
|
||||||
@@ -492,8 +475,6 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
trident = new UnitType("trident"){{
|
trident = new UnitType("trident"){{
|
||||||
//wraith.upgrade = this;
|
|
||||||
tier = 3;
|
|
||||||
|
|
||||||
health = 500;
|
health = 500;
|
||||||
speed = 2f;
|
speed = 2f;
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ abstract class BlockUnitComp implements Unitc{
|
|||||||
return tile == null || tile.dead();
|
return tile == null || tile.dead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Replace
|
||||||
|
public boolean isValid(){
|
||||||
|
return tile != null && tile.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
@Replace
|
@Replace
|
||||||
public void team(Team team){
|
public void team(Team team){
|
||||||
if(tile != null && this.team != team){
|
if(tile != null && this.team != team){
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(unit.dead() || !unit.isAdded()){
|
if(!unit.isValid()){
|
||||||
clearUnit();
|
clearUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ public class UnitType extends UnlockableContent{
|
|||||||
public boolean flying;
|
public boolean flying;
|
||||||
public @NonNull Prov<? extends Unitc> constructor;
|
public @NonNull Prov<? extends Unitc> constructor;
|
||||||
public @NonNull Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
|
public @NonNull Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
|
||||||
public @Nullable UnitType upgrade;
|
|
||||||
public int tier = 1;
|
|
||||||
public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f;
|
public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f;
|
||||||
public float drag = 0.3f, accel = 0.5f, landShake = 0f;
|
public float drag = 0.3f, accel = 0.5f, landShake = 0f;
|
||||||
public float health = 200f, range = -1, armor = 0f;
|
public float health = 200f, range = -1, armor = 0f;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import mindustry.entities.*;
|
|||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -19,8 +20,8 @@ public class Reconstructor extends UnitBlock{
|
|||||||
public @Load(value = "@-top", fallback = "factory-top") TextureRegion topRegion;
|
public @Load(value = "@-top", fallback = "factory-top") TextureRegion topRegion;
|
||||||
public @Load(value = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
public @Load(value = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
||||||
public @Load(value = "@-in", fallback = "factory-in") TextureRegion inRegion;
|
public @Load(value = "@-in", fallback = "factory-in") TextureRegion inRegion;
|
||||||
public int tier = 1;
|
|
||||||
public float constructTime = 60 * 2;
|
public float constructTime = 60 * 2;
|
||||||
|
public UnitType[][] upgrades = {};
|
||||||
|
|
||||||
public Reconstructor(String name){
|
public Reconstructor(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -57,8 +58,7 @@ public class Reconstructor extends UnitBlock{
|
|||||||
return this.payload == null
|
return this.payload == null
|
||||||
&& relativeTo(source) != rotation()
|
&& relativeTo(source) != rotation()
|
||||||
&& payload instanceof UnitPayload
|
&& payload instanceof UnitPayload
|
||||||
&& ((UnitPayload)payload).unit.type().upgrade != null
|
&& hasUpgrade(((UnitPayload)payload).unit.type());
|
||||||
&& ((UnitPayload)payload).unit.type().tier == tier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,7 +79,7 @@ public class Reconstructor extends UnitBlock{
|
|||||||
Draw.alpha(1f - progress/ constructTime);
|
Draw.alpha(1f - progress/ constructTime);
|
||||||
Draw.rect(payload.unit.type().icon(Cicon.full), x, y, rotdeg() - 90);
|
Draw.rect(payload.unit.type().icon(Cicon.full), x, y, rotdeg() - 90);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
Drawf.construct(this, payload.unit.type().upgrade, rotdeg() - 90f, progress / constructTime, speedScl, time);
|
Drawf.construct(this, upgrade(payload.unit.type()), rotdeg() - 90f, progress / constructTime, speedScl, time);
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
Draw.z(Layer.blockOver);
|
Draw.z(Layer.blockOver);
|
||||||
@@ -98,7 +98,7 @@ public class Reconstructor extends UnitBlock{
|
|||||||
|
|
||||||
if(payload != null){
|
if(payload != null){
|
||||||
//check if offloading
|
//check if offloading
|
||||||
if(payload.unit.type().upgrade == null || payload.unit.type().tier != tier){
|
if(!hasUpgrade(payload.unit.type())){
|
||||||
moveOutPayload();
|
moveOutPayload();
|
||||||
}else{ //update progress
|
}else{ //update progress
|
||||||
if(moveInPayload()){
|
if(moveInPayload()){
|
||||||
@@ -109,7 +109,7 @@ public class Reconstructor extends UnitBlock{
|
|||||||
|
|
||||||
//upgrade the unit
|
//upgrade the unit
|
||||||
if(progress >= constructTime){
|
if(progress >= constructTime){
|
||||||
payload.unit = payload.unit.type().upgrade.create(payload.unit.team());
|
payload.unit = upgrade(payload.unit.type()).create(payload.unit.team());
|
||||||
progress = 0;
|
progress = 0;
|
||||||
Effects.shake(2f, 3f, this);
|
Effects.shake(2f, 3f, this);
|
||||||
Fx.producesmoke.at(this);
|
Fx.producesmoke.at(this);
|
||||||
@@ -124,7 +124,16 @@ public class Reconstructor extends UnitBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean constructing(){
|
public boolean constructing(){
|
||||||
return payload != null && payload.unit.type().upgrade != null && payload.unit.type().tier == tier;
|
return payload != null && hasUpgrade(payload.unit.type());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUpgrade(UnitType type){
|
||||||
|
return upgrade(type) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitType upgrade(UnitType type){
|
||||||
|
UnitType[] r = Structs.find(upgrades, arr -> arr[0] == type);
|
||||||
|
return r == null ? null : r[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user