Skip to content

Commit

Permalink
Added more parameters for cells and for all cell structures
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattHolliday committed May 25, 2024
1 parent b535b46 commit 76c7b46
Show file tree
Hide file tree
Showing 18 changed files with 987 additions and 236 deletions.
681 changes: 637 additions & 44 deletions cell_spawner.tscn

Large diffs are not rendered by default.

176 changes: 88 additions & 88 deletions dark_menu.tres

Large diffs are not rendered by default.

176 changes: 88 additions & 88 deletions dark_mode.tres

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/src/cell_membrane.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Description: the CellMembrane class is a CellStructure that contains and manages
- Vector\<Receptor *\> getReceptors(): returns _receptors
- Vector\<Receptor *\> getActivatedReceptors(): returns _activatedReceptors

- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node
- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node; calls setActivationThreshold(), setCreationNutrientCost(), setCreationNutrientCost(), setMaintenanceNutrientCost() and setMaintenanceEnergyCost() with their respective setting in the InitalValues menu within the UI

- void _rearrangeReceptors(): resets the position, rotation, and scaling of each Receptor in _receptors

Expand Down
2 changes: 1 addition & 1 deletion docs/src/cell_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Description: the CellState Node is a manager for the Cell's state variables, suc
- void setReceptorVectors(const Vector<Vector2>): sets _receptorVectors to the given value
- Vector<Vector2> getReceptorVectors() const: returns _receptorVectors

- void _ready() override: runs once when the CellState enters the node tree; sets _birthTime to the current simulation second; calls setLifespan(), setGrowthNutrientCost() and setGrowthEnergyCost() with their respective setting in the InitalValues menu within the UI
- void _ready() override: runs once when the CellState enters the node tree; sets _birthTime to the current simulation second; calls setGrowthRate(), setLifespan(), setGrowthNutrientCost() and setGrowthEnergyCost() with their respective setting in the InitalValues menu within the UI

## Non-Member Functions
None
2 changes: 1 addition & 1 deletion docs/src/flagella.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Description: the Flagella class is a CellStructure that enables the randomized m
- void setActivationEnergyThreshold(const float): sets the _activationEnergyThreshold to the given value
- float getActivationEnergyThreshold() const: returns _activationEnergyThreshold

- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node
- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node; calls setActivationEnergyThreshold(), setActivationEnergyCost(), setMovementForceVector() for x and y, setCreationNutrientCost(), setCreationEnergyCost(), setMaintenanceNutrientCost() and setMaintenanceEnergyCost() with their respective setting in the InitalValues menu within the UI

### Non-Member Functions
None
2 changes: 1 addition & 1 deletion docs/src/mitochondria.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Description: the Mitochondria class is a CellStructure that converts nutrients i
- void setThresholdType(const String thresholdType): sets _thresholdType to the given value if it is either "high-pass" or "low-pass"
- String getThresholdType() const: returns _thresholdType

- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node
- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node; calls setActivationThreshold(), setStrength(), setEfficiency(), setPreferredConversionRate(), setActivationResource(), setThresholdType(), setCreationNutrientCost(), setCreationEnergyCost(), setMaintenanceNutrientCost() and setMaintenanceEnergyCost() with their respective setting in the InitalValues menu within the UI

## Non-Member Functions
None
2 changes: 1 addition & 1 deletion docs/src/nucleus.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Description: the Nucleus class is CellStructure that manages reproduction
- void setReproductionEnergyThreshold(const float reproductionNutrientThreshold): sets _reproductionEnergyThreshold to the given value if it is > 0.0
- float getReproductionEnergyThreshold() const: returns reproductionEnergyThreshold

- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node
- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node; calls setReproductionNutrientThreshold(), setCreationNutrientCost(), setCreationEnergyCost(), setMaintenanceNutrientCost() and setMaintenanceEnergyCost() with their respective setting in the InitalValues menu within the UI

## Non-Member Functions
None
2 changes: 1 addition & 1 deletion docs/src/ribosomes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Description: the Ribosomes class is a CellStructure that converts energy into nu
- void setThresholdType(const String thresholdType): sets _thresholdType to the given value if it is either "high-pass" or "low-pass"
- String getThresholdType() const: returns _thresholdType

- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node
- void _ready() override: runs once when this object enters the node tree; sets this CellStructure's sprite property to a child Sprite2D node; calls setActivationThreshold(), setStrength(), setEfficiency(), setPreferredConversionRate(), setActivationResource(), setThresholdType(), setCreationNutrientCost(), setCreationEnergyCost(), setMaintenanceNutrientCost() and setMaintenanceEnergyCost() with their respective setting in the InitalValues menu within the UI

## Non-Member Functions
None
2 changes: 1 addition & 1 deletion src/cell_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,6 @@ void CellEnvironment::_ready() {
CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));

// Connect to values from simulation parameters menu
Node *NStartingNutrientZonesSpinBox = spawner->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/NNutrientZoneContainer/SpinBox");
Node *NStartingNutrientZonesSpinBox = spawner->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/NutrientZone/ScrollContainer/VBoxContainer/NNutrientZoneContainer/SpinBox");
NStartingNutrientZonesSpinBox->connect("value_changed", Callable(this, "setNNutrientZones"));
}
23 changes: 23 additions & 0 deletions src/cell_membrane.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "cell_membrane.hpp"
#include "cell_spawner.hpp"

#include "helpers.hpp"

#include <godot_cpp/classes/spin_box.hpp>

void CellMembrane::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_activation_threshold", "activation_threshold"), &CellMembrane::setActivationThreshold);
Expand Down Expand Up @@ -101,11 +106,29 @@ Vector<Receptor *> CellMembrane::getReceptors() { return _receptors; }
Vector<Receptor *> CellMembrane::getActivatedReceptors() { return _activatedReceptors; }

void CellMembrane::_ready() {
DONT_RUN_IN_EDITOR;
AnimatedSprite2D *sprite = this->get_node<AnimatedSprite2D>("AnimatedSprite2D");
if (sprite)
this->setSprite(sprite);

_updateReceptors();

CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));
// Set to values from simulation parameters menu
SpinBox *activationThresholdSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/CellMembrane/ScrollContainer/VBoxContainer/activationThreshold/SpinBox");
this->setActivationThreshold(activationThresholdSpinBox->get_value());

SpinBox *creationNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/CellMembrane/ScrollContainer/VBoxContainer/creationNutrientCost/SpinBox");
this->setCreationNutrientCost(creationNutrientCostSpinBox->get_value());

SpinBox *creationEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/CellMembrane/ScrollContainer/VBoxContainer/creationEnergyCost/SpinBox");
this->setCreationEnergyCost(creationEnergyCostSpinBox->get_value());

SpinBox *maintenanceNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/CellMembrane/ScrollContainer/VBoxContainer/maintenanceNutrientCost/SpinBox");
this->setMaintenanceNutrientCost(maintenanceNutrientCostSpinBox->get_value());

SpinBox *maintenanceEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/CellMembrane/ScrollContainer/VBoxContainer/maintenanceEnergyCost/SpinBox");
this->setMaintenanceEnergyCost(maintenanceEnergyCostSpinBox->get_value());
}

void CellMembrane::_rearrangeReceptors() {
Expand Down
4 changes: 2 additions & 2 deletions src/cell_spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ void CellSpawner::_ready() {
#endif

// Connect to values from simulation parameters menu
Node *NumberOfStartingCellsSpinBox = this->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/NStartingCellsContainer/SpinBox");
Node *NumberOfStartingCellsSpinBox = this->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/NStartingCellsContainer/SpinBox");
NumberOfStartingCellsSpinBox->connect("value_changed", Callable(this, "setNumCells"));

Node *ResourceProportionSpinBox = this->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/ResourceProportionContainer/SpinBox");
Node *ResourceProportionSpinBox = this->get_node<Node>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/ResourceProportionContainer/SpinBox");
ResourceProportionSpinBox->connect("value_changed", Callable(this, "setResourceProportion"));

// Spawn back ground cells that don't die
Expand Down
9 changes: 6 additions & 3 deletions src/cell_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,15 @@ void CellState::_ready() {

CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));
// Set to values from simulation parameters menu
SpinBox *LifeSpanSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/CellLifespanContainer/SpinBox");
SpinBox *GrowthRateSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/GrowthRateContainer/SpinBox");
this->setGrowthRate(GrowthRateSpinBox->get_value());

SpinBox *LifeSpanSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/CellLifespanContainer/SpinBox");
this->setLifespan(LifeSpanSpinBox->get_value());

SpinBox *GrowthNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/GrowthNutrientCostContainer/SpinBox");
SpinBox *GrowthNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/GrowthNutrientCostContainer/SpinBox");
this->setGrowthNutrientCost(GrowthNutrientCostSpinBox->get_value());

SpinBox *GrowthEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/ScrollContainer/InitalValuesContainer/GrowthEnergyCostContainer/SpinBox");
SpinBox *GrowthEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Cell/ScrollContainer/VBoxContainer/GrowthEnergyCostContainer/SpinBox");
this->setGrowthEnergyCost(GrowthEnergyCostSpinBox->get_value());
}
32 changes: 32 additions & 0 deletions src/flagella.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "flagella.hpp"
#include "cell_spawner.hpp"

#include "helpers.hpp"

#include <godot_cpp/classes/spin_box.hpp>

void Flagella::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_movement_force_vector", "movement_force_vector"), &Flagella::setMovementForceVector);
Expand Down Expand Up @@ -95,7 +100,34 @@ void Flagella::setActivationEnergyThreshold(const float activationEnergyThreshol
float Flagella::getActivationEnergyThreshold() const { return _activationEnergyThreshold; }

void Flagella::_ready() {
DONT_RUN_IN_EDITOR;
AnimatedSprite2D *sprite = this->get_node<AnimatedSprite2D>("AnimatedSprite2D");
if (sprite)
this->setSprite(sprite);

CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));
// Set to values from simulation parameters menu
SpinBox *activationEnergyThresholdSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/activationEnergyThreshold/SpinBox");
this->setActivationEnergyThreshold(activationEnergyThresholdSpinBox->get_value());

SpinBox *activationEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/activationEnergyCost/SpinBox");
this->setActivationEnergyCost(activationEnergyCostSpinBox->get_value());

SpinBox *movementForceVectorXSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/movementForceVectorX/SpinBox");
this->setMovementForceVector(Vector2(movementForceVectorXSpinBox->get_value(), _movementForceVector.y));

SpinBox *movementForceVectorYSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/movementForceVectorY/SpinBox");
this->setMovementForceVector(Vector2(_movementForceVector.x, movementForceVectorYSpinBox->get_value()));

SpinBox *creationNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/creationNutrientCost/SpinBox");
this->setCreationNutrientCost(creationNutrientCostSpinBox->get_value());

SpinBox *creationEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/creationEnergyCost/SpinBox");
this->setCreationEnergyCost(creationEnergyCostSpinBox->get_value());

SpinBox *maintenanceNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/maintenanceNutrientCost/SpinBox");
this->setMaintenanceNutrientCost(maintenanceNutrientCostSpinBox->get_value());

SpinBox *maintenanceEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Flagella/ScrollContainer/VBoxContainer/maintenanceEnergyCost/SpinBox");
this->setMaintenanceEnergyCost(maintenanceEnergyCostSpinBox->get_value());
}
39 changes: 39 additions & 0 deletions src/mitochondria.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#include "mitochondria.hpp"
#include "cell_spawner.hpp"

#include "helpers.hpp"

#include <godot_cpp/classes/option_button.hpp>
#include <godot_cpp/classes/spin_box.hpp>

void Mitochondria::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_activation_threshold", "activation_threshold"), &Mitochondria::setActivationThreshold);
Expand Down Expand Up @@ -149,7 +155,40 @@ void Mitochondria::setThresholdType(const String thresholdType) {
String Mitochondria::getThresholdType() const { return _thresholdType; }

void Mitochondria::_ready() {
DONT_RUN_IN_EDITOR;
AnimatedSprite2D *sprite = this->get_node<AnimatedSprite2D>("AnimatedSprite2D");
if (sprite)
this->setSprite(sprite);

CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));
// Set to values from simulation parameters menu
SpinBox *activationThresholdSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/activationThreshold/SpinBox");
this->setActivationThreshold(activationThresholdSpinBox->get_value());

SpinBox *strengthSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/strength/SpinBox");
this->setStrength(strengthSpinBox->get_value());

SpinBox *efficiencySpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/efficiency/SpinBox");
this->setEfficiency(efficiencySpinBox->get_value());

SpinBox *preferredConversionRateSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/preferredConversionRate/SpinBox");
this->setPreferredConversionRate(preferredConversionRateSpinBox->get_value());

OptionButton *activationResourceOptionButton = spawner->get_node<OptionButton>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/activationResource/OptionButton");
this->setActivationResource(activationResourceOptionButton->get_item_text(activationResourceOptionButton->get_selected()));

OptionButton *thresholdTypeOptionButton = spawner->get_node<OptionButton>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/thresholdType/OptionButton");
this->setThresholdType(thresholdTypeOptionButton->get_item_text(thresholdTypeOptionButton->get_selected()));

SpinBox *creationNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/creationNutrientCost/SpinBox");
this->setCreationNutrientCost(creationNutrientCostSpinBox->get_value());

SpinBox *creationEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/creationEnergyCost/SpinBox");
this->setCreationEnergyCost(creationEnergyCostSpinBox->get_value());

SpinBox *maintenanceNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/maintenanceNutrientCost/SpinBox");
this->setMaintenanceNutrientCost(maintenanceNutrientCostSpinBox->get_value());

SpinBox *maintenanceEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Mitochondria/ScrollContainer/VBoxContainer/maintenanceEnergyCost/SpinBox");
this->setMaintenanceEnergyCost(maintenanceEnergyCostSpinBox->get_value());
}
22 changes: 22 additions & 0 deletions src/nucleus.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "nucleus.hpp"
#include "cell.hpp"
#include "cell_spawner.hpp"

#include "helpers.hpp"

#include <godot_cpp/classes/spin_box.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

void Nucleus::_bind_methods() {
Expand Down Expand Up @@ -70,7 +74,25 @@ void Nucleus::setReproductionEnergyThreshold(const float reproductionEnergyThres
float Nucleus::getReproductionEnergyThreshold() const { return _reproductionEnergyThreshold; }

void Nucleus::_ready() {
DONT_RUN_IN_EDITOR;
AnimatedSprite2D *sprite = this->get_node<AnimatedSprite2D>("AnimatedSprite2D");
if (sprite)
this->setSprite(sprite);

CellSpawner *spawner = Object::cast_to<CellSpawner>(this->find_parent("CellSpawner"));
// Set to values from simulation parameters menu
SpinBox *reproductionNutrientThresholdSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Nucleus/ScrollContainer/VBoxContainer/reproductionNutrientThreshold/SpinBox");
this->setReproductionNutrientThreshold(reproductionNutrientThresholdSpinBox->get_value());

SpinBox *creationNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Nucleus/ScrollContainer/VBoxContainer/creationNutrientCost/SpinBox");
this->setCreationNutrientCost(creationNutrientCostSpinBox->get_value());

SpinBox *creationEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Nucleus/ScrollContainer/VBoxContainer/creationEnergyCost/SpinBox");
this->setCreationEnergyCost(creationEnergyCostSpinBox->get_value());

SpinBox *maintenanceNutrientCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Nucleus/ScrollContainer/VBoxContainer/maintenanceNutrientCost/SpinBox");
this->setMaintenanceNutrientCost(maintenanceNutrientCostSpinBox->get_value());

SpinBox *maintenanceEnergyCostSpinBox = spawner->get_node<SpinBox>("UI/MenuPanel/TabContainer/InitalValues/TabContainer/Nucleus/ScrollContainer/VBoxContainer/maintenanceEnergyCost/SpinBox");
this->setMaintenanceEnergyCost(maintenanceEnergyCostSpinBox->get_value());
}
Loading

0 comments on commit 76c7b46

Please sign in to comment.