change dimension mapping
This commit is contained in:
parent
cad8ff6adb
commit
dc7726f0b4
6 changed files with 39 additions and 145 deletions
|
@ -1,22 +1,13 @@
|
||||||
package common.dimension;
|
package common.dimension;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import common.collect.Sets;
|
|
||||||
|
|
||||||
public final class Domain extends Nameable implements Comparable<Domain> {
|
public final class Domain extends Nameable implements Comparable<Domain> {
|
||||||
public final String id;
|
public final String id;
|
||||||
private final Set<Area> areas = Sets.newHashSet();
|
|
||||||
|
|
||||||
public Domain(String id, boolean custom) {
|
public Domain(String id, boolean custom) {
|
||||||
super(custom);
|
super(custom);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addArea(Area area) {
|
|
||||||
this.areas.add(area);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Domain other) {
|
public int compareTo(Domain other) {
|
||||||
return other == null ? -1 : this.id.compareTo(other.id);
|
return other == null ? -1 : this.id.compareTo(other.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
package common.dimension;
|
package common.dimension;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import common.collect.Sets;
|
|
||||||
|
|
||||||
public final class Galaxy extends Nameable implements Comparable<Galaxy> {
|
public final class Galaxy extends Nameable implements Comparable<Galaxy> {
|
||||||
public final String id;
|
public final String id;
|
||||||
private final Set<Sector> sectors = Sets.newTreeSet();
|
|
||||||
|
|
||||||
public Galaxy(String id, boolean custom) {
|
public Galaxy(String id, boolean custom) {
|
||||||
super(custom);
|
super(custom);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSector(Sector sector) {
|
|
||||||
this.sectors.add(sector);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Galaxy other) {
|
public int compareTo(Galaxy other) {
|
||||||
return other == null ? -1 : this.id.compareTo(other.id);
|
return other == null ? -1 : this.id.compareTo(other.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package common.dimension;
|
package common.dimension;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import common.collect.Lists;
|
|
||||||
import common.init.UniverseRegistry;
|
import common.init.UniverseRegistry;
|
||||||
|
|
||||||
public final class Planet extends Dimension {
|
public final class Planet extends Dimension {
|
||||||
private final List<Moon> moons = Lists.newArrayList();
|
|
||||||
|
|
||||||
Planet() {
|
Planet() {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
@ -34,10 +31,6 @@ public final class Planet extends Dimension {
|
||||||
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);
|
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMoon(Moon moon) {
|
|
||||||
this.moons.add(moon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final DimType getType() {
|
public final DimType getType() {
|
||||||
return DimType.PLANET;
|
return DimType.PLANET;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +41,10 @@ public final class Planet extends Dimension {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int[] calcMoonColors() {
|
protected int[] calcMoonColors() {
|
||||||
int[] colors = new int[this.moons.size()];
|
List<Moon> moons = UniverseRegistry.getMoons(this);
|
||||||
|
int[] colors = new int[moons.size()];
|
||||||
for(int z = 0; z < colors.length; z++) {
|
for(int z = 0; z < colors.length; z++) {
|
||||||
colors[z] = this.moons.get(z).getSkyColor() | (this.moons.get(z).isExterminated() ? 0x80000000 : 0);
|
colors[z] = moons.get(z).getSkyColor() | (moons.get(z).isExterminated() ? 0x80000000 : 0);
|
||||||
}
|
}
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
package common.dimension;
|
package common.dimension;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import common.collect.Sets;
|
|
||||||
|
|
||||||
public final class Sector extends Nameable implements Comparable<Sector> {
|
public final class Sector extends Nameable implements Comparable<Sector> {
|
||||||
public final String id;
|
public final String id;
|
||||||
private final Set<Star> stars = Sets.newHashSet();
|
|
||||||
|
|
||||||
public Sector(String id, boolean custom) {
|
public Sector(String id, boolean custom) {
|
||||||
super(custom);
|
super(custom);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStar(Star star) {
|
|
||||||
this.stars.add(star);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Sector other) {
|
public int compareTo(Sector other) {
|
||||||
return other == null ? -1 : this.id.compareTo(other.id);
|
return other == null ? -1 : this.id.compareTo(other.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
package common.dimension;
|
package common.dimension;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import common.collect.Sets;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
|
||||||
public final class Star extends Dimension {
|
public final class Star extends Dimension {
|
||||||
private final Set<Planet> planets = Sets.newHashSet();
|
|
||||||
|
|
||||||
Star() {
|
Star() {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
@ -20,105 +15,7 @@ public final class Star extends Dimension {
|
||||||
this.setSkyColor(color).setFogColor(color).setFlatGen(surface, height);
|
this.setSkyColor(color).setFogColor(color).setFlatGen(surface, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlanet(Planet planet) {
|
|
||||||
this.planets.add(planet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final DimType getType() {
|
public final DimType getType() {
|
||||||
return DimType.STAR;
|
return DimType.STAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public final ChunkGenerator createChunkGenerator(Random rand) {
|
|
||||||
// return new GeneratorFlat(this.getHeight(), this.getFiller());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final BlockReplacer createBlockReplacer(Random rand) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public float getGravity() {
|
|
||||||
// return 4.0f;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final long getOrbitalPeriod() {
|
|
||||||
// return 1L;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final long getRotationalPeriod() {
|
|
||||||
// return 1L;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final float getOrbitOffset() {
|
|
||||||
// return 0.0f;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public Biome getBiome() {
|
|
||||||
// return Biome.star;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getCaveFiller() {
|
|
||||||
// return Blocks.air.getDefaultState();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getTop() {
|
|
||||||
// return Blocks.air.getDefaultState();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getSurface() {
|
|
||||||
// return Blocks.air.getDefaultState();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getAltFiller() {
|
|
||||||
// return Blocks.air.getDefaultState();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getLavaFiller() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getWorldFloor() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final boolean hasRavines() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final boolean hasSnow() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final boolean hasCaves() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final float getLavaChance() {
|
|
||||||
// return 0.0f;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final float getWaterChance() {
|
|
||||||
// return 0.0f;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final boolean hasDungeons() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public final IBlockState getSurfaceLiquid() {
|
|
||||||
// return Blocks.air.getDefaultState();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public int getBrightness() {
|
|
||||||
// return 15;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public float getStarBrightness() {
|
|
||||||
// return 0.75f;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public float getDeepStarBrightness() {
|
|
||||||
// return 0.75f;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,17 @@ public abstract class UniverseRegistry {
|
||||||
private static final Map<String, Sector> SECTORS = Maps.newHashMap();
|
private static final Map<String, Sector> SECTORS = Maps.newHashMap();
|
||||||
private static final Map<String, Galaxy> GALAXIES = Maps.newHashMap();
|
private static final Map<String, Galaxy> GALAXIES = Maps.newHashMap();
|
||||||
private static final Map<String, Domain> DOMAINS = Maps.newHashMap();
|
private static final Map<String, Domain> DOMAINS = Maps.newHashMap();
|
||||||
|
|
||||||
private static final Map<Moon, Planet> MOON_MAP = Maps.newHashMap();
|
private static final Map<Moon, Planet> MOON_MAP = Maps.newHashMap();
|
||||||
|
private static final Map<Planet, List<Moon>> MOONS_MAP = Maps.newHashMap();
|
||||||
private static final Map<Planet, Star> PLANET_MAP = Maps.newHashMap();
|
private static final Map<Planet, Star> PLANET_MAP = Maps.newHashMap();
|
||||||
|
private static final Map<Star, List<Planet>> PLANETS_MAP = Maps.newHashMap();
|
||||||
private static final Map<Star, Sector> STAR_MAP = Maps.newHashMap();
|
private static final Map<Star, Sector> STAR_MAP = Maps.newHashMap();
|
||||||
|
private static final Map<Sector, List<Star>> STARS_MAP = Maps.newHashMap();
|
||||||
private static final Map<Sector, Galaxy> SECTOR_MAP = Maps.newHashMap();
|
private static final Map<Sector, Galaxy> SECTOR_MAP = Maps.newHashMap();
|
||||||
|
private static final Map<Galaxy, List<Sector>> SECTORS_MAP = Maps.newHashMap();
|
||||||
private static final Map<Area, Domain> AREA_MAP = Maps.newHashMap();
|
private static final Map<Area, Domain> AREA_MAP = Maps.newHashMap();
|
||||||
|
private static final Map<Domain, List<Area>> AREAS_MAP = Maps.newHashMap();
|
||||||
private static final Set<Semi> SEMI_SET = Sets.newHashSet();
|
private static final Set<Semi> SEMI_SET = Sets.newHashSet();
|
||||||
|
|
||||||
public static List<Dimension> getDimensions() {
|
public static List<Dimension> getDimensions() {
|
||||||
|
@ -80,6 +85,26 @@ public abstract class UniverseRegistry {
|
||||||
return SEMI_SET;
|
return SEMI_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Sector> getSectors(Galaxy galaxy) {
|
||||||
|
return SECTORS_MAP.get(galaxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Star> getStars(Sector sector) {
|
||||||
|
return STARS_MAP.get(sector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Planet> getPlanets(Star star) {
|
||||||
|
return PLANETS_MAP.get(star);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Moon> getMoons(Planet planet) {
|
||||||
|
return MOONS_MAP.get(planet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Area> getAreas(Domain domain) {
|
||||||
|
return AREAS_MAP.get(domain);
|
||||||
|
}
|
||||||
|
|
||||||
public static Dimension getDimension(int dim) {
|
public static Dimension getDimension(int dim) {
|
||||||
return ID_MAP.get(dim);
|
return ID_MAP.get(dim);
|
||||||
}
|
}
|
||||||
|
@ -188,6 +213,7 @@ public abstract class UniverseRegistry {
|
||||||
Galaxy galaxy = new Galaxy(name, custom);
|
Galaxy galaxy = new Galaxy(name, custom);
|
||||||
galaxy.setCustomName(display);
|
galaxy.setCustomName(display);
|
||||||
GALAXIES.put(name, galaxy);
|
GALAXIES.put(name, galaxy);
|
||||||
|
SECTORS_MAP.put(galaxy, Lists.newArrayList());
|
||||||
return galaxy;
|
return galaxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +230,8 @@ public abstract class UniverseRegistry {
|
||||||
sector.setCustomName(display);
|
sector.setCustomName(display);
|
||||||
SECTORS.put(name, sector);
|
SECTORS.put(name, sector);
|
||||||
SECTOR_MAP.put(sector, base);
|
SECTOR_MAP.put(sector, base);
|
||||||
base.addSector(sector);
|
STARS_MAP.put(sector, Lists.newArrayList());
|
||||||
|
SECTORS_MAP.get(base).add(sector);
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +244,7 @@ public abstract class UniverseRegistry {
|
||||||
Domain domain = new Domain(name, custom);
|
Domain domain = new Domain(name, custom);
|
||||||
domain.setCustomName(display);
|
domain.setCustomName(display);
|
||||||
DOMAINS.put(name, domain);
|
DOMAINS.put(name, domain);
|
||||||
|
AREAS_MAP.put(domain, Lists.newArrayList());
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +269,8 @@ public abstract class UniverseRegistry {
|
||||||
throw new IllegalArgumentException("Sektor " + sector + " existiert nicht");
|
throw new IllegalArgumentException("Sektor " + sector + " existiert nicht");
|
||||||
registerDimension(name, display, dim);
|
registerDimension(name, display, dim);
|
||||||
STAR_MAP.put((Star)dim, base);
|
STAR_MAP.put((Star)dim, base);
|
||||||
base.addStar((Star)dim);
|
PLANETS_MAP.put((Star)dim, Lists.newArrayList());
|
||||||
|
STARS_MAP.get(base).add((Star)dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerPlanet(String name, String display, Dimension dim, String star) {
|
private static void registerPlanet(String name, String display, Dimension dim, String star) {
|
||||||
|
@ -250,7 +279,8 @@ public abstract class UniverseRegistry {
|
||||||
throw new IllegalArgumentException("Stern " + star + " existiert nicht");
|
throw new IllegalArgumentException("Stern " + star + " existiert nicht");
|
||||||
registerDimension(name, display, dim);
|
registerDimension(name, display, dim);
|
||||||
PLANET_MAP.put((Planet)dim, ((Star)base));
|
PLANET_MAP.put((Planet)dim, ((Star)base));
|
||||||
((Star)base).addPlanet((Planet)dim);
|
MOONS_MAP.put((Planet)dim, Lists.newArrayList());
|
||||||
|
PLANETS_MAP.get((Star)base).add((Planet)dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerMoon(String name, String display, Dimension dim, String planet) {
|
private static void registerMoon(String name, String display, Dimension dim, String planet) {
|
||||||
|
@ -259,7 +289,7 @@ public abstract class UniverseRegistry {
|
||||||
throw new IllegalArgumentException("Planet " + planet + " existiert nicht");
|
throw new IllegalArgumentException("Planet " + planet + " existiert nicht");
|
||||||
registerDimension(name, display, dim);
|
registerDimension(name, display, dim);
|
||||||
MOON_MAP.put((Moon)dim, ((Planet)base));
|
MOON_MAP.put((Moon)dim, ((Planet)base));
|
||||||
((Planet)base).addMoon((Moon)dim);
|
MOONS_MAP.get((Planet)base).add((Moon)dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerArea(String name, String display, Dimension dim, String domain) {
|
private static void registerArea(String name, String display, Dimension dim, String domain) {
|
||||||
|
@ -268,7 +298,7 @@ public abstract class UniverseRegistry {
|
||||||
throw new IllegalArgumentException("Bereich " + domain + " existiert nicht");
|
throw new IllegalArgumentException("Bereich " + domain + " existiert nicht");
|
||||||
registerDimension(name, display, dim);
|
registerDimension(name, display, dim);
|
||||||
AREA_MAP.put((Area)dim, base);
|
AREA_MAP.put((Area)dim, base);
|
||||||
base.addArea((Area)dim);
|
AREAS_MAP.get(base).add((Area)dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerSemi(String name, String display, Dimension dim) {
|
private static void registerSemi(String name, String display, Dimension dim) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue