From 68def4ecd5b93a540fc65e8686912c84987ae4c6 Mon Sep 17 00:00:00 2001 From: Dak2896 Date: Fri, 22 Feb 2019 00:18:15 +0100 Subject: [PATCH] Work on player cell size and physics matching bacteria by Dak2896 starting cell bacteria grab render node of cell cell size update - starting cell is like other prokaryotic - micorbe use compund physics instead spheres - size of player species change from prokaryotic to eukariotic cell Update setup.as Update organelle.as restore * 2 in organelle physics Update microbe_editor.as remove space Update organelle.as remove useless space RunCodeFormatting Offset for physic organelles shape - Each organelle has different physics depending if species is bacteria or not Update organelle physycis functions - hexSize and translation depending on presence or not of nucleus RunCodeFormatting - update physics render size and translation parameter - all microbe fit with organelle instead having a sphere - player cell start as microbe - add nucleus upgrade render and physics to same of other eurayotic RunCodeFormatting update all - remove useless restoreOrganelleLayout call - render of offset is no more divided - translation is not divide Fix blank line style fix style fix fix species parameter --- scripts/microbe_stage/configs.as | 2 +- .../microbe_editor/microbe_editor.as | 20 ++++++++++++++++++- scripts/microbe_stage/microbe_operations.as | 16 ++------------- scripts/microbe_stage/organelle.as | 14 +++++++++++-- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/scripts/microbe_stage/configs.as b/scripts/microbe_stage/configs.as index 7dd26f29acd..138fd2aaa15 100644 --- a/scripts/microbe_stage/configs.as +++ b/scripts/microbe_stage/configs.as @@ -360,7 +360,7 @@ const dictionary STARTER_MICROBES = { OrganelleTemplatePlaced("cytoplasm", 0, 0, 0) }, Float4(1, 1, 1, 1), - false, + 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..47cf5b79bfc 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,21 @@ class MicrobeEditor{ templateOrganelles = newOrganelles; + // Grab render of player cell + auto node = world.GetComponent_RenderNode(player); + + //! Change player species cell size depending on presence or not of nucleus + 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..f43a3fa57d8 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -834,6 +834,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 +860,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 +887,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 +907,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..641b852e2ab 100644 --- a/scripts/microbe_stage/organelle.as +++ b/scripts/microbe_stage/organelle.as @@ -683,11 +683,21 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{ auto species = MicrobeOperations::getSpeciesComponent(world, microbeEntity); if (species !is null){ this.speciesColour = species.colour; - } + } // Our coordinates are already set when this is called // so just cache this this.cartesianPosition = Hex::axialToCartesian(q, r); + // Calculate hexSize depending if species is baceteria or not + // Scaling parameters that we need to scale + double hexSize = 0; + if(species.isBacteria) { + this.cartesianPosition /= 2; + hexSize = 0.375; + } + else + hexSize = HEX_SIZE; + assert(organelleEntity == NULL_OBJECT, "PlacedOrganelle already had an entity"); Float3 offset = organelle.calculateCenterOffset(); @@ -733,7 +743,7 @@ class PlacedOrganelle : SpeciesStoredOrganelleType{ // Create the matrix with the offset Ogre::Matrix4 hexFinalOffset(translation); - PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(HEX_SIZE * 2); + PhysicsShape@ hexCollision = world.GetPhysicalWorld().CreateSphere(hexSize * 2); if(hexCollision is null) assert(false, "Failed to create Sphere for hex");