diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index 18364056b90..2bea03ce98e 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -3,11 +3,12 @@ "name": "Respiration", "inputs": { + "oxygen": 1.0, "glucose": 0.2 }, "outputs": { - "atp": 14.0 + "atp": 38.0 } }, @@ -27,7 +28,7 @@ "name": "Photosynthesis", "inputs": { - "glucose": 0.0 + "carbondioxide": 0.09 }, "outputs": { @@ -39,11 +40,12 @@ "name": "Oxytoxy Synthesis", "inputs": { - "atp": 1.0 + "oxygen": 1.0, + "atp": 5.0 }, "outputs": { - "oxytoxy": 1.0 + "oxytoxy": 5.0 } }, @@ -51,6 +53,7 @@ "name": "Chemo Synthesis", "inputs": { + "carbondioxide": 0.09, "hydrogensulfide": 1.0 }, @@ -63,6 +66,7 @@ "name": "Bacterial Chemosynthesis", "inputs": { + "carbondioxide": 0.09, "hydrogensulfide": 1.0 }, @@ -87,11 +91,12 @@ "name": "RespirationProtein", "inputs": { + "oxygen": 1.0, "glucose": 0.7 }, "outputs": { - "atp": 14.0 + "atp": 38.0 } }, @@ -99,7 +104,7 @@ "name": "Bacterial Photosynthesis", "inputs": { - "glucose": 0.0 + "carbondioxide": 0.09 }, "outputs": { diff --git a/scripts/SimulationParameters/MicrobeStage/Biomes.json b/scripts/SimulationParameters/MicrobeStage/Biomes.json index d428f8b6f65..2ed652b12d2 100644 --- a/scripts/SimulationParameters/MicrobeStage/Biomes.json +++ b/scripts/SimulationParameters/MicrobeStage/Biomes.json @@ -15,30 +15,44 @@ } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 8, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, @@ -58,30 +72,44 @@ } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 98, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, "tidepool": { @@ -100,30 +128,44 @@ } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 23, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, "bathypalagic": { @@ -141,29 +183,43 @@ "b": 0.9 } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 2, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, @@ -182,29 +238,43 @@ "b": 0.9 } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 2, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, @@ -223,29 +293,43 @@ "b": 0.9 } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 17, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, @@ -264,29 +348,43 @@ "b": 0.9 } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": 23, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 - } + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } }, @@ -298,38 +396,109 @@ "r": 0.98, "g": 0.7, "b": 0.75 - }, + }, "diffuseColors": { "r": 1.0, "g": 0.9, "b": 0.9 - } + } }, - "oxygenPercentage": 0.21, - "carbonDioxidePercentage": 0.09, "averageTemperature": -1, "compounds": { "ammonia": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "glucose": { "amount": 350000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "phosphates": { "amount": 300000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 }, "hydrogensulfide": { "amount": 325000, - "density": 0.00002 + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } + } + }, + + "estuary": { + "name": "Estuary", + "background": "Background_Estuary", + "colors":{ + "specularColors": { + "r": 0.98, + "g": 0.7, + "b": 0.75 + }, + "diffuseColors": { + "r": 1.0, + "g": 0.9, + "b": 0.9 } + }, + + "averageTemperature": 17, + + "compounds": { + "ammonia": { + "amount": 300000, + "density": 0.00002, + "dissolved": 0.0 + }, + + "glucose": { + "amount": 350000, + "density": 0.00002, + "dissolved": 0.0 + }, + + "phosphates": { + "amount": 300000, + "density": 0.00002, + "dissolved": 0.0 + }, + + "hydrogensulfide": { + "amount": 325000, + "density": 0.00002, + "dissolved": 0.0 + }, + + "oxygen": { + "amount": 0, + "density": 0.0, + "dissolved": 0.21 + }, + + "carbondioxide": { + "amount": 0, + "density": 0.0, + "dissolved": 0.09 + } } } } diff --git a/scripts/SimulationParameters/MicrobeStage/Compounds.json b/scripts/SimulationParameters/MicrobeStage/Compounds.json index 7d6032e0da4..c0979c86914 100644 --- a/scripts/SimulationParameters/MicrobeStage/Compounds.json +++ b/scripts/SimulationParameters/MicrobeStage/Compounds.json @@ -4,6 +4,7 @@ "volume": 1, "isCloud": false, "isUseful": true, + "isEnvironmental": false, "colour": { "r": 0.235, "g": 0.627, @@ -16,6 +17,7 @@ "volume": 1, "isCloud": true, "isUseful": true, + "isEnvironmental": false, "colour": { "r": 0.6, "g": 0.7, @@ -28,6 +30,7 @@ "volume": 1, "isCloud": true, "isUseful": true, + "isEnvironmental": false, "colour": { "r": 0.7, "g": 0.0, @@ -40,6 +43,7 @@ "volume": 1, "isCloud": true, "isUseful": false, + "isEnvironmental": false, "colour": { "r": 1.0, "g": 0.4, @@ -52,6 +56,7 @@ "volume": 1, "isCloud": true, "isUseful": false, + "isEnvironmental": false, "colour": { "r": 0.9, "g": 0.9, @@ -64,10 +69,37 @@ "volume": 1, "isCloud": false, "isUseful": true, + "isEnvironmental": false, "colour": { "r": 0.078, "g": 0.0, "b": 0.078 } + }, + + "oxygen": { + "name": "Oxygen", + "volume": 1, + "isCloud": false, + "isUseful": true, + "isEnvironmental": true, + "colour": { + "r": 0.0, + "g": 0.0, + "b": 1.0 + } + }, + + "carbondioxide": { + "name": "Carbon Dioxide", + "volume": 1, + "isCloud": false, + "isUseful": true, + "isEnvironmental": true, + "colour": { + "r": 1.0, + "g": 0.0, + "b": 0.0 + } } } diff --git a/scripts/gui/microbe_editor.mjs b/scripts/gui/microbe_editor.mjs index 134da298d69..cf08ff04127 100644 --- a/scripts/gui/microbe_editor.mjs +++ b/scripts/gui/microbe_editor.mjs @@ -49,8 +49,8 @@ const organelleSelectionElements = [ organelle: "nitrogenfixingplastid" }, { - element: document.getElementById("addChemoSynthisizingProtiens"), - organelle: "chemoSynthisizingProtiens" + element: document.getElementById("addChemoSynthisizingProteins"), + organelle: "chemoSynthisizingProteins" }, { element: document.getElementById("addFlagellum"), diff --git a/scripts/gui/microbe_hud.mjs b/scripts/gui/microbe_hud.mjs index fff717c06f8..3e159265140 100644 --- a/scripts/gui/microbe_hud.mjs +++ b/scripts/gui/microbe_hud.mjs @@ -68,6 +68,11 @@ export function runMicrobeHUDSetup(){ checkExtinction(vars.population); }); + // Event for updating o2 and c02 numbers + Leviathan.OnGeneric("UpdateDissolvedGasses", (event, vars) => { + updateDissolvedGasses(vars.oxygenPercent, vars.co2Percent); + }); + // Event for checking win conditions Leviathan.OnGeneric("CheckWin", (event, vars) => { checkGeneration(vars.generation, vars.population); @@ -392,6 +397,15 @@ function updatePopulation(population){ population; } +// Update dissolved gasses +function updateDissolvedGasses(oxygen, c02){ + document.getElementById("oxygenPercent").textContent = + "O2: " + oxygen + "%"; + document.getElementById("carbonDioxidePercent").textContent = + "CO2: " + c02 + "%"; +} + + //! Checks if the player is extinct function checkExtinction(population){ if(population <= 0){ diff --git a/scripts/gui/thrive_gui.html b/scripts/gui/thrive_gui.html index 9750af9a1b7..c46a84ad208 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -117,7 +117,21 @@ POPULATION: 0 - + +
+ +
+ O2: 21% +
+ +
+ +
+ CO2: 9% +
+ + +
YOU HAVE THRIVED! Congratulation- a winner is y... who am I kidding, you have thrived! You have won in the 0.4.0 build Good job, you may continue playing after this screen closes if you wish, or start a new game in a new world. @@ -354,7 +368,7 @@ Mitochondria

Cost: 40 mutation points

- Performs Process: Respiration
(0.2 glucose -> 14 ATP)/Second

+ Performs Process: Respiration
(1 Oxygen + 0.2 glucose -> 38 ATP)/Second (Depending On Environmental Oxygen)

A captured prokaryote used by eukaryotic cells to perform respiration.
The Mitochondria is the powerhouse of the cell
@@ -363,17 +377,17 @@ Chloroplast

Cost: 40 mutation points

- Performs Process: Photosynthesis
(1 glucose)/Second

+ Performs Process: Photosynthesis
( 0.09 Carbon Dioxide -> 1 glucose)/Second (Depending On Environmental C02)

A captured prokaryote used by eukaryotic cells to perform photosynthesis.
The chloroplast is used primarily by plant cells on earth, but some ciliates and other organisms use it too.
Chloroplast
40 MP - Chloroplast

Cost: 40 mutation points

- Performs Process: Photosynthesis
(1 glucose)/Second

- A captured prokaryote used by eukaryotic cells to perform photosynthesis.
- The chloroplast is used primarily by plant cells on earth, but some ciliates and other organisms use it too. + Thermoplast

Cost: 40 mutation points

+ Performs Process: Thermosynthesis
(Heat -> 1 glucose)/Second (Depending On Environmental Heat)

+ A captured prokaryote used by eukaryotic cells to perform thermosynthesis.
+ The thermoplast is a theoretical organelle that takes environmental heat gradients and generates energy from them.
Thermoplast
40 MP @@ -386,7 +400,7 @@ Toxin Vacuole

Cost: 80 mutation points

- Performs Process: OxytoxyNT Production
(1 ATP -> 1 Oxytoxy)/Second

+ Performs Process: OxytoxyNT Production
(1 Oxygen + 5 ATP -> 5 Oxytoxy)/Second (Depending On Environmental Oxygen)

Allows for production and storage of OxytoxyNT which can be shot at enemy cells using E. The more of this organelle you have the faster your toxin fire rate aswell.
Toxin Vacuole
80 MP @@ -396,7 +410,7 @@ Chemoplast

Cost: 40 mutation points

- Performs Process: Chemosynthesis
(1 Hydrogen Sulfide -> 2 Glucose)/Second

+ Performs Process: Chemosynthesis
(0.09 CO2 + 1 Hydrogen Sulfide -> 2 Glucose)/Second (Depending On Environmental C02)

Allows for synthesis of glucose from hydrogen sulfide and atmospheric carbon dioxide.
Can be used to process the normally toxic soup containing hydrogen sulfide that comes out of hydrothermal vents at the bottom of the ocean. Into glucose. @@ -429,7 +443,7 @@ Metabolosomes

Cost: 20 mutation points

- Performs Process: Metabolsome Respiration (In real life they Ferment, but we dont have those compounds in the game yet)
(0.7 Glucose -> 14 ATP)/Second

+ Performs Process: Metabolsome Respiration (In real life they Ferment, but we dont have those compounds in the game yet)
(1 Oxygen + 0.7 Glucose -> 38 ATP)/Second (Depending On Environmental Oxygen)

Storage Space: 10

Organelle-like Bacterial microcompartments (BMCs) consisting of a protein shell that encloses enzymes used for fermentation.
@@ -437,21 +451,21 @@ Chromatophores

Cost: 25 mutation points

- Performs Process: Chromatophore Photosynthesis
(0.33 glucose)/Second
- Performs Process: Glycolysis
(0.125 glucose -> 5 ATP)/Second

+ Performs Process: Chromatophore Photosynthesis
(0.09 CO2 -> 0.33 glucose)/Second (Depending On Environmental C02)
+ Performs Process: Glycolysis
(0.125 glucose -> 5 ATP)/Second (Depending On Environmental C02)

Storage Space: 10

Coloured, membrane-associated vesicles used by various prokaryotes perform photosynthesis. Chromatophores contain bacteriochlorophyll pigments and carotenoids.
Chromatophores
25 MP - + - ChemosynthisizingProtiens

Cost: 20 mutation points

- Performs Process: Bacterial Chemosynthesis
(1 Hydrogen Sulfide -> 1 Glucose)/Second
+ ChemosynthisizingProteins

Cost: 20 mutation points

+ Performs Process: Bacterial Chemosynthesis
(1 CO2 + 1 Hydrogen Sulfide -> 1 Glucose)/Second (Depending On Environmental C02)
Performs Process: Glycolysis
(0.125 glucose -> 5 ATP)/Second

Storage Space: 20

Small membrane-associated structures that convert the noxious soup containing hydrogen sulfide from hydrothermal vents into usable energy in the form of glucose.
-
Chemosynthisizing Protiens
20 MP +
Chemosynthisizing Proteins
20 MP
@@ -526,7 +540,7 @@ Metabolosomes: Produces the same amount of ATP of a mitocondria, but is way way less efficient, it only takes up 1 Hex and has 10 storage space
-Chemosynthisizing Protiens: Produces half of the glucose out of Hydrogen Sulfide as a chemoplast, but also performs glycolysis, takes up 1 Hex and has 20 storage space
+Chemosynthisizing Proteins: Produces half of the glucose out of Hydrogen Sulfide as a chemoplast, but also performs glycolysis, takes up 1 Hex and has 20 storage space
Chromatophores: Produces 1/3rd the amount of glucose as a normal chloroplast, but also performs glycolysis, and has 10 storage space, and takes up 1 Hex.

diff --git a/scripts/gui/thrive_style.css b/scripts/gui/thrive_style.css index f31a8cf7d5c..05c14baa92b 100644 --- a/scripts/gui/thrive_style.css +++ b/scripts/gui/thrive_style.css @@ -409,6 +409,12 @@ video { } #OxygenIcon { + width: 40px; + height: 40px; + transform: scale(0.75, 0.75); + top: 0; + left: 600px; + position: absolute; background-image: url("../../Textures/gui/bevel/Oxygen.png"); } @@ -441,6 +447,12 @@ video { } #CO2Icon { + width: 40px; + height: 40px; + transform: scale(0.75, 0.75); + top: 0; + left: 720px; + position: absolute; background-image: url("../../Textures/gui/bevel/CO2.png"); } @@ -643,7 +655,7 @@ video { height: 40px; width: 150px; top: 0; - left: 600px; + left: 840px; font-size: 10pt; line-height: 40px; background-image: url("../../Textures/gui/bevel/LongTwoNormal.png"); @@ -654,7 +666,49 @@ video { height: 40px; width: 150px; top: 0; - left: 680px; + left: 920px; + font-size: 10pt; + line-height: 40px; +} + +#oxygenTab { + position: absolute; + height: 40px; + width: 120px; + top: 0; + left: 600px; + font-size: 10pt; + line-height: 40px; + background-image: url("../../Textures/gui/bevel/EditPanelHeaderNormal.png"); +} + +#oxygenPercent { + position: absolute; + height: 40px; + width: 150px; + top: 0; + left: 640px; + font-size: 10pt; + line-height: 40px; +} + +#carbonDioxideTab { + position: absolute; + height: 40px; + width: 120px; + top: 0; + left: 720px; + font-size: 10pt; + line-height: 40px; + background-image: url("../../Textures/gui/bevel/EditPanelHeaderNormal.png"); +} + +#carbonDioxidePercent { + position: absolute; + height: 40px; + width: 150px; + top: 0; + left: 760px; font-size: 10pt; line-height: 40px; } @@ -1186,7 +1240,7 @@ video { background-image: url("../../Textures/gui/bevel/ChromatophorIcon.png"); } -#ChemosynthisizingProtiensIcon { +#ChemosynthisizingProteinsIcon { position: relative; left: calc(50% - 30px); width: 60px; diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 7f918ab6594..2c57b47f0d6 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -1,5 +1,7 @@ -// Global table which stores the current biome the player is in. -uint64 currentBiome = 0; +// The current biome's id. This is initially set this high because now +// the biome is only changed if the number changed. So if there ever +// are more biomes than this initial value something will break. +uint64 currentBiome = 1000000; const Biome@ getCurrentBiome(){ @@ -94,6 +96,19 @@ void setBiome(uint64 biomeId, CellStageWorld@ world){ setSunlightForBiome(world); // Changing the background. GetThriveGame().setBackgroundMaterial(biome.background); + //Update biome for process system + world.GetProcessSystem().setProcessBiome(biomeId); + + // Update oxygen and carbon dioxide numbers + auto oxyId = SimulationParameters::compoundRegistry().getTypeId("oxygen"); + auto c02Id = SimulationParameters::compoundRegistry().getTypeId("carbondioxide"); + GenericEvent@ updateDissolvedGasses = GenericEvent("UpdateDissolvedGasses"); + NamedVars@ vars = updateDissolvedGasses.GetNamedVars(); + vars.AddValue(ScriptSafeVariableBlock("oxygenPercent", + world.GetProcessSystem().getDissolved(oxyId)*100)); + vars.AddValue(ScriptSafeVariableBlock("co2Percent", + world.GetProcessSystem().getDissolved(c02Id)*100)); + GetEngine().GetEventHandler().CallEvent(updateDissolvedGasses); } void setSunlightForBiome(CellStageWorld@ world){ @@ -111,20 +126,22 @@ void setSunlightForBiome(CellStageWorld@ world){ LOG_INFO("specular Colours For Biome r:" + getCurrentBiome().diffuseColors.r + "g:" + getCurrentBiome().specularColors.g + "b:" + getCurrentBiome().specularColors.b); - // Diffused gasses percenatge - LOG_INFO("Diffused Oxygen For Biome " + getCurrentBiome().oxygenPercentage); - LOG_INFO("Diffused C02 For Biome " + getCurrentBiome().carbonDioxidePercentage); } // Setting the current biome to a random biome selected from the biome table. -void setRandomBiome(CellStageWorld@ world){ - LOG_INFO("setting random biome"); +void setRandomBiome(CellStageWorld@ world) +{ + LOG_INFO("setting random biome"); + // Getting the size of the biome table. // Selecting a random biome. - auto biome = GetEngine().GetRandom().GetNumber(0, + uint64 biome = GetEngine().GetRandom().GetNumber(0, int(SimulationParameters::biomeRegistry().getSize()-1)); - // Switching to that biome. - setBiome(biome, world); + // Switching to that biome if we arent in that biome already + if (currentBiome != biome) + { + setBiome(biome, world); + } } diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor.as b/scripts/microbe_stage/microbe_editor/microbe_editor.as index 228c126af4c..27739eba152 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor.as @@ -61,7 +61,7 @@ class MicrobeEditor{ {"chemoplast", PlacementFunctionType(this.addOrganelle)}, {"chromatophors", PlacementFunctionType(this.addOrganelle)}, {"metabolosome", PlacementFunctionType(this.addOrganelle)}, - {"chemoSynthisizingProtiens", PlacementFunctionType(this.addOrganelle)}, + {"chemoSynthisizingProteins", PlacementFunctionType(this.addOrganelle)}, {"remove", PlacementFunctionType(this.removeOrganelle)} }; } diff --git a/scripts/microbe_stage/microbe_operations.as b/scripts/microbe_stage/microbe_operations.as index 65df873c3be..9e0fbfa6a55 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -289,8 +289,10 @@ void respawnPlayer(CellStageWorld@ world) sceneNodeComponent.Marked = true; setRandomBiome(world); + cast(world.GetScriptSystem("MicrobeStageHudSystem")). - suicideButtonreset(); + suicideButtonreset(); + // Reset membrane color to fix the bug that made membranes sometimes red after you respawn. MicrobeOperations::applyMembraneColour(world, playerEntity); } diff --git a/scripts/microbe_stage/organelle_table.as b/scripts/microbe_stage/organelle_table.as index 9a4da27a739..6076900cf8f 100644 --- a/scripts/microbe_stage/organelle_table.as +++ b/scripts/microbe_stage/organelle_table.as @@ -515,7 +515,7 @@ void setupOrganelles(){ // Prokaryotic Organelles (all meshes are placeholders)// // ------------------------------------ // - // Respiratory Protien + // Respiratory Protein auto respiratoryProtein = OrganelleParameters("metabolosome"); respiratoryProtein.mass = 0.1; @@ -568,7 +568,7 @@ void setupOrganelles(){ _addOrganelleToTable(Organelle(photosyntheticProtein)); - // Oxytoxy Protien + // Oxytoxy Protein auto oxytoxyProtein = OrganelleParameters("oxytoxyProteins"); oxytoxyProtein.mass = 0.1; @@ -597,32 +597,32 @@ void setupOrganelles(){ _addOrganelleToTable(Organelle(oxytoxyProtein)); - // chemoSynthisizingProtien - auto chemoSynthisizingProtien = OrganelleParameters("chemoSynthisizingProtiens"); + // chemoSynthisizingProtein + auto chemoSynthisizingProtein = OrganelleParameters("chemoSynthisizingProteins"); - chemoSynthisizingProtien.mass = 0.1; - chemoSynthisizingProtien.gene = "c"; - chemoSynthisizingProtien.mesh = "chemoproteins.mesh"; - chemoSynthisizingProtien.chanceToCreate = 0; - chemoSynthisizingProtien.prokaryoteChance = 1; - chemoSynthisizingProtien.mpCost = 20; - chemoSynthisizingProtien.initialComposition = { + chemoSynthisizingProtein.mass = 0.1; + chemoSynthisizingProtein.gene = "c"; + chemoSynthisizingProtein.mesh = "chemoproteins.mesh"; + chemoSynthisizingProtein.chanceToCreate = 0.5f; + chemoSynthisizingProtein.prokaryoteChance = 1; + chemoSynthisizingProtein.mpCost = 20; + chemoSynthisizingProtein.initialComposition = { {"phosphates", 1}, {"ammonia", 1} }; - chemoSynthisizingProtien.components = { + chemoSynthisizingProtein.components = { processorOrganelleFactory(1.0f), storageOrganelleFactory(20.0f) }; - chemoSynthisizingProtien.processes = { + chemoSynthisizingProtein.processes = { TweakedProcess("bacterial_ChemoSynthesis", 1), TweakedProcess("glycolosis", 1) }; - chemoSynthisizingProtien.hexes = { + chemoSynthisizingProtein.hexes = { Int2(0, 0), }; - _addOrganelleToTable(Organelle(chemoSynthisizingProtien)); + _addOrganelleToTable(Organelle(chemoSynthisizingProtein)); // Bacterial cytoplasm equivilent (so they dont die immediately) (just a stopgap measure for now, though it is real) auto protoplasmParameters = OrganelleParameters("protoplasm"); @@ -649,33 +649,35 @@ void setupOrganelles(){ }; _addOrganelleToTable(Organelle(protoplasmParameters)); - // nitrogenFixationProtien + // nitrogenFixationProtein // Uses same mode as chemoplast for now - auto nitrogenFixationProtien = OrganelleParameters("nitrogenFixationProtiens"); - - nitrogenFixationProtien.mass = 0.1; - nitrogenFixationProtien.gene = "i"; - nitrogenFixationProtien.mesh = "nitrogenplastid.mesh"; - nitrogenFixationProtien.chanceToCreate = 0; - nitrogenFixationProtien.prokaryoteChance = 1; - nitrogenFixationProtien.mpCost = 15; - nitrogenFixationProtien.initialComposition = { + auto nitrogenFixationProtein = OrganelleParameters("nitrogenFixationProteins"); + + nitrogenFixationProtein.mass = 0.1; + nitrogenFixationProtein.gene = "i"; + nitrogenFixationProtein.mesh = "nitrogenplastid.mesh"; + nitrogenFixationProtein.chanceToCreate = 0; + nitrogenFixationProtein.prokaryoteChance = 1; + nitrogenFixationProtein.mpCost = 15; + nitrogenFixationProtein.initialComposition = { {"phosphates", 1}, {"ammonia",1} }; - nitrogenFixationProtien.components = { + nitrogenFixationProtein.components = { processorOrganelleFactory(1.0f), storageOrganelleFactory(25.0f) }; - nitrogenFixationProtien.processes = { + nitrogenFixationProtein.processes = { TweakedProcess("nitrogenFixing", 1), TweakedProcess("glycolosis", 1) }; - nitrogenFixationProtien.hexes = { + nitrogenFixationProtein.hexes = { Int2(0, 0), }; - _addOrganelleToTable(Organelle(nitrogenFixationProtien)); // ------------------------------------ // + _addOrganelleToTable(Organelle(nitrogenFixationProtein)); + + // ------------------------------------ // // Setup the organelle letters setupOrganelleLetters(); } diff --git a/scripts/microbe_stage/species_system.as b/scripts/microbe_stage/species_system.as index 2f2d00548fa..d4c336cc09b 100644 --- a/scripts/microbe_stage/species_system.as +++ b/scripts/microbe_stage/species_system.as @@ -699,10 +699,10 @@ class Species{ } // Bacteria - // will randomly have 1 of 3 organelles right now, photosynthesizing protiens, - // respiratory Protiens, or Oxy Toxy Producing Protiens, also pure cytoplasm + // will randomly have 1 of 3 organelles right now, photosynthesizing proteins, + // respiratory Proteins, or Oxy Toxy Producing Proteins, also pure cytoplasm // aswell for variety. - //TODO when chemosynthesis is added add a protien for that aswell + //TODO when chemosynthesis is added add a protein for that aswell switch(GetEngine().GetRandom().GetNumber(1,7)) { case 1: @@ -718,10 +718,10 @@ class Species{ stringCode = getOrganelleDefinition("oxytoxyProteins").gene; break; case 5: - stringCode = getOrganelleDefinition("chemoSynthisizingProtiens").gene; + stringCode = getOrganelleDefinition("chemoSynthisizingProteins").gene; break; case 6: - stringCode = getOrganelleDefinition("nitrogenFixationProtiens").gene; + stringCode = getOrganelleDefinition("nitrogenFixationProteins").gene; break; default: stringCode = getOrganelleDefinition("protoplasm").gene; diff --git a/src/microbe_stage/biomes.cpp b/src/microbe_stage/biomes.cpp index 02499a3ddff..1bc1431c079 100644 --- a/src/microbe_stage/biomes.cpp +++ b/src/microbe_stage/biomes.cpp @@ -34,11 +34,6 @@ Biome::Biome(Json::Value value) diffuseColors = Ogre::ColourValue(r, g, b, 1.0); // Getting the compound information. - Json::Value oxygenPercent = value["oxygenPercentage"]; - Json::Value carbonDioxidePercent = value["carbonDioxidePercentage"]; - oxygenPercentage = oxygenPercent.asFloat(); - carbonDioxidePercentage = carbonDioxidePercent.asFloat(); - Json::Value compoundData = value["compounds"]; std::vector compoundInternalNames = compoundData.getMemberNames(); @@ -48,7 +43,8 @@ Biome::Biome(Json::Value value) compoundData[compoundInternalName]["amount"].asUInt(); double density = compoundData[compoundInternalName]["density"].asDouble(); - + double dissolved = + compoundData[compoundInternalName]["dissolved"].asDouble(); // Getting the compound id from the compound registry. size_t id = SimulationParameters::compoundRegistry @@ -56,7 +52,7 @@ Biome::Biome(Json::Value value) .id; compounds.emplace(std::piecewise_construct, std::forward_as_tuple(id), - std::forward_as_tuple(amount, density)); + std::forward_as_tuple(amount, density, dissolved)); } } // ------------------------------------ // diff --git a/src/microbe_stage/biomes.h b/src/microbe_stage/biomes.h index d3e449cf466..aa73b80a10d 100644 --- a/src/microbe_stage/biomes.h +++ b/src/microbe_stage/biomes.h @@ -13,12 +13,13 @@ namespace thrive { struct BiomeCompoundData { public: unsigned int amount = 0; - double density = 1.0; + double density = 1.0f; + double dissolved = 0.0f; BiomeCompoundData() {} - BiomeCompoundData(unsigned int amount, double density) : - amount(amount), density(density) + BiomeCompoundData(unsigned int amount, double density, double dissolved) : + amount(amount), density(density), dissolved(dissolved) {} }; @@ -31,8 +32,6 @@ class Biome : public RegistryType { Ogre::ColourValue specularColors; Ogre::ColourValue diffuseColors; - float oxygenPercentage; - float carbonDioxidePercentage; Biome(); Biome(Json::Value value); diff --git a/src/microbe_stage/compounds.cpp b/src/microbe_stage/compounds.cpp index dfb3eacbda7..4a8189b0cfc 100644 --- a/src/microbe_stage/compounds.cpp +++ b/src/microbe_stage/compounds.cpp @@ -10,7 +10,7 @@ Compound::Compound(Json::Value value) volume = value["volume"].asDouble(); isCloud = value["isCloud"].asBool(); isUseful = value["isUseful"].asBool(); - + isEnvironmental = value["isEnvironmental"].asBool(); // Setting the cloud colour. float r = value["colour"]["r"].asFloat(); float g = value["colour"]["g"].asFloat(); diff --git a/src/microbe_stage/compounds.h b/src/microbe_stage/compounds.h index 7cd8384b4d6..2e2c83eff4f 100644 --- a/src/microbe_stage/compounds.h +++ b/src/microbe_stage/compounds.h @@ -11,6 +11,7 @@ class Compound : public RegistryType { double volume = 1.0; bool isCloud = false; bool isUseful = false; + bool isEnvironmental = false; Ogre::ColourValue colour; Compound(); diff --git a/src/microbe_stage/generate_cell_stage_world.rb b/src/microbe_stage/generate_cell_stage_world.rb index 1e4e25f6680..2c8a0558420 100644 --- a/src/microbe_stage/generate_cell_stage_world.rb +++ b/src/microbe_stage/generate_cell_stage_world.rb @@ -148,7 +148,8 @@ runtick: {group: 900, parameters: []}), EntitySystem.new("ProcessSystem", ["CompoundBagComponent", "ProcessorComponent"], - runtick: {group: 10, parameters: []}), + runtick: {group: 10, parameters: []}, + visibletoscripts: true), EntitySystem.new("TimedLifeSystem", [], runtick: {group: 45, parameters: [ "ComponentTimedLifeComponent.GetIndex()" diff --git a/src/microbe_stage/process_system.cpp b/src/microbe_stage/process_system.cpp index 19c2fb0ada8..0a02873acbe 100644 --- a/src/microbe_stage/process_system.cpp +++ b/src/microbe_stage/process_system.cpp @@ -41,7 +41,6 @@ CompoundBagComponent::CompoundBagComponent() : Leviathan::Component(TYPE) { storageSpace = 0; storageSpaceOccupied = 0; - for(size_t id = 0; id < SimulationParameters::compoundRegistry.getSize(); id++) { compounds[id].amount = 0; @@ -132,6 +131,20 @@ double return compounds[compoundId].usedLastTime; } +void + ProcessSystem::setProcessBiome(int biomeId) +{ + curBiomeId = biomeId; +} + +double + ProcessSystem::getDissolved(CompoundId compoundData) +{ + Biome ourBiome = + SimulationParameters::biomeRegistry.getTypeData(curBiomeId); + return ourBiome.getCompound(compoundData)->dissolved; +} + // ------------------------------------ // // ProcessSystem @@ -195,20 +208,37 @@ void // really be looping at max two or three times anyway. also make // sure you wont run out of space when you do add the compounds. // Input + // Defaults to 1 + double environmentModifier = 1.0f; + for(const auto& input : processData.inputs) { const CompoundId inputId = input.first; - + auto compoundData = + SimulationParameters::compoundRegistry.getTypeData(inputId); // Set price of used compounds to 1, we dont want to purge // those bag.compounds[inputId].price = 1; - const double inputRemoved = + double inputRemoved = ((input.second * processCapacity) / (processLimitCapacity)); + // do environmental modifier here, and save it for later + if(compoundData.isEnvironmental) { + environmentModifier = + environmentModifier * + (getDissolved(inputId) / input.second); + inputRemoved = inputRemoved * environmentModifier; + } + // If not enough compound we can't do the process - if(bag.compounds[inputId].amount < inputRemoved) { - canDoProcess = false; + // If the compound is environmental the cell doesnt actually + // contain it right now and theres no where to take it from + if(!compoundData.isEnvironmental) { + if(bag.compounds[inputId].amount < inputRemoved || + environmentModifier == 0.0f) { + canDoProcess = false; + } } } @@ -218,17 +248,26 @@ void for(const auto& output : processData.outputs) { const CompoundId outputId = output.first; + auto compoundData = + SimulationParameters::compoundRegistry.getTypeData( + outputId); // For now lets assume compounds we produce are also // useful bag.compounds[outputId].price = 1; - const double outputAdded = ((output.second * processCapacity) / - (processLimitCapacity)); - - // If no space we can't do the process - if(bag.getCompoundAmount(outputId) + outputAdded > - bag.storageSpace) { - canDoProcess = false; + double outputAdded = ((output.second * processCapacity) / + (processLimitCapacity)); + // Apply the environmental modifier + outputAdded = outputAdded * environmentModifier; + + // If no space we can't do the process, and if environmental + // right now this isnt released anywhere + if(!compoundData.isEnvironmental) { + if((bag.getCompoundAmount(outputId) + outputAdded > + bag.storageSpace) || + environmentModifier == 0.0f) { + canDoProcess = false; + } } } @@ -238,24 +277,40 @@ void // Inputs. for(const auto& input : processData.inputs) { const CompoundId inputId = input.first; - const double inputRemoved = - ((input.second * processCapacity) / - (processLimitCapacity)); + auto compoundData = + SimulationParameters::compoundRegistry.getTypeData( + inputId); + double inputRemoved = ((input.second * processCapacity) / + (processLimitCapacity)); + + // Apply the environmental modifier + inputRemoved = inputRemoved * environmentModifier; // This should always be true (due to the earlier check) so // it is always assumed here that the process succeeded - if(bag.compounds[inputId].amount >= inputRemoved) { - bag.compounds[inputId].amount -= inputRemoved; + if(!compoundData.isEnvironmental) { + if(bag.compounds[inputId].amount >= inputRemoved) { + bag.compounds[inputId].amount -= inputRemoved; + } } } // Outputs. for(const auto& output : processData.outputs) { const CompoundId outputId = output.first; - const double outputGenerated = + auto compoundData = + SimulationParameters::compoundRegistry.getTypeData( + outputId); + double outputGenerated = ((output.second * processCapacity) / (processLimitCapacity)); - bag.compounds[outputId].amount += outputGenerated; + + // Apply the environmental modifier + outputGenerated = outputGenerated * environmentModifier; + + if(!compoundData.isEnvironmental) { + bag.compounds[outputId].amount += outputGenerated; + } } } } diff --git a/src/microbe_stage/process_system.h b/src/microbe_stage/process_system.h index 38743bb9fd7..54350412591 100644 --- a/src/microbe_stage/process_system.h +++ b/src/microbe_stage/process_system.h @@ -136,8 +136,15 @@ class ProcessSystem CachedComponents.RemoveBasedOnKeyTupleList(seconddata); } + void + setProcessBiome(int biomeId); + + double + getDissolved(CompoundId compoundData); + protected: private: + int curBiomeId = 0; static constexpr double TIME_SCALING_FACTOR = 1000; }; diff --git a/src/scripting/script_initializer.cpp b/src/scripting/script_initializer.cpp index 825947beb53..6b816a227fb 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -211,6 +211,11 @@ bool ANGELSCRIPT_REGISTERFAIL; } + if(engine->RegisterObjectProperty("Compound", "bool isEnvironmental", + asOFFSET(Compound, isEnvironmental)) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } + if(engine->RegisterObjectProperty("Compound", "Ogre::ColourValue colour", asOFFSET(Compound, colour)) < 0) { ANGELSCRIPT_REGISTERFAIL; @@ -229,14 +234,6 @@ bool asOFFSET(Biome, diffuseColors)) < 0) { ANGELSCRIPT_REGISTERFAIL; } - if(engine->RegisterObjectProperty("Biome", "float oxygenPercentage", - asOFFSET(Biome, oxygenPercentage)) < 0) { - ANGELSCRIPT_REGISTERFAIL; - } - if(engine->RegisterObjectProperty("Biome", "float carbonDioxidePercentage", - asOFFSET(Biome, carbonDioxidePercentage)) < 0) { - ANGELSCRIPT_REGISTERFAIL; - } if(engine->RegisterObjectProperty("Biome", "const string background", asOFFSET(Biome, background)) < 0) { @@ -272,6 +269,10 @@ bool ANGELSCRIPT_REGISTERFAIL; } + if(engine->RegisterObjectProperty("BiomeCompoundData", "double dissolved", + asOFFSET(BiomeCompoundData, dissolved)) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } return true; } @@ -1136,7 +1137,23 @@ bool ANGELSCRIPT_REGISTERFAIL; } + // Process System + if(engine->RegisterObjectType( + "ProcessSystem", 0, asOBJ_REF | asOBJ_NOCOUNT) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } + + if(engine->RegisterObjectMethod("ProcessSystem", + "void setProcessBiome(int biomeId)", + asMETHOD(ProcessSystem, setProcessBiome), asCALL_THISCALL) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } + if(engine->RegisterObjectMethod("ProcessSystem", + "double getDissolved(CompoundId compoundData)", + asMETHOD(ProcessSystem, getDissolved), asCALL_THISCALL) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } // ------------------------------------ // // CompoundCloudSystem if(engine->RegisterObjectType(