SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
2 geänderte Dateien mit 31 neuen und 13 gelöschten Zeilen
Nur Änderungen aus Commit 1094f4a979 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -158,7 +158,7 @@ public class Trace {
//Apply filters
for(ViewFlag flag : flags)
workingRecords = flag.filter.apply(workingRecords);
workingRecords = flag.filter(workingRecords);
//Bundle records at unique positions
List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter);
@ -171,7 +171,7 @@ public class Trace {
//Apply modifiers
for(ViewFlag flag : flags)
flag.modify.accept(server, entities);
flag.modify(server, entities);
}
/** Bundles the passed TNTRecords based on whether they are at the same location

Datei anzeigen

@ -27,18 +27,21 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
public abstract class ViewFlag {
/**
* The filtering part of the flag
*/
public final UnaryOperator<List<TNTRecord>> filter;
public static ViewFlag EXPLOSION = new ViewFlag(true,"explosion") {
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream()
.filter(TNTRecord::isExplosion)
.collect(Collectors.toList());
}
/**
* The modifieng part of the flag
*/
public final BiConsumer<REntityServer, List<TraceEntity>> modify;
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
};
/**
* Name of the flag
@ -50,14 +53,29 @@ public abstract class ViewFlag {
*/
public final String[] aliases;
/**
* Static registry of static flags
*/
public static final List<ViewFlag> flags = new ArrayList<>();
public ViewFlag(UnaryOperator<List<TNTRecord>> filter, BiConsumer<REntityServer,List<TraceEntity>> modify, boolean isStatic, String name, String... aliases) {
this.filter = filter;
this.modify = modify;
public ViewFlag(boolean isStatic, String name, String... aliases) {
this.name = name;
this.aliases = aliases;
if(isStatic)
flags.add(this);
}
/** Filters the given records for a given condition
*
* @param records Records to be filtered
* @return Filtered records
*/
public abstract List<TNTRecord> filter (List<TNTRecord> records);
/** Modifies the trace rendering
*
* @param server the server the trace is rendered on
* @param entities the entities representing tnts
*/
public abstract void modify (REntityServer server, List<TraceEntity> entities);
}