-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDisplayModel.java
More file actions
56 lines (43 loc) · 1.63 KB
/
DisplayModel.java
File metadata and controls
56 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package stellarium.display;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.world.World;
import stellarapi.api.lib.config.SimpleHierarchicalConfig;
import stellarium.client.ClientSettings;
import stellarium.stellars.StellarManager;
import stellarium.view.ViewerInfo;
import stellarium.world.StellarScene;
public class DisplayModel implements IDisplayInjectable {
List<Delegate> displayList = Lists.newArrayList();
public DisplayModel() {
DisplayRegistry.getInstance().setupDisplay(this);
}
@Override
public <Cfg extends PerDisplaySettings, Cache extends IDisplayCache<Cfg>> void injectDisplay(
IDisplayElementType<Cfg, Cache> type, Cfg settings) {
displayList.add(new Delegate(type, settings));
}
public void updateSettings(ClientSettings settings) {
for(Delegate delegate : this.displayList)
delegate.cache.initialize(settings, delegate.settings);
}
public void stellarLoad(StellarManager manager) { }
public void dimensionLoad(StellarScene dimManager) { }
public void onTick(World world, ViewerInfo update) {
DisplayCacheInfo info = new DisplayCacheInfo(update.coordinate, update.sky);
for(Delegate delegate : this.displayList)
delegate.cache.updateCache(info);
}
static class Delegate<Cfg extends PerDisplaySettings, Cache extends IDisplayCache<Cfg>> {
public Delegate(IDisplayElementType<Cfg, Cache> type, Cfg settings) {
this.type = type;
this.settings = settings;
this.cache = type.generateCache();
this.renderer = type.getRenderer();
}
private IDisplayElementType<Cfg, Cache> type;
Cache cache;
private Cfg settings;
IDisplayRenderer<Cache> renderer;
}
}