Switched to unit UI icons for minimap/players

This commit is contained in:
Anuken 2024-04-18 10:05:21 -04:00
parent 243cc1e527
commit 604e732edb
5 changed files with 15 additions and 4 deletions

View File

@ -43,6 +43,12 @@ abstract class BlockUnitComp implements Unitc{
return tile.block.fullIcon;
}
@Replace
@Override
public TextureRegion uiIcon(){
return tile.block.uiIcon;
}
@Override
public void killed(){
tile.kill();

View File

@ -72,9 +72,9 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
public TextureRegion icon(){
//display default icon for dead players
if(dead()) return core() == null ? UnitTypes.alpha.fullIcon : ((CoreBlock)bestCore().block).unitType.fullIcon;
if(dead()) return core() == null ? UnitTypes.alpha.uiIcon : ((CoreBlock)bestCore().block).unitType.uiIcon;
return unit.icon();
return unit.uiIcon();
}
public boolean displayAmmo(){

View File

@ -671,6 +671,11 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return type.fullIcon;
}
/** @return a preview UI icon for this unit. */
public TextureRegion uiIcon(){
return type.uiIcon;
}
/** Actually destroys the unit, removing it and creating explosions. **/
public void destroy(){
if(!isAdded() || !type.killable) return;

View File

@ -166,7 +166,7 @@ public class MinimapRenderer{
if(unit.inFogTo(player.team()) || !unit.type.drawMinimap) continue;
float scale = Scl.scl(1f) * tilesize * 3;
var region = unit.icon();
var region = unit.uiIcon();
Draw.mixcol(unit.team.color, 1f);
Draw.rect(region, unit.x, unit.y, scale, scale * (float)region.height / region.width, unit.rotation() - 90);

View File

@ -129,7 +129,7 @@ public class OverlayRenderer{
Draw.mixcol(Pal.accent, 1f);
Draw.alpha(unitFade);
Building build = (select instanceof BlockUnitc b ? b.tile() : select instanceof Building b ? b : null);
TextureRegion region = build != null ? build.block.fullIcon : select instanceof Unit u ? u.icon() : Core.atlas.white();
TextureRegion region = build != null ? build.block.fullIcon : Core.atlas.white();
if(!(select instanceof Unitc)){
Draw.rect(region, select.getX(), select.getY());