SteamWar/BauSystem2.0
Archiviert
12
0

Setup Record for Simulator use and Trace use
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-09-06 21:27:21 +02:00
Ursprung 853aae1b8e
Commit 12d0ecbf0e
5 geänderte Dateien mit 18 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -81,14 +81,14 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
startRecording(); startRecording();
} }
if (recording) { if (recording) {
getRecord(tntPrimed).source(tntPrimed); getRecord(tntPrimed).source(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
} }
} }
@Override @Override
public final void tick(TNTPrimed tntPrimed) { public final void tick(TNTPrimed tntPrimed) {
if (recording) { if (recording) {
getRecord(tntPrimed).location(tntPrimed); getRecord(tntPrimed).location(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
} }
} }
@ -100,7 +100,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
if (recording) { if (recording) {
Record.TNTRecord tntRecord = getRecord(tntPrimed); Record.TNTRecord tntRecord = getRecord(tntPrimed);
if (inBuildRegion) tntRecord.setInBuildArea(true); if (inBuildRegion) tntRecord.setInBuildArea(true);
tntRecord.explode(tntPrimed); tntRecord.explode(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
} }
lastExplosion = 0; lastExplosion = 0;
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.tracer.record;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.StoredRecords; import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
@ -100,7 +101,7 @@ public class Recorder implements Listener {
public void set(Region region, TraceRecorder traceRecorder) { public void set(Region region, TraceRecorder traceRecorder) {
regionTraceRecorderMap.put(region, traceRecorder); regionTraceRecorderMap.put(region, traceRecorder);
traceRecorder.recordSupplier(() -> { traceRecorder.recordSupplier(() -> {
Record record = new Record(region); Record record = new Record(region, TraceShowManager::show);
StoredRecords.add(region, record); StoredRecords.add(region, record);
return record; return record;
}); });

Datei anzeigen

@ -56,19 +56,19 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
@Override @Override
public void spawn(TNTPrimed tntPrimed) { public void spawn(TNTPrimed tntPrimed) {
getRecord(tntPrimed).source(tntPrimed); getRecord(tntPrimed).source(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
} }
@Override @Override
public void tick(TNTPrimed tntPrimed) { public void tick(TNTPrimed tntPrimed) {
getRecord(tntPrimed).location(tntPrimed); getRecord(tntPrimed).location(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
} }
@Override @Override
public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) {
Record.TNTRecord tntRecord = getRecord(tntPrimed); Record.TNTRecord tntRecord = getRecord(tntPrimed);
if (inBuildRegion) tntRecord.setInBuildArea(true); if (inBuildRegion) tntRecord.setInBuildArea(true);
tntRecord.explode(tntPrimed); tntRecord.explode(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks());
recordMap.remove(tntPrimed); recordMap.remove(tntPrimed);
} }

Datei anzeigen

@ -31,6 +31,7 @@ import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiConsumer;
@RequiredArgsConstructor @RequiredArgsConstructor
public class Record { public class Record {
@ -38,6 +39,7 @@ public class Record {
@Getter @Getter
private final List<TNTRecord> tnt = new ArrayList<>(); private final List<TNTRecord> tnt = new ArrayList<>();
private final Region region; private final Region region;
private final BiConsumer<Region, TNTPosition> showFunction;
public int size() { public int size() {
return tnt.size(); return tnt.size();
@ -102,16 +104,16 @@ public class Record {
this.region = region; this.region = region;
} }
public void source(TNTPrimed tntPrimed) { public void source(Vector location, Vector velocity, int fuseTicks) {
add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), true, false); add(location, velocity, fuseTicks, true, false);
} }
public void location(TNTPrimed tntPrimed) { public void location(Vector location, Vector velocity, int fuseTicks) {
add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), false, false); add(location, velocity, fuseTicks, false, false);
} }
public void explode(TNTPrimed tntPrimed) { public void explode(Vector location, Vector velocity, int fuseTicks) {
add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), false, true); add(location, velocity, fuseTicks, false, true);
record.checkMicroMotion(); record.checkMicroMotion();
} }
@ -125,7 +127,7 @@ public class Record {
position = new TNTPosition(this, location, fuseTicks, positions.get(positions.size() - 1).getLocation(), velocity, lastVelocity, source, exploded); position = new TNTPosition(this, location, fuseTicks, positions.get(positions.size() - 1).getLocation(), velocity, lastVelocity, source, exploded);
} }
positions.add(position); positions.add(position);
TraceShowManager.show(region, position); record.showFunction.accept(region, position);
} }
} }
} }

Datei anzeigen

@ -90,7 +90,7 @@ public class TraceShowManager implements Listener {
} }
/* Only to be called by record */ /* Only to be called by record */
static void show(Region region, TNTPosition tnt) { public static void show(Region region, TNTPosition tnt) {
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region); Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) { if (regionalShowModes == null) {
return; return;