Added inverse flags
Dieser Commit ist enthalten in:
Ursprung
8a3d8a9c33
Commit
04b49fe827
@ -57,6 +57,11 @@ public class Recorder implements Listener {
|
|||||||
*/
|
*/
|
||||||
private final Map<TNTPrimed, Region> tntSpawnRegion = new HashMap<>();
|
private final Map<TNTPrimed, Region> tntSpawnRegion = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of all active traces that no explosion has been recorded on
|
||||||
|
*/
|
||||||
|
private final Set<Trace> noExplosionRecorded = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a tracked tnt entity to its entire recording history
|
* Maps a tracked tnt entity to its entire recording history
|
||||||
*/
|
*/
|
||||||
@ -103,6 +108,7 @@ public class Recorder implements Listener {
|
|||||||
public int startRecording(Region region){
|
public int startRecording(Region region){
|
||||||
if(activeTraces.containsKey(region)) return -1;
|
if(activeTraces.containsKey(region)) return -1;
|
||||||
Trace trace = new Trace(region);
|
Trace trace = new Trace(region);
|
||||||
|
noExplosionRecorded.add(trace);
|
||||||
activeTraces.put(region, trace);
|
activeTraces.put(region, trace);
|
||||||
return manager.add(trace);
|
return manager.add(trace);
|
||||||
}
|
}
|
||||||
@ -116,6 +122,7 @@ public class Recorder implements Listener {
|
|||||||
if (trace == null) return;
|
if (trace == null) return;
|
||||||
trace.setRecords(Collections.unmodifiableList(trace.getRecords()));
|
trace.setRecords(Collections.unmodifiableList(trace.getRecords()));
|
||||||
|
|
||||||
|
noExplosionRecorded.remove(trace);
|
||||||
activeTraces.remove(region);
|
activeTraces.remove(region);
|
||||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList()))
|
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList()))
|
||||||
historyMap.remove(tnt);
|
historyMap.remove(tnt);
|
||||||
@ -153,8 +160,12 @@ public class Recorder implements Listener {
|
|||||||
else
|
else
|
||||||
tntID = history.get(0).getTntId();
|
tntID = history.get(0).getTntId();
|
||||||
|
|
||||||
|
boolean isExplosion = tntPrimed.getFuseTicks() == 0;
|
||||||
|
if(isExplosion)
|
||||||
|
noExplosionRecorded.remove(trace);
|
||||||
|
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
||||||
|
|
||||||
TNTRecord record = new TNTRecord(tntID, tntPrimed, tntPrimed.getFuseTicks() == 0, TPSUtils.currentTick.get() - trace.getStartTime(), history);
|
TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history);
|
||||||
history.add(record);
|
history.add(record);
|
||||||
|
|
||||||
trace.add(record);
|
trace.add(record);
|
||||||
|
@ -41,6 +41,16 @@ public class TNTRecord {
|
|||||||
*/
|
*/
|
||||||
private final boolean explosion;
|
private final boolean explosion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this is a record of a tnt that was in water
|
||||||
|
*/
|
||||||
|
private final boolean inWater;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this record was taken after the first tnt exploded
|
||||||
|
*/
|
||||||
|
private final boolean afterFirstExplosion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tick offset, from this record being taken to the start of the trace
|
* Tick offset, from this record being taken to the start of the trace
|
||||||
*/
|
*/
|
||||||
@ -66,9 +76,11 @@ public class TNTRecord {
|
|||||||
*/
|
*/
|
||||||
private final List<TNTRecord> history;
|
private final List<TNTRecord> history;
|
||||||
|
|
||||||
public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, long ticksSinceStart, List<TNTRecord> history){
|
public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTRecord> history){
|
||||||
this.tntId = tntId;
|
this.tntId = tntId;
|
||||||
this.explosion = explosion;
|
this.explosion = explosion;
|
||||||
|
this.inWater = tnt.isInWater();
|
||||||
|
this.afterFirstExplosion = afterFirstExplosion;
|
||||||
this.ticksSinceStart = ticksSinceStart;
|
this.ticksSinceStart = ticksSinceStart;
|
||||||
fuse = tnt.getFuseTicks();
|
fuse = tnt.getFuseTicks();
|
||||||
location = tnt.getLocation();
|
location = tnt.getLocation();
|
||||||
|
@ -156,8 +156,19 @@ public class Trace {
|
|||||||
|
|
||||||
List<TNTRecord> workingRecords = records;
|
List<TNTRecord> workingRecords = records;
|
||||||
|
|
||||||
|
List<ViewFlag> flagList = new ArrayList<>();
|
||||||
|
|
||||||
|
//Manage inverse flags
|
||||||
|
flagList.addAll(ViewFlag.inverseFlags);
|
||||||
|
for(ViewFlag flag: flags){
|
||||||
|
if(flagList.contains(flag))
|
||||||
|
flagList.remove(flag);
|
||||||
|
else
|
||||||
|
flagList.add(flag);
|
||||||
|
}
|
||||||
|
|
||||||
//Apply filters
|
//Apply filters
|
||||||
for(ViewFlag flag : flags)
|
for(ViewFlag flag : flagList)
|
||||||
workingRecords = flag.filter(workingRecords);
|
workingRecords = flag.filter(workingRecords);
|
||||||
|
|
||||||
//Bundle records at unique positions
|
//Bundle records at unique positions
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
|||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
@ -35,7 +36,12 @@ public abstract class ViewFlag {
|
|||||||
*/
|
*/
|
||||||
public static final List<ViewFlag> flags = new ArrayList<>();
|
public static final List<ViewFlag> flags = new ArrayList<>();
|
||||||
|
|
||||||
public static ViewFlag EXPLOSION = new ViewFlag(true,"explosion") {
|
/**
|
||||||
|
* Inverse flags are used by trace render by default, as long as they are not explicidly added as argument
|
||||||
|
*/
|
||||||
|
public static final List<ViewFlag> inverseFlags = new ArrayList<>();
|
||||||
|
|
||||||
|
public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosionOnly") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
@ -47,6 +53,18 @@ public abstract class ViewFlag {
|
|||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite") {
|
||||||
|
@Override
|
||||||
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
|
return records.stream()
|
||||||
|
.filter(record -> !record.isAfterFirstExplosion())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the flag
|
* Name of the flag
|
||||||
*/
|
*/
|
||||||
@ -57,11 +75,13 @@ public abstract class ViewFlag {
|
|||||||
*/
|
*/
|
||||||
public final String[] aliases;
|
public final String[] aliases;
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, String name, String... aliases) {
|
public ViewFlag(boolean isStatic, boolean isInverse, String name, String... aliases) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
if(isStatic)
|
if(isStatic)
|
||||||
flags.add(this);
|
flags.add(this);
|
||||||
|
if(isInverse)
|
||||||
|
inverseFlags.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Filters the given records for a given condition
|
/** Filters the given records for a given condition
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren