Support for team-only lighting

This commit is contained in:
Anuken
2020-06-15 13:54:02 -04:00
parent b5660a50ca
commit 7001ad09cb
24 changed files with 90 additions and 75 deletions
+21 -16
View File
@@ -8,6 +8,7 @@ import arc.math.geom.*;
import arc.util.*;
import mindustry.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.ui.*;
import mindustry.world.*;
@@ -48,24 +49,28 @@ public class Drawf{
return z;
}
public static void light(float x, float y, float radius, Color color, float opacity){
renderer.lights.add(x, y, radius, color, opacity);
public static void light(Team team, float x, float y, float radius, Color color, float opacity){
if(allowLight(team)) renderer.lights.add(x, y, radius, color, opacity);
}
public static void light(Position pos, float radius, Color color, float opacity){
light(pos.getX(), pos.getY(), radius, color, opacity);
public static void light(Team team, Position pos, float radius, Color color, float opacity){
light(team, pos.getX(), pos.getY(), radius, color, opacity);
}
public static void light(float x, float y, TextureRegion region, Color color, float opacity){
renderer.lights.add(x, y, region, color, opacity);
public static void light(Team team, float x, float y, TextureRegion region, Color color, float opacity){
if(allowLight(team)) renderer.lights.add(x, y, region, color, opacity);
}
public static void light(float x, float y, float x2, float y2){
renderer.lights.line(x, y, x2, y2, 30, Color.orange, 0.3f);
public static void light(Team team, float x, float y, float x2, float y2){
if(allowLight(team)) renderer.lights.line(x, y, x2, y2, 30, Color.orange, 0.3f);
}
public static void light(float x, float y, float x2, float y2, float stroke, Color tint, float alpha){
renderer.lights.line(x, y, x2, y2, stroke, tint, alpha);
public static void light(Team team, float x, float y, float x2, float y2, float stroke, Color tint, float alpha){
if(allowLight(team)) renderer.lights.line(x, y, x2, y2, stroke, tint, alpha);
}
private static boolean allowLight(Team team){
return team == Team.derelict || team == Vars.player.team() || state.rules.enemyLights;
}
public static void selected(Tilec tile, Color color){
@@ -155,15 +160,15 @@ public class Drawf{
Draw.color();
}
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float scale){
laser(line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), scale);
public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float scale){
laser(team, line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), scale);
}
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2){
laser(line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), 1f);
public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2){
laser(team, line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), 1f);
}
public static void laser(TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float rotation, float scale){
public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float rotation, float scale){
Tmp.v1.trns(rotation, 8f * scale * Draw.scl);
Draw.rect(edge, x, y, edge.getWidth() * scale * Draw.scl, edge.getHeight() * scale * Draw.scl, rotation + 180);
@@ -175,7 +180,7 @@ public class Drawf{
Lines.precise(false);
Lines.stroke(1f);
Drawf.light(x, y, x2, y2);
light(team, x, y, x2, y2);
}
public static void tri(float x, float y, float width, float length, float rotation){