use of org.blockartistry.DynSurround.client.footsteps.implem.ProbabilityWeightsAcoustic in project DynamicSurroundings by OreCruncher.
the class AcousticsJsonReader method solveAcousticsCompound.
private IAcoustic solveAcousticsCompound(final JsonObject unsolved) throws JsonParseException {
IAcoustic ret = null;
if (!unsolved.has("type") || unsolved.get("type").getAsString().equals("basic")) {
final BasicAcoustic a = new BasicAcoustic();
prepareDefaults(a);
setupClassics(a, unsolved);
ret = a;
} else {
final String type = unsolved.get("type").getAsString();
if (type.equals("simultaneous")) {
final List<IAcoustic> acoustics = new ArrayList<>();
final JsonArray sim = unsolved.getAsJsonArray("array");
final Iterator<JsonElement> iter = sim.iterator();
while (iter.hasNext()) {
final JsonElement subElement = iter.next();
acoustics.add(solveAcoustic(subElement));
}
final SimultaneousAcoustic a = new SimultaneousAcoustic(acoustics);
ret = a;
} else if (type.equals("delayed")) {
final DelayedAcoustic a = new DelayedAcoustic();
prepareDefaults(a);
setupClassics(a, unsolved);
if (unsolved.has("delay")) {
a.setDelayMin(unsolved.get("delay").getAsInt());
a.setDelayMax(unsolved.get("delay").getAsInt());
} else {
a.setDelayMin(unsolved.get("delay_min").getAsInt());
a.setDelayMax(unsolved.get("delay_max").getAsInt());
}
ret = a;
} else if (type.equals("probability")) {
final List<Integer> weights = new ArrayList<>();
final List<IAcoustic> acoustics = new ArrayList<>();
final JsonArray sim = unsolved.getAsJsonArray("array");
final Iterator<JsonElement> iter = sim.iterator();
while (iter.hasNext()) {
JsonElement subElement = iter.next();
weights.add(subElement.getAsInt());
if (!iter.hasNext())
throw new JsonParseException("Probability has odd number of children!");
subElement = iter.next();
acoustics.add(solveAcoustic(subElement));
}
final ProbabilityWeightsAcoustic a = new ProbabilityWeightsAcoustic(acoustics, weights);
ret = a;
}
}
return ret;
}
Aggregations