|
|
|
@ -47,21 +47,49 @@ public class Trace {
|
|
|
|
|
@Getter
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
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){
|
|
|
|
|
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){
|
|
|
|
|
records.add(record);
|
|
|
|
|
protected void add (TNTRecord records){
|
|
|
|
|
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
|
|
|
|
@ -73,19 +101,41 @@ public class Trace {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO default options
|
|
|
|
|
//TODO Life rendering
|
|
|
|
|
/** Renders this traces
|
|
|
|
|
*
|
|
|
|
|
* @param player The player the trace is rendered to
|
|
|
|
|
* @param flags Flags modefieing the rendering
|
|
|
|
|
* @param bundleFilter Filter to determin bundeling of records
|
|
|
|
|
*/
|
|
|
|
|
public void render(Player player, Collection<ViewFlag> flags, BundleFilter bundleFilter){
|
|
|
|
|
if(serverMap.containsKey(player)){
|
|
|
|
|
REntityServer server = serverMap.get(player);
|
|
|
|
|
server.close();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
@ -97,9 +147,6 @@ public class Trace {
|
|
|
|
|
List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter);
|
|
|
|
|
|
|
|
|
|
//Render bundled records
|
|
|
|
|
REntityServer server = new REntityServer();
|
|
|
|
|
serverMap.put(player, server);
|
|
|
|
|
server.addPlayer(player);
|
|
|
|
|
List<TraceEntity> entities = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
for(List<TNTRecord> bundle : bundles)
|
|
|
|
|