package net.sourceforge.pain.data;
import net.sourceforge.pain.db.*;
import net.sourceforge.pain.data.type.*;
import java.util.*;
public final class World extends DbObject {
private static final int NAME = 0;
private static final int TIME = 1;
private static final int PROTOTYPES_REGISTRY = 2;
private static final int RACES = 3;
private static final int INDEXED_SPACES_REGISTRY = 4;
private static final int FIRST_ACTIVE_PLAYER = 5;
private static final int RESET_GROUPS = 6;
private static final int PLAYERS_QUIT_SPACE = 7;
private static final int DEFAULT_BIRTH_SPACE = 8;
private static final int NFIELDS = 9;
public World() {
}
public World(PainDB db) {
super(db);
// all these values aggregated!
setReference(TIME, new WorldTime(db));
setReference(PROTOTYPES_REGISTRY, new PrototypesRegistry(db));
setReference(INDEXED_SPACES_REGISTRY, new IndexedSpacesRegistry(db));
setReference(RESET_GROUPS, new ResetGroupRegistry(db));
final Space quitSpace = new Space(db);
quitSpace.setCapacity(Integer.MAX_VALUE);
quitSpace.setDesc("quit space");
quitSpace.setName("quit space");
setReference(PLAYERS_QUIT_SPACE, quitSpace);
}
public DbClassSchema provideSchema() {
byte types[] = new byte[NFIELDS];
String names[] = new String[NFIELDS];
types[NAME] = DbType.STRING;
names[NAME] = "name";
types[TIME] = DbType.REFERENCE;
names[TIME] = "time";
types[PROTOTYPES_REGISTRY] = DbType.REFERENCE;
names[PROTOTYPES_REGISTRY] = "prototypes_registry";
types[INDEXED_SPACES_REGISTRY] = DbType.REFERENCE;
names[INDEXED_SPACES_REGISTRY] = "indexed_spaces";
types[RACES] = DbType.REFERENCE_SET;
names[RACES] = "races";
types[FIRST_ACTIVE_PLAYER] = DbType.REFERENCE;
names[FIRST_ACTIVE_PLAYER] = "first_active_player";
types[RESET_GROUPS] = DbType.REFERENCE;
names[RESET_GROUPS] = "resets_groups";
types[PLAYERS_QUIT_SPACE] = DbType.REFERENCE;
names[PLAYERS_QUIT_SPACE] = "quit_players_space";
types[DEFAULT_BIRTH_SPACE] = DbType.REFERENCE;
names[DEFAULT_BIRTH_SPACE] = "default_birth_space";
return new DbClassSchema(types, names);
}
public void setName(String name) {
setString(NAME, name);
}
public String getName() {
return getString(NAME);
}
public WorldTime getWorldTime() {
return (WorldTime) getReference(TIME);
}
public Player getFirstActivePlayer() {
return (Player) getReference(FIRST_ACTIVE_PLAYER);
}
public void setFirstActivePlayer(Player p) {
setReference(FIRST_ACTIVE_PLAYER, p);
}
public PrototypesRegistry getPrototypesRegistry() {
return (PrototypesRegistry) getReference(PROTOTYPES_REGISTRY);
}
public IndexedSpacesRegistry getIndexedSpacesRegistry() {
return (IndexedSpacesRegistry) getReference(INDEXED_SPACES_REGISTRY);
}
public Set getRaces() {
return getRefSet(RACES);
}
public ResetGroupRegistry getResetGroupRegistry() {
return (ResetGroupRegistry) getReference(RESET_GROUPS);
}
public Space getPlayersQuitSpace() {
return (Space) getReference(PLAYERS_QUIT_SPACE);
}
public Space getDefaultBirthSpace() {
return (Space) getReference(DEFAULT_BIRTH_SPACE);
}
public void setDefaultBirthSpace(Space space) {
setReference(DEFAULT_BIRTH_SPACE, space);
}
}