namespace
CellCell stage functionality.
This namespace contains all the functionality of the Cell stage. The main classes are:
- Simulator::
Cell:: cCellGame: Used to control cell gameplay. Quick access with CellGame. - Simulator::
Cell:: cCellGFX: Keeps track of the visuals, like models, effects, anim worlds, etc. Quick access with CellGFX. - Simulator::
Cell:: cCellUI: The user interface. Quick access with CellUI. - App::
cCellModeStrategy: The App:: IGameMode for the cell stage. It has the functions for mouse and keyboard controls, and the Update()
function where cell stage code is executed.
Most of cell stage is defined thorugh several files: .effectMap
, .cell
, .lootTable
, etc. All these files have their representation in code as Simulator::CellGame.globals
, which can be obtained in code with Simulator::
Everything you see in the cell stage is considered a "cell", including rocks, bubbles, poison and food. Cells are represented by the Simulator::.cell
file (Simulator::
For many of the cells actions, it is just enough to change a variable to see changes, as the cell stage update method takes care of the rest. Such values are mTargetPosition
, mTargetOrientation
, mTargetOpacity
, mTargetSize
, etc. For example, changing mTargetPosition
and setting mIsIdle
to false, will not teleport the cell but make it swim towards the target position instead.
Code examples
Moving the player cell 10 units to the right. This does not teleport it immediately, but it makes it swim towards there.
auto cell = Simulator::Cell::GetPlayerCell(); cell->mTargetPosition.x += 10.0f; cell->mIsIdle = false;
Creating a cell next to the player:
auto player = Simulator::Cell::GetPlayerCell(); auto cellIndex = Simulator::Cell::CreateCellObject( CellGame.mpCellQuery, player->mTransform.GetOffset() + Math::Vector3(4.0f, 0.0f, 0.0f), 0.0f, player->mCellResource, player->mScale, 1.0f, 1.0f );
Finding nearby cells and enlarging them:
auto player = Simulator::Cell::GetPlayerCell(); Simulator::cObjectPoolIndex cellIndices[400]; int numCells = Simulator::Cell::FindCellsInRadius( CellGame.mpCellQuery, player->GetPosition(), 5.0, // center and radius of search cellIndices, 400); for (int i = 0; i < numCells; i++) { auto cell = CellGame.mCells.Get(cellIndices[i]); cell->mTargetSize *= 2.0f; }
Make nearby cells chase the player:
auto player = Simulator::Cell::GetPlayerCell(); Simulator::cObjectPoolIndex cellIndices[400]; int numCells = Simulator::Cell::FindCellsInRadius( CellGame.mpCellQuery, player->GetPosition(), 20.0, // center and radius of search cellIndices, 400); for (int i = 0; i < numCells; i++) { auto cell = CellGame.mCells.Get(cellIndices[i]); if (cell->IsCreature()) { cell->mChaseCellTime = 10.0f; cell->mChaseCellIndex = player->Index(); // If we don't disable this, fleeing cells will not chase us cell->mFleeCellTime = 0.0f; cell->mFleeCellIndex = 0; } }
Read data from a .cell
file:
// Declare this as a static variable Simulator::Cell::cCellCellResource::Reference* sCellChomperReference; // In the initialize method, choose which `.cell` file we are reading sCellChomperReference = Simulator::Cell::cCellCellResource::Reference::Create(id("cell_chomper")); // To use the data cCellCellResourcePtr cellResource; auto cellData = Simulator::Cell::GetData(sCellChomperReference, cellResource);
Classes
- class cAdvectResource
- struct cCellAnimDefinition
- struct cCellBackgroundMapResource
- struct cCellCellResource
- struct cCellDataReference
- struct cCellDataReference_
- struct cCellEffectMapResource
- class cCellGame
- class cCellGFX
- struct cCellGlobalsResource
- struct cCellLookAlgorithmResource
- struct cCellLookTableResource
- struct cCellLootTableResource
- struct cCellMission
- struct cCellObjectData
- struct cCellPopulateResource
- struct cCellPowersResource
- struct cCellQueryEntry
- struct cCellQueryLinkedPool
- Class used to quickly query cell positions.
- struct cCellQueryLinkedPoolData
- struct cCellRandomCreatureResource
- class cCellResource
- struct cCellScaleInfo
- class cCellSerializableData
- struct cCellStructureResource
- class cCellUI
- struct cCellUIRollover
- struct cCellWorldResource
- struct CellSerializer
- struct CellSerializerField
Enums
- enum class ScaleDifference { MuchSmaller = 0, Smaller = 1, Equal = 2, Larger = 3, MuchLarger = 4 }
- enum class CellStageScale: int { None = -1, _0 = 0, _1 = 1, _2 = 2, _4 = 3, _10 = 4, _20 = 5, _40 = 6, _100 = 7, _200 = 8, _400 = 9, _1K = 10, _2K = 11, _4K = 12, _10K = 13, _20K = 14, _40K = 15, _100K = 16, _200K = 17, _400K = 18, _1M = 19 }
- enum CellAnimations { kAnimIndexCellIdle = 0, kAnimIndexCellIdleBlink1 = 1, kAnimIndexCellIdleBlink2 = 2, kAnimIndexCellIdleBlink3 = 3, kAnimIndexCellMovFlg = 4, kAnimIndexCellMovFlgBlink = 5, kAnimIndexCellEatFilter = 6, kAnimIndexCellDmgSolidSpike = 7, kAnimIndexCellDmgSolidMand = 8, kAnimIndexCellDeathAvatar = 9, kAnimIndexCellDeathNpc = 10, kAnimIndexCellDeathNpcIdle = 11, kAnimIndexCellEatFilterNpc = 12, kAnimIndexCellEatMand = 13, kAnimIndexCellEatMandNpc = 14, kAnimIndexCellEatProb = 15, kAnimIndexCellTakeDmgElec = 16, kAnimIndexCellTakeDmgPoison = 17, kAnimIndexCellTakeDmgStab = 18, kAnimIndexCellMoveJet = 19, kAnimIndexCellMoveJetBlink = 20, kAnimIndexCellMovFlg2 = 21, kAnimIndexCellMoveNpcScared = 22, kAnimIndexCellMoveNpcMad = 23, kAnimIndexCellMoveNpcScared2 = 24, kAnimIndexCellMoveNpcMad2 = 25, kAnimIndexCellMoveJet2 = 26, kAnimIndexCellMoveJet3 = 27, kAnimIndexCellNpcScared = 28, kAnimIndexCellNpcMad = 29, kAnimIndexCellDeathNpcIdle2 = 30, kAnimIndexCellEatFilterFail = 31, kAnimIndexCellEatMandFail = 32, kAnimIndexCellGlanceMad = 33, kAnimIndexCellGlanceSpike = 34, kAnimIndexCellPunctureSpike = 35, kAnimIndexCellGrow = 36, kAnimIndexCellDeathAvatarIdle = 37, kAnimIndexCellElecRelease = 38, kAnimIndexCellBubblePop = 39, kAnimIndexCellEatProbStun = 40, kAnimIndexCellNpcStartled = 41, kAnimIndexCellPoked = 42, kAnimIndexCellTakeDmgElecNpc = 43, kAnimIndexCellTakeDmgPoisonNpc = 44, kAnimIndexCellTakeDmgStabNpc = 45, kAnimIndexCellGlanceSpikeOnSpike = 46, kAnimIndexCellEatProbRetractTrgt = 47, kAnimIndexCellEatProbRetract = 48, kAnimIndexCellEatMandNpcBig = 49, kAnimIndexCellIdleBig = 50, kAnimIndexCellIdleBlink1Big = 51, kAnimIndexCellIdleBlink2Big = 52, kAnimIndexCellIdleBlink3Big = 53, kAnimIndexCellMovFlgBig = 54, kAnimIndexCellMovFlgBigBlink = 55, kAnimIndexCellMovFlgBigMad = 56, kAnimIndexCellMovCilBig = 57, kAnimIndexCellMovCilBigBlink = 58, kAnimIndexCellMovCilBigMad = 59, kAnimIndexCellMovCilBig2 = 60, kAnimIndexCellMovCilBigBlink2 = 61, kAnimIndexCellMovCilBigMad2 = 62, kAnimIndexCellNpcMadBig = 63, kAnimIndexCellMovCil = 64, kAnimIndexCellMovCilBlink = 65, kAnimIndexCellMovPoisonRelease = 66, kAnimIndexCellMovCilMad = 67, kAnimIndexCellMovCilScared = 68, kAnimIndexCellDmgSolidDeath = 69, kAnimIndexCellPoisonRelease = 70, kAnimIndexCellHatchLayEgg = 71, kAnimIndexCellHatchEgg = 72, kAnimIndexCellHatchIce = 73, kAnimIndexCellGoToEditor = 74, kAnimIndexCellDeathEaten = 75, kAnimIndexCellDeathEatenNpc = 76, kAnimIndexCellTakeDmgMand = 77, kAnimIndexCellPartDiscover = 78, kAnimIndexCellEatFilterChew = 79, kAnimIndexCellEatMandChew = 80, kAnimIndexCellEatProbChew = 81, kAnimIndexCellDmgSolidMandNpc = 82, kAnimIndexCellDmgSolidDeathNpc = 83, kAnimIndexCellTakeDmgMandNpc = 84, kAnimIndexCellMovToBeach = 85, kAnimIndexCellGlanceMad2 = 86, kAnimIndexCellMovFlgBigMadBlink = 87, kAnimIndexCellGlanceProbOnProb = 88, kAnimIndexCellMovCil180 = 89, kAnimIndexCellMovCil180v2 = 90, kAnimIndexCellMovCil180v3 = 91, kAnimIndexCellMovCil180v4 = 92, kAnimIndexCellMovCil180v5 = 93, kAnimIndexCellMovFlgStart = 94, kAnimIndexCellMovFlgStart2 = 95, kAnimIndexCellMovCil2 = 96, kAnimIndexCellMoveJet4 = 97, kAnimIndexCellTakeDmgPoisonBig = 98, kAnimIndexCellMovBankLt = 99, kAnimIndexCellMovBankRt = 100, kAnimIndexCellBackgrndGuy = 101, kAnimIndexCellTakeDmgElecNpcBig = 102, kAnimIndexEpicCellEyePokeReact = 103, kAnimIndexEpicCellEyePokeClosedLF = 104, kAnimIndexEpicCellEyePokeClosedRF = 105, kAnimIndexEpicCellEyePokeClosedLC = 106, kAnimIndexEpicCellEyePokeClosedRC = 107, kAnimIndexEpicCellEyePokeClosedLB = 108, kAnimIndexEpicCellEyePokeClosedRB = 109, kAnimIndexEpicCellBiteRock = 110, kAnimIndexEpicCellElectrocuted = 111, kAnimIndexEpicCellChokes = 112, kAnimIndexEpicCellProboscised = 113, kAnimIndexEpicCellDeathTurnover = 114, kAnimIndexEpicCellDeathIdle = 115, kAnimIndexEpicCellEyePokeReactLt = 116, kAnimIndexEpicCellEyePokeReactRt = 117, kAnimIndexCellMate01 = 118, kAnimIndexCellMate02 = 119, kAnimIndexCellMatingCall = 120, kAnimIndexCellEatProbRetractTrgtNpc = 121, kAnimIndexCellEatProbRetractNpc = 122, kAnimIndexCellEatProbStunNpc = 123, kAnimIndexCellEatProbNpc = 124, kAnimIndexCellTakeDmgStabNpcBig = 125, kAnimIndexCellTakeDmgMandNpcBig = 126, kAnimIndexEpicCellPoked = 127, kAnimIndexEpicCellPoked2 = 128, kAnimIndexCellBrainUpgrade = 129, kAnimIndexCellHatchLayEggNpc = 130 }
Functions
- auto Addresses(GameModeCell) -> namespace
- ASSERT_SIZE(cCellGame, 0x51E4)
- auto Addresses(cCellGame) -> namespace
- ASSERT_SIZE(cCellGFX, 0x1625C)
- auto Addresses(cCellGFX) -> namespace
- ASSERT_SIZE(cCellObjectData, 0x398)
- ASSERT_SIZE(cCellQueryEntry, 0x1C)
- ASSERT_SIZE(cCellQueryLinkedPoolData, 0x18)
- ASSERT_SIZE(cCellQueryLinkedPool, 16)
- ASSERT_SIZE(CellSerializerField, 0x28)
- ASSERT_SIZE(CellSerializer, 0x28)
- ASSERT_SIZE(cCellResource, 0x20)
-
ASSERT_SIZE(cCellDataReference_
, 0x10) -
auto Addresses(cCellDataReference_
) -> namespace - ASSERT_SIZE(cCellPowersResource, 0x8)
- ASSERT_SIZE(cCellRandomCreatureResource, 8)
- ASSERT_SIZE(cCellStructureResource, 0x1C)
- ASSERT_SIZE(cCellPopulateResource, 0x10)
- ASSERT_SIZE(cCellWorldResource, 0x10)
- ASSERT_SIZE(cCellCellResource, 0x31C)
- ASSERT_SIZE(cCellLootTableResource, 0x24)
- ASSERT_SIZE(cCellLookTableResource, 8)
- ASSERT_SIZE(cCellLookAlgorithmResource, 8)
- ASSERT_SIZE(cCellEffectMapResource, 8)
- ASSERT_SIZE(cCellBackgroundMapResource, 8)
- ASSERT_SIZE(cCellGlobalsResource, 0x114)
- ASSERT_SIZE(cAdvectResource, 0x20)
- auto GetGlobalsData() -> cCellGlobalsResource*
-
auto GetData(cCellDataReference_
* reference, eastl::intrusive_ptr<cCellDataReference<T>>& dst) -> T* - Loads the data of a cell file reference, or returns the existing cached file.
- ASSERT_SIZE(cCellScaleInfo, 0x1C)
- ASSERT_SIZE(cCellMission, 0x10)
- ASSERT_SIZE(cCellSerializableData, 0xEC)
- auto Addresses(cCellSerializableData) -> namespace
- ASSERT_SIZE(cCellUIRollover, 0x38)
- ASSERT_SIZE(cCellUI, 0x944)
- auto Addresses(cCellUI) -> namespace
- ASSERT_SIZE(cCellAnimDefinition, 0x24)
- auto GetGoalCards() -> GoalCard*
- auto GetPlayerCell() -> cCellObjectData*
- Returns the player cell.
-
auto GetCurrentAdvectInfo(CellStageScale& dst0,
float& dstStrength,
float& dstVariance,
float& dstPeriod) -> uint32_
t - Returns the info of the cCellWorldResource::cAdvectInfo of the current world and cell scale, based on the current food progression.
-
auto GetNextAdvectID() -> uint32_
t - Returns the advect file ID for the next cell scale in the current world, based on the current food progression.
-
auto CreateCellObject(cCellQueryLinkedPool* query,
const Math::
Vector3& position, float elevation, cCellDataReference<cCellCellResource>* resource, CellStageScale scaleLevel, float sizeFactor, float cellSize, bool applySize = true, Math:: Quaternion* pTargetOrientation = nullptr, int = 0) -> cObjectPoolIndex - auto MovePlayerToMousePosition(float deltaTime) -> void
- auto GetScaleDifferenceWithPlayer(cCellObjectData* otherCell) -> ScaleDifference
- Returns scale difference between the given cell and the player cell, telling whether it is smaller, larger or the same scale (level).
- auto ShouldNotAttack(cCellObjectData* cell1, cCellObjectData* cell2) -> bool
- Calculates whether the first cell will or will not attack the second cell.
- auto GetDamageAmount(cCellObjectData* attackerCell, cCellObjectData* victimCell) -> int
- Returns how much hp damage the victim cell takes when attacked by another cell.
-
auto FindCellsInRadius(cCellQueryLinkedPool* query,
const Math::
Vector3& position, float radius, cObjectPoolIndex* dst, int dstArraySize, void* dst2 = nullptr) -> int - Finds all the cells that are within a radius of a specific position.
- auto PlayAnimation(cCellObjectData* cell, cCellObjectData* otherCell, CellAnimations targetAnim, CellAnimations currentAnim) -> void
- Makes the cell play an animation.
- auto GetModelKeyForCellResource(cCellDataReference<cCellCellResource>* cellResource) -> ResourceKey
- Returns the main model key that must be used for a specific cell definition.
Enum documentation
enum class Simulator:: Cell:: ScaleDifference
Enumerators | |
---|---|
MuchSmaller |
Cell is 2 or more levels smaller than player cell. |
Smaller |
Cell is 1 level smaller than player cell. |
Equal |
Cell is same level as player cell. |
Larger |
Cell is 1 level larger than player cell. |
MuchLarger |
Cell is 2 or more levels larger than player cell. |
enum class Simulator:: Cell:: CellStageScale: int
enum Simulator:: Cell:: CellAnimations
Function documentation
namespace Simulator:: Cell:: Addresses(GameModeCell)
Simulator:: Cell:: ASSERT_SIZE(cCellGame,
0x51E4)
Simulator:: Cell:: ASSERT_SIZE(cCellGFX,
0x1625C)
Simulator:: Cell:: ASSERT_SIZE(cCellObjectData,
0x398)
Simulator:: Cell:: ASSERT_SIZE(cCellQueryEntry,
0x1C)
Simulator:: Cell:: ASSERT_SIZE(cCellQueryLinkedPoolData,
0x18)
Simulator:: Cell:: ASSERT_SIZE(cCellQueryLinkedPool,
16)
Simulator:: Cell:: ASSERT_SIZE(CellSerializerField,
0x28)
Simulator:: Cell:: ASSERT_SIZE(CellSerializer,
0x28)
Simulator:: Cell:: ASSERT_SIZE(cCellResource,
0x20)
Simulator:: Cell:: ASSERT_SIZE(cCellDataReference_ ,
0x10)
namespace Simulator:: Cell:: Addresses(cCellDataReference_ )
Simulator:: Cell:: ASSERT_SIZE(cCellPowersResource,
0x8)
Simulator:: Cell:: ASSERT_SIZE(cCellRandomCreatureResource,
8)
Simulator:: Cell:: ASSERT_SIZE(cCellStructureResource,
0x1C)
Simulator:: Cell:: ASSERT_SIZE(cCellPopulateResource,
0x10)
Simulator:: Cell:: ASSERT_SIZE(cCellWorldResource,
0x10)
Simulator:: Cell:: ASSERT_SIZE(cCellCellResource,
0x31C)
Simulator:: Cell:: ASSERT_SIZE(cCellLootTableResource,
0x24)
Simulator:: Cell:: ASSERT_SIZE(cCellLookTableResource,
8)
Simulator:: Cell:: ASSERT_SIZE(cCellLookAlgorithmResource,
8)
Simulator:: Cell:: ASSERT_SIZE(cCellEffectMapResource,
8)
Simulator:: Cell:: ASSERT_SIZE(cCellBackgroundMapResource,
8)
Simulator:: Cell:: ASSERT_SIZE(cCellGlobalsResource,
0x114)
Simulator:: Cell:: ASSERT_SIZE(cAdvectResource,
0x20)
cCellGlobalsResource* Simulator:: Cell:: GetGlobalsData()
T* Simulator:: Cell:: GetData(cCellDataReference_ * reference,
eastl::intrusive_ptr<cCellDataReference<T>>& dst)
Loads the data of a cell file reference, or returns the existing cached file.
Parameters | |
---|---|
reference | |
dst |
Simulator:: Cell:: ASSERT_SIZE(cCellScaleInfo,
0x1C)
Simulator:: Cell:: ASSERT_SIZE(cCellMission,
0x10)
Simulator:: Cell:: ASSERT_SIZE(cCellSerializableData,
0xEC)
namespace Simulator:: Cell:: Addresses(cCellSerializableData)
Simulator:: Cell:: ASSERT_SIZE(cCellUIRollover,
0x38)
Simulator:: Cell:: ASSERT_SIZE(cCellUI,
0x944)
Simulator:: Cell:: ASSERT_SIZE(cCellAnimDefinition,
0x24)
GoalCard* Simulator:: Cell:: GetGoalCards()
cCellObjectData* Simulator:: Cell:: GetPlayerCell()
Returns the player cell.
uint32_ t Simulator:: Cell:: GetCurrentAdvectInfo(CellStageScale& dst0,
float& dstStrength,
float& dstVariance,
float& dstPeriod)
Returns the info of the cCellWorldResource::cAdvectInfo of the current world and cell scale, based on the current food progression.
Parameters | |
---|---|
dst0 out | |
dstStrength out | |
dstVariance out | |
dstPeriod out | |
Returns | The advect file ID |
uint32_ t Simulator:: Cell:: GetNextAdvectID()
Returns the advect file ID for the next cell scale in the current world, based on the current food progression.
cObjectPoolIndex Simulator:: Cell:: CreateCellObject(cCellQueryLinkedPool* query,
const Math:: Vector3& position,
float elevation,
cCellDataReference<cCellCellResource>* resource,
CellStageScale scaleLevel,
float sizeFactor,
float cellSize,
bool applySize = true,
Math:: Quaternion* pTargetOrientation = nullptr,
int = 0)
void Simulator:: Cell:: MovePlayerToMousePosition(float deltaTime)
ScaleDifference Simulator:: Cell:: GetScaleDifferenceWithPlayer(cCellObjectData* otherCell)
Returns scale difference between the given cell and the player cell, telling whether it is smaller, larger or the same scale (level).
Parameters | |
---|---|
otherCell |
bool Simulator:: Cell:: ShouldNotAttack(cCellObjectData* cell1,
cCellObjectData* cell2)
Calculates whether the first cell will or will not attack the second cell.
Parameters | |
---|---|
cell1 | |
cell2 | |
Returns | True if cell 1 must not attack cell 2, false if it must attack. |
This returns false when:
int Simulator:: Cell:: GetDamageAmount(cCellObjectData* attackerCell,
cCellObjectData* victimCell)
Returns how much hp damage the victim cell takes when attacked by another cell.
Parameters | |
---|---|
attackerCell | |
victimCell | |
Returns | The amount of HP damage. |
The maximum HP for all cells is 6.
int Simulator:: Cell:: FindCellsInRadius(cCellQueryLinkedPool* query,
const Math:: Vector3& position,
float radius,
cObjectPoolIndex* dst,
int dstArraySize,
void* dst2 = nullptr)
Finds all the cells that are within a radius of a specific position.
The caller must provide a buffer where For example, getting all the cells 10 units from the player:
Math::Vector3 position = Simulator::Cell::GetAvatarCell()->mTransform.GetOffset(); cObjectPoolIndex buffer[400]; int numCells = Simulator::Cell::FindCellsInRadius(CellGame.field_40FC, position, 10.0f, buffer, 400);
void Simulator:: Cell:: PlayAnimation(cCellObjectData* cell,
cCellObjectData* otherCell,
CellAnimations targetAnim,
CellAnimations currentAnim)
Makes the cell play an animation.
Parameters | |
---|---|
cell | |
otherCell | |
targetAnim | |
currentAnim |
ResourceKey Simulator:: Cell:: GetModelKeyForCellResource(cCellDataReference<cCellCellResource>* cellResource)
Returns the main model key that must be used for a specific cell definition.
Parameters | |
---|---|
cellResource |
This looks at the structure
field of the resource, and finds the first entry that is either:
Creature
: returns the instance ID with.cll
extension and group 0RandomCreature
: evaluates the random creature query and returns the keyPlayerCreature
: returns the player model key For all other cases, it returns 0.