SteamWar/BauSystem2.0
Archiviert
12
0

Added live rendering
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
D4rkr34lm 2024-02-21 13:34:25 +01:00
Ursprung 3a3c4819f9
Commit f62d9e626b
3 geänderte Dateien mit 56 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -102,6 +102,7 @@ public class Recorder implements Listener {
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){ for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
record(tnt, trace); record(tnt, trace);
} }
trace.comitAdd();
} }
} }

Datei anzeigen

@ -47,21 +47,49 @@ public class Trace {
@Getter @Getter
private List<TNTRecord> records = new ArrayList<>(); private List<TNTRecord> records = new ArrayList<>();
/**
* Records to be added
*/
private List<TNTRecord> newRecords = new ArrayList<>();
/** /**
* A map of players -> REntityServers for rendering traces to a player * A map of players -> REntityServers for rendering traces to a player
*/ */
private final Map<Player, REntityServer> serverMap = new HashMap<>(); private final Map<Player, REntityServer> serverMap = new HashMap<>();
/**
* A map saving the bundle filters for rendered traces, for life rendering
*/
private final Map<Player, BundleFilter> bundleFilterMap = new HashMap<>();
/**
* A map saving the view flags for rendered traces, for life rendering
*/
private final Map<Player, Collection<ViewFlag>> viewFlagMap = new HashMap<>();
public Trace (Region region){ public Trace (Region region){
this.region = region; this.region = region;
} }
/** Methode to add a record to the trace /** Methode to add a records to add staging
* *
* @param record record to add * @param records records to add
*/ */
protected void add (TNTRecord record){ protected void add (TNTRecord records){
records.add(record); newRecords.add(records);
}
protected void comitAdd(){
records.addAll(newRecords);
for(Player player: serverMap.keySet()){
REntityServer server = serverMap.get(player);
BundleFilter bundleFilter = bundleFilterMap.get(player);
Collection<ViewFlag> viewFlags = viewFlagMap.get(player);
render(server, newRecords, viewFlags, bundleFilter);
}
newRecords.clear();
} }
/** Internal methode to make records immutable after recording is finished /** Internal methode to make records immutable after recording is finished
@ -73,19 +101,41 @@ public class Trace {
} }
//TODO default options //TODO default options
//TODO Life rendering
/** Renders this traces /** Renders this traces
* *
* @param player The player the trace is rendered to * @param player The player the trace is rendered to
* @param flags Flags modefieing the rendering * @param flags Flags modefieing the rendering
* @param bundleFilter Filter to determin bundeling of records
*/ */
public void render(Player player, Collection<ViewFlag> flags, BundleFilter bundleFilter){ public void render(Player player, Collection<ViewFlag> flags, BundleFilter bundleFilter){
if(serverMap.containsKey(player)){ if(serverMap.containsKey(player)){
REntityServer server = serverMap.get(player); REntityServer server = serverMap.get(player);
server.close(); server.close();
serverMap.remove(player); serverMap.remove(player);
viewFlagMap.remove(player);
bundleFilterMap.remove(player);
} }
viewFlagMap.put(player, flags);
bundleFilterMap.put(player, bundleFilter);
REntityServer server = new REntityServer();
server.addPlayer(player);
serverMap.put(player, server);
render(server, records, flags, bundleFilter);
}
/** Internal methode to render records to a REntityServer
*
* @param server Server to render to
* @param records Records to render
* @param flags Flags modefieing the rendering
* @param bundleFilter Filter to determin bundeling of records
*/
private void render (REntityServer server, List<TNTRecord> records, Collection<ViewFlag> flags, BundleFilter bundleFilter){
if(records.size() == 0) return;
List<TNTRecord> workingRecords = records; List<TNTRecord> workingRecords = records;
@ -97,9 +147,6 @@ public class Trace {
List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter); List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter);
//Render bundled records //Render bundled records
REntityServer server = new REntityServer();
serverMap.put(player, server);
server.addPlayer(player);
List<TraceEntity> entities = new LinkedList<>(); List<TraceEntity> entities = new LinkedList<>();
for(List<TNTRecord> bundle : bundles) for(List<TNTRecord> bundle : bundles)

Datei anzeigen

@ -28,8 +28,6 @@ import java.util.stream.Collectors;
@Linked @Linked
public class TraceManager implements Listener { public class TraceManager implements Listener {
//TODO no null returns
/** /**
* Map of all current traces * Map of all current traces
*/ */