Thrive
Table of Contents
1. Stage
Top-level scene management.
Base classes are under the directory src/general/base_stage
classStageBaseNodeworld: The World Godot nodeNode: This is the Godot node that sprites are added.PauseMenupauseMenuControlhudrootboolgameoverGameWorldGameWorldvirtual voidSetupStage(): call virtual void OnGameStartedvoid_Process(double delta): load stage if not loaded, andGameWorld.Process((float)delta)
classCreatureStageBase<TPlsyer, TSimulation> : StageBaseTSimulationWorldSimulationoverride void_Process(double delta): pass to StageBase, handle respawn and extinction
1.1. MicrobeStage
Under the directory src/microbe_stage
classMicrobeStage: CreatureStageBase<Entity,>override void_Ready(): Setup HUD, fluid current, and SetupStageoverride voidSetupStage(): initializes system and cloud, and call OnGameStarted via base.SetupStageoverride voidOnGameStarted(): call SpawnPlayeroverride voidSpawnPlayer()spawn using SpawnMicrobeWithoutFinalizing and attach player specific componentsoverride void_Process(double delta): call base.Process, and run ProcessAll
2. GameWorld
The global informations of the world, in contrast to the information about the world that we can see: World.
classGameWorldDictionary<uint, Species>worldSpeciesTimedWorldOperationsTimedEffectsSpeciesPlayerSpeciesPatchMapMapMicrobeSpeciesCreatePlayerSpecies()DayNightCycleLightCyclevoidProcess(float delta):LightCycle.Process(delta)- GameWorld
(WroldGenerationSettings settings, Species? startingSpecies = null): add effects to the game, create the player cell,
3. Components
3.1. Common Components
3.1.1. SpatialInstance
The Godot node container
classSpatialInstanceNode3D?GraphicalInstance: the Godot node
3.1.2. Physics
3.1.3. WorldPosition
classWorldPosition: IArchivableComponentVector3PositionQuaternionRotation
4. Physical World
Under the directory src/engine/physics,
which uses the library in src/native/ which is compiled against third_party/JoltPhysics/.
classPhysicalWorld- ProcessPhysics
4.0.1. NativePhysicsBody
It contains the IntPtr called nativeInstance, which is used in the physical world.
5. WorldSimulation
Base under src/general/base_stage
abstract classWorldSimulationprotected readonly Worldentites:Arch.Core.Worldfrom the Arch ECSWorldEntitySystem: wrapper for the readonly variable entities.World EntitySystem => entities;meansWorld EntitySystem { get { return entities; } }
Vector3PlayerPositionfloatWorldTimeScale: default to 1bool(float delta): runProcessLogic(delta)andProcessFrameLogic(delta)virtual boolProcessLogic(float delta): runOnProcesFixedLogic(accumulatedLogicTime), andOnProcessPhysics(accumulatedLogicTime)- Not overrided by MicrobeWorldSimulation
voidProcessFrameLogic(float delta): runOnProcessFrameLogic(delta)virtual voidOnProcessPhysics(float delta): runWaitForStartedPhysicsRun()andOnStartPhysicsRunIfTime(delta)- Not overrided by MicrobeWroldSimulation
- above call back functions are defined as
abstractmethods here
abstract voidOnProcessFixedLogic(float delta)
classWorldSimulationWithPhysics: WorldSimulationPhysicalWorldPhysicalWorld (equal to "physics")List<NativePhysicsBody>createdBodiesoverride voidWaitForStartedPhysicsRun(): runphysics.WaitUntilPhysicsRunEnds()override voidOnStartPhysicsRunIfTime(float delta): runphysics.ProcessPhysics(delta)
class partialMicrobeWorldSimulation: WorldSimulationWithPhysicsoverride voidOnProcessFixedLogic(float delta): call either OnProcessFixedWithThreads or OnProcessFixedWithoutThreads defined in the separte .generated fileoverride voidOnProcessFrameLogic(float delta): call OnProcessFrameLogicGenerated defined in .generated file
5.1. Common Systems
5.1.1. SpatialAttachSystem
classSpatialAttachSystem: AComponentSystem<float, SpatialInstance>NodegodotWorldRoot: it is the visualsParent, that is, rootOfDynamicallySpawned.Dictionary<Node3D, AttachedInfo>attachedSpatialInstancesoverride voidUpdate(float state, Span<SpatialInstance components)attach only not attached components, such as microbes and minerals, to the godotWorldRoot
5.1.2. SpatialPositionSystem
Transform the graphicalInstance based on the WorldPosition of the entity
classSpatialPositionSystem
5.1.3. Physical World to Screen
classPhysicsUpdateAndPositionSystem- Update the WorldPosition (includes position and rotation) to the physical world position.
classSpatialPositionSystem- Transform the Godot node into the WorldPosition.
5.1.4. PhysicsBodyControlSystem
This is a fallback mechanism when we don't use physical world for the motion, or we don't use it altogether.
The velocity of Physics component is applied to the body in the physical world when VelocityApplied is set to false.
5.2. Microbe Systems
Microbe under src/microbe_stage
classMicrobeWorldSimulation: WorldSimulationWithPhysicsNode: the Godot nodes where entities are attachedvoidInit(Node visualDisplayRoot, CompoundCloudSystem cloudSystem, IMicrobeSpawnEnvironment spawnEnvironment)Set the rootOfDynamicallySpawned to the visualsParent, set up various systems that controls game mechanics.- various systems that control each aspect of the game mechanism
override voidOnProcessFixedLogic(float delta): either runOnProcessFixedWithThreads(delta)orOnProcessFixedWithoutThreads(delta), which are generated in separate file.override voidOnProcessFrameLogic(float delta): runOnProcessFrameLogicGenerated(delta)which is generated in separate file.- the generated file is suffixed with
.generated.cs, and the methods are included using partial class. generated methods call theUpdate(delta)on each system.
5.2.1. MicrobeAI
Make decision about movement and change the MicrobeControl accordingly.
5.2.2. MicrobeMovementSystem
Motion is applied to the body in physical world, based on the current WorldPosition and MicrobeControl.
The control is modified in order to generate motion.
5.2.3. MicrobeVisualsSystem
Generate the membrane into the graphicalInstance
6. UI
6.1. MainMenu
Scene: src/general/MainMenu.tscn
6.2. HUD
classCreatureStageHUDBase<TStage>TStage?stagevoidInit(TStage containedInStage): set stage
6.3. Input
6.3.1. Microbe
classPlayerMicrobeInput: NodeWithInput- Set the control LookAtPoint of the player to the cursor position.
7. DefaultEcs
- C# Entity-Component-System Library