Custom shield colouring (#9647)
Five extra minutes I had the luxury of spending fixing Git because it exploded again Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -82,7 +82,7 @@ public class ForceFieldAbility extends Ability{
|
|||||||
if(unit.shield <= 0f && !wasBroken){
|
if(unit.shield <= 0f && !wasBroken){
|
||||||
unit.shield -= cooldown * regen;
|
unit.shield -= cooldown * regen;
|
||||||
|
|
||||||
Fx.shieldBreak.at(unit.x, unit.y, radius, unit.team.color, this);
|
Fx.shieldBreak.at(unit.x, unit.y, radius, unit.type.shieldColor(unit), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wasBroken = unit.shield <= 0f;
|
wasBroken = unit.shield <= 0f;
|
||||||
@@ -110,7 +110,7 @@ public class ForceFieldAbility extends Ability{
|
|||||||
checkRadius(unit);
|
checkRadius(unit);
|
||||||
|
|
||||||
if(unit.shield > 0){
|
if(unit.shield > 0){
|
||||||
Draw.color(unit.team.color, Color.white, Mathf.clamp(alpha));
|
Draw.color(unit.type.shieldColor(unit), Color.white, Mathf.clamp(alpha));
|
||||||
|
|
||||||
if(Vars.renderer.animateShields){
|
if(Vars.renderer.animateShields){
|
||||||
Draw.z(Layer.shields + 0.001f * alpha);
|
Draw.z(Layer.shields + 0.001f * alpha);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class ShieldArcAbility extends Ability{
|
|||||||
if(paramField.data <= b.damage()){
|
if(paramField.data <= b.damage()){
|
||||||
paramField.data -= paramField.cooldown * paramField.regen;
|
paramField.data -= paramField.cooldown * paramField.regen;
|
||||||
|
|
||||||
Fx.arcShieldBreak.at(paramPos.x, paramPos.y, 0, paramUnit.team.color, paramUnit);
|
Fx.arcShieldBreak.at(paramPos.x, paramPos.y, 0, paramField.color == null ? paramUnit.type.shieldColor(paramUnit) : paramField.color, paramUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
paramField.data -= b.damage();
|
paramField.data -= b.damage();
|
||||||
@@ -60,6 +60,8 @@ public class ShieldArcAbility extends Ability{
|
|||||||
public boolean drawArc = true;
|
public boolean drawArc = true;
|
||||||
/** If not null, will be drawn on top. */
|
/** If not null, will be drawn on top. */
|
||||||
public @Nullable String region;
|
public @Nullable String region;
|
||||||
|
/** Color override of the shield. Uses unit shield colour by default. */
|
||||||
|
public @Nullable Color color;
|
||||||
/** If true, sprite position will be influenced by x/y. */
|
/** If true, sprite position will be influenced by x/y. */
|
||||||
public boolean offsetRegion = false;
|
public boolean offsetRegion = false;
|
||||||
|
|
||||||
@@ -109,7 +111,7 @@ public class ShieldArcAbility extends Ability{
|
|||||||
if(widthScale > 0.001f){
|
if(widthScale > 0.001f){
|
||||||
Draw.z(Layer.shields);
|
Draw.z(Layer.shields);
|
||||||
|
|
||||||
Draw.color(unit.team.color, Color.white, Mathf.clamp(alpha));
|
Draw.color(color == null ? unit.type.shieldColor(unit) : color, Color.white, Mathf.clamp(alpha));
|
||||||
var pos = paramPos.set(x, y).rotate(unit.rotation - 90f).add(unit);
|
var pos = paramPos.set(x, y).rotate(unit.rotation - 90f).add(unit);
|
||||||
|
|
||||||
if(!Vars.renderer.animateShields){
|
if(!Vars.renderer.animateShields){
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ public class ShieldRegenFieldAbility extends Ability{
|
|||||||
if(other.shield < max){
|
if(other.shield < max){
|
||||||
other.shield = Math.min(other.shield + amount, max);
|
other.shield = Math.min(other.shield + amount, max);
|
||||||
other.shieldAlpha = 1f; //TODO may not be necessary
|
other.shieldAlpha = 1f; //TODO may not be necessary
|
||||||
applyEffect.at(unit.x, unit.y, 0f, unit.team.color, parentizeEffects ? other : null);
|
applyEffect.at(other.x, other.y, 0f, other.type.shieldColor(other), parentizeEffects ? other : null);
|
||||||
applied = true;
|
applied = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(applied){
|
if(applied){
|
||||||
activeEffect.at(unit.x, unit.y, unit.team.color);
|
activeEffect.at(unit.x, unit.y, unit.type.shieldColor(unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = 0f;
|
timer = 0f;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ abstract class ShieldComp implements Healthc, Posc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hadShields && shield <= 0.0001f){
|
if(hadShields && shield <= 0.0001f){
|
||||||
Fx.unitShieldBreak.at(x, y, 0, team.color, this);
|
Fx.unitShieldBreak.at(x, y, 0, type.shieldColor(self()), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
public Color healColor = Pal.heal;
|
public Color healColor = Pal.heal;
|
||||||
/** Color of light that this unit produces when lighting is enabled in the map. */
|
/** Color of light that this unit produces when lighting is enabled in the map. */
|
||||||
public Color lightColor = Pal.powerLight;
|
public Color lightColor = Pal.powerLight;
|
||||||
|
/** override for unit shield colour. */
|
||||||
|
public @Nullable Color shieldColor;
|
||||||
/** sound played when this unit explodes (*not* when it is shot down) */
|
/** sound played when this unit explodes (*not* when it is shot down) */
|
||||||
public Sound deathSound = Sounds.bang;
|
public Sound deathSound = Sounds.bang;
|
||||||
/** sound played on loop when this unit is around. */
|
/** sound played on loop when this unit is around. */
|
||||||
@@ -1305,6 +1307,12 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//...where do I put this
|
||||||
|
public Color shieldColor(Unit unit){
|
||||||
|
return shieldColor == null ? unit.team.color : shieldColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void drawMining(Unit unit){
|
public void drawMining(Unit unit){
|
||||||
if(!unit.mining()) return;
|
if(!unit.mining()) return;
|
||||||
@@ -1345,7 +1353,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
float radius = unit.hitSize() * 1.3f;
|
float radius = unit.hitSize() * 1.3f;
|
||||||
Fill.light(unit.x, unit.y, Lines.circleVertices(radius), radius,
|
Fill.light(unit.x, unit.y, Lines.circleVertices(radius), radius,
|
||||||
Color.clear,
|
Color.clear,
|
||||||
Tmp.c2.set(unit.team.color).lerp(Color.white, Mathf.clamp(unit.hitTime() / 2f)).a(0.7f * alpha)
|
Tmp.c2.set(unit.type.shieldColor(unit)).lerp(Color.white, Mathf.clamp(unit.hitTime() / 2f)).a(0.7f * alpha)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user