Merge pull request #2726 from Voz-Duh/shadow-fix

Shadow Fix
This commit is contained in:
Anuken 2020-09-25 09:53:13 -04:00 committed by GitHub
commit 85d32cd510
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 15 deletions

View file

@ -72,8 +72,6 @@ public class Vars implements Loadable{
public static final int maxTextLength = 150;
/** max player name length in bytes */
public static final int maxNameLength = 40;
/** shadow color for turrets */
public static final float turretShadowColor = Color.toFloatBits(0, 0, 0, 0.22f);
/** displayed item size when ingame. */
public static final float itemSize = 5f;
/** units outside of this bound will die instantly */

View file

@ -84,6 +84,18 @@ public class Drawf{
Draw.color();
}
public static void shadow(TextureRegion region, float x, float y, float rotation){
Draw.color(Pal.shadow);
Draw.rect(region, x, y, rotation);
Draw.color();
}
public static void shadow(TextureRegion region, float x, float y){
Draw.color(Pal.shadow);
Draw.rect(region, x, y);
Draw.color();
}
public static void dashCircle(float x, float y, float rad, Color color){
Lines.stroke(3f, Pal.gray);
Lines.dashCircle(x, y, rad);

View file

@ -47,6 +47,7 @@ public class Pal{
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
darkerGray = new Color(0.2f, 0.2f, 0.2f, 1f),
darkestGray = new Color(0.1f, 0.1f, 0.1f, 1f),
shadow = new Color(0, 0, 0, 0.22f),
ammo = Color.valueOf("ff8947"),
rubble = Color.valueOf("1c1817"),

View file

@ -34,7 +34,7 @@ import mindustry.world.consumers.*;
import static mindustry.Vars.*;
public class UnitType extends UnlockableContent{
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f), outlineSpace = 0.01f;
public static final float shadowTX = -12, shadowTY = -13, outlineSpace = 0.01f;
private static final Vec2 legOffset = new Vec2();
/** If true, the unit is always at elevation 1. */
@ -409,7 +409,7 @@ public class UnitType extends UnlockableContent{
}
public void drawShadow(Unit unit){
Draw.color(shadowColor);
Draw.color(Pal.shadow);
float e = Math.max(unit.elevation, visualElevation);
Draw.rect(shadowRegion, unit.x + shadowTX * e, unit.y + shadowTY * e, unit.rotation - 90);
Draw.color();
@ -594,7 +594,7 @@ public class UnitType extends UnlockableContent{
if(leg.moving && visualElevation > 0){
float scl = visualElevation;
float elev = Mathf.slope(1f - leg.stage) * scl;
Draw.color(shadowColor);
Draw.color(Pal.shadow);
Draw.rect(footRegion, leg.base.x + shadowTX * elev, leg.base.y + shadowTY * elev, position.angleTo(leg.base));
Draw.color();
}

View file

@ -112,9 +112,7 @@ public class PointDefenseTurret extends Block{
@Override
public void draw(){
Draw.rect(baseRegion, x, y);
Draw.color(Vars.turretShadowColor);
Draw.rect(region, x - (size / 2f), y - (size / 2f), rotation - 90);
Draw.color();
Drawf.shadow(region, x - (size / 2f), y - (size / 2f), rotation - 90);
Draw.rect(region, x, y, rotation - 90);
}

View file

@ -107,9 +107,7 @@ public class TractorBeamTurret extends Block{
@Override
public void draw(){
Draw.rect(baseRegion, x, y);
Draw.color(Vars.turretShadowColor);
Draw.rect(region, x - (size / 2f), y - (size / 2f), rotation - 90);
Draw.color();
Drawf.shadow(region, x - (size / 2f), y - (size / 2f), rotation - 90);
Draw.rect(region, x, y, rotation - 90);
//draw laser if applicable

View file

@ -11,7 +11,6 @@ import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
@ -203,9 +202,7 @@ public abstract class Turret extends Block{
tr2.trns(rotation, -recoil);
Draw.color(Vars.turretShadowColor);
Draw.rect(region, x + tr2.x - (size / 2f), y + tr2.y - (size / 2f), rotation - 90);
Draw.color();
Drawf.shadow(region, x + tr2.x - (size / 2f), y + tr2.y - (size / 2f), rotation - 90);
drawer.get(this);
if(heatRegion != Core.atlas.find("error")){

View file

@ -188,6 +188,9 @@ public class MassDriver extends Block{
Draw.z(Layer.turret);
Drawf.shadow(region,
x + Angles.trnsx(rotation + 180f, reload * knockback) - (size / 2),
y + Angles.trnsy(rotation + 180f, reload * knockback) - (size / 2), rotation - 90);
Draw.rect(region,
x + Angles.trnsx(rotation + 180f, reload * knockback),
y + Angles.trnsy(rotation + 180f, reload * knockback), rotation - 90);

View file

@ -6,6 +6,7 @@ import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.*;
import mindustry.gen.*;
@ -70,6 +71,7 @@ public class RepairPoint extends Block{
Draw.rect(baseRegion, x, y);
Draw.z(Layer.turret);
Drawf.shadow(region, x - (size / 2), y - (size / 2), rotation - 90);
Draw.rect(region, x, y, rotation - 90);
if(target != null && Angles.angleDist(angleTo(target), rotation) < 30f){