diff --git a/CMakeLists.txt b/CMakeLists.txt index 63f096672fd..e2348df455f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,14 +55,14 @@ set(LEVIATHAN_SKIP_OPTIONAL_ASSETS ON) include(LeviathanCompileOptions) include(LeviathanSetRPath) -set(LEVIATHAN_FULL_BUILD ON) - -set(USE_ANGELSCRIPT ON) -set(USE_BOOST ON) -set(USE_OGRE ON) -set(USE_NEWTON ON) -set(USE_SFML ON) -set(USE_SDL2 ON) +set(LEVIATHAN_USING_ANGELSCRIPT ON) +set(LEVIATHAN_USING_OGRE ON) +set(LEVIATHAN_USING_BULLET ON) +set(LEVIATHAN_USING_CEF ON) +set(LEVIATHAN_USING_GUI ON) +set(LEVIATHAN_USING_SFML ON) +set(LEVIATHAN_USING_SDL2 ON) +set(LEVIATHAN_USING_LEAP ON) include(LeviathanFindLibraries) @@ -98,8 +98,8 @@ link_directories("${LEVIATHAN_SRC}/build/bin") # Version set(PROGRAM_VERSION_STABLE 0) set(PROGRAM_VERSION_MAJOR 4) -set(PROGRAM_VERSION_MINOR 0) -set(PROGRAM_VERSION_PATCH 2) +set(PROGRAM_VERSION_MINOR 1) +set(PROGRAM_VERSION_PATCH 0) set(PROGRAM_VERSION_SUFFIX "") set(PROGRAM_VERSION_STR ${PROGRAM_VERSION_STABLE}.${PROGRAM_VERSION_MAJOR}.${PROGRAM_VERSION_MINOR}.${PROGRAM_VERSION_PATCH}${PROGRAM_VERSION_SUFFIX}) diff --git a/SetupThrive.rb b/SetupThrive.rb index b2500ebcb52..97fe50d08ed 100755 --- a/SetupThrive.rb +++ b/SetupThrive.rb @@ -78,7 +78,7 @@ def parseExtraArgs leviathan = Leviathan.new( # Use this if you always want the latest commit # version: "develop", - version: "0d08da11c7d15bb5710427634371b62eccf7867d", + version: "109ae9e19a05967c9160bf5dbaeb69c9373cf1b1", # Doesn't actually work, but leviathan doesn't install with sudo by # default, or install at all for that matter noInstallSudo: true diff --git a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json index e0359718b7f..9a588a9661e 100644 --- a/scripts/SimulationParameters/MicrobeStage/BioProcesses.json +++ b/scripts/SimulationParameters/MicrobeStage/BioProcesses.json @@ -8,7 +8,7 @@ }, "outputs": { - "atp": 38.0 + "atp": 45.0 } }, @@ -93,7 +93,7 @@ "inputs": { "oxygen": 1.0, - "glucose": 0.7 + "glucose": 1.0 }, "outputs": { @@ -109,7 +109,7 @@ }, "outputs": { - "glucose": 0.33 + "glucose": 0.15 } }, @@ -118,6 +118,7 @@ "inputs": { "carbondioxide": 0.09, + "oxygen": 0.21, "iron": 0.175 }, diff --git a/scripts/SimulationParameters/MicrobeStage/SpeciesNames.json b/scripts/SimulationParameters/MicrobeStage/SpeciesNames.json index dbf97ed7f70..56f977c0ad0 100644 --- a/scripts/SimulationParameters/MicrobeStage/SpeciesNames.json +++ b/scripts/SimulationParameters/MicrobeStage/SpeciesNames.json @@ -24,7 +24,11 @@ "River", "Prim", "Prem", - "Kapp" + "Kapp", + "Vip", + "Viper", + "Spik", + "Vuper" ], "prefixes_v": [ @@ -77,7 +81,12 @@ "Cya", "Cyo", "Cyi", - "Cyu" + "Cyu", + "Vi", + "Ve", + "Va", + "Vo", + "Vu" ], "prefixes_c": [ @@ -134,6 +143,8 @@ "Var", "Vic", "Vir", + "Vip", + "Vup", "Zy", "Ab", "Ant", diff --git a/scripts/gui/microbe_editor.mjs b/scripts/gui/microbe_editor.mjs index d486079e533..9e6454b3efb 100644 --- a/scripts/gui/microbe_editor.mjs +++ b/scripts/gui/microbe_editor.mjs @@ -371,16 +371,13 @@ function openHelpEditor(){ "Paramecium? Predator, or Prey?", "Heres a tip, toxins can be used to knock other toxins away from you " + "if you are quick enough.", - "Heres a tip, Osmoregulation costs 1 ATP per second per organelle your cell has, " + + "Heres a tip, Osmoregulation costs 1 ATP per second per hex your cell has, " + " each empty hex of cytoplasm generates 5 ATP per second aswell," + "which means if you are losing ATP due to osmoregulation just add a couple" + " empty hexes cytoplasm or remove some organelles.", "Fun Fact, In real life prokaryotes have something called Biocompartments " + "which act like organelles, and are in fact called Polyhedral organelles", "Fun Fact, The metabolosome is what is called a Polyhedral organelle", - "Heres a Tip, You generate exactly 14 atp per second per mitochondria.", - "Heres a Tip, You generate exactly 14 atp per second per metabolosome," + - "however, it is 7 times less efficient than a mitochondria.", "Heres a Tip, Chromatophores generate 1/3rd the glucose of a chloroplast", "Heres a Tip, You generate exactly 2 glucose per second per chemoplast," + "as long as you have at least 1 hydrogen sulfide to convert.", @@ -389,7 +386,52 @@ function openHelpEditor(){ "or two other species due to evolution happening around you, see if you can " + "identify them!", "One of the first playable game-play prototypes was made by our awesome programmer," + - " untrustedlife!" + " untrustedlife!", + "Fun Fact, The Didinium and Paramecium are a textbook example of a " + + "predator prey relationship" + + " that has been studied for decades, now are you the Didinium, or the " + + "Paramecium? Predator, or Prey?", + "Heres a tip, toxins can be used to knock other toxins away from you " + + "if you are quick enough.", + "Heres a tip, sometimes its best just to run away from other cells.", + "Heres a tip, if a cell is about half your size, thats when you can engulf them.", + "Heres a tip, Bacteria can be stronger then they appear, they may look " + + "small, but some of them can burrow into you and kill you that way!", + "Heres a tip, You can hunt other species to extinction if you arent careful " + + "enough, they can also be hunted to extinction by other species.", + "Heres a tip, Every 5 minutes an Auto-evo step happens, if you dont evolve " + + "fast enough you may be out-competed.", + "Heres a tip, If you mouse over a cloud a box will pop up on the top left " + + "of your screen that tells you exactly whats there.", + "WIGGLY THINGS!!", + "Smeltal the meltal.", + "Those blue cells though.", + "Fun Fact, The thrive team does podcasts every so often, you should check them out!", + "Heres a tip, Biomes are more then just differnet backgrounds, " + + "the compounds in, different biomes sometimes spawn at different rates.", + "Heres a tip, The more flagella you have, the faster you go, " + + "vroom vroom, but it also costs more ATP", + "Heres a tip, you can en[g]ulf chunks iron or otherwise.", + "Heres a tip, prepare before adding a nucleus." + + " those things are expensive! In upkeep and up front cost.", + "Fun Fact, Did you know that there are over 8000 species of ciliate on planet earth?", + "Fun Fact, The Stentor is a ciliate that can stretch itself and catch prey " + + "in a kind of trumpet like mouth that draws prey in by generating " + + "water currents with cilia.", + "Fun Fact, The Didinum is a ciliate that hunts paramecia.", + "Fun Fact, The Ameoba hunts and catches prey with 'legs' made of " + + "cytoplasm called pseudopods, eventually we want those in thrive.", + "Heres a tip, Watch out for larger cells and large bacteria, " + + "it's not fun to be digested, and they will eat you.", + "Heres a tip, Osmoregulation costs 1 ATP per second per hex, " + + " each empty hex of cytoplasm generates 5 ATP per second aswell," + + "which means if you are losing ATP due to osmoregulation just add a couple" + + " empty hexes cytoplasm or remove some organelles", + "Fun Fact, Thrive is meant as a simulation of an alien planet, therefore it makes" + + "sense that most creatures you find will be related to one " + + "or two other species due to evolution happening around you, see if" + + " you can identify them!", + "Heres a tip, if your cell is 150 hexes, you can engulf the large iron chunks." ]; diff --git a/scripts/gui/microbe_hud.mjs b/scripts/gui/microbe_hud.mjs index b98d879442e..1cc67f6a643 100644 --- a/scripts/gui/microbe_hud.mjs +++ b/scripts/gui/microbe_hud.mjs @@ -221,6 +221,9 @@ function openHelp(){ "the compounds in, different biomes sometimes spawn at different rates.", "Heres a tip, The more flagella you have, the faster you go, " + "vroom vroom, but it also costs more ATP", + "Heres a tip, you can en[g]ulf chunks iron or otherwise.", + "Heres a tip, prepare before adding a nucleus." + + " those things are expensive! In upkeep and up front cost.", "Fun Fact, Did you know that there are over 8000 species of ciliate on planet earth?", "Fun Fact, The Stentor is a ciliate that can stretch itself and catch prey " + "in a kind of trumpet like mouth that draws prey in by generating " + @@ -230,7 +233,7 @@ function openHelp(){ "cytoplasm called pseudopods, eventually we want those in thrive.", "Heres a tip, Watch out for larger cells and large bacteria, " + "it's not fun to be digested, and they will eat you.", - "Heres a tip, Osmoregulation costs 1 ATP per second per organelle your cell has, " + + "Heres a tip, Osmoregulation costs 1 ATP per second per hex, " + " each empty hex of cytoplasm generates 5 ATP per second aswell," + "which means if you are losing ATP due to osmoregulation just add a couple" + " empty hexes cytoplasm or remove some organelles", @@ -238,6 +241,7 @@ function openHelp(){ "sense that most creatures you find will be related to one " + "or two other species due to evolution happening around you, see if" + " you can identify them!", + "Heres a tip, if your cell is 150 hexes, you can engulf the large iron chunks.", "Fun Fact, One of the first playable game-play prototypes was made " + "by our awesome programmer, untrustedlife!" ]; diff --git a/scripts/gui/thrive_gui.html b/scripts/gui/thrive_gui.html index 7dea5b48690..0afc05c11fe 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -134,7 +134,7 @@
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. + Congratulation- a winner is y... who am I kidding, you have thrived! You have won in the 0.4.1 build Good job, you may continue playing after this screen closes if you wish, or start a new game in a new world.
@@ -294,37 +294,36 @@ environment to process in your cell's organelles and generate ATP. Be careful not to let your ATP stores run out, or you will slow down, lose health and eventually die. -

The various compound clouds are:
White – -Glucose
Yellow – Hydrogen Sulfide
Orange - Ammonia
Purple - Phosphates
+

The various compound clouds are:

White – +Glucose
Yellow – Hydrogen Sulfide
Orange - Ammonia
Purple - Phosphates
Rust Brown - Iron Ions

-Glucose makes ATP, Hydrogen Sulfide can be converted into glucose via chemoplasts and Ammonia and Phosphates are crucial for -reproduction.

+Glucose makes ATP
+Hydrogen Sulfide can be converted into glucose via chemoplasts and chemosynthesizing proteins
+Iron Ions can be converted via rusticyanin into ATP
+and Ammonia and Phosphates are crucial for reproduction.

Press E to release a dangerous agent, Oxytoxy NT, to kill other cells and then collect the spilled compounds if you have a toxin vacuole.

-You can also engulf cells and bacteria that are smaller than you by pressing +You can also engulf cells and bacteria and iron chunks and cell chunks that are smaller than you by pressing G. This will cost additional ATP and will slow you down. Don't forget to press G a second time to stop engulfing.

-You can also gain a pilus in the editor and skewer other cells and bacteria

- To reproduce you need to divide each of your organelles into two and then duplicate the DNA in your nucleus. Each organelle needs 2 ammonia and 2 phosphate to split in half.

-Osmoregulation Now costs ATP, which means the bigger your cell is, the more Mitochondria (or cytoplasm, which does Glycolysis now) you need to avoid losing ATP when you are stationary. -It works this way: Osmoregulation costs are ((Organelle Amount)x1)/per second , each empty hex of cytoplasm generates 4 ATP per second aswell (Due to glycolysis), which means if you are losing ATP -due to osmoregulation just add a couple empty hexes cytoplasm or a mitochondria or remove some organelles. Be wary of this when making huge cells... +Osmoregulation Now costs ATP, which means the bigger your cell is, the more Mitochondria or Metabolosomes or Rusticyanin (or cytoplasm, which does Glycolysis) you need to avoid losing ATP when you are stationary. +It works this way: Osmoregulation costs are ((Hex Amount * 1) per second...

There are many Organelles in the editor for you to evolve, allowing for a wide range of different playstyles.

For this Release if your population (top tab) drops to zero you go extinct.
-But if you survive for fifteen generations, you are considered to have won, after winning you get a popup and can continue playing as you wish. +But if you survive for fifteen generations with 200 population, you are considered to have won, after winning you get a popup and can continue playing as you wish.

-Be wary because your competitors are evolving alongside you. +Be wary because your competitors are evolving alongside you. Every time you enter the editor they evolve as well.

@@ -381,7 +380,7 @@ Metabolosomes

Cost: 45 mutation points

- 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)

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

Storage Space: 1

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

Cost: 55 mutation points

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

Storage Space: 1

Coloured, membrane-associated vesicles used by various prokaryotes perform photosynthesis. @@ -409,9 +408,9 @@ Rusticyanin

Cost: 45 mutation points

- Performs Process: Iron Chemolithotrophy
(0.09 CO2 + 0.175 Iron Ion -> 10 ATP)/Second (Depending On Environmental C02)

+ Performs Process: Iron Chemolithotrophy
(0.21 Oxygen (Primary Electron acceptor) + 0.09 CO2 + 0.175 Iron Ion -> 10 ATP)/Second (Depending On Environmental C02 and O2)

Storage Space: 1

- Siderophores and Rusticyanin for storing and using iron ions and carbon from atmospheric carbon dioxide to produce ATP. + Siderophores and Rusticyanin for storing and using iron ions with oxygen as the primary electron acceptor and carbon from atmospheric carbon dioxide to produce ATP. Iron Chemolithotrophy is a process by which organisms obtain their energy from the oxidation of reduced inorganic ions.
Rusticyanin
45 MP @@ -438,13 +437,14 @@ Performs Process: Eukaryote Evolution

Storage Space: 15

Allows for synthesis of RNA and MRNA, allows cell to evolve membrane bound organelles. +

Warning! The nucleus will slow you down significantly and has an upkeep cost of 11 ATP per second due to osmoregulation! It is also irreversible.

Nucleus
100 MP Mitochondria

Cost: 45 mutation points

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

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

Storage Space: 2

A captured prokaryote used by eukaryotic cells to perform respiration.
- The Mitochondria is the powerhouse of the cell @@ -561,30 +561,41 @@ Each visit to the editor in the Microbe Stage Represents 200 million years of evolution
Each generation, you have 100 mutation points to spend, and each change (or mutation) will cost a certain amount of that MP, removing costs mutation points aswell as adding.

-You can rotate your organelles, with A and D
-Mitochondrion: Produces ATP out of glucose and atmospheric 02. Much more eficiently then cytoplasm
+You can rotate your organelles, with A and D

-Chloroplast: Makes glucose out of sunlight and atmospheric CO2.
+Prokaryotic Structures
+Metabolosomes: Produces the same amount of ATP of a mitocondria, but is way way less efficient, it only takes up 1 Hex
-Chemoplast: Makes glucose out of Hydrogen Sulfide.
+Chemosynthisizing Proteins: Produces half of the glucose out of Hydrogen Sulfide as a chemoplast, but also performs glycolysis, takes up 1 Hex
-Nitrogen Fixing Plastid: Makes ammonia from ATP and atmospheric Nitrogen.
+Chromatophores: Produces 1/3rd the amount of glucose as a normal chloroplast, but also performs glycolysis, and takes up 1 Hex.
-Vacuole: Stores 50 collected compounds.
+Rusticyanin: Converts iron ions into ATP, and takes up 1 Hex.
-Toxin Vacuoles: Produces toxins (called OxyToxyNT).
+Cytoplasm: Increases the rate of compound absorbtion and has 4 storage space and performs glycolysis (Produces small amounts of ATP).

+ +External Organelles
Flagella: Moves your cell faster by consuming ATP.
-Pilus: Can be used to stab other cells.
+Pilus: Can be used to stab other cells.

+ +Membrane Bound Organelles
+ +Nucleus: Takes up 11 hexes and allows for evolution of membrane bound organelles. And also doubles your cells size. (Can only be evolved once)
-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
+Mitochondrion: Produces ATP out of glucose and atmospheric 02. Much more efficiently then cytoplasm
+ +Chloroplast: Makes glucose out of sunlight and atmospheric CO2.
+ +Chemoplast: Makes glucose out of Hydrogen Sulfide.
+ +Nitrogen Fixing Plastid: Makes ammonia from ATP and atmospheric Nitrogen.
-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
+Vacuole: Stores 15 collected compounds.
-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.

+Toxin Vacuoles: Produces toxins (called OxyToxyNT).

-Cytoplasm: Increases the rate of compound absorbtion and has 20 storage space and performs glycolysis (Produces small amounts of ATP).

diff --git a/scripts/microbe_stage/configs.as b/scripts/microbe_stage/configs.as index 7dd26f29acd..dd8c3369ca2 100644 --- a/scripts/microbe_stage/configs.as +++ b/scripts/microbe_stage/configs.as @@ -347,7 +347,7 @@ const dictionary STARTER_MICROBES = { "Default", MicrobeTemplate(1/14000, { - //for testing + // For testing {"atp", InitialCompound(60)}, {"glucose", InitialCompound(60)}, {"ammonia", InitialCompound(0)}, @@ -360,7 +360,8 @@ const dictionary STARTER_MICROBES = { OrganelleTemplatePlaced("cytoplasm", 0, 0, 0) }, Float4(1, 1, 1, 1), - false, + // Player starts as bacteria + true, MEMBRANE_TYPE::MEMBRANE) } }; diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor.as b/scripts/microbe_stage/microbe_editor/microbe_editor.as index f8671a8948c..60eefb21661 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor.as @@ -940,9 +940,12 @@ class MicrobeEditor{ } else if(type == "MicrobeEditorExited"){ LOG_INFO("MicrobeEditor: applying changes to player Species"); + auto world = GetThriveGame().getCellStage(); + auto player = GetThriveGame().playerData().activeCreature(); + // We need to grab the player's species SpeciesComponent@ playerSpecies = MicrobeOperations::getSpeciesComponent( - GetThriveGame().getCellStage(), GetThriveGame().playerData().activeCreature()); + world, player); assert(playerSpecies !is null, "didn't find edited species"); @@ -960,6 +963,20 @@ class MicrobeEditor{ templateOrganelles = newOrganelles; + // Grab render node of player cell + auto node = world.GetComponent_RenderNode(player); + + // Change player species cell size depending on whether they are a bacteria or not + if(checkIsNucleusPresent()) { + playerSpecies.isBacteria = false; + node.Scale = Float3(1.0, 1.0, 1.0); + node.Marked = true; + } else { + playerSpecies.isBacteria = true; + node.Scale = Float3(0.5, 0.5, 0.5); + node.Marked = true; + } + LOG_INFO("MicrobeEditor: updated organelles for species: " + playerSpecies.name); return 1; } else if (type == "SymmetryClicked"){ diff --git a/scripts/microbe_stage/microbe_operations.as b/scripts/microbe_stage/microbe_operations.as index a1890ba6ba7..ccb8f183af4 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -679,35 +679,39 @@ void emitAgent(CellStageWorld@ world, ObjectID microbeEntity, CompoundId compoun } } -void playSoundWithDistance(CellStageWorld@ world, const string &in soundPath, ObjectID microbeEntity) - { +void playSoundWithDistance(CellStageWorld@ world, const string &in soundPath, + ObjectID microbeEntity) +{ auto location = world.GetComponent_Position(microbeEntity)._Position; auto playerEntity = GetThriveGame().playerData().activeCreature(); + Position@ thisPosition = world.GetComponent_Position(playerEntity); MicrobeComponent@ microbeComponent = getMicrobeComponent(world, microbeEntity); + // Length is squared so also square the variable we are dividing float thisVolume = 1000.0f/(sqrt(((thisPosition._Position-location).LengthSquared()))+1); float soundVolume = thisVolume; + // Play sound - if (@microbeComponent.otherAudio is null || + if (microbeComponent.otherAudio is null || !microbeComponent.otherAudio.Get().isPlaying()) - { - @microbeComponent.otherAudio = GetEngine().GetSoundDevice().Play2DSound( + { + @microbeComponent.otherAudio = GetEngine().GetSoundDevice().Play2DSound( soundPath, false, true); if(microbeComponent.otherAudio !is null){ if(microbeComponent.otherAudio.HasInternalSource()){ - microbeComponent.otherAudio.Get().setVolume(soundVolume); - microbeComponent.otherAudio.Get().play(); - } else { - LOG_ERROR("Created sound player doesn't have internal " - "sound source"); - } + microbeComponent.otherAudio.Get().setVolume(soundVolume); + microbeComponent.otherAudio.Get().play(); } else { - //this was happening so often it caused lag - //LOG_ERROR("Failed to create sound player"); + LOG_ERROR("Created sound player doesn't have internal " + "sound source"); } + } else { + //this was happening so often it caused lag + //LOG_ERROR("Failed to create sound player"); } } +} // Default version of toggleEngulfMode that takes ObjectID void toggleEngulfMode(CellStageWorld@ world, ObjectID microbeEntity) @@ -834,6 +838,7 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie return NULL_OBJECT; } + // Create microbeEntity with correct template, physics and species name auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName, // in_editor false); @@ -859,15 +864,8 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie // TODO: Why is this here with the separate spawnBacteria function existing? // Bacteria get scaled to half size if(species.isBacteria){ - // TODO: wow, this is a big hack and no way guarantees that - // the physics size matches the rendered size node.Scale = Float3(0.5, 0.5, 0.5); node.Marked = true; - // This call is also not the cheapest. So would be much better - // if the physics generation actually did the right then when - // species.isBacteria is true - physics.ChangeShape(world.GetPhysicalWorld(), - world.GetPhysicalWorld().CreateSphere(HEX_SIZE/2.0f)); } return microbeEntity; @@ -893,6 +891,7 @@ ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speci return NULL_OBJECT; } + // Create microbeEntity with correct template, physics and species name auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName, // in_editor false); @@ -912,15 +911,8 @@ ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speci node.Node.setPosition(pos); // Bacteria get scaled to half size - // TODO: wow, this is a big hack and no way guarantees that - // the physics size matches the rendered size node.Scale = Float3(0.5, 0.5, 0.5); node.Marked = true; - // This call is also not the cheapest. So would be much better - // if the physics generation actually did the right then when - // species.isBacteria is true - physics.ChangeShape(world.GetPhysicalWorld(), - world.GetPhysicalWorld().CreateSphere(HEX_SIZE/2.0f)); // Need to set bacteria spawn and it needs to be squared like it // is in the spawn system. code, if part of colony but not diff --git a/scripts/microbe_stage/organelle.as b/scripts/microbe_stage/organelle.as index 0b6bc190d7b..76c49fdde5d 100644 --- a/scripts/microbe_stage/organelle.as +++ b/scripts/microbe_stage/organelle.as @@ -679,21 +679,31 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{ microbeEntity = microbe; + bool bacteria = false; + // This should be the only species check any organelle ever makes. auto species = MicrobeOperations::getSpeciesComponent(world, microbeEntity); if (species !is null){ this.speciesColour = species.colour; - } + bacteria = species.isBacteria; + } // Our coordinates are already set when this is called // so just cache this this.cartesianPosition = Hex::axialToCartesian(q, r); + float hexSize = HEX_SIZE; + + // Scale the hex size down for bacteria + if(bacteria) + hexSize /= 2.f; + assert(organelleEntity == NULL_OBJECT, "PlacedOrganelle already had an entity"); Float3 offset = organelle.calculateCenterOffset(); RenderNode@ renderNode; + // Graphics setup if(IsInGraphicalMode()){ organelleEntity = world.CreateEntity(); @@ -709,17 +719,17 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{ @renderNode = world.Create_RenderNode(organelleEntity); renderNode.Scale = Float3(HEX_SIZE, HEX_SIZE, HEX_SIZE); renderNode.Marked = true; - } - // For performance reasons we set the position here directly - // instead of with the position system - renderNode.Node.setPosition(offset + this.cartesianPosition); - // TODO: this MUST BE moved to the mesh file. Otherwise this mess will grow over time - //maybe instead of changing this here we should do so in the generation routine. - renderNode.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(90), + // For performance reasons we set the position here directly + // instead of with the position system + renderNode.Node.setPosition(offset + this.cartesianPosition); + + renderNode.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3(1, 0, 0)) * Ogre::Quaternion(Ogre::Degree(180), Ogre::Vector3(0, 1, 0)) * Ogre::Quaternion(Ogre::Degree(rotation), Ogre::Vector3(0, 0, 1))); + } + // Add hex collision shapes auto hexes = organelle.getHexes(); @@ -730,13 +740,11 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{ // Also add our offset to the hex offset Float3 translation = Hex::axialToCartesian(hex.q, hex.r) + this.cartesianPosition; - // Create the matrix with the offset - Ogre::Matrix4 hexFinalOffset(translation); - - PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(HEX_SIZE * 2); + // Scale for bacteria physics. This might be pretty expensive to be in this loop... + if(bacteria) + translation /= 2.f; - if(hexCollision is null) - assert(false, "Failed to create Sphere for hex"); + PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(hexSize * 2); collisionShape.AddChildShape(hexCollision, translation); _addedCollisions.insertLast(hexCollision); diff --git a/scripts/microbe_stage/species_system.as b/scripts/microbe_stage/species_system.as index a38d82b3b29..82c3d71e1bb 100644 --- a/scripts/microbe_stage/species_system.as +++ b/scripts/microbe_stage/species_system.as @@ -1449,7 +1449,8 @@ void restoreOrganelleLayout(CellStageWorld@ world, ObjectID microbeEntity, MicrobeOperations::addOrganelle(world, microbeEntity, organelle, editShape); } - // cache isBacteria from species + // Cache isBacteria from species. This can be changed depending on + // the added organelles in the editor microbeComponent.isBacteria = species.isBacteria; }