diff --git a/scripts/microbe_stage/configs.as b/scripts/microbe_stage/configs.as index 3930895c47a..6ec8c24bf70 100644 --- a/scripts/microbe_stage/configs.as +++ b/scripts/microbe_stage/configs.as @@ -112,7 +112,7 @@ const auto FLAGELLA_BASE_FORCE = 0.7f; const auto CELL_BASE_THRUST = 1.6f; // is set by this and modified by applyCellMovement like the player later -const auto AI_BASE_MOVEMENT = 1.6f; +const auto AI_BASE_MOVEMENT = 1.0f; const auto AI_FOCUSED_MOVEMENT = 1.0f; //! The drag force is calculated by taking the current velocity and multiplying it by this. diff --git a/scripts/microbe_stage/microbe_operations.as b/scripts/microbe_stage/microbe_operations.as index 9b5902f25b5..eb69cdac8b1 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -895,10 +895,8 @@ bool validPlacement(CellStageWorld@ world, ObjectID microbeEntity, const Organel return touching; } -// speciesName decides the template to use, while individualName is -// used for referencing the instance ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in speciesName, - bool aiControlled) + bool aiControlled, bool partOfColony = false) { assert(world !is null); assert(speciesName != ""); @@ -906,10 +904,9 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie if(pos.Y != 0) LOG_WARNING("spawnMicrobe: spawning at y-coordinate: " + pos.Y); - // Create microbeEntity with correct template, physics and species name auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName, - // in_editor + //in editor false); // Teleport the cell to the right position @@ -918,6 +915,10 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie microbePos.Marked = true; auto physics = world.GetComponent_Physics(microbeEntity); + + auto speciesEntity = findSpeciesEntityByName(world, speciesName); + auto species = world.GetComponent_SpeciesComponent(speciesEntity); + physics.JumpTo(microbePos); // Try setting the position immediately as well (as otherwise it @@ -927,58 +928,18 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie if(IsInGraphicalMode()) node.Node.setPosition(pos); - auto speciesEntity = findSpeciesEntityByName(world, speciesName); - auto species = world.GetComponent_SpeciesComponent(speciesEntity); - - // TODO: Why is this here with the separate spawnBacteria function existing? - // Bacteria get scaled to half size + // Checks if the cell is a bacteria/prokaryote if(species.isBacteria){ node.Scale = Float3(0.5, 0.5, 0.5); node.Marked = true; - } - - return microbeEntity; -} - -// TODO: merge common parts with spawnMicrobe -ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speciesName, - bool aiControlled, bool partOfColony) -{ - assert(world !is null); - assert(speciesName != ""); - - if(pos.Y != 0) - LOG_WARNING("spawnBacteria: spawning at y-coordinate: " + pos.Y); - // Create microbeEntity with correct template, physics and species name - auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName, - // in_editor - false); - - // Teleport the cell to the right position - auto microbePos = world.GetComponent_Position(microbeEntity); - microbePos._Position = pos; - microbePos.Marked = true; - - auto physics = world.GetComponent_Physics(microbeEntity); - physics.Body.SetMass(physics.Body.Mass * 10); - physics.JumpTo(microbePos); - - // Try setting the position immediately as well (as otherwise it - // takes until the next tick for this to take effect) - auto node = world.GetComponent_RenderNode(microbeEntity); - node.Node.setPosition(pos); - - // Bacteria get scaled to half size - node.Scale = Float3(0.5, 0.5, 0.5); - node.Marked = true; - - // 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 - // directly spawned give a spawned component - if (partOfColony){ - world.Create_SpawnedComponent(microbeEntity, BACTERIA_SPAWN_RADIUS * + // 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 + // directly spawned give a spawned component + if (partOfColony){ + world.Create_SpawnedComponent(microbeEntity, BACTERIA_SPAWN_RADIUS * BACTERIA_SPAWN_RADIUS); + } } return microbeEntity; diff --git a/scripts/microbe_stage/species_system.as b/scripts/microbe_stage/species_system.as index b0d0dc0ccd0..6eb50d18349 100644 --- a/scripts/microbe_stage/species_system.as +++ b/scripts/microbe_stage/species_system.as @@ -337,66 +337,72 @@ class Species{ { this.isBacteria = parent.isBacteria; LOG_INFO("Gene Code Is:"+parent.stringCode); + if (!isBacteria) { name = randomSpeciesName(); + } + else { + name = randomBacteriaName(); + } - //Mutate the epithet - if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ - epithet = mutateWord(parent.epithet); - } - else { + //Mutate the epithet + if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ + epithet = mutateWord(parent.epithet); + } + else { epithet = generateNameSection(); - } - genus = parent.genus; - colour=parent.colour; - mutateBehavior(parent); + } + genus = parent.genus; + colour=parent.colour; + mutateBehavior(parent); - // Make sure not over or under our scales - cleanPersonality(); + // Make sure not over or under our scales + cleanPersonality(); - // Subtly mutate color - this.colour = Float4(parent.colour.X + randomMutationColourChannel(), - parent.colour.Y + randomMutationColourChannel(), - parent.colour.Z + randomMutationColourChannel(), - parent.colour.W + randomMutationColourChannel()); + // Subtly mutate color + this.colour = Float4(parent.colour.X + randomMutationColourChannel(), + parent.colour.Y + randomMutationColourChannel(), + parent.colour.Z + randomMutationColourChannel(), + parent.colour.W + randomMutationColourChannel()); - LOG_INFO("X:"+parent.colour.X+" Y:"+parent.colour.Y+" Z:"+parent.colour.Z+" W:"+parent.colour.W); - LOG_INFO("X:"+colour.X+" Y:"+colour.Y+" Z:"+colour.Z+" W:"+colour.W); - // Chance of new color needs to be low - if (GetEngine().GetRandom().GetNumber(0,100) <= MUTATION_CHANGE_GENUS) + LOG_INFO("X:"+parent.colour.X+" Y:"+parent.colour.Y+" Z:"+parent.colour.Z+" W:"+parent.colour.W); + LOG_INFO("X:"+colour.X+" Y:"+colour.Y+" Z:"+colour.Z+" W:"+colour.W); + // Chance of new color needs to be low + if (GetEngine().GetRandom().GetNumber(0,100) <= MUTATION_CHANGE_GENUS) + { + if (!isBacteria) { LOG_INFO("New Genus"); - // We can do more fun stuff here later - if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ - genus = mutateWord(parent.genus); - } - else { - genus = generateNameSection(); - } - // New genuses get to double their color change - this.colour = Float4(parent.colour.X + randomMutationColourChannel(), - parent.colour.Y + randomMutationColourChannel(), - parent.colour.Z + randomMutationColourChannel(), - parent.colour.W + randomMutationColourChannel()); + }else { + LOG_INFO("New Genus of Bacteria"); + } + + // We can do more fun stuff here later + if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ + genus = mutateWord(parent.genus); } + else { + genus = generateNameSection(); + } + // New genuses get to double their color change + this.colour = Float4(parent.colour.X + randomMutationColourChannel(), + parent.colour.Y + randomMutationColourChannel(), + parent.colour.Z + randomMutationColourChannel(), + parent.colour.W + randomMutationColourChannel()); + } - this.stringCode = mutateMicrobe(parent.stringCode,false); + this.stringCode = mutateMicrobe(parent.stringCode,isBacteria); - generateMembranes(parent); + generateMembranes(parent); - commonConstructor(world); + commonConstructor(world); - this.setupSpawn(world); - } - else - { - mutateBacteria(parent,world); - } + this.setupSpawn(world); } private void generateMembranes(SpeciesComponent@ parent){ @@ -509,7 +515,7 @@ class Species{ //dont spawn them on top of each other because it //causes them to bounce around and lag - MicrobeOperations::spawnBacteria(world, pos + curSpawn, this.name, true, true); + MicrobeOperations::spawnMicrobe(world, pos + curSpawn, this.name, true, true); curSpawn = curSpawn + Float3(GetEngine().GetRandom().GetNumber(-7, 7), 0, GetEngine().GetRandom().GetNumber(-7, 7)); } @@ -528,7 +534,7 @@ class Species{ // Dont spawn them on top of each other because it // Causes them to bounce around and lag - MicrobeOperations::spawnBacteria(world, pos+curSpawn, this.name, true, true); + MicrobeOperations::spawnMicrobe(world, pos+curSpawn, this.name, true, true); curSpawn = curSpawn + Float3(lineX + GetEngine().GetRandom().GetNumber(-2, 2), 0, linez + GetEngine().GetRandom().GetNumber(-2, 2)); } @@ -560,7 +566,7 @@ class Species{ // Add a litlle organicness to the look curSpawn.Z += GetEngine().GetRandom().GetNumber(-2, 2); - MicrobeOperations::spawnBacteria(world, pos + curSpawn, this.name, + MicrobeOperations::spawnMicrobe(world, pos + curSpawn, this.name, true, true); } } @@ -573,7 +579,7 @@ class Species{ curSpawn.Z += GetEngine().GetRandom().GetNumber(5,7); // Add a litlle organicness to the look curSpawn.X += GetEngine().GetRandom().GetNumber(-2,2); - MicrobeOperations::spawnBacteria(world, pos+curSpawn, this.name, true, + MicrobeOperations::spawnMicrobe(world, pos+curSpawn, this.name, true, true); } } @@ -590,7 +596,7 @@ class Species{ curSpawn.X -= GetEngine().GetRandom().GetNumber(5, 7); // Add a litlle organicness to the look curSpawn.Z -= GetEngine().GetRandom().GetNumber(-2, 2); - MicrobeOperations::spawnBacteria(world, pos + curSpawn, this.name, + MicrobeOperations::spawnMicrobe(world, pos + curSpawn, this.name, true, true); } } @@ -606,7 +612,7 @@ class Species{ curSpawn.Z -= GetEngine().GetRandom().GetNumber(5, 7); //add a litlle organicness to the look curSpawn.X -= GetEngine().GetRandom().GetNumber(-2, 2); - MicrobeOperations::spawnBacteria(world, pos+curSpawn, this.name, true, + MicrobeOperations::spawnMicrobe(world, pos+curSpawn, this.name, true, true); } } @@ -622,14 +628,14 @@ class Species{ // Causes them to bounce around and lag curSpawn.Z += GetEngine().GetRandom().GetNumber(5, 7); curSpawn.X += GetEngine().GetRandom().GetNumber(5, 7); - MicrobeOperations::spawnBacteria(world, pos + curSpawn, this.name, + MicrobeOperations::spawnMicrobe(world, pos + curSpawn, this.name, true, true); } } } } - return MicrobeOperations::spawnBacteria(world, pos, this.name, true, false); + return MicrobeOperations::spawnMicrobe(world, pos, this.name, true); } // Sets up the spawn of the species @@ -657,63 +663,6 @@ class Species{ BACTERIA_SPAWN_RADIUS); } - void mutateBacteria(SpeciesComponent@ parent, CellStageWorld@ world) - { - name = randomBacteriaName(); - genus = parent.genus; - colour=parent.colour; - //Mutate the epithet - if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ - epithet = mutateWord(parent.epithet); - } - else { - epithet = generateNameSection(); - } - - - mutateBehavior(parent); - - // Make sure not over or under our scales - cleanPersonality(); - - // Subtly mutate color - this.colour = Float4(parent.colour.X + randomMutationColourChannel(), - parent.colour.Y + randomMutationColourChannel(), - parent.colour.Z + randomMutationColourChannel(), - parent.colour.W + randomMutationColourChannel()); - - - LOG_INFO("X:"+parent.colour.X+" Y:"+parent.colour.Y+" Z:"+parent.colour.Z+" W:"+parent.colour.W); - LOG_INFO("X:"+colour.X+" Y:"+colour.Y+" Z:"+colour.Z+" W:"+colour.W); - - if (GetEngine().GetRandom().GetNumber(0,100) <= MUTATION_CHANGE_GENUS) - { - LOG_INFO("New Genus of bacteria"); - - // We can do more fun stuff here later - //Mutate the genus - if (GetEngine().GetRandom().GetNumber(0, 100) < MUTATION_WORD_EDIT){ - genus = mutateWord(parent.genus); - } - else { - genus = generateNameSection(); - } - - // New genuses get to double color change - this.colour = Float4(parent.colour.X + randomMutationColourChannel(), - parent.colour.Y + randomMutationColourChannel(), - parent.colour.Z + randomMutationColourChannel(), - parent.colour.W + randomMutationColourChannel()); - } - - this.stringCode = mutateMicrobe(parent.stringCode,true); - - generateMembranes(parent); - - commonConstructor(world); - this.setupSpawn(world); - } - //! updates the population count of the species void updatePopulation() {