mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
- SettingsStack<F> replaces List<Entry<F>> wherever settings stack: entries in level order, values(), dimension(), level(Level) and mostSpecific(). - com.volmit.config.Level replaces FeatureAttachment.Target; FeatureAttachment folds into FeatureDescriptor.targets(). - FeatureSettings.declaredInChunk answers every entry any column of a chunk declares, each once. - ChunkContext gives chunkX/chunkZ, centreX/centreZ and area(). - registerSettings takes several types at once. - ModuleLifecycle.packLoaded(PackContext) carries resources, settings and the module's log. - TerrainSampler.surfaceHeight gives the surface in whole blocks. - Stage contexts drop worldSeed() and resources(); world() always answers. The scoped world is kept per world and module. - Javadoc fixes; README, DESIGN and CONTRACTS updated.
32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
package com.volmit.host;
|
|
|
|
import com.volmit.ModuleLog;
|
|
import com.volmit.world.PackWorld;
|
|
import java.util.Objects;
|
|
|
|
/** The views of worlds one module's stages get, whose log is the module's own ({@link PackWorld#withLog}). It keeps
|
|
* the view of the world it was last asked for, so the stages of a host that generates one world per resolved graph
|
|
* get it without a new view per invocation; a host that alternates worlds on one graph asks the world each time.
|
|
* The kept world is released when the next one is asked for or the graph is dropped. Safe for concurrent use.
|
|
*/
|
|
final class ScopedWorlds {
|
|
private final ModuleLog log;
|
|
private volatile Scoped last;
|
|
|
|
ScopedWorlds(ModuleLog log) {
|
|
this.log = Objects.requireNonNull(log, "log");
|
|
}
|
|
|
|
PackWorld of(PackWorld world) {
|
|
var scoped = last;
|
|
if (scoped != null && scoped.world() == world) {
|
|
return scoped.view();
|
|
}
|
|
var view = world.withLog(log);
|
|
last = new Scoped(world, view);
|
|
return view;
|
|
}
|
|
|
|
private record Scoped(PackWorld world, PackWorld view) {}
|
|
}
|