Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2025-02-09 13:05:59 -05:00
46 changed files with 264 additions and 68 deletions

View File

@@ -1438,8 +1438,10 @@ rules.title.unit = Units
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1403,8 +1403,10 @@ rules.title.unit = Баяв. адз.
rules.title.experimental = Эксперыментальны
rules.title.environment = Асяродзе
rules.title.teams = Кманды
rules.title.light = Lighting
rules.title.planet = Планета
rules.lighting = Асвятленне
rules.lighting.unitlight = Unit Lighting
rules.fog = Туман Вайны
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1420,8 +1420,10 @@ rules.title.unit = Единици
rules.title.experimental = Експериментално
rules.title.environment = Околна среда
rules.title.teams = Отбори
rules.title.light = Lighting
rules.title.planet = Планета
rules.lighting = Светкавици
rules.lighting.unitlight = Unit Lighting
rules.fog = Мъгла на войната
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1417,8 +1417,10 @@ rules.title.unit = Unitats
rules.title.experimental = Experimental
rules.title.environment = Entorn
rules.title.teams = Equips
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Il·luminació
rules.lighting.unitlight = Unit Lighting
rules.fog = Amaga el terreny inexplorat
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1419,8 +1419,10 @@ rules.title.unit = Jednotky
rules.title.experimental = Experimentální
rules.title.environment = Environmentální
rules.title.teams = Týmy
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Osvětlení
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1405,8 +1405,10 @@ rules.title.unit = Enheder
rules.title.experimental = Eksperimentel
rules.title.environment = Miljø
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lys
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1430,8 +1430,10 @@ rules.title.unit = Einheiten
rules.title.experimental = Experimentell
rules.title.environment = Umgebung
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Blitze
rules.lighting.unitlight = Unit Lighting
rules.fog = Kriegsnebel
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1423,8 +1423,10 @@ rules.title.unit = Unidades
rules.title.experimental = Experimental
rules.title.environment = Entorno
rules.title.teams = Equipos
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Iluminación
rules.lighting.unitlight = Unit Lighting
rules.fog = Ocultar terreno inexplorado (Fog of War)
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1408,8 +1408,10 @@ rules.title.unit = Väeüksused
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1407,8 +1407,10 @@ rules.title.unit = Unitateak
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1406,8 +1406,10 @@ rules.title.unit = Yksiköt
rules.title.experimental = Kokeellinen
rules.title.environment = Ympäristö
rules.title.teams = Joukkueet
rules.title.light = Lighting
rules.title.planet = Planeetta
rules.lighting = Salamointi
rules.lighting.unitlight = Unit Lighting
rules.fog = Sodan sumu (Fog of War)
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1412,8 +1412,10 @@ rules.title.unit = Mga Yunit
rules.title.experimental = Experimental
rules.title.environment = Kapaligiran
rules.title.teams = Mga Team
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1431,8 +1431,10 @@ rules.title.unit = Unités
rules.title.experimental = Expérimental
rules.title.environment = Environnement
rules.title.teams = Équipes
rules.title.light = Lighting
rules.title.planet = Planète
rules.lighting = Éclairage
rules.lighting.unitlight = Unit Lighting
rules.fog = Brouillard de Guerre
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1438,8 +1438,10 @@ rules.title.unit = Egységek
rules.title.experimental = Kísérleti
rules.title.environment = Környezet
rules.title.teams = Csapatok
rules.title.light = Lighting
rules.title.planet = Bolygó
rules.lighting = Világítás
rules.lighting.unitlight = Unit Lighting
rules.fog = A háború köde
rules.invasions = Ellenséges szektorokból érkező inváziók
rules.legacylaunchpads = Hagyományos kilövőállás-mechanizmus

View File

@@ -1438,8 +1438,10 @@ rules.title.unit = Unit
rules.title.experimental = Eksperimental
rules.title.environment = Lingkungan
rules.title.teams = Tim
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Penerangan
rules.lighting.unitlight = Unit Lighting
rules.fog = Kabut Perang
rules.invasions = Invasi Sektor Musuh
rules.legacylaunchpads = Mekanisme Alas Peluncur Warisan

View File

@@ -1410,8 +1410,10 @@ rules.title.unit = Unità
rules.title.experimental = Sperimentale
rules.title.environment = Ambiente
rules.title.teams = squadre
rules.title.light = Lighting
rules.title.planet = pianeta
rules.lighting = Illuminazione
rules.lighting.unitlight = Unit Lighting
rules.fog = Nebbia di guerra
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1416,8 +1416,10 @@ rules.title.unit = ユニット
rules.title.experimental = 実験的なゲームプレイ
rules.title.environment = 環境
rules.title.teams = チーム
rules.title.light = Lighting
rules.title.planet = 惑星
rules.lighting =
rules.lighting.unitlight = Unit Lighting
rules.fog = 戦場の霧
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1437,8 +1437,10 @@ rules.title.unit = 기체
rules.title.experimental = 실험적인 기능
rules.title.environment = 환경
rules.title.teams =
rules.title.light = Lighting
rules.title.planet = 행성
rules.lighting = 조명 표시
rules.lighting.unitlight = Unit Lighting
rules.fog = 전장의 안개
rules.invasions = 적 지역 침공
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1405,8 +1405,10 @@ rules.title.unit = Vienetai
rules.title.experimental = Eksperimentinis
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Apšvietimas
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1417,8 +1417,10 @@ rules.title.unit = Eenheden
rules.title.experimental = Experimenteel
rules.title.environment = Omgeving
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planeet
rules.lighting = Belichting
rules.lighting.unitlight = Unit Lighting
rules.fog = Mist van de Oorlog
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1405,8 +1405,10 @@ rules.title.unit = Units
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1414,8 +1414,10 @@ rules.title.unit = Jednostki
rules.title.experimental = Eksperymentalne
rules.title.environment = Otoczenie
rules.title.teams = Drużyny
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Oświetlenie
rules.lighting.unitlight = Unit Lighting
rules.fog = Mgła Wojny
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1435,8 +1435,10 @@ rules.title.unit = Unidades
rules.title.experimental = Experimental
rules.title.environment = Ambiente
rules.title.teams = Times
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Iluminação
rules.lighting.unitlight = Unit Lighting
rules.fog = Névoa de Guerra
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1447,8 +1447,10 @@ rules.title.unit = Unidades
rules.title.experimental = Experimental
rules.title.environment = Ambiente
rules.title.teams = Equipas
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Iluminação
rules.lighting.unitlight = Unit Lighting
rules.fog = Névoa de guerra
rules.invasions = Invasões de Setores Inimigos
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1416,8 +1416,10 @@ rules.title.unit = Unități
rules.title.experimental = Experimental
rules.title.environment = Mediu
rules.title.teams = Echipe
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Luminozitate Ambientală
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1420,8 +1420,10 @@ rules.title.unit = Боевые единицы
rules.title.experimental = Экспериментально
rules.title.environment = Окружение
rules.title.teams = Команды
rules.title.light = Lighting
rules.title.planet = Планета
rules.lighting = Освещение
rules.lighting.unitlight = Unit Lighting
rules.fog = Туман войны
rules.invasions = Вторжения врагов на сектора
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1418,8 +1418,10 @@ rules.title.unit = Jedinice
rules.title.experimental = Experimental
rules.title.environment = Okolina
rules.title.teams = Timovi
rules.title.light = Lighting
rules.title.planet = Planeta
rules.lighting = Osvetljenje
rules.lighting.unitlight = Unit Lighting
rules.fog = Magla Rata
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1405,8 +1405,10 @@ rules.title.unit = Units
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1419,8 +1419,10 @@ rules.title.unit = ยูนิต
rules.title.experimental = ทดลอง
rules.title.environment = สิ่งแวดล้อม
rules.title.teams = ทีม
rules.title.light = Lighting
rules.title.planet = ดาว
rules.lighting = แสง
rules.lighting.unitlight = Unit Lighting
rules.fog = หมอกแห่งสงคราม
rules.invasions = การรุกรานของฐานทัพศัตรู
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1405,8 +1405,10 @@ rules.title.unit = Units
rules.title.experimental = Experimental
rules.title.environment = Environment
rules.title.teams = Teams
rules.title.light = Lighting
rules.title.planet = Planet
rules.lighting = Lighting
rules.lighting.unitlight = Unit Lighting
rules.fog = Fog of War
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1414,8 +1414,10 @@ rules.title.unit = Birlikler
rules.title.experimental = Deneysel
rules.title.environment = Çevre
rules.title.teams = Takımlar
rules.title.light = Lighting
rules.title.planet = Gezegen
rules.lighting = ıklandırma
rules.lighting.unitlight = Unit Lighting
rules.fog = Savaş Sisi
rules.invasions = Düşman Sektör Saldırıları
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1425,8 +1425,10 @@ rules.title.unit = Бойові одиниці
rules.title.experimental = Експериментальне
rules.title.environment = Середовище
rules.title.teams = Команди
rules.title.light = Lighting
rules.title.planet = Планета
rules.lighting = Світлотінь
rules.lighting.unitlight = Unit Lighting
rules.fog = Туман війни
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -1438,8 +1438,10 @@ rules.title.unit = Đơn Vị
rules.title.experimental = Thử Nghiệm
rules.title.environment = Môi Trường
rules.title.teams = Đội
rules.title.light = Lighting
rules.title.planet = Hành Tinh
rules.lighting = Ánh Sáng
rules.lighting.unitlight = Unit Lighting
rules.fog = Sương Mù Chiến Tranh
rules.invasions = Kẻ Địch Xâm Lược Khu Vực
rules.legacylaunchpads = Cơ chế bệ phóng di sản

View File

@@ -1429,8 +1429,10 @@ rules.title.unit = 单位
rules.title.experimental = 实验性
rules.title.environment = 环境
rules.title.teams = 队伍
rules.title.light = Lighting
rules.title.planet = 星球
rules.lighting = 环境光
rules.lighting.unitlight = Unit Lighting
rules.fog = 战争迷雾
rules.invasions = 敌方区块入侵
rules.legacylaunchpads = 旧版发射台机制

View File

@@ -1431,8 +1431,10 @@ rules.title.unit = 單位
rules.title.experimental = 實驗中
rules.title.environment = 環境
rules.title.teams = 分隊
rules.title.light = Lighting
rules.title.planet = 星球
rules.lighting = 光照
rules.lighting.unitlight = Unit Lighting
rules.fog = 戰爭迷霧
rules.invasions = Enemy Sector Invasions
rules.legacylaunchpads = Legacy Launch Pad Mechanics

View File

@@ -320,6 +320,37 @@ public class Renderer implements ApplicationListener{
}
}
//draw objective markers
float scaleFactor = 4f / renderer.getDisplayScale();
state.rules.objectives.eachRunning(obj -> {
for(var marker : obj.markers){
if(marker.world != -1){
marker.draw(marker.autoscale ? scaleFactor : 1);
}
}
});
for(var marker : state.markers.worldMarkers){
marker.draw(marker.autoscale ? scaleFactor : 1);
}
Draw.reset();
lights.add(() -> {
state.rules.objectives.eachRunning(obj -> {
for(var marker : obj.markers){
if(marker.light != -1){
marker.drawLight(marker.autoscale ? scaleFactor : 1);
}
}
});
for(var marker : state.markers.lightMarkers){
marker.drawLight(marker.autoscale ? scaleFactor : 1);
}
Draw.reset();
});
if(state.rules.lighting && drawLight){
Draw.draw(Layer.light, lights::draw);
}
@@ -353,23 +384,6 @@ public class Renderer implements ApplicationListener{
});
}
float scaleFactor = 4f / renderer.getDisplayScale();
//draw objective markers
state.rules.objectives.eachRunning(obj -> {
for(var marker : obj.markers){
if(marker.world){
marker.draw(marker.autoscale ? scaleFactor : 1);
}
}
});
for(var marker : state.markers){
if(marker.world){
marker.draw(marker.autoscale ? scaleFactor : 1);
}
}
Draw.reset();
Draw.draw(Layer.overlayUI, overlays::drawTop);

View File

@@ -302,6 +302,11 @@ public class MapObjectivesDialog extends BaseDialog{
}).growX().fillY();
});
setInterpreter(IndexBool.class, int.class, (cont, name, type, field, remover, indexer, get, set) -> {
getInterpreter(Boolean.class).build(cont, name, type, field, remover, indexer, () -> get.get() != -1, v -> set.get(v ? +1 : -1));
});
// Special data structure interpreters.
// Instantiate default `Seq`s with a reflectively allocated array.
setProvider(Seq.class, (type, cons) -> cons.get(new Seq<>(type.element.raw)));

View File

@@ -1,42 +1,37 @@
package mindustry.game;
import arc.func.*;
import arc.struct.*;
import arc.util.*;
import mindustry.game.MapObjectives.*;
import mindustry.io.*;
import java.io.*;
import java.util.*;
public class MapMarkers implements Iterable<ObjectiveMarker>{
public class MapMarkers{
/** Maps marker unique ID to marker. */
private IntMap<ObjectiveMarker> map = new IntMap<>();
/** Sequential list of markers. This allows for faster iteration than a map. */
private Seq<ObjectiveMarker> all = new Seq<>(false);
public Seq<ObjectiveMarker> worldMarkers = new Seq<>(false);
public Seq<ObjectiveMarker> mapMarkers = new Seq<>(false);
public Seq<ObjectiveMarker> lightMarkers = new Seq<>(false);
public void add(int id, ObjectiveMarker marker){
if(marker == null) return;
var prev = map.put(id, marker);
if(prev != null){
all.set(prev.arrayIndex, marker);
}else{
all.add(marker);
marker.arrayIndex = all.size - 1;
}
setMarker(worldMarkers, marker, prev, m -> m.world, (m, i) -> m.world = i);
setMarker(mapMarkers, marker, prev, m -> m.minimap, (m, i) -> m.minimap = i);
setMarker(lightMarkers, marker, prev, m -> m.light, (m, i) -> m.light = i);
}
public void remove(int id){
var prev = map.remove(id);
if(prev != null){
if(all.size > prev.arrayIndex + 1){ //there needs to be something above the index to replace it with
all.remove(prev.arrayIndex);
//update its index
all.get(prev.arrayIndex).arrayIndex = prev.arrayIndex;
}else{
//no sense updating the index of the replaced element when it was not replaced
all.remove(prev.arrayIndex);
}
remove(worldMarkers, prev.world, (m, i) -> m.world = i);
remove(mapMarkers, prev.minimap, (m, i) -> m.minimap = i);
remove(lightMarkers, prev.light, (m, i) -> m.light = i);
}
}
@@ -49,7 +44,7 @@ public class MapMarkers implements Iterable<ObjectiveMarker>{
}
public int size(){
return all.size;
return map.size;
}
public void write(DataOutput stream) throws IOException{
@@ -57,16 +52,64 @@ public class MapMarkers implements Iterable<ObjectiveMarker>{
}
public void read(DataInput stream) throws IOException{
all.clear();
worldMarkers.clear();
mapMarkers.clear();
lightMarkers.clear();
map = JsonIO.readBytes(IntMap.class, ObjectiveMarker.class, (DataInputStream)stream);
for(var entry : map.entries()){
all.add(entry.value);
entry.value.arrayIndex = all.size - 1;
var marker = entry.value;
if(marker.world != -1) marker.world = worldMarkers.add(marker).size - 1;
if(marker.minimap != -1) marker.minimap = mapMarkers.add(marker).size - 1;
if(marker.light != -1) marker.light = lightMarkers.add(marker).size - 1;
}
}
@Override
public Iterator<ObjectiveMarker> iterator(){
return all.iterator();
public interface MarkerSetter{
void set(ObjectiveMarker marker, int index);
}
public void updateMarker(Seq<ObjectiveMarker> markers, ObjectiveMarker marker, boolean visible, Intf<ObjectiveMarker> getter, MarkerSetter setter){
if((getter.get(marker) != -1) == visible) return; // nothing to change
if(!visible){
setter.set(markers.peek(), getter.get(marker));
markers.remove(getter.get(marker));
setter.set(marker, -1);
}else{
setter.set(marker, markers.size);
markers.add(marker);
}
}
private void setMarker(Seq<ObjectiveMarker> markers, ObjectiveMarker curr, ObjectiveMarker prev, Intf<ObjectiveMarker> getter, MarkerSetter setter){
int currIndex = getter.get(curr);
if(prev != null && getter.get(prev) != -1){
int prevIndex = getter.get(prev);
if(currIndex != -1){
// both markers visible, replace previous with current
setter.set(curr, prevIndex);
markers.set(prevIndex, curr);
}else{
// previous marker visible but not current
setter.set(markers.peek(), prevIndex);
markers.remove(prevIndex);
}
}else{
if(currIndex != -1){
setter.set(curr, markers.size);
markers.add(curr);
}
}
}
private void remove(Seq<ObjectiveMarker> markers, int index, MarkerSetter setter){
if(index != -1){
setter.set(markers.peek(), index);
markers.remove(index);
}
}
}

View File

@@ -65,7 +65,8 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
TextMarker::new,
LineMarker::new,
TextureMarker::new,
QuadMarker::new
QuadMarker::new,
LightMarker::new
);
registerLegacyMarker("Minimap", PointMarker::new);
@@ -620,13 +621,12 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
/** Marker used for drawing various content to indicate something along with an objective. Mostly used as UI overlay. */
public static abstract class ObjectiveMarker{
/** Internal use only! Do not access. */
public transient int arrayIndex;
/** Whether to display marker in the world. */
public boolean world = true;
/** Whether to display marker on minimap. */
public boolean minimap = false;
/** Whether to display marker in the world. Do not modify directly if added, use control() instead. */
public @IndexBool int world = 1;
/** Whether to display marker on the minimap. Do not modify directly if added, use control() instead. */
public @IndexBool int minimap = -1;
/** Whether to use the marker as light. Do not modify directly if added, use control() instead. */
public @IndexBool int light = -1;
/** Whether to scale marker corresponding to player's zoom level. */
public boolean autoscale = false;
/** On which z-sorting layer is marker drawn. */
@@ -634,13 +634,18 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
public void draw(float scaleFactor){}
public void drawLight(float scaleFactor){
draw(scaleFactor);
}
/** Control marker with world processor code. Ignores NaN (null) values. */
public void control(LMarkerControl type, double p1, double p2, double p3){
if(Double.isNaN(p1)) return;
switch(type){
case world -> world = !Mathf.equal((float)p1, 0f);
case minimap -> minimap = !Mathf.equal((float)p1, 0f);
case world -> state.markers.updateMarker(state.markers.worldMarkers, this, !Mathf.equal((float)p1, 0f), m -> m.world, (m, i) -> m.world = i);
case minimap -> state.markers.updateMarker(state.markers.mapMarkers, this, !Mathf.equal((float)p1, 0f), m -> m.minimap, (m, i) -> m.minimap = i);
case light -> state.markers.updateMarker(state.markers.lightMarkers, this, !Mathf.equal((float)p1, 0f), m -> m.light, (m, i) -> m.light = i);
case autoscale -> autoscale = !Mathf.equal((float)p1, 0f);
case drawLayer -> drawLayer = (float)p1;
}
@@ -842,8 +847,13 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
Draw.z(drawLayer);
Lines.stroke(Scl.scl((1f - fin) * stroke + 0.1f), color);
Lines.circle(pos.x, pos.y, rad * fin);
}
Draw.reset();
@Override
public void drawLight(float scaleFactor){
float rad = radius * tilesize * scaleFactor;
renderer.lights.add(pos.x, pos.y, radius, color, color.a);
}
@Override
@@ -901,8 +911,6 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
Fill.arc(pos.x, pos.y, radius * scaleFactor, (startAngle - endAngle) / 360f, rotation + endAngle, sides);
}
}
Draw.reset();
}
@Override
@@ -1043,6 +1051,11 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
Lines.line(pos.x, pos.y, color1, endPos.x, endPos.y, color2);
}
@Override
public void drawLight(float scaleFactor){
renderer.lights.line(pos.x, pos.y, endPos.x, endPos.y, stroke, color1, color1.a);
}
@Override
public void control(LMarkerControl type, double p1, double p2, double p3){
super.control(type, p1, p2, p3);
@@ -1247,6 +1260,48 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
}
/** Displays a single point light. */
public static class LightMarker extends PosMarker{
public float radius = 5f;
public Color color = Color.valueOf("ffd37f");
public LightMarker(int x, int y){
this.pos.set(x, y);
}
public LightMarker(int x, int y, Color color){
this.pos.set(x, y);
this.color = color;
}
public LightMarker(int x, int y, float radius, Color color){
this.pos.set(x, y);
this.radius = radius;
this.color = color;
}
public LightMarker(){}
@Override
public void drawLight(float scaleFactor){
float rad = radius * tilesize * scaleFactor;
renderer.lights.add(pos.x, pos.y, radius, color, color.a);
}
@Override
public void control(LMarkerControl type, double p1, double p2, double p3){
super.control(type, p1, p2, p3);
if(!Double.isNaN(p1)){
switch(type){
case radius -> radius = (float)p1;
case color -> color.fromDouble(p1);
}
}
}
}
private static void lookupRegion(String name, TextureRegion out){
TextureRegion region = Core.atlas.find(name);
if(region.found()){
@@ -1275,6 +1330,11 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
@Retention(RUNTIME)
public @interface Vertices{}
/** For {@code int}; treats it as a boolean with -1 for false and any other value for true (defaulting to 1) */
@Target(FIELD)
@Retention(RUNTIME)
public @interface IndexBool{}
/** For {@code byte}; treats it as a world label flag. */
@Target(FIELD)
@Retention(RUNTIME)

View File

@@ -180,6 +180,8 @@ public class Rules{
public boolean lighting = false;
/** Ambient light color, used when lighting is enabled. */
public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f);
/** Whether units produce light when lighting is enabled. */
public boolean unitLight = true;
/** team of the player by default. */
public Team defaultTeam = Team.sharded;
/** team of the enemy in waves/sectors. */

View File

@@ -262,17 +262,15 @@ public class MinimapRenderer{
//TODO autoscale markers
state.rules.objectives.eachRunning(obj -> {
for(var marker : obj.markers){
if(marker.minimap){
if(marker.minimap != -1){
marker.draw(1);
}
}
});
for(var marker : state.markers){
if(marker.minimap){
marker.draw(1);
}
for(var marker : state.markers.mapMarkers){
marker.draw(1);
}
Draw.reset();
Draw.trans(Tmp.m2);
}

View File

@@ -1548,6 +1548,7 @@ public class LExecutor{
}
}
case ambientLight -> state.rules.ambientLight.fromDouble(value.num());
case unitLight -> state.rules.unitLight = value.bool();
case solarMultiplier -> state.rules.solarMultiplier = Math.max(value.numf(), 0f);
case dragMultiplier -> state.rules.dragMultiplier = Math.max(value.numf(), 0f);
case ban -> {

View File

@@ -4,6 +4,7 @@ public enum LMarkerControl{
remove,
world("true/false"),
minimap("true/false"),
light("true/false"),
autoscale("true/false"),
pos("x", "y"),
endPos("x", "y"),

View File

@@ -15,6 +15,7 @@ public enum LogicRule{
lighting,
canGameOver,
ambientLight,
unitLight,
solarMultiplier,
dragMultiplier,
ban,

View File

@@ -1547,7 +1547,7 @@ public class UnitType extends UnlockableContent implements Senseable{
}
public void drawLight(Unit unit){
if(lightRadius > 0){
if(lightRadius > 0 && state.rules.unitLight){
Drawf.light(unit.x, unit.y, lightRadius, lightColor, lightOpacity);
}
}

View File

@@ -221,6 +221,11 @@ public class CustomRulesDialog extends BaseDialog{
number("@rules.solarmultiplier", f -> rules.solarMultiplier = f, () -> rules.solarMultiplier);
if(Core.bundle.get("rules.weather").toLowerCase().contains(ruleSearch)){
current.button("@rules.weather", this::weatherDialog).width(250f).left().row();
}
category("light");
if(Core.bundle.get("rules.ambientlight").toLowerCase().contains(ruleSearch)){
current.button(b -> {
b.left();
@@ -232,11 +237,7 @@ public class CustomRulesDialog extends BaseDialog{
b.add("@rules.ambientlight");
}, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f).row();
}
if(Core.bundle.get("rules.weather").toLowerCase().contains(ruleSearch)){
current.button("@rules.weather", this::weatherDialog).width(250f).left().row();
}
check("@rules.lighting.unitlight", b -> rules.unitLight = b, () -> rules.unitLight);
category("planet");
if(Core.bundle.get("rules.title.planet").toLowerCase().contains(ruleSearch)){