From 80eeffec38ff6381c075f571e9b0dc52cd092054 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Sat, 5 Jan 2019 17:47:05 -0600 Subject: [PATCH 01/16] Started ion this, not sure how to tackle it, we have the percentages defined in the biomes already, so maybe it doenst even need to be a "real " compound, but i also feel like this would allow us to add more abstract things like light and heat. And have them be "compounds" with a flag like "environmental". --- .../MicrobeStage/Compounds.json | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/SimulationParameters/MicrobeStage/Compounds.json b/scripts/SimulationParameters/MicrobeStage/Compounds.json index 7d6032e0da4..09319747445 100644 --- a/scripts/SimulationParameters/MicrobeStage/Compounds.json +++ b/scripts/SimulationParameters/MicrobeStage/Compounds.json @@ -69,5 +69,29 @@ "g": 0.0, "b": 0.078 } + }, + + "Oxygen": { + "name": "Oxygen", + "volume": 1, + "isCloud": false, + "isUseful": true, + "colour": { + "r": 0.078, + "g": 0.0, + "b": 0.078 + } + }, + + "CarbonDioxide": { + "name": "Carbon Dioxide", + "volume": 1, + "isCloud": false, + "isUseful": true, + "colour": { + "r": 0.078, + "g": 0.0, + "b": 0.078 + } } } From 330263651694677730f3d00a16edc68825c379e8 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Mon, 7 Jan 2019 15:13:50 -0600 Subject: [PATCH 02/16] changed color (even though it wont show up in game) and lowercased new compounds. --- .../SimulationParameters/MicrobeStage/Compounds.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/Compounds.json b/scripts/SimulationParameters/MicrobeStage/Compounds.json index 09319747445..dc22f445c79 100644 --- a/scripts/SimulationParameters/MicrobeStage/Compounds.json +++ b/scripts/SimulationParameters/MicrobeStage/Compounds.json @@ -71,27 +71,27 @@ } }, - "Oxygen": { + "oxygen": { "name": "Oxygen", "volume": 1, "isCloud": false, "isUseful": true, "colour": { - "r": 0.078, + "r": 0.0, "g": 0.0, - "b": 0.078 + "b": 1.0 } }, - "CarbonDioxide": { + "carbondioxide": { "name": "Carbon Dioxide", "volume": 1, "isCloud": false, "isUseful": true, "colour": { - "r": 0.078, + "r": 1.0, "g": 0.0, - "b": 0.078 + "b": 0.0 } } } From 16e1a4884eaa30fa2b41c814f68212b74070674a Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Mon, 7 Jan 2019 15:18:47 -0600 Subject: [PATCH 03/16] added new flag to compounds, game doesnt load it yet. --- scripts/SimulationParameters/MicrobeStage/Compounds.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/SimulationParameters/MicrobeStage/Compounds.json b/scripts/SimulationParameters/MicrobeStage/Compounds.json index dc22f445c79..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,6 +69,7 @@ "volume": 1, "isCloud": false, "isUseful": true, + "isEnvironmental": false, "colour": { "r": 0.078, "g": 0.0, @@ -76,6 +82,7 @@ "volume": 1, "isCloud": false, "isUseful": true, + "isEnvironmental": true, "colour": { "r": 0.0, "g": 0.0, @@ -88,6 +95,7 @@ "volume": 1, "isCloud": false, "isUseful": true, + "isEnvironmental": true, "colour": { "r": 1.0, "g": 0.0, From e7b8a3357fc3e2205203dcc95b60432528758278 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Mon, 7 Jan 2019 15:59:21 -0600 Subject: [PATCH 04/16] it now grabs that variable from the json for use later. --- src/microbe_stage/compounds.cpp | 2 +- src/microbe_stage/compounds.h | 1 + src/scripting/script_initializer.cpp | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) 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/scripting/script_initializer.cpp b/src/scripting/script_initializer.cpp index 825947beb53..2eec1d0153c 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; From 7e3d0d94db26053f581a719e29b6bdb11aab17fa Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Mon, 7 Jan 2019 17:14:56 -0600 Subject: [PATCH 05/16] A three year old is making it really really hard for me to do my work, but now all biome compounds have a dissolved number, and ive update dteh files to reflectr this, i need to us ethe onld values fo rthem still but hey, I also removed oxygen percentage and carbon dioxide percentage which were hacky variables we shouldnt use since c02 and oxygen are wrappe dinto the compound system. game now works again. updated dissolved gas percentages, processes now take in the new compounds as inputs, but since each cells have none, this means they cant do the process. chemosynthesis now takes in carbon dioxide. added prototype getDissolved method to process system process system now keeps track of the current biome. (need to make it get set in the biome.as now, also getDissolved now returns dissolved without a loop. Process system is now visible to scripts, and the biome is now set (which is a variable in the process system used to grab dissolved), it probabbly doesn't need the "release" part --- .../MicrobeStage/BioProcesses.json | 10 +- .../MicrobeStage/Biomes.json | 228 +++++++++++++----- scripts/microbe_stage/biome.as | 5 +- src/microbe_stage/biomes.cpp | 10 +- src/microbe_stage/biomes.h | 9 +- .../generate_cell_stage_world.rb | 4 +- src/microbe_stage/process_system.cpp | 18 +- src/microbe_stage/process_system.h | 12 + src/scripting/script_initializer.cpp | 26 +- 9 files changed, 234 insertions(+), 88 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index 18364056b90..89bbedae137 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -3,6 +3,7 @@ "name": "Respiration", "inputs": { + "oxygen": 1.0, "glucose": 0.2 }, @@ -27,7 +28,7 @@ "name": "Photosynthesis", "inputs": { - "glucose": 0.0 + "carbondioxide": 1.0 }, "outputs": { @@ -51,6 +52,7 @@ "name": "Chemo Synthesis", "inputs": { + "carbondioxide": 0.1, "hydrogensulfide": 1.0 }, @@ -63,6 +65,7 @@ "name": "Bacterial Chemosynthesis", "inputs": { + "carbondioxide": 0.1, "hydrogensulfide": 1.0 }, @@ -87,7 +90,8 @@ "name": "RespirationProtein", "inputs": { - "glucose": 0.7 + "glucose": 0.7, + "oxygen": 1.0 }, "outputs": { @@ -99,7 +103,7 @@ "name": "Bacterial Photosynthesis", "inputs": { - "glucose": 0.0 + "carbondioxide": 1.0 }, "outputs": { diff --git a/scripts/SimulationParameters/MicrobeStage/Biomes.json b/scripts/SimulationParameters/MicrobeStage/Biomes.json index d428f8b6f65..80f8c101da4 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,52 @@ "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 + } } } } diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 7f918ab6594..8965d62499f 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -94,6 +94,8 @@ void setBiome(uint64 biomeId, CellStageWorld@ world){ setSunlightForBiome(world); // Changing the background. GetThriveGame().setBackgroundMaterial(biome.background); + //Update biome for process system + world.GetProcessSystem().setProcessBiome(biomeId); } void setSunlightForBiome(CellStageWorld@ world){ @@ -111,9 +113,6 @@ 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); } 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/generate_cell_stage_world.rb b/src/microbe_stage/generate_cell_stage_world.rb index 1e4e25f6680..14d4c6a24e0 100644 --- a/src/microbe_stage/generate_cell_stage_world.rb +++ b/src/microbe_stage/generate_cell_stage_world.rb @@ -148,7 +148,9 @@ runtick: {group: 900, parameters: []}), EntitySystem.new("ProcessSystem", ["CompoundBagComponent", "ProcessorComponent"], - runtick: {group: 10, parameters: []}), + runtick: {group: 10, parameters: []}, + visibletoscripts: true, + release: []), 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..4a45058c4e8 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 @@ -282,3 +295,6 @@ void } } } +void + ProcessSystem::Release() +{} diff --git a/src/microbe_stage/process_system.h b/src/microbe_stage/process_system.h index 38743bb9fd7..4dee5f4c7b5 100644 --- a/src/microbe_stage/process_system.h +++ b/src/microbe_stage/process_system.h @@ -112,6 +112,9 @@ class ProcessSystem void Run(GameWorld& world); + void + Release(); + void CreateNodes( const std::vector>& @@ -136,8 +139,17 @@ class ProcessSystem CachedComponents.RemoveBasedOnKeyTupleList(seconddata); } + void + setProcessBiome(int biomeId); + + protected: + double + getDissolved(CompoundId compoundData); + + 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 2eec1d0153c..708e6ca161b 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -211,8 +211,8 @@ bool ANGELSCRIPT_REGISTERFAIL; } - if(engine->RegisterObjectProperty( - "Compound", "bool isEnvironmental", asOFFSET(Compound, isEnvironmental)) < 0) { + if(engine->RegisterObjectProperty("Compound", "bool isEnvironmental", + asOFFSET(Compound, isEnvironmental)) < 0) { ANGELSCRIPT_REGISTERFAIL; } @@ -234,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) { @@ -277,6 +269,10 @@ bool ANGELSCRIPT_REGISTERFAIL; } + if(engine->RegisterObjectProperty("BiomeCompoundData", "double dissolved", + asOFFSET(BiomeCompoundData, dissolved)) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } return true; } @@ -1141,7 +1137,17 @@ 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; + } // ------------------------------------ // // CompoundCloudSystem if(engine->RegisterObjectType( From f6cd09abc885f06cdad45789cafc5028b7fcbec9 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Tue, 8 Jan 2019 23:04:34 -0600 Subject: [PATCH 06/16] envrionmental compounds are now taken into account in the process system ran clang format --- src/microbe_stage/process_system.cpp | 63 ++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/microbe_stage/process_system.cpp b/src/microbe_stage/process_system.cpp index 4a45058c4e8..30c257759ca 100644 --- a/src/microbe_stage/process_system.cpp +++ b/src/microbe_stage/process_system.cpp @@ -208,18 +208,29 @@ 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 + 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 + if(compoundData.isEnvironmental) { + environmentModifier = environmentModifier * + getDissolved(inputId) * input.second; + inputRemoved = inputRemoved * environmentModifier; + } + // If not enough compound we can't do the process + // If the compound is environmental the cell doesnt actually + // contain it right now and theres no where to take it from if(bag.compounds[inputId].amount < inputRemoved) { canDoProcess = false; } @@ -231,6 +242,9 @@ 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; @@ -238,37 +252,60 @@ void 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; + // 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 * environmentModifier) > + bag.storageSpace) { + canDoProcess = false; + } } } // Only carry out this process if you have all the required // ingredients and enough space for the outputs + environmentModifier = 1.0f; if(canDoProcess) { // 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)); + + // do environmental modifier (if 0 it obviously wouldnt + // work) + if(compoundData.isEnvironmental) { + environmentModifier = environmentModifier * + getDissolved(inputId) * + input.second; + 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; + auto compoundData = + SimulationParameters::compoundRegistry.getTypeData( + outputId); const double outputGenerated = ((output.second * processCapacity) / (processLimitCapacity)); - bag.compounds[outputId].amount += outputGenerated; + if(!compoundData.isEnvironmental) { + bag.compounds[outputId].amount += + (outputGenerated * environmentModifier); + } } } } From fefc0c6f5acfaaaae86dcc8ed0428407f338e409 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Tue, 8 Jan 2019 23:21:34 -0600 Subject: [PATCH 07/16] if environmental modifier ends up as 0, you are no longer allowed to do the process ran code formatter, and switched respiration protein stuff. cleaned up environmental compound code in process system. --- .../MicrobeStage/BioProcesses.json | 4 +- src/microbe_stage/process_system.cpp | 40 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index 89bbedae137..42de82ea05c 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -90,8 +90,8 @@ "name": "RespirationProtein", "inputs": { - "glucose": 0.7, - "oxygen": 1.0 + "oxygen": 1.0, + "glucose": 0.7 }, "outputs": { diff --git a/src/microbe_stage/process_system.cpp b/src/microbe_stage/process_system.cpp index 30c257759ca..7aa6c6a966b 100644 --- a/src/microbe_stage/process_system.cpp +++ b/src/microbe_stage/process_system.cpp @@ -208,7 +208,9 @@ 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; @@ -221,7 +223,7 @@ void double inputRemoved = ((input.second * processCapacity) / (processLimitCapacity)); - // do environmental modifier + // do environmental modifier here, and save it for later if(compoundData.isEnvironmental) { environmentModifier = environmentModifier * getDissolved(inputId) * input.second; @@ -231,7 +233,8 @@ void // If not enough compound we can't do the process // If the compound is environmental the cell doesnt actually // contain it right now and theres no where to take it from - if(bag.compounds[inputId].amount < inputRemoved) { + if(bag.compounds[inputId].amount < inputRemoved || + environmentModifier == 0.0f) { canDoProcess = false; } } @@ -249,15 +252,17 @@ void // useful bag.compounds[outputId].price = 1; - const double outputAdded = ((output.second * processCapacity) / - (processLimitCapacity)); + 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 * environmentModifier) > - bag.storageSpace) { + if((bag.getCompoundAmount(outputId) + outputAdded > + bag.storageSpace) || + environmentModifier == 0.0f) { canDoProcess = false; } } @@ -265,7 +270,6 @@ void // Only carry out this process if you have all the required // ingredients and enough space for the outputs - environmentModifier = 1.0f; if(canDoProcess) { // Inputs. for(const auto& input : processData.inputs) { @@ -276,14 +280,9 @@ void double inputRemoved = ((input.second * processCapacity) / (processLimitCapacity)); - // do environmental modifier (if 0 it obviously wouldnt - // work) - if(compoundData.isEnvironmental) { - environmentModifier = environmentModifier * - getDissolved(inputId) * - input.second; - inputRemoved = inputRemoved * environmentModifier; - } + // 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(!compoundData.isEnvironmental) { @@ -299,12 +298,15 @@ void auto compoundData = SimulationParameters::compoundRegistry.getTypeData( outputId); - const double outputGenerated = + double outputGenerated = ((output.second * processCapacity) / (processLimitCapacity)); + + // Apply the environmental modifier + outputGenerated = outputGenerated * environmentModifier; + if(!compoundData.isEnvironmental) { - bag.compounds[outputId].amount += - (outputGenerated * environmentModifier); + bag.compounds[outputId].amount += outputGenerated; } } } From f8e40132aa1654165510a093d2de88bf567e65b5 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Wed, 9 Jan 2019 12:25:36 -0600 Subject: [PATCH 08/16] math now makes more sense (eg if a process needs more c02, it shoud obviously be less productive when there is less c02) fixed bug with environmental compounds respiration now has more realistic process numbers, but also is balanced (and weaker then it used to be) ran clang exposed getDissolved to the scripts for UI. --- .../MicrobeStage/BioProcesses.json | 4 ++-- src/microbe_stage/process_system.cpp | 13 ++++++++----- src/microbe_stage/process_system.h | 4 +--- src/scripting/script_initializer.cpp | 6 ++++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index 42de82ea05c..98d60c0515c 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -8,7 +8,7 @@ }, "outputs": { - "atp": 14.0 + "atp": 38.0 } }, @@ -95,7 +95,7 @@ }, "outputs": { - "atp": 14.0 + "atp": 38.0 } }, diff --git a/src/microbe_stage/process_system.cpp b/src/microbe_stage/process_system.cpp index 7aa6c6a966b..dd293f4bc71 100644 --- a/src/microbe_stage/process_system.cpp +++ b/src/microbe_stage/process_system.cpp @@ -225,17 +225,20 @@ void // do environmental modifier here, and save it for later if(compoundData.isEnvironmental) { - environmentModifier = environmentModifier * - getDissolved(inputId) * input.second; + environmentModifier = + environmentModifier * + (getDissolved(inputId) / input.second); inputRemoved = inputRemoved * environmentModifier; } // If not enough compound we can't do the process // If the compound is environmental the cell doesnt actually // contain it right now and theres no where to take it from - if(bag.compounds[inputId].amount < inputRemoved || - environmentModifier == 0.0f) { - canDoProcess = false; + if(!compoundData.isEnvironmental) { + if(bag.compounds[inputId].amount < inputRemoved || + environmentModifier == 0.0f) { + canDoProcess = false; + } } } diff --git a/src/microbe_stage/process_system.h b/src/microbe_stage/process_system.h index 4dee5f4c7b5..bb80cc9bd9c 100644 --- a/src/microbe_stage/process_system.h +++ b/src/microbe_stage/process_system.h @@ -142,12 +142,10 @@ class ProcessSystem void setProcessBiome(int biomeId); - -protected: 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 708e6ca161b..3cba9c41b3e 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -1148,6 +1148,12 @@ bool asMETHOD(ProcessSystem, setProcessBiome), asCALL_THISCALL) < 0) { ANGELSCRIPT_REGISTERFAIL; } + + if(engine->RegisterObjectMethod("ProcessSystem", + "void getDissolved(CompoundId compoundData)", + asMETHOD(ProcessSystem, getDissolved), asCALL_THISCALL) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } // ------------------------------------ // // CompoundCloudSystem if(engine->RegisterObjectType( From c927c932c2fd8d67d8e447dc8733fbead7c32fd7 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Wed, 9 Jan 2019 16:03:14 -0600 Subject: [PATCH 09/16] ENvironmental o2 and c02 ar enow displayed at teh top of the screen, all processes have been update dto the new system, all tooltips have been updated to reflect the environmental compounds fixed some typos --- .../MicrobeStage/BioProcesses.json | 13 +++-- scripts/gui/thrive_gui.html | 40 ++++++++----- scripts/gui/thrive_style.css | 58 ++++++++++++++++++- 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index 98d60c0515c..2bea03ce98e 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -28,7 +28,7 @@ "name": "Photosynthesis", "inputs": { - "carbondioxide": 1.0 + "carbondioxide": 0.09 }, "outputs": { @@ -40,11 +40,12 @@ "name": "Oxytoxy Synthesis", "inputs": { - "atp": 1.0 + "oxygen": 1.0, + "atp": 5.0 }, "outputs": { - "oxytoxy": 1.0 + "oxytoxy": 5.0 } }, @@ -52,7 +53,7 @@ "name": "Chemo Synthesis", "inputs": { - "carbondioxide": 0.1, + "carbondioxide": 0.09, "hydrogensulfide": 1.0 }, @@ -65,7 +66,7 @@ "name": "Bacterial Chemosynthesis", "inputs": { - "carbondioxide": 0.1, + "carbondioxide": 0.09, "hydrogensulfide": 1.0 }, @@ -103,7 +104,7 @@ "name": "Bacterial Photosynthesis", "inputs": { - "carbondioxide": 1.0 + "carbondioxide": 0.09 }, "outputs": { diff --git a/scripts/gui/thrive_gui.html b/scripts/gui/thrive_gui.html index 9750af9a1b7..516787460d6 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -117,7 +117,21 @@ POPULATION: 0 - + +
+ +
+ O2: 20% +
+ +
+ +
+ 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,8 +451,8 @@ 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.
@@ -446,7 +460,7 @@ ChemosynthisizingProtiens

Cost: 20 mutation points

- Performs Process: Bacterial Chemosynthesis
(1 Hydrogen Sulfide -> 1 Glucose)/Second
+ 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 diff --git a/scripts/gui/thrive_style.css b/scripts/gui/thrive_style.css index f31a8cf7d5c..9fb61f084b8 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; } From 7a015d16132b39a284e1ea01259f5be744d73968 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Wed, 9 Jan 2019 18:13:43 -0600 Subject: [PATCH 10/16] AI eukaryotes can now get chemosynthesizing proteins. --- scripts/microbe_stage/organelle_table.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/microbe_stage/organelle_table.as b/scripts/microbe_stage/organelle_table.as index 9a4da27a739..2c14feb6075 100644 --- a/scripts/microbe_stage/organelle_table.as +++ b/scripts/microbe_stage/organelle_table.as @@ -603,7 +603,7 @@ void setupOrganelles(){ chemoSynthisizingProtien.mass = 0.1; chemoSynthisizingProtien.gene = "c"; chemoSynthisizingProtien.mesh = "chemoproteins.mesh"; - chemoSynthisizingProtien.chanceToCreate = 0; + chemoSynthisizingProtien.chanceToCreate = 0.5f; chemoSynthisizingProtien.prokaryoteChance = 1; chemoSynthisizingProtien.mpCost = 20; chemoSynthisizingProtien.initialComposition = { From 144fb69a2ab7ab57873efb8d2dfc97f1303cbd3f Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Wed, 9 Jan 2019 21:08:15 -0600 Subject: [PATCH 11/16] biome.as now checks to see if you are already a certain biome before switching, if not, no need to set. Quick change to prevent potential bug fixed signed unsigned mismatch. --- scripts/microbe_stage/biome.as | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 8965d62499f..1819c39f50a 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -1,5 +1,5 @@ // Global table which stores the current biome the player is in. -uint64 currentBiome = 0; +uint64 currentBiome = 42; const Biome@ getCurrentBiome(){ @@ -121,9 +121,12 @@ 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 that biome already + if (currentBiome != biome) + { + setBiome(biome, world); + } } From 79d4b4968d3a696cca679c535302dce8cd593dfb Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Fri, 11 Jan 2019 00:32:32 -0600 Subject: [PATCH 12/16] Biome dissolved compound numbers are now applied whenever the biome is set. --- scripts/gui/microbe_hud.mjs | 14 ++++++++++++++ scripts/gui/thrive_gui.html | 2 +- scripts/microbe_stage/biome.as | 11 +++++++++++ scripts/microbe_stage/microbe_operations.as | 4 +++- src/scripting/script_initializer.cpp | 2 +- 5 files changed, 30 insertions(+), 3 deletions(-) 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 516787460d6..e98479589ab 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -121,7 +121,7 @@
- O2: 20% + O2: 21%
diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 1819c39f50a..46f1bb9709a 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -96,6 +96,17 @@ void setBiome(uint64 biomeId, CellStageWorld@ world){ 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){ 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/src/scripting/script_initializer.cpp b/src/scripting/script_initializer.cpp index 3cba9c41b3e..6b816a227fb 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -1150,7 +1150,7 @@ bool } if(engine->RegisterObjectMethod("ProcessSystem", - "void getDissolved(CompoundId compoundData)", + "double getDissolved(CompoundId compoundData)", asMETHOD(ProcessSystem, getDissolved), asCALL_THISCALL) < 0) { ANGELSCRIPT_REGISTERFAIL; } From 8084e7b4a3c8ce0cb0f54d54b2ba14255379ce74 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Fri, 11 Jan 2019 18:32:09 -0600 Subject: [PATCH 13/16] removed release from process system, made biome.as default to 10000 --- scripts/microbe_stage/biome.as | 2 +- src/microbe_stage/generate_cell_stage_world.rb | 3 +-- src/microbe_stage/process_system.cpp | 3 --- src/microbe_stage/process_system.h | 3 --- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 46f1bb9709a..9ff0dd33e26 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -1,5 +1,5 @@ // Global table which stores the current biome the player is in. -uint64 currentBiome = 42; +uint64 currentBiome = 1000000; const Biome@ getCurrentBiome(){ diff --git a/src/microbe_stage/generate_cell_stage_world.rb b/src/microbe_stage/generate_cell_stage_world.rb index 14d4c6a24e0..2c8a0558420 100644 --- a/src/microbe_stage/generate_cell_stage_world.rb +++ b/src/microbe_stage/generate_cell_stage_world.rb @@ -149,8 +149,7 @@ EntitySystem.new("ProcessSystem", ["CompoundBagComponent", "ProcessorComponent"], runtick: {group: 10, parameters: []}, - visibletoscripts: true, - release: []), + 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 dd293f4bc71..0a02873acbe 100644 --- a/src/microbe_stage/process_system.cpp +++ b/src/microbe_stage/process_system.cpp @@ -337,6 +337,3 @@ void } } } -void - ProcessSystem::Release() -{} diff --git a/src/microbe_stage/process_system.h b/src/microbe_stage/process_system.h index bb80cc9bd9c..54350412591 100644 --- a/src/microbe_stage/process_system.h +++ b/src/microbe_stage/process_system.h @@ -112,9 +112,6 @@ class ProcessSystem void Run(GameWorld& world); - void - Release(); - void CreateNodes( const std::vector>& From a41c28f68d9b5509fbe40922f2099a6d73e1bd2e Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Fri, 11 Jan 2019 18:56:31 -0600 Subject: [PATCH 14/16] added estuary biome added back missing comma --- .../MicrobeStage/Biomes.json | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/scripts/SimulationParameters/MicrobeStage/Biomes.json b/scripts/SimulationParameters/MicrobeStage/Biomes.json index 80f8c101da4..2ed652b12d2 100644 --- a/scripts/SimulationParameters/MicrobeStage/Biomes.json +++ b/scripts/SimulationParameters/MicrobeStage/Biomes.json @@ -406,6 +406,63 @@ "averageTemperature": -1, + "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 + } + } + }, + + "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, From 2d4ea98d01a92ea36d0806f943b4c28817a9d12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henri=20Hyyryl=C3=A4inen?= Date: Sat, 12 Jan 2019 12:15:19 +0200 Subject: [PATCH 15/16] Fixed a ton of "protien" typos. There should be none left according to ag --- scripts/gui/microbe_editor.mjs | 4 +- scripts/gui/thrive_gui.html | 8 +-- scripts/gui/thrive_style.css | 2 +- .../microbe_editor/microbe_editor.as | 2 +- scripts/microbe_stage/organelle_table.as | 60 ++++++++++--------- scripts/microbe_stage/species_system.as | 10 ++-- 6 files changed, 44 insertions(+), 42 deletions(-) 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/thrive_gui.html b/scripts/gui/thrive_gui.html index e98479589ab..c46a84ad208 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -457,15 +457,15 @@ Coloured, membrane-associated vesicles used by various prokaryotes perform photosynthesis. Chromatophores contain bacteriochlorophyll pigments and carotenoids.
Chromatophores
25 MP - + - ChemosynthisizingProtiens

Cost: 20 mutation points

+ 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
@@ -540,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 9fb61f084b8..05c14baa92b 100644 --- a/scripts/gui/thrive_style.css +++ b/scripts/gui/thrive_style.css @@ -1240,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/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/organelle_table.as b/scripts/microbe_stage/organelle_table.as index 2c14feb6075..3b0f5ad6478 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.5f; - 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; From 7c75e91f11f07bf598f0a6c5f68071ebdf4d40b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henri=20Hyyryl=C3=A4inen?= Date: Sat, 12 Jan 2019 12:19:51 +0200 Subject: [PATCH 16/16] Added clarifying comment about the initial biome number --- scripts/microbe_stage/biome.as | 16 ++++++++++------ scripts/microbe_stage/organelle_table.as | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/microbe_stage/biome.as b/scripts/microbe_stage/biome.as index 9ff0dd33e26..2c57b47f0d6 100644 --- a/scripts/microbe_stage/biome.as +++ b/scripts/microbe_stage/biome.as @@ -1,4 +1,6 @@ -// Global table which stores the current biome the player is in. +// 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(){ @@ -128,16 +130,18 @@ void setSunlightForBiome(CellStageWorld@ world){ } // 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. uint64 biome = GetEngine().GetRandom().GetNumber(0, int(SimulationParameters::biomeRegistry().getSize()-1)); - // Switching to that biome if we arent that biome already + // Switching to that biome if we arent in that biome already if (currentBiome != biome) - { + { setBiome(biome, world); - } + } } diff --git a/scripts/microbe_stage/organelle_table.as b/scripts/microbe_stage/organelle_table.as index 3b0f5ad6478..6076900cf8f 100644 --- a/scripts/microbe_stage/organelle_table.as +++ b/scripts/microbe_stage/organelle_table.as @@ -676,7 +676,7 @@ void setupOrganelles(){ }; _addOrganelleToTable(Organelle(nitrogenFixationProtein)); - + // ------------------------------------ // // Setup the organelle letters setupOrganelleLetters();