org.gjt.universe
Class SystemBase

java.lang.Object
  |
  +--org.gjt.universe.DBItem
        |
        +--org.gjt.universe.SystemBase
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SystemStd, SystemUndefined

public abstract class SystemBase
extends DBItem

The abstract base class from which concrete star system classes are defined. A star system contains one or more stars, and zero or more planets orbiting these stars. The system is enclosed in a single hyperlimit (i.e. the stars in the system orbit each other close enough that they represent a single end point to a hyperspace flight).

Version:
$Id: SystemBase.java,v 1.8 2001/07/01 06:53:25 noordvyk Exp $
Author:
Sean Starkey, Allan Noordvyk (noordvyk@home.com)
See Also:
SystemStd, Serialized Form

Field Summary
private  Coord coord_location
           
private static SystemID currentID
           
private  VectorFleetID fleetsInOrbit
           
private  GalaxyID GalaxyMember
           
private  SystemID ID
           
private  java.util.Vector myStars
           
private  java.util.Vector myWormholeIDs
           
private  java.lang.String name
           
private  CivID owner
           
private  SimpleAccrete.StarMakeup starMakeup
           
private  VectorPlanetID SystemPlanets
           
 
Constructor Summary
protected SystemBase()
          Creates a new system with a default undefined name and ID.
protected SystemBase(GalaxyID in_galID, java.lang.String in_name, Coord in_coord, SimpleAccrete.StarMakeup sm)
          Creates a new instance of this class, containing a single star and no planets.
 
Method Summary
 void addStar(Star aStar)
          Adds the given star to the set of those present in the system.
 void fleetArrived(FleetBase aFleet)
          This method is called automatically by fleets when they arrive in orbit around the star system.
 void fleetDeparted(FleetBase aFleet)
          This method is called automatically by fleets when they depart orbit around the star system.
 void generatePlanetsForStar(SimpleAccrete.PlanetaryMakeup[] pms, int starIndex)
          Adds planets to the star with the given index in the system, based on the given planetary make-ups.
 Coord getCoords()
          Returns the three-space coordinates of the system instance within the galaxy to which it belongs.
 VectorFleetID getFleetsInOrbit()
          This method returns the IDs of all fleets currently directly orbiting the star system.
 VectorFleetID getFleetsPresent()
          This method returns the IDs of all fleets currently present in the star system, regardless of the individual body within the star system which the fleet is directly orbiting.
 GalaxyID getGalaxy()
          Returns the ID of the galaxy to which the system instance belongs
 SystemID getID()
          Returns the unique ID assigned to the receiving system when it was created.
(package private) static SystemID getID(java.lang.String in_name)
          Class meethod returns the ID of the system with the given name.
 Index getIndex()
          Simply calls getID().
 Location getLocation()
          Returns the location (i.e.
 java.lang.String getName()
          Returns the name of the receiving system.
 CivID getOwner()
          Returns the ID of the civ who is deemed to be in control of the receiving system.
 SimpleAccrete.StarMakeup getStarMakeup()
          Returns the stellar make-up of the primary star in the receiving system instance.
 VectorPlanetID getSystemPlanets()
          Returns the planets which are orbitting the system instance.
 java.util.Vector getWormholeIDs()
          Returns a vector of wormhole IDs representing the wormholes with end-points in the star system.
 void insertPlanet(PlanetID PID)
          Adds a new planet with the given ID to the system instance.
 void insertWormholeID(WormholeID wid)
          Adds the wormhole with the given ID to those present in the star system.
 void planetChangedOwner(PlanetID aPlanetID, CivID newPlanetOwner)
          This method is called by planets in the star system when they have changed ownership.
 void removeWormholeID(WormholeID wid)
          Removes the wormhole with the given ID from those present in the star system.
 void setName(java.lang.String newName)
          Sets the name of the receiving system.
 void setOwner(CivID newOwner)
          Sets the civ who is deemed to be in control of the system instance.
 void setStarMakeup(SimpleAccrete.StarMakeup sm)
          Sets the stellar make-up of the primary star in the receiving instance.
 Star starAtIndex(int index)
          This method returns the star at the given index in the set of those stars present in the system.
 int starCount()
          This method returns the number of stars present in the system.
 
Methods inherited from class org.gjt.universe.DBItem
specificDisplayDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentID

private static SystemID currentID

ID

private SystemID ID

name

private java.lang.String name

GalaxyMember

private GalaxyID GalaxyMember

coord_location

private Coord coord_location

myStars

private java.util.Vector myStars

SystemPlanets

private VectorPlanetID SystemPlanets

starMakeup

private SimpleAccrete.StarMakeup starMakeup

owner

private CivID owner

myWormholeIDs

private java.util.Vector myWormholeIDs

fleetsInOrbit

private VectorFleetID fleetsInOrbit
Constructor Detail

SystemBase

protected SystemBase(GalaxyID in_galID,
                     java.lang.String in_name,
                     Coord in_coord,
                     SimpleAccrete.StarMakeup sm)
Creates a new instance of this class, containing a single star and no planets.

Parameters:
in_galID - The unique ID of the galaxy to which the system is being added.
in_name - The name which is to be shown to the user for this system.
in_coord - The coordinates of the system within its galaxy.
sm - The composition of the intial star in the system.

SystemBase

protected SystemBase()
Creates a new system with a default undefined name and ID.

Method Detail

getID

public SystemID getID()
Returns the unique ID assigned to the receiving system when it was created.


getIndex

public Index getIndex()
Simply calls getID(). Used for backwards compatibility.

Specified by:
getIndex in class DBItem
See Also:
getID()

getID

static SystemID getID(java.lang.String in_name)
Class meethod returns the ID of the system with the given name. Returns undefined system's ID if no match is found.

HACK: This currently does a brute force search. A hashtable might be warranted here if this is called often and performance is an issue.


getName

public java.lang.String getName()
Returns the name of the receiving system.

Specified by:
getName in class DBItem

setName

public void setName(java.lang.String newName)
Sets the name of the receiving system.


getLocation

public Location getLocation()
Returns the location (i.e. galaxy and coordinates) of the receiving system.

Overrides:
getLocation in class DBItem

getOwner

public CivID getOwner()
Returns the ID of the civ who is deemed to be in control of the receiving system. If the star system is not owned by any civ then null is returned.

Overrides:
getOwner in class DBItem
See Also:
setOwner( CivID newOwner ), planetChangedOwner( PlanetID aPlanetID, CivID newPlanetOwner )

setOwner

public void setOwner(CivID newOwner)
Sets the civ who is deemed to be in control of the system instance.


getCoords

public Coord getCoords()
Returns the three-space coordinates of the system instance within the galaxy to which it belongs.


getGalaxy

public GalaxyID getGalaxy()
Returns the ID of the galaxy to which the system instance belongs


getStarMakeup

public SimpleAccrete.StarMakeup getStarMakeup()
Returns the stellar make-up of the primary star in the receiving system instance.


setStarMakeup

public void setStarMakeup(SimpleAccrete.StarMakeup sm)
Sets the stellar make-up of the primary star in the receiving instance.


starCount

public int starCount()
This method returns the number of stars present in the system.

See Also:
starAtIndex

starAtIndex

public Star starAtIndex(int index)
This method returns the star at the given index in the set of those stars present in the system.

Parameters:
index - The position of the desired star in the set of those present in the system (starting from zero).

addStar

public void addStar(Star aStar)
Adds the given star to the set of those present in the system. This method causes the name of the system to be updated to reflect the additional star.

Parameters:
aStar - The star to be added as a new component of the system.

getSystemPlanets

public VectorPlanetID getSystemPlanets()
Returns the planets which are orbitting the system instance. The planet objects in the returned vector will be given in ascending order of distance from their primary.


insertPlanet

public void insertPlanet(PlanetID PID)
Adds a new planet with the given ID to the system instance.

Parameters:
PID - The unique ID of the planet to be added. NOTE: Check if this this method called anywhere? Maybe from PlanetBase?

generatePlanetsForStar

public void generatePlanetsForStar(SimpleAccrete.PlanetaryMakeup[] pms,
                                   int starIndex)
Adds planets to the star with the given index in the system, based on the given planetary make-ups. The generated planets will be given default names based on their star and relative position in the array (e.g. If the star is Altair, the planets will be Altair I, Altair II, and so on).

Parameters:
pms - Planetary make-up information for the new planets.
starIndex - Index of the star that is being populated with planets.

planetChangedOwner

public void planetChangedOwner(PlanetID aPlanetID,
                               CivID newPlanetOwner)
This method is called by planets in the star system when they have changed ownership. The receiving instance decides if this means a change of ownership of the star system as a whole by determining if there are any remaining planets still occupied by an original owner.


getWormholeIDs

public java.util.Vector getWormholeIDs()
Returns a vector of wormhole IDs representing the wormholes with end-points in the star system. If the system contains no wormholes, then an empty vector is returned.


insertWormholeID

public void insertWormholeID(WormholeID wid)
Adds the wormhole with the given ID to those present in the star system.

Parameters:
wid - The unique ID of wormhole being added to the star system.

removeWormholeID

public void removeWormholeID(WormholeID wid)
Removes the wormhole with the given ID from those present in the star system.

Parameters:
wid - The unique ID of wormhole being removed to the star system.

getFleetsInOrbit

public VectorFleetID getFleetsInOrbit()
This method returns the IDs of all fleets currently directly orbiting the star system. This does not include fleets which are orbiting a planet within the star system.

See Also:
getFleetsPresent

getFleetsPresent

public VectorFleetID getFleetsPresent()
This method returns the IDs of all fleets currently present in the star system, regardless of the individual body within the star system which the fleet is directly orbiting.

See Also:
getFleetsInOrbit

fleetArrived

public void fleetArrived(FleetBase aFleet)
This method is called automatically by fleets when they arrive in orbit around the star system. This method adds the fleet's ID to the list of those in orbit.

Parameters:
aFleet - The fleet which just arrived.

fleetDeparted

public void fleetDeparted(FleetBase aFleet)
This method is called automatically by fleets when they depart orbit around the star system. This method removes the fleet's ID from the list of those in orbit.

Parameters:
aFleet - The fleet which just arrived.


Copyright © 2001 Universe Dev Team All Rights Reserved.