class
cStarManagerThis class controls most stuff related with the galaxy, stars, planets and empires.
Use StarManager to access it, like StarManager.GetSol()
Stars and planets are organized in "records": cStarRecord and cPlanetRecord. Those contain all the data that is saved into the save games database, and is loaded every time you open the game. A star record is anything you can click on the galaxy view: stars but also black holes, proto-planterary disks, binary star systems, and the galaxy core. The star records keeps a field of StarType to differentiate them.
The galaxy is divided in a 64x64 grid of star sectors, each star sector can have at most 4096 stars. This is only used to quickly access stars, and it doesn't seem to have any impact on the game.
The galaxy is generated using the 0x035DD6E7
(SG_galaxy_messages~
) effect. This effect is a bunch of distribute
effects, one for each star type, which generate random positions depending on a map (with the shape of the galaxy); then a message is emmited (check SimulatorMessages::
After the galaxy has been generated it is recommended to not add any new star records; if you want to make special stars, you can instead use cStarManager::
Galaxy generation generates the star records, but NOT the planets. Planet records are only created when a star system is first visited (or a bit earlier, for example if a mission has to know a planet from a star) by calling cStarManager::
Base classes
- class cStrategy
- class App::IMessageListener
- An interface that can receive messages sent through the app.
Public static functions
-
static auto StarGenerationMessageHandler(uint32_
t messageId, Swarm:: Components:: DistributeEffectMessageData* pDistributeData, StarType starType) -> bool - Method used by the galaxy generation effect to create the cStarRecord instances.
- static auto Get() -> cStarManager*
- Returns the active Simulator star manager, used for most things in space stage.
Public functions
-
auto GetEmpire(uint32_
t politicalID) -> cEmpire* - Returns the empire that has the given political ID, or nullptr if no empire uses it.
- auto GetStarRecord(StarID starID) -> cStarRecord*
- Returns the star record assigned to the specified id.
- auto GetPlanetRecord(PlanetID planetID) -> cPlanetRecord*
- Returns the planet recor assigned to the specified id.
- auto GetEmpires() -> EmpiresMap&
-
auto GetGrobEmpireID() -> uint32_
t - Returns the political ID of the Grox empire.
-
auto NextPoliticalID(bool) -> uint32_
t - Generates a new political ID.
- auto GetEmpireForStar(cStarRecord* starRecord) -> cEmpire*
- Returns the empire that controls this star record, creating it if necessary.
- auto RecordToPlanet(cPlanetRecord* record, cPlanetPtr& dst) -> void
- Creates a cPlanet from its planet record.
- auto GetSol() const -> cStarRecord*
- Returns the star record for the Sol system (the one that contains the Earth, Mars, etc)
- auto GetScenarioStar() const -> cStarRecord*
- Can only be used in adventure (scenario) mode, returns the star record being used for the adventure.
- auto FindClosestStar(const Vector3& coords, const StarRequestFilter& filter = StarRequestFilter()) -> cStarRecord*
- Returns the record for the star closest to the given coords.
- auto FindStars(const Vector3& coords, const StarRequestFilter& filter, eastl::vector<cStarRecordPtr>& dst) -> void
- Finds all the stars that match the given star filter.
- auto CalculatePlanetScores(cPlanetRecord* pPlanetRecord, cStarRecord* pStarRecord = nullptr, int = 0) -> void
- Calculates the
mAtmosphereScore
,mTemperatureScore
andmWaterScore
of a cPlanetRecord depending on the planet type and the generated terrain key. - auto GetStarGridPosition(const Vector3& position, unsigned int& dstX, unsigned int& dstY) -> void
- Obtains the X and Y coordinates within the 64x64 grid in which galaxy stars are organized.
- auto GetRecordGridIndex(unsigned int gridX, unsigned int gridY) -> unsigned int
- Converts X and Y indices of the star record grid (like obtained with GetStarGridPosition()) and translates them into an index that can be used to access the corresponding star second in
mStarRecordGrid
. - auto GenerateEllipticalOrbit(cStarRecord* pStarRecord, cEllipticalOrbit& dst, float minDistance, float maxDistance, cPlanetRecord* pOrbitAroundPlanet = nullptr) -> void
- Generates an elliptical orbit that has a distance between the
minDistance
andmaxDistance
arguments. - auto GenerateSolSystem() -> void
- Generates the sol system with the Earth and the rest of planets; this does not create a new star record, instead it modifies the star closest to the
(257.34799, 257.34799)
position. - auto CreateNewStarID(const Vector3& position) -> StarID
- Generates the StarID for a new star that would be added to
mStarRecordGrid
. - auto RequirePlanetsForStar(cStarRecord* pStarRecord, StarRequestFilter* pFilter = nullptr) -> void
- Ensures that the given star record has planets.
- auto GeneratePlanetsForStar(cStarRecord* pStarRecord, StarRequestFilter* pFilter, bool useMaxPlanets) -> void
- Generates the planets for a star record.
Public variables
- eastl::map<int, int> field_20
- eastl::vector<int> field_3C
- eastl::vector<cPlanetPtr> field_50
- bool field_64
- int field_68
- eastl::string16 field_6C
- char _padding_7C
-
eastl::vector<uint32_
t> mAvailableStarterWorlds - List of all instance IDs of files in
StarterWorlds
folder, only the ones that aren't already used. -
App::
MessageListenerData mMessageListenerData - eastl::vector<eastl::vector<cStarRecordPtr>> mStarRecordGrid
- All star records of the galaxy, organized in a grid of 64x64 different blocks.
- eastl::vector<cStarRecordPtr> mStarterStarRecords
- eastl::vector<cStarRecordPtr> mSavedGameStarRecords
- eastl::vector<cStarRecordPtr> mBlackHoles
- eastl::vector<cStarRecordPtr> mPossibleStartLocations
-
eastl::map<uint32_
t, cStarRecordPtr> mEmpireHomeStarRecords - Maps empire political IDs to their home star cStarRecord.
- cStarRecordPtr mSol
- cStarRecordPtr mpTempStar
- A star record used in contexts where a real one is not available, such as playing an adventure from the create menu.
- EmpiresMap mEmpires
- eastl::vector<eastl::string16> mEmpireNamesInUse
- int field_180
-
eastl::map<PlanetID, uint32_
t> mAdventureIDs - PropertyListPtr mpSolarSystemPropList
gametuning~!SpaceSolarSystem.prop
- PropertyListPtr mpGalacticConstantsPropList
gametuning~!SpaceGalacticConstants.prop
- int mTScoreTribePlanet
- int mTScoreCivPlanet
- int mTScoreColonyPlanet
- int mTScoreEmpireHomeWorld
- int mTScoreGrobPlanet
- float mGrobOnlyRadius
- float mChanceStarIsHomeStar
- int mPercentChanceStarHasRare
- int mGalacticCoreTravelLimit
- Vector2 mGalacticCoreTravelRadii
- int mNextPoliticalID
-
uint32_
t mGrobID - Political ID for the Grox (Grob)
- cStarRecordPtr mpScenarioStar
- cSpaceTradeRouteManager mTradeRouteManager
- eastl::intrusive_ptr<cRelationshipManager> mpRelationshipManager
- eastl::vector<eastl::string> mTransactionLog
- bool field_21C
- cCollectableItemsPtr mpGlobalCLGItems
- DatabasePtr mpPlanetRecordsTempDatabase
planetRecords.pkt
- DatabasePtr mpPlanetRecordsDatabase
planetRecords.pkp
Function documentation
static bool Simulator:: cStarManager:: StarGenerationMessageHandler(uint32_ t messageId,
Swarm:: Components:: DistributeEffectMessageData* pDistributeData,
StarType starType)
Method used by the galaxy generation effect to create the cStarRecord instances.
Parameters | |
---|---|
messageId | |
pDistributeData | |
starType | |
Returns | True |
This method is the handler of the corresponding kMsgGalaxyGenerate...
messages, such as SimulatorMessages::pDistributeData
object.
cStarRecord* Simulator:: cStarManager:: GetStarRecord(StarID starID)
Returns the star record assigned to the specified id.
Parameters | |
---|---|
starID |
There are three possibilities:
- If id == 0, the temporary star is returned (it is nowhere in the galaxy)
- If id == -1, nullptr is returned.
- Otherwise, the id is divided in sector index (& 0xFFFFF000) and star index (& 0x00000FFF) and the star record is returned.
cPlanetRecord* Simulator:: cStarManager:: GetPlanetRecord(PlanetID planetID)
Returns the planet recor assigned to the specified id.
Parameters | |
---|---|
planetID |
cEmpire* Simulator:: cStarManager:: GetEmpireForStar(cStarRecord* starRecord)
Returns the empire that controls this star record, creating it if necessary.
Parameters | |
---|---|
starRecord |
If no empire controls this star record or the one that controls it does not yet exist, it will be created and added to the empire map.
void Simulator:: cStarManager:: RecordToPlanet(cPlanetRecord* record,
cPlanetPtr& dst)
Creates a cPlanet from its planet record.
Parameters | |
---|---|
record | |
dst out |
cStarRecord* Simulator:: cStarManager:: GetScenarioStar() const
Can only be used in adventure (scenario) mode, returns the star record being used for the adventure.
If not playing from the Space stage, this will return a temporary star that is nowhere in the galaxy.
cStarRecord* Simulator:: cStarManager:: FindClosestStar(const Vector3& coords,
const StarRequestFilter& filter = StarRequestFilter())
Returns the record for the star closest to the given coords.
Parameters | |
---|---|
coords | The reference coordinates. |
filter | A filter that describes which kind of stars are accepted. |
Returns | The closest star record that matches the filter. |
The Z coordinate is not considered when calculating distances between stars. A StarRequestFilter can be passed to accept only certain stars (with a certain type, at a minimum distance, etc)
void Simulator:: cStarManager:: FindStars(const Vector3& coords,
const StarRequestFilter& filter,
eastl::vector<cStarRecordPtr>& dst)
Finds all the stars that match the given star filter.
Parameters | |
---|---|
coords | The reference coordinates. |
filter | A filter that describes which kind of stars are accepted. |
dst | A vector where all found stars will be added. |
This can be used to find all the star systems close to a certain position that match some parameters. For example, you can find all the stars with empires in a 20 parsec radius, etc.
void Simulator:: cStarManager:: CalculatePlanetScores(cPlanetRecord* pPlanetRecord,
cStarRecord* pStarRecord = nullptr,
int = 0)
Calculates the mAtmosphereScore
, mTemperatureScore
and mWaterScore
of a cPlanetRecord depending on the planet type and the generated terrain key.
Parameters | |
---|---|
pPlanetRecord | |
pStarRecord | Not used |
If planet type is PlanetType::
unsigned int Simulator:: cStarManager:: GetRecordGridIndex(unsigned int gridX,
unsigned int gridY)
Converts X and Y indices of the star record grid (like obtained with GetStarGridPosition()) and translates them into an index that can be used to access the corresponding star second in mStarRecordGrid
.
Parameters | |
---|---|
gridX | |
gridY |
void Simulator:: cStarManager:: GenerateEllipticalOrbit(cStarRecord* pStarRecord,
cEllipticalOrbit& dst,
float minDistance,
float maxDistance,
cPlanetRecord* pOrbitAroundPlanet = nullptr)
Generates an elliptical orbit that has a distance between the minDistance
and maxDistance
arguments.
Parameters | |
---|---|
pStarRecord | |
dst out | |
minDistance | |
maxDistance | |
pOrbitAroundPlanet | Optional, if specified orbit will be around this planet instead of the star. |
By default, the orbit is made around the given star but if pOrbitAroundPlanet
is specified, it will be made to orbit the planet instead (like a moon). The period of the orbit will be detemined as a function of the distance and properties averageMoonOrbitPeriodGasGiant
, averageMoonOrbitPeriodRocky
and averagePlanetaryOrbitPeriod
.
void Simulator:: cStarManager:: GenerateSolSystem()
Generates the sol system with the Earth and the rest of planets; this does not create a new star record, instead it modifies the star closest to the (257.34799, 257.34799)
position.
This method is called during the galaxy generation (which only happens after a galaxy reset) and before the stars database is saved, so it can be detoured to make changes to other stars as well.
StarID Simulator:: cStarManager:: CreateNewStarID(const Vector3& position)
Generates the StarID for a new star that would be added to mStarRecordGrid
.
Parameters | |
---|---|
position | Position of the star in the galaxy |
The star record using this ID will have to be added at the end of the corresponding vector using GetStarGridPosition()
void Simulator:: cStarManager:: RequirePlanetsForStar(cStarRecord* pStarRecord,
StarRequestFilter* pFilter = nullptr)
Ensures that the given star record has planets.
Parameters | |
---|---|
pStarRecord | |
pFilter |
If cStarRecord::
void Simulator:: cStarManager:: GeneratePlanetsForStar(cStarRecord* pStarRecord,
StarRequestFilter* pFilter,
bool useMaxPlanets)
Generates the planets for a star record.
Parameters | |
---|---|
pStarRecord | |
pFilter | |
useMaxPlanets | If true, spawn the maximum amount of planets. |
Planet records are not generated when the galaxy is generated; instead, they are only created the first time the star is discovered. This function will create a number of planets between properties numPlanetsMin
and numPlanetsMax
from mpSolarSystemPropList
. This function changes the cStarRecord::
Variable documentation
eastl::vector<eastl::vector<cStarRecordPtr>> Simulator:: cStarManager:: mStarRecordGrid
All star records of the galaxy, organized in a grid of 64x64 different blocks.
First index is "y" index of the grid, second index is "x" index of the grid. You can get x, y for certain coordinates with the GetStarGridPosition() method