Added unit decal system for mods/future units
This commit is contained in:
25
core/src/mindustry/entities/units/UnitDecal.java
Normal file
25
core/src/mindustry/entities/units/UnitDecal.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package mindustry.entities.units;
|
||||||
|
|
||||||
|
import arc.graphics.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
|
||||||
|
/** A sprite drawn in addition to the base unit sprites. */
|
||||||
|
public class UnitDecal{
|
||||||
|
public String region = "error";
|
||||||
|
public float x, y, rotation;
|
||||||
|
public float layer = Layer.flyingUnit + 1f;
|
||||||
|
public float xScale = 1f, yScale = 1f;
|
||||||
|
public Color color = Color.white;
|
||||||
|
|
||||||
|
public UnitDecal(String region, float x, float y, float rotation, float layer, Color color){
|
||||||
|
this.region = region;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.rotation = rotation;
|
||||||
|
this.layer = layer;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitDecal(){
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,8 @@ public class UnitType extends UnlockableContent{
|
|||||||
public Effect fallEffect = Fx.fallSmoke;
|
public Effect fallEffect = Fx.fallSmoke;
|
||||||
public Effect fallThrusterEffect = Fx.fallSmoke;
|
public Effect fallThrusterEffect = Fx.fallSmoke;
|
||||||
public Effect deathExplosionEffect = Fx.dynamicExplosion;
|
public Effect deathExplosionEffect = Fx.dynamicExplosion;
|
||||||
|
/** Additional sprites that are drawn with the unit. */
|
||||||
|
public Seq<UnitDecal> decals = new Seq<>();
|
||||||
public Seq<Ability> abilities = new Seq<>();
|
public Seq<Ability> abilities = new Seq<>();
|
||||||
/** Flags to target based on priority. Null indicates that the closest target should be found. The closest enemy core is used as a fallback. */
|
/** Flags to target based on priority. Null indicates that the closest target should be found. The closest enemy core is used as a fallback. */
|
||||||
public BlockFlag[] targetFlags = {null};
|
public BlockFlag[] targetFlags = {null};
|
||||||
@@ -565,6 +567,18 @@ public class UnitType extends UnlockableContent{
|
|||||||
unit.trns(-legOffset.x, -legOffset.y);
|
unit.trns(-legOffset.x, -legOffset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(decals.size > 0){
|
||||||
|
float base = unit.rotation - 90;
|
||||||
|
for(var d : decals){
|
||||||
|
Draw.z(d.layer);
|
||||||
|
Draw.scl(d.xScale, d.yScale);
|
||||||
|
Draw.color(d.color);
|
||||||
|
Draw.rect(d.region, unit.x + Angles.trnsx(base, d.x, d.y), unit.y + Angles.trnsy(base, d.x, d.y), base + d.rotation);
|
||||||
|
}
|
||||||
|
Draw.reset();
|
||||||
|
Draw.z(z);
|
||||||
|
}
|
||||||
|
|
||||||
if(unit.abilities.size > 0){
|
if(unit.abilities.size > 0){
|
||||||
for(Ability a : unit.abilities){
|
for(Ability a : unit.abilities){
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -849,4 +863,5 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -537,7 +537,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
|
|
||||||
//sector notifications & search
|
//sector notifications & search
|
||||||
c.top().right();
|
c.top().right();
|
||||||
c.defaults().width(280f);
|
c.defaults().width(290f);
|
||||||
|
|
||||||
c.button(bundle.get("sectorlist") +
|
c.button(bundle.get("sectorlist") +
|
||||||
(attacked == 0 ? "" : "\n[red]⚠[lightgray] " + bundle.format("sectorlist.attacked", "[red]" + attacked + "[]")),
|
(attacked == 0 ? "" : "\n[red]⚠[lightgray] " + bundle.format("sectorlist.attacked", "[red]" + attacked + "[]")),
|
||||||
@@ -585,6 +585,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
for(Sector sec : all){
|
for(Sector sec : all){
|
||||||
if(sec.hasBase() && (searchText.isEmpty() || sec.name().toLowerCase().contains(searchText.toLowerCase()))){
|
if(sec.hasBase() && (searchText.isEmpty() || sec.name().toLowerCase().contains(searchText.toLowerCase()))){
|
||||||
con.button(t -> {
|
con.button(t -> {
|
||||||
|
t.marginRight(10f);
|
||||||
t.left();
|
t.left();
|
||||||
t.defaults().growX();
|
t.defaults().growX();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user