mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 05:51:47 -08:00
🚮Upgrade cleanup
This commit is contained in:
parent
34568f12d6
commit
140e1fa53e
6 changed files with 28 additions and 29 deletions
|
|
@ -1701,6 +1701,12 @@ public class Blocks implements ContentList{
|
|||
itemCapacity = 30;
|
||||
|
||||
constructTime = 60f * 5f;
|
||||
|
||||
upgrades = new UnitType[][]{
|
||||
{UnitTypes.dagger, UnitTypes.titan},
|
||||
{UnitTypes.crawler, UnitTypes.eruptor},
|
||||
{UnitTypes.wraith, UnitTypes.ghoul},
|
||||
};
|
||||
}};
|
||||
|
||||
repairPoint = new RepairPoint("repair-point"){{
|
||||
|
|
|
|||
|
|
@ -99,9 +99,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
titan = new UnitType("titan"){{
|
||||
dagger.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
speed = 0.4f;
|
||||
hitsize = 9f;
|
||||
range = 10f;
|
||||
|
|
@ -193,9 +190,6 @@ public class UnitTypes implements ContentList{
|
|||
};
|
||||
|
||||
fortress = new UnitType("fortress"){{
|
||||
titan.upgrade = this;
|
||||
tier = 3;
|
||||
|
||||
speed = 0.38f;
|
||||
hitsize = 13f;
|
||||
rotateSpeed = 3f;
|
||||
|
|
@ -226,9 +220,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
eruptor = new UnitType("eruptor"){{
|
||||
crawler.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
speed = 0.4f;
|
||||
drag = 0.4f;
|
||||
hitsize = 10f;
|
||||
|
|
@ -269,9 +260,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
ghoul = new UnitType("ghoul"){{
|
||||
wraith.upgrade = this;
|
||||
tier = 2;
|
||||
|
||||
health = 220;
|
||||
speed = 2f;
|
||||
accel = 0.08f;
|
||||
|
|
@ -297,9 +285,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
revenant = new UnitType("revenant"){{
|
||||
ghoul.upgrade = this;
|
||||
tier = 3;
|
||||
|
||||
health = 220;
|
||||
speed = 1.9f;
|
||||
accel = 0.04f;
|
||||
|
|
@ -459,8 +444,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
oculon = new UnitType("oculon"){{
|
||||
tier = 2;
|
||||
|
||||
drillTier = -1;
|
||||
speed = 0.6f;
|
||||
hitsize = 9f;
|
||||
|
|
@ -492,8 +475,6 @@ public class UnitTypes implements ContentList{
|
|||
}};
|
||||
|
||||
trident = new UnitType("trident"){{
|
||||
//wraith.upgrade = this;
|
||||
tier = 3;
|
||||
|
||||
health = 500;
|
||||
speed = 2f;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ abstract class BlockUnitComp implements Unitc{
|
|||
return tile == null || tile.dead();
|
||||
}
|
||||
|
||||
@Replace
|
||||
public boolean isValid(){
|
||||
return tile != null && tile.isValid();
|
||||
}
|
||||
|
||||
@Replace
|
||||
public void team(Team team){
|
||||
if(tile != null && this.team != team){
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||
|
||||
@Override
|
||||
public void update(){
|
||||
if(unit.dead() || !unit.isAdded()){
|
||||
if(!unit.isValid()){
|
||||
clearUnit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ public class UnitType extends UnlockableContent{
|
|||
public boolean flying;
|
||||
public @NonNull Prov<? extends Unitc> constructor;
|
||||
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 drag = 0.3f, accel = 0.5f, landShake = 0f;
|
||||
public float health = 200f, range = -1, armor = 0f;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import mindustry.entities.*;
|
|||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
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 = "@-out", fallback = "factory-out") TextureRegion outRegion;
|
||||
public @Load(value = "@-in", fallback = "factory-in") TextureRegion inRegion;
|
||||
public int tier = 1;
|
||||
public float constructTime = 60 * 2;
|
||||
public UnitType[][] upgrades = {};
|
||||
|
||||
public Reconstructor(String name){
|
||||
super(name);
|
||||
|
|
@ -57,8 +58,7 @@ public class Reconstructor extends UnitBlock{
|
|||
return this.payload == null
|
||||
&& relativeTo(source) != rotation()
|
||||
&& payload instanceof UnitPayload
|
||||
&& ((UnitPayload)payload).unit.type().upgrade != null
|
||||
&& ((UnitPayload)payload).unit.type().tier == tier;
|
||||
&& hasUpgrade(((UnitPayload)payload).unit.type());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -79,7 +79,7 @@ public class Reconstructor extends UnitBlock{
|
|||
Draw.alpha(1f - progress/ constructTime);
|
||||
Draw.rect(payload.unit.type().icon(Cicon.full), x, y, rotdeg() - 90);
|
||||
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{
|
||||
Draw.z(Layer.blockOver);
|
||||
|
|
@ -98,7 +98,7 @@ public class Reconstructor extends UnitBlock{
|
|||
|
||||
if(payload != null){
|
||||
//check if offloading
|
||||
if(payload.unit.type().upgrade == null || payload.unit.type().tier != tier){
|
||||
if(!hasUpgrade(payload.unit.type())){
|
||||
moveOutPayload();
|
||||
}else{ //update progress
|
||||
if(moveInPayload()){
|
||||
|
|
@ -109,7 +109,7 @@ public class Reconstructor extends UnitBlock{
|
|||
|
||||
//upgrade the unit
|
||||
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;
|
||||
Effects.shake(2f, 3f, this);
|
||||
Fx.producesmoke.at(this);
|
||||
|
|
@ -124,7 +124,16 @@ public class Reconstructor extends UnitBlock{
|
|||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue