Skip to content

Commit

Permalink
Improve transparent and invisible units for modded content
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed May 3, 2024
1 parent ad649be commit 7ea34cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 7 additions & 0 deletions core/src/mindustry/entities/comp/UnitComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mindustry.ai.*;
import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*;
import mindustry.client.*;
import mindustry.client.navigation.*;
import mindustry.content.*;
import mindustry.core.*;
Expand Down Expand Up @@ -747,6 +748,12 @@ public boolean isImmune(StatusEffect effect){

@Override
public void draw(){
UnitType.alpha =
ClientVars.hidingUnits || ClientVars.hidingAirUnits && isFlying() ? 0 :
(controller() instanceof Player p && p.assisting && !p.isLocal() && !type.isModded()) ? UnitType.formationAlpha : // Don't draw modded units with partial transparency as it won't apply to custom UnitType.draw() code
1;
if (UnitType.alpha == 0) return; // Don't bother drawing what we can't see.

type.draw(self());
}

Expand Down
6 changes: 0 additions & 6 deletions core/src/mindustry/type/UnitType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import mindustry.ai.Pathfinder.*;
import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*;
import mindustry.client.*;
import mindustry.content.*;
import mindustry.core.*;
import mindustry.ctype.*;
Expand Down Expand Up @@ -1179,11 +1178,6 @@ public void draw(Unit unit){
boolean isPayload = !unit.isAdded();

Mechc mech = unit instanceof Mechc ? (Mechc)unit : null;
alpha =
ClientVars.hidingUnits || ClientVars.hidingAirUnits && unit.isFlying() ? 0 :
(unit.controller() instanceof Player p && p.assisting && !p.isLocal()) ? formationAlpha :
1;
if (alpha == 0) return; // Don't bother drawing what we can't see.
float z = isPayload ? Draw.z() : unit.elevation > 0.5f ? (lowAltitude ? Layer.flyingUnitLow : Layer.flyingUnit) : groundLayer + Mathf.clamp(hitSize / 4000f, 0, 0.01f);

if(unit.controller().isBeingControlled(player.unit())){
Expand Down

0 comments on commit 7ea34cf

Please sign in to comment.