From c0a2c442971ae1bb527a190445db880a162c9fac Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Fri, 26 Apr 2019 13:45:03 -0500 Subject: [PATCH] started working on my issues game currently cannot run got rid of proc gen species completely species can now mutate new membranes added population to c++ side species, fixed epithet game now runs again, it crashes when you ente rthe editor though because your species lacks a stringcode --- .../MicrobeStage/Species.json | 5 +- scripts/microbe_stage/configs.as | 12 +- .../microbe_editor/microbe_editor.as | 4 + scripts/microbe_stage/microbe_operations.as | 24 - scripts/microbe_stage/setup.as | 1 - scripts/microbe_stage/species_system.as | 416 ++++-------------- src/microbe_stage/species.cpp | 3 + src/microbe_stage/species.h | 1 + src/microbe_stage/species_component.h | 6 + src/scripting/script_initializer.cpp | 6 +- 10 files changed, 109 insertions(+), 369 deletions(-) diff --git a/scripts/SimulationParameters/MicrobeStage/Species.json b/scripts/SimulationParameters/MicrobeStage/Species.json index 25d347cd855..03b182f889c 100644 --- a/scripts/SimulationParameters/MicrobeStage/Species.json +++ b/scripts/SimulationParameters/MicrobeStage/Species.json @@ -15,6 +15,9 @@ "organelles": { }, "membranetype": 0, - "isBacteria": false + "isBacteria": false, + "genus": "Primum", + "epithet":"Thrivium", + "population": 30 } } diff --git a/scripts/microbe_stage/configs.as b/scripts/microbe_stage/configs.as index 22f36a593e7..cdd1761bafe 100644 --- a/scripts/microbe_stage/configs.as +++ b/scripts/microbe_stage/configs.as @@ -312,7 +312,9 @@ class MicrobeTemplate{ array organelles, Float4 colour, bool isBacteria, - MEMBRANE_TYPE speciesMembraneType + MEMBRANE_TYPE speciesMembraneType, + string genus, + string epithet ) { this.spawnDensity = spawnDensity; this.compounds = compounds; @@ -320,8 +322,12 @@ class MicrobeTemplate{ this.colour = colour; this.isBacteria = isBacteria; this.speciesMembraneType = speciesMembraneType; + this.genus = genus; + this.epithet = epithet; } + string genus; + string epithet; float spawnDensity; dictionary compounds; array organelles; @@ -368,7 +374,9 @@ const dictionary STARTER_MICROBES = { Float4(1, 1, 1, 1), // Player starts as bacteria true, - MEMBRANE_TYPE::WALL) + MEMBRANE_TYPE::WALL, + "Primum", + "Thrivium") } }; diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor.as b/scripts/microbe_stage/microbe_editor/microbe_editor.as index 66c727a155d..c77f922fa56 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor.as @@ -134,6 +134,10 @@ class MicrobeEditor{ // Update GUI buttons now that we have correct organelles updateGuiButtonStatus(checkIsNucleusPresent()); + + //force add your species + cast(GetThriveGame().getCellStage().GetScriptSystem("SpeciesSystem")).splitSpecies(playerSpecies); + //force an auto-evo step cast(GetThriveGame().getCellStage().GetScriptSystem("SpeciesSystem")).doAutoEvoStep(); // Reset to cytoplasm if nothing is selected diff --git a/scripts/microbe_stage/microbe_operations.as b/scripts/microbe_stage/microbe_operations.as index 7697ce305ac..c3eb65a422a 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -1047,30 +1047,6 @@ ObjectID _createMicrobeEntity(CellStageWorld@ world, bool aiControlled, ObjectID entity = world.CreateEntity(); // TODO: movement sound for microbes - // auto soundComponent = SoundSourceComponent(); - // auto s1 = null; - // soundComponent.addSound("microbe-release-toxin", - // "soundeffects/microbe-release-toxin.ogg"); - // soundComponent.addSound("microbe-toxin-damage", - // "soundeffects/microbe-toxin-damage.ogg"); - // soundComponent.addSound("microbe-death", "soundeffects/microbe-death.ogg"); - // soundComponent.addSound("microbe-pickup-organelle", - // "soundeffects/microbe-pickup-organelle.ogg"); - // soundComponent.addSound("microbe-engulfment", "soundeffects/engulfment.ogg"); - // soundComponent.addSound("microbe-reproduction", "soundeffects/reproduction.ogg"); - - // s1 = soundComponent.addSound("microbe-movement-1", - // "soundeffects/microbe-movement-1.ogg"); - // s1.properties.volume = 0.4; - // s1.properties.touch(); - // s1 = soundComponent.addSound("microbe-movement-turn", - // "soundeffects/microbe-movement-2.ogg"); - // s1.properties.volume = 0.1; - // s1.properties.touch(); - // s1 = soundComponent.addSound("microbe-movement-2", - // "soundeffects/microbe-movement-3.ogg"); - // s1.properties.volume = 0.4; - // s1.properties.touch(); auto position = world.Create_Position(entity, Float3(0, 0, 0), Float4::IdentityQuaternion); diff --git a/scripts/microbe_stage/setup.as b/scripts/microbe_stage/setup.as index 137d94c36d8..233a8b95617 100644 --- a/scripts/microbe_stage/setup.as +++ b/scripts/microbe_stage/setup.as @@ -663,7 +663,6 @@ void resetWorld(CellStageWorld@ world) // but eh. We can call it all in this method. cast(world.GetScriptSystem("SpeciesSystem")).resetAutoEvo(); - cast(world.GetScriptSystem("SpeciesSystem")).createNewEcoSystem(); } //! AI species are spawned by Species in species_system diff --git a/scripts/microbe_stage/species_system.as b/scripts/microbe_stage/species_system.as index 05e7b0695b7..ce4cd544d04 100644 --- a/scripts/microbe_stage/species_system.as +++ b/scripts/microbe_stage/species_system.as @@ -253,172 +253,6 @@ string randomBacteriaName() class Species{ - //! Constructor for automatically creating a random species - Species(CellStageWorld@ world, bool isBacteria) - { - this.isBacteria = isBacteria; - - if (!isBacteria) - { - name = randomSpeciesName(); - genus = generateNameSection(); - epithet = generateNameSection(); - - initializeBehavior(); - - auto stringSize = GetEngine().GetRandom().GetNumber(MIN_INITIAL_LENGTH, - MAX_INITIAL_LENGTH); - if (GetEngine().GetRandom().GetNumber(0, 100) <= 10){ - // Generate an extremely large cell, players never really had enough challenge - LOG_INFO("Generating EPIC cell"); - stringSize = GetEngine().GetRandom().GetNumber(MIN_INITIAL_EPIC_LENGTH, - MAX_INITIAL_EPIC_LENGTH); - } - - const auto cytoplasmGene = getOrganelleDefinition("cytoplasm").gene; - string energyGene = cytoplasmGene; - const auto bonusPadding = GetEngine().GetRandom().GetNumber(1, 10); - - // it should always have a nucleus and a cytoplasm. - stringCode = getOrganelleDefinition("nucleus").gene + - cytoplasmGene; - - // generated cells need to be viable for now. so heres all possible survival strategies i can think of - switch (GetEngine().GetRandom().GetNumber(0, 15)) - { - case 0: - energyGene = getOrganelleDefinition("cytoplasm").gene; - //if cytoplasm you need a few more of them - for(int i = 0; i < bonusPadding; i++){ - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), energyGene); - } - break; - case 1: - energyGene = getOrganelleDefinition("metabolosome").gene; - break; - case 2: - energyGene = getOrganelleDefinition("rusticyanin").gene; - energyGene += getOrganelleDefinition("cytoplasm").gene; - break; - case 3: - energyGene = getOrganelleDefinition("cytoplasm").gene; - //if cytoplasm you need a few more of them - for(int i = 0; i < bonusPadding; i++){ - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), energyGene); - } - energyGene += getOrganelleDefinition("chemoSynthisizingProteins").gene; - break; - case 4: - energyGene = getOrganelleDefinition("mitochondrion").gene; - break; - case 5: - energyGene = getOrganelleDefinition("chemoSynthisizingProteins").gene; - energyGene += getOrganelleDefinition("mitochondrion").gene; - break; - case 6: - energyGene = getOrganelleDefinition("chloroplast").gene; - energyGene += getOrganelleDefinition("mitochondrion").gene; - break; - case 7: - energyGene = getOrganelleDefinition("metabolosome").gene; - energyGene += getOrganelleDefinition("chemoSynthisizingProteins").gene; - break; - case 8: - energyGene = getOrganelleDefinition("metabolosome").gene; - energyGene += getOrganelleDefinition("chromatophors").gene; - break; - case 9: - energyGene = getOrganelleDefinition("chromatophors").gene; - energyGene += getOrganelleDefinition("mitochondrion").gene; - break; - case 10: - energyGene = getOrganelleDefinition("chemoplast").gene; - energyGene += getOrganelleDefinition("mitochondrion").gene; - break; - case 11: - energyGene = getOrganelleDefinition("chemoplast").gene; - energyGene += getOrganelleDefinition("metabolosome").gene; - break; - case 12: - energyGene = getOrganelleDefinition("chromatophors").gene; - energyGene += getOrganelleDefinition("cytoplasm").gene; - break; - case 13: - energyGene = getOrganelleDefinition("chloroplast").gene; - energyGene += getOrganelleDefinition("cytoplasm").gene; - break; - case 14: - - energyGene = getOrganelleDefinition("cytoplasm").gene; - //if cytoplasm you need a few more of them - for(int i = 0; i < bonusPadding; i++){ - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), energyGene); - } - energyGene += getOrganelleDefinition("chemoplast").gene; - break; - case 15: - energyGene = getOrganelleDefinition("chloroplast").gene; - energyGene += getOrganelleDefinition("metabolosome").gene; - break; - } - - const auto energyPadding = GetEngine().GetRandom().GetNumber(1, 5); - for(int i = 0; i < energyPadding; i++){ - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), energyGene); - } - - for(int i = 0; i < stringSize; i++){ - this.stringCode += getRandomLetter(false); - } - - // And then random cytoplasm padding - const auto cytoplasmPadding = GetEngine().GetRandom().GetNumber(0, 20); - if (GetEngine().GetRandom().GetNumber(0, 100) <= 25) - { - for(int i = 0; i < cytoplasmPadding; i++){ - if (GetEngine().GetRandom().GetNumber(0, 20)<= 10) - { - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), energyGene); - } - else { - this.stringCode.insert(GetEngine().GetRandom().GetNumber(2, - stringCode.length()), cytoplasmGene); - } - } - } - - this.colour = getRightColourForSpecies(); - - if (GetEngine().GetRandom().GetNumber(0,100) < 50){ - this.speciesMembraneType = MEMBRANE_TYPE::MEMBRANE; - } - else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { - this.speciesMembraneType = MEMBRANE_TYPE::DOUBLEMEMBRANE; - this.colour.W = randomOpacityChitin();; - } - else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { - this.speciesMembraneType = MEMBRANE_TYPE::WALL; - } - else { - this.speciesMembraneType = MEMBRANE_TYPE::CHITIN; - this.colour.W = randomOpacityChitin(); - } - - commonConstructor(world); - this.setupSpawn(world); - - } - else{ - // We are creating a bacteria right now - generateBacteria(world); - } - } - ~Species() { if(templateEntity != NULL_OBJECT){ @@ -428,8 +262,8 @@ class Species{ } } - // Creates a mutated version of the species and reduces the species population by half - Species(Species@ parent, CellStageWorld@ world, bool isBacteria) + // Creates a mutated version of the species + Species(SpeciesComponent@ parent, CellStageWorld@ world, bool isBacteria) { this.isBacteria = parent.isBacteria; @@ -450,6 +284,7 @@ class Species{ // Make sure not over or under our scales cleanPersonality(); + // Subtly mutate color if (GetEngine().GetRandom().GetNumber(0,5) == 0) { @@ -477,11 +312,29 @@ class Species{ parent.colour.W + randomMutationColourChannel()); } - this.population = int(floor(parent.population / 2.f)); - parent.population = int(ceil(parent.population / 2.f)); this.stringCode = Species::mutate(parent.stringCode); - this.speciesMembraneType = parent.speciesMembraneType; + + if (GetEngine().GetRandom().GetNumber(0,100)<=20){ + if (GetEngine().GetRandom().GetNumber(0,100) < 50){ + this.speciesMembraneType = MEMBRANE_TYPE::MEMBRANE; + } + else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { + this.speciesMembraneType = MEMBRANE_TYPE::DOUBLEMEMBRANE; + this.colour.W = randomOpacityChitin();; + } + else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { + this.speciesMembraneType = MEMBRANE_TYPE::WALL; + } + else { + this.speciesMembraneType = MEMBRANE_TYPE::CHITIN; + this.colour.W = randomOpacityChitin(); + } + } + else { + this.speciesMembraneType = parent.speciesMembraneType; + } + commonConstructor(world); @@ -502,21 +355,7 @@ class Species{ this.opportunism = clamp(this.opportunism, 0.0f, MAX_SPECIES_OPPORTUNISM); } - private void initializeBehavior(){ - // Variables used in AI to determine general behavior - this.aggression = GetEngine().GetRandom().GetFloat(0.0f, - MAX_SPECIES_AGRESSION); - this.fear = GetEngine().GetRandom().GetFloat(0.0f, - MAX_SPECIES_FEAR); - this.activity = GetEngine().GetRandom().GetFloat(0.0f, - MAX_SPECIES_ACTIVITY); - this.focus = GetEngine().GetRandom().GetFloat(0.0f, - MAX_SPECIES_FOCUS); - this.opportunism = GetEngine().GetRandom().GetFloat(0.0f, - MAX_SPECIES_OPPORTUNISM); - } - - private void mutateBehavior(Species@ parent){ + private void mutateBehavior(SpeciesComponent@ parent){ // Variables used in AI to determine general behavior mutate these this.aggression = parent.aggression+GetEngine().GetRandom().GetFloat( MIN_SPECIES_PERSONALITY_MUTATION, MAX_SPECIES_PERSONALITY_MUTATION); @@ -742,92 +581,7 @@ class Species{ BACTERIA_SPAWN_RADIUS); } - void generateBacteria(CellStageWorld@ world) - { - // Chance they spawn with flagella - int bacterialFlagellumChance = 10; - - name = randomBacteriaName(); - genus = generateNameSection(); - epithet = generateNameSection(); - - initializeBehavior(); - - // Bacteria are tiny, start off with a max of 3 hexes (maybe - // we should start them all off with just one? ) - auto stringSize = GetEngine().GetRandom().GetNumber(0, 2); - if (GetEngine().GetRandom().GetNumber(0, 100) <= 10){ - // Generate an extremely large cell, players never really had enough challenge - LOG_INFO("Generating EPIC bacterium"); - stringSize = GetEngine().GetRandom().GetNumber(MIN_INITIAL_EPIC_BACTERIA_LENGTH, - MAX_INITIAL_EPIC_BACTERIA_LENGTH); - } - - // Bacteria - // 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 protein for that aswell - switch(GetEngine().GetRandom().GetNumber(1,8)) - { - case 1: - stringCode = getOrganelleDefinition("protoplasm").gene; - break; - case 2: - stringCode = getOrganelleDefinition("metabolosome").gene; - break; - case 3: - stringCode = getOrganelleDefinition("chromatophors").gene; - break; - case 4: - stringCode = getOrganelleDefinition("oxytoxyProteins").gene; - break; - case 5: - stringCode = getOrganelleDefinition("chemoSynthisizingProteins").gene; - break; - case 6: - stringCode = getOrganelleDefinition("nitrogenase").gene; - break; - case 7: - stringCode = getOrganelleDefinition("rusticyanin").gene; - stringCode += getOrganelleDefinition("protoplasm").gene; - break; - default: - stringCode = getOrganelleDefinition("protoplasm").gene; - break; - } - - string chosenType= stringCode; - for(int i = 0; i < stringSize; i++){ - this.stringCode += chosenType; - } - - // Allow bacteria to sometimes start with a flagella instead of having to evolve it - this.colour = getRightColourForSpecies(); - if (GetEngine().GetRandom().GetNumber(1,100) <= bacterialFlagellumChance) - { - this.stringCode+=getOrganelleDefinition("flagellum").gene; - } - if (GetEngine().GetRandom().GetNumber(0,100) < 50) { - this.speciesMembraneType = MEMBRANE_TYPE::WALL; - - } else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { - this.speciesMembraneType = MEMBRANE_TYPE::CHITIN; - this.colour.W = randomOpacityChitin(); - - } else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { - this.speciesMembraneType = MEMBRANE_TYPE::MEMBRANE; - - } else { - this.speciesMembraneType = MEMBRANE_TYPE::DOUBLEMEMBRANE; - this.colour.W = randomOpacityChitin(); - } - - commonConstructor(world); - this.setupSpawn(world); - } - - void mutateBacteria(Species@ parent, CellStageWorld@ world) + void mutateBacteria(SpeciesComponent@ parent, CellStageWorld@ world) { name = randomBacteriaName(); genus = parent.genus; @@ -874,11 +628,27 @@ class Species{ parent.colour.W + randomMutationColourChannel()); } - this.population = int(floor(parent.population / 2.f)); - parent.population = int(ceil(parent.population / 2.f)); - this.stringCode = Species::mutateProkaryote(parent.stringCode); - this.speciesMembraneType = parent.speciesMembraneType; + + if (GetEngine().GetRandom().GetNumber(0,100)<=20){ + if (GetEngine().GetRandom().GetNumber(0,100) < 50){ + this.speciesMembraneType = MEMBRANE_TYPE::MEMBRANE; + } + else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { + this.speciesMembraneType = MEMBRANE_TYPE::DOUBLEMEMBRANE; + this.colour.W = randomOpacityChitin();; + } + else if (GetEngine().GetRandom().GetNumber(0,100) < 50) { + this.speciesMembraneType = MEMBRANE_TYPE::WALL; + } + else { + this.speciesMembraneType = MEMBRANE_TYPE::CHITIN; + this.colour.W = randomOpacityChitin(); + } + } + else { + this.speciesMembraneType = parent.speciesMembraneType; + } commonConstructor(world); this.setupSpawn(world); @@ -987,9 +757,6 @@ class SpeciesSystem : ScriptSystem{ { @this.world = cast(w); assert(this.world !is null, "SpeciesSystem expected CellStageWorld"); - - // This is needed to actually have AI species in the world - createNewEcoSystem(); } void Release() @@ -1014,6 +781,7 @@ class SpeciesSystem : ScriptSystem{ LOG_INFO("Processing Auto-evo Step"); this.timeSinceLastCycle -= SPECIES_SIM_INTERVAL; bool ranEventThisStep=false; + countSpecies(); // Every 8 steps or so do a cambrian explosion style // Event, this should increase variablility significantly if(GetEngine().GetRandom().GetNumber(0, 200) <= 25){ @@ -1094,15 +862,10 @@ class SpeciesSystem : ScriptSystem{ // To prevent ridiculous population numbers currentSpecies.population=MAX_POP_SIZE; auto oldPop = currentSpecies.population; - auto newSpecies = Species(currentSpecies, world, + auto speciesComp = world.GetComponent_SpeciesComponent(currentSpecies.templateEntity); + auto newSpecies = Species(speciesComp, world, currentSpecies.isBacteria); - if (newSpecies.isBacteria){ - currentBacteriaAmount+=1; - } - else{ - currentEukaryoteAmount+=1; - } ranSpeciesEvent=true; species.insertLast(newSpecies); LOG_INFO("Species " + currentSpecies.name + @@ -1117,14 +880,14 @@ class SpeciesSystem : ScriptSystem{ // To prevent ridiculous population numbers currentSpecies.population=MAX_POP_SIZE; - auto newSpecies = Species(currentSpecies, world, + currentSpecies.population = int(floor(currentSpecies.population / 2.f)); + + auto speciesComp = world.GetComponent_SpeciesComponent(currentSpecies.templateEntity); + auto newSpecies = Species(speciesComp, world, currentSpecies.isBacteria); - if (newSpecies.isBacteria){ - currentBacteriaAmount+=1; - } - else{ - currentEukaryoteAmount+=1; - } + + newSpecies.population = int(ceil(currentSpecies.population)); + species.insertLast(newSpecies); LOG_INFO("Species " + currentSpecies.name + " split off a child species:" + newSpecies.name); @@ -1137,30 +900,8 @@ class SpeciesSystem : ScriptSystem{ LOG_INFO("Species " + currentSpecies.name + " went extinct"); currentSpecies.extinguish(); species.removeAt(index); - // Tweak numbers here - if (currentSpecies.isBacteria){ - currentBacteriaAmount-=1; - } - else{ - currentEukaryoteAmount-=1; - } } } - - // These are kind of arbitray, we should pronbabbly make it less arbitrary - // New species - while(currentEukaryoteAmount < MIN_SPECIES){ - LOG_INFO("Creating new species as there's too few"); - createSpecies(); - currentEukaryoteAmount++; - } - - // New bacteria - while(currentBacteriaAmount < MIN_BACTERIA){ - LOG_INFO("Creating new prokaryote as there's too few"); - createBacterium(); - currentBacteriaAmount++; - } } void Clear(){} @@ -1178,6 +919,15 @@ class SpeciesSystem : ScriptSystem{ } } + void splitSpecies(SpeciesComponent@ currentSpecies){ + auto newSpecies = Species(currentSpecies, world, + currentSpecies.isBacteria); + + int population = GetEngine().GetRandom().GetNumber(600,INITIAL_POPULATION); + newSpecies.population=GetEngine().GetRandom().GetNumber(600,INITIAL_POPULATION); + species.insertLast(newSpecies); + } + int getSpeciesPopulation(string speciesName) { auto numberOfSpecies = species.length(); @@ -1225,31 +975,17 @@ class SpeciesSystem : ScriptSystem{ } } - //! Adds a new AI species - private void createSpecies() - { - auto newSpecies = Species(world, false); - species.insertLast(newSpecies); - } - - //! Adds a new AI bacterium - private void createBacterium() - { - auto newSpecies = Species(world, true); - species.insertLast(newSpecies); - } - - void createNewEcoSystem() + void countSpecies() { - for(int i = 0; i < INITIAL_SPECIES; i++){ - createSpecies(); - currentEukaryoteAmount++; - } - - //generate bacteria aswell - for(int i = 0; i < INITIAL_BACTERIA; i++){ - createBacterium(); - currentBacteriaAmount++; + currentBacteriaAmount=0; + currentEukaryoteAmount=0; + for(uint i = 0; i < species.length(); i++){ + if (species[i].isBacteria){ + currentBacteriaAmount++; + } + else { + currentEukaryoteAmount++; + } } } @@ -1478,7 +1214,7 @@ ObjectID createSpecies(CellStageWorld@ world, const string &in name, organelle.rotation)); } - return createSpecies(world, name, "Player", "Species", convertedOrganelles, + return createSpecies(world, name, fromTemplate.genus, fromTemplate.epithet, convertedOrganelles, fromTemplate.colour, fromTemplate.isBacteria, fromTemplate.speciesMembraneType, fromTemplate.compounds, 100.0f, 100.0f, 100.0f, 200.0f, 100.0f); } diff --git a/src/microbe_stage/species.cpp b/src/microbe_stage/species.cpp index 0923f1f82f1..9b6fd7ce228 100644 --- a/src/microbe_stage/species.cpp +++ b/src/microbe_stage/species.cpp @@ -13,6 +13,9 @@ Species::Species(Json::Value value) // cast an int as a member of the enum (eg (0,1,2)(membrane,wall,chitin)) speciesMembraneType = static_cast(value["membranetype"].asInt()); + genus = value["genus"].asString(); + epithet = value["epithet"].asString(); + population = value["population"].asInt(); // Setting the cloud colour. float r = value["colour"]["r"].asFloat(); diff --git a/src/microbe_stage/species.h b/src/microbe_stage/species.h index 3aa53d0ea3d..67e53c0aca5 100644 --- a/src/microbe_stage/species.h +++ b/src/microbe_stage/species.h @@ -25,6 +25,7 @@ class Species : public RegistryType { double opportunism; double activity; double focus; + int population; MEMBRANE_TYPE speciesMembraneType; std::map startingCompounds; std::map organelles; // TODO: get a position as the key. diff --git a/src/microbe_stage/species_component.h b/src/microbe_stage/species_component.h index 53132e8f888..1a32d7d4017 100644 --- a/src/microbe_stage/species_component.h +++ b/src/microbe_stage/species_component.h @@ -33,6 +33,12 @@ class SpeciesComponent : public Leviathan::Component { std::string name; std::string genus; std::string epithet; + + // TODO: + // I really like this but we probabbly will have to remove it later since it + // doesnt code for location The only reason im leaving this here is because + // i dont feel like changing the mutation code at the moment + std::string stringCode; double aggression; double fear; double activity; diff --git a/src/scripting/script_initializer.cpp b/src/scripting/script_initializer.cpp index 43d34ec9d5b..7ae34f5c2a7 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -892,11 +892,15 @@ bool ANGELSCRIPT_REGISTERFAIL; } + if(engine->RegisterObjectProperty("SpeciesComponent", "string stringCode", + asOFFSET(SpeciesComponent, stringCode)) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } + if(engine->RegisterObjectProperty("SpeciesComponent", "Float4 colour", asOFFSET(SpeciesComponent, colour)) < 0) { ANGELSCRIPT_REGISTERFAIL; } - if(engine->RegisterObjectProperty("SpeciesComponent", "string name", asOFFSET(SpeciesComponent, name)) < 0) { ANGELSCRIPT_REGISTERFAIL;