UnitSpawnAbility 'type' field JSON compat / Fixed health bar out of bounds

This commit is contained in:
Anuken
2021-02-26 18:51:14 -05:00
parent d06eee99ba
commit ae6be1db3b
4 changed files with 12 additions and 10 deletions
@@ -15,14 +15,14 @@ import mindustry.ui.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class UnitSpawnAbility extends Ability{ public class UnitSpawnAbility extends Ability{
public UnitType type; public UnitType unit;
public float spawnTime = 60f, spawnX, spawnY; public float spawnTime = 60f, spawnX, spawnY;
public Effect spawnEffect = Fx.spawn; public Effect spawnEffect = Fx.spawn;
protected float timer; protected float timer;
public UnitSpawnAbility(UnitType type, float spawnTime, float spawnX, float spawnY){ public UnitSpawnAbility(UnitType unit, float spawnTime, float spawnX, float spawnY){
this.type = type; this.unit = unit;
this.spawnTime = spawnTime; this.spawnTime = spawnTime;
this.spawnX = spawnX; this.spawnX = spawnX;
this.spawnY = spawnY; this.spawnY = spawnY;
@@ -35,10 +35,10 @@ public class UnitSpawnAbility extends Ability{
public void update(Unit unit){ public void update(Unit unit){
timer += Time.delta * state.rules.unitBuildSpeedMultiplier; timer += Time.delta * state.rules.unitBuildSpeedMultiplier;
if(timer >= spawnTime && Units.canCreate(unit.team, type)){ if(timer >= spawnTime && Units.canCreate(unit.team, this.unit)){
float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX); float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX);
spawnEffect.at(x, y); spawnEffect.at(x, y);
Unit u = type.create(unit.team); Unit u = this.unit.create(unit.team);
u.set(x, y); u.set(x, y);
u.rotation = unit.rotation; u.rotation = unit.rotation;
if(!Vars.net.client()){ if(!Vars.net.client()){
@@ -51,16 +51,16 @@ public class UnitSpawnAbility extends Ability{
@Override @Override
public void draw(Unit unit){ public void draw(Unit unit){
if(Units.canCreate(unit.team, type)){ if(Units.canCreate(unit.team, this.unit)){
Draw.draw(Draw.z(), () -> { Draw.draw(Draw.z(), () -> {
float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX); float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX);
Drawf.construct(x, y, type.icon(Cicon.full), unit.rotation - 90, timer / spawnTime, 1f, timer); Drawf.construct(x, y, this.unit.icon(Cicon.full), unit.rotation - 90, timer / spawnTime, 1f, timer);
}); });
} }
} }
@Override @Override
public String localized(){ public String localized(){
return Core.bundle.format("ability.unitspawn", type.localizedName); return Core.bundle.format("ability.unitspawn", unit.localizedName);
} }
} }
+1 -1
View File
@@ -337,7 +337,7 @@ public class Net{
*/ */
void discoverServers(Cons<Host> callback, Runnable done); void discoverServers(Cons<Host> callback, Runnable done);
/** Ping a host. If an error occured, failed() should be called with the exception. */ /** Ping a host. If an error occurred, failed() should be called with the exception. */
void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed); void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed);
/** Host a server at specified port. */ /** Host a server at specified port. */
@@ -643,6 +643,8 @@ public class HudFragment extends Fragment{
void drawInner(Color color, float fract){ void drawInner(Color color, float fract){
if(fract < 0) return; if(fract < 0) return;
fract = Mathf.clamp(fract);
if(flip){ if(flip){
x += width; x += width;
width = -width; width = -width;
+1 -1
View File
@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=919af3d6fab9319626fbd0e28ccb0a8588fcc221 archash=9f916a1b401216c68e39635f6c99769391c8555a