From 6879a618a138db654dbb03b1622077e3ef2ee7cf Mon Sep 17 00:00:00 2001 From: Dak2896 Date: Tue, 15 Jan 2019 15:02:11 +0100 Subject: [PATCH] nucleus in editor, locked organelle, gui change #677 #678 #679 (#709) * nucleus in editor, locked organelle, gui change * fix function editor * clang format fix * fix space at line 196 * fix function onSelectNewOrganelle from common.isEngine to common.isInEngine * span space * second span space * space in microbe editor * restore GUI function, update editor function I restore GUI as was, the check is made inside the listener. I just notice that the editor if statment wasn't correct, * fix bracket sapce * fix some spaces and usless blank lines * fixes if statment remove jquery, use plain javascript * fix space * fix brackets * removed jquery line * fix clang format line 271 * update check for UpdateGuiButtons function - button are disabled only if weren't already disabled - same thing for enabling. * fix format * move comment * Update microbe_editor.mjs * update comment for select button * update comment of updateSelectedOrganelle Better explanation for updateSelectedOrganelle function, introducing the concept of button status made in updateGuiButtons * delete usless check delete usless and branch of if statment in updateSelectedOrganelle function * restore comment * update functions and gui text - delete select removed class - change toltip text according to one more scientifically corret * restore completly old function * nucleus button has disabled status - I just forgot that this could be necessary, so nucleus is prevent to be insert more times by guy, and if bypassed by changing the source code there is still the check in as files * Nucleus name in editor - i revert htis changment before commit, my bad. * Rotation for nucleus organelle. - In renderHighlightedOrganelle method if organelle that is going to be placed is nucleus rotation parameter change to 180 degrees. - in _addOrganelle method is rotating again in order to have the same rotation of render. * Nucleus rotation parameters - removed manual rotation in prodecural_microbe.as - added one time rotation in nucleus_organelle.as Now nucleus is in right position both for microbe controleld by IA and player one, without any modification in editor * clang format fix * nucleus rotation for npc I do not why it works, i also try put 180 degreesin that line and in inserLast organelle few lines later another 180 and i obtain same result * editor name --- scripts/gui/microbe_editor.mjs | 40 ++++++++++++++++++- scripts/gui/thrive_gui.html | 16 ++++++-- scripts/gui/thrive_style.css | 9 +++++ scripts/microbe_stage/configs.as | 4 +- .../microbe_editor/microbe_editor.as | 33 +++++++++++++++ .../organelle_components/nucleus_organelle.as | 4 +- scripts/microbe_stage/organelle_table.as | 2 +- scripts/microbe_stage/procedural_microbes.as | 4 +- 8 files changed, 99 insertions(+), 13 deletions(-) diff --git a/scripts/gui/microbe_editor.mjs b/scripts/gui/microbe_editor.mjs index cf08ff04127..408bc803cfc 100644 --- a/scripts/gui/microbe_editor.mjs +++ b/scripts/gui/microbe_editor.mjs @@ -63,6 +63,10 @@ const organelleSelectionElements = [ { element: document.getElementById("addChromatophor"), organelle: "chromatophors" + }, + { + element: document.getElementById("addNucleus"), + organelle: "nucleus" } // AddPilus @@ -126,7 +130,9 @@ export function setupMicrobeEditor(){ element.element.addEventListener("click", (event) => { event.stopPropagation(); - onSelectNewOrganelle(element.organelle); + if(!element.element.classList.contains("DisabledButton")) { + onSelectNewOrganelle(element.organelle); + } }, true); } @@ -193,6 +199,11 @@ export function setupMicrobeEditor(){ // Event for restoring the microbe GUI Leviathan.OnGeneric("MicrobeEditorExited", doExitMicrobeEditor); + // Event for update buttons depending on presence or not of nucleus + Leviathan.OnGeneric("MicrobeEditorNucleusIsPresent", (event, vars) => { + updateGuiButtons(vars.nucleus); + }); + } else { updateSelectedOrganelle("cytoplasm"); } @@ -287,6 +298,33 @@ function updateGeneration(generation){ generation; } +//! Updates buttons status depending on presence of nucleus in GUI +function updateGuiButtons(isNucleusPresent){ + + if(!isNucleusPresent && + !document.getElementById("addMitochondrion").classList.contains("DisabledButton")) { + + document.getElementById("addNucleus").classList.remove("DisabledButton"); + document.getElementById("addMitochondrion").classList.add("DisabledButton"); + document.getElementById("addChloroplast").classList.add("DisabledButton"); + document.getElementById("addChemoplast").classList.add("DisabledButton"); + document.getElementById("addNitrogenFixingPlastid").classList.add("DisabledButton"); + document.getElementById("addVacuole").classList.add("DisabledButton"); + document.getElementById("addToxinVacuole").classList.add("DisabledButton"); + + } else if(isNucleusPresent && + document.getElementById("addMitochondrion").classList.contains("DisabledButton")) { + + document.getElementById("addNucleus").classList.add("DisabledButton"); + document.getElementById("addMitochondrion").classList.remove("DisabledButton"); + document.getElementById("addChloroplast").classList.remove("DisabledButton"); + document.getElementById("addChemoplast").classList.remove("DisabledButton"); + document.getElementById("addNitrogenFixingPlastid").classList.remove("DisabledButton"); + document.getElementById("addVacuole").classList.remove("DisabledButton"); + document.getElementById("addToxinVacuole").classList.remove("DisabledButton"); + } +} + //! Updates generation points in GUI function updateSpeed(speed){ document.getElementById("speedLabel").textContent = diff --git a/scripts/gui/thrive_gui.html b/scripts/gui/thrive_gui.html index c46a84ad208..0bea23fd77e 100644 --- a/scripts/gui/thrive_gui.html +++ b/scripts/gui/thrive_gui.html @@ -398,7 +398,7 @@ A space or vesicle within the cytoplasm of a cell, enclosed by a membrane and used to hold compounds
Vacuole
30 MP - + Toxin Vacuole

Cost: 80 mutation points

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. @@ -412,10 +412,18 @@ Chemoplast

Cost: 40 mutation points

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. -
+
+ 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. +
Chemoplast
40 MP + + + Nucleus

Cost: 100 mutation points

+ Performs Process: Eukaryote Evolution

+ Allows for synthesis of RNA, MRNA, allows cell to evolve membrane bound organelles. +
+
+
Nucleus
100 MP Nitrogen Fixing Plastid

Cost: 80 mutation points

diff --git a/scripts/gui/thrive_style.css b/scripts/gui/thrive_style.css index 05c14baa92b..be1a60e5c95 100644 --- a/scripts/gui/thrive_style.css +++ b/scripts/gui/thrive_style.css @@ -1105,6 +1105,15 @@ video { top: 15px; } +#NucleusIcon { + position: relative; + left: calc(50% - 30px); + width: 60px; + height: 60px; + background-size: contain; + background-image: url("../../Textures/gui/bevel/NucleusIcon.png"); +} + #CytoplasmIcon { position: relative; left: calc(50% - 30px); diff --git a/scripts/microbe_stage/configs.as b/scripts/microbe_stage/configs.as index a7ab339d2e5..ccf73f1a4cf 100644 --- a/scripts/microbe_stage/configs.as +++ b/scripts/microbe_stage/configs.as @@ -347,9 +347,7 @@ const dictionary STARTER_MICROBES = { {"oxytoxy", InitialCompound(0)} }, { - OrganelleTemplatePlaced("nucleus", 0, 0, 180), - OrganelleTemplatePlaced("cytoplasm", 1, 1, 0), - OrganelleTemplatePlaced("cytoplasm", -1, 2, 0) + OrganelleTemplatePlaced("cytoplasm", 0, 0, 0) }, Float4(1, 1, 1, 1), false, diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor.as b/scripts/microbe_stage/microbe_editor/microbe_editor.as index 27739eba152..79d4c320f65 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor.as @@ -51,6 +51,7 @@ class MicrobeEditor{ placementFunctions = { {"nucleus", PlacementFunctionType(this.createNewMicrobe)}, + {"nucleus", PlacementFunctionType(this.addOrganelle)}, {"flagellum", PlacementFunctionType(this.addOrganelle)}, {"cytoplasm", PlacementFunctionType(this.addOrganelle)}, {"mitochondrion", PlacementFunctionType(this.addOrganelle)}, @@ -69,6 +70,7 @@ class MicrobeEditor{ //! This is called each time the editor is entered so this needs to properly reset state void init() { + updateGuiButtonStatus(checkIsNucleusPresent()); gridSceneNode = hudSystem.world.CreateEntity(); auto node = hudSystem.world.Create_RenderNode(gridSceneNode); node.Scale = Float3(HEX_SIZE, 1, HEX_SIZE); @@ -228,6 +230,12 @@ class MicrobeEditor{ private void _addOrganelle(PlacedOrganelle@ organelle) { + // 1 - you put nucleus but you already have it + // 2 - you put organelle that need nucleus and you don't have it + if((organelle.organelle.name == "nucleus" && checkIsNucleusPresent()) || + (organelle.organelle.prokaryoteChance == 0 && !checkIsNucleusPresent()) && organelle.organelle.chanceToCreate != 0 ) + return; + EditorAction@ action = EditorAction(organelle.organelle.mpCost, // redo function(EditorAction@ action, MicrobeEditor@ editor){ @@ -256,6 +264,9 @@ class MicrobeEditor{ LOG_INFO("Placing organelle '" + organelle.organelle.name + "' at: " + organelle.q + ", " + organelle.r); editor.editedMicrobe.insertLast(organelle); + + // send to gui current status of cell + editor.updateGuiButtonStatus(editor.checkIsNucleusPresent()); }, // undo function(EditorAction@ action, MicrobeEditor@ editor){ @@ -274,6 +285,9 @@ class MicrobeEditor{ } } + + // send to gui current status of cell + editor.updateGuiButtonStatus(editor.checkIsNucleusPresent()); }); @action.data["organelle"] = organelle; @@ -562,6 +576,25 @@ class MicrobeEditor{ // LOG_WRITE("Mouse hex: " + qr + ", " + rr); } + bool checkIsNucleusPresent() + { + for(uint i = 0; i < editedMicrobe.length(); ++i){ + auto organelle = cast(editedMicrobe[i]); + if (organelle.organelle.name == "nucleus"){ + return true; + } + } + return false; + } + + void updateGuiButtonStatus(bool nucleusIsPresent){ + + GenericEvent@ event = GenericEvent("MicrobeEditorNucleusIsPresent"); + NamedVars@ vars = event.GetNamedVars(); + + vars.AddValue(ScriptSafeVariableBlock("nucleus", nucleusIsPresent)); + GetEngine().GetEventHandler().CallEvent(event); + } bool isValidPlacement(const string &in organelleType, int q, int r, int rotation) diff --git a/scripts/microbe_stage/organelle_components/nucleus_organelle.as b/scripts/microbe_stage/organelle_components/nucleus_organelle.as index c890b8a4643..1d01a48c64a 100644 --- a/scripts/microbe_stage/organelle_components/nucleus_organelle.as +++ b/scripts/microbe_stage/organelle_components/nucleus_organelle.as @@ -41,7 +41,7 @@ class NucleusOrganelle : OrganelleComponent{ sceneNode1.Node.setPosition(Hex::axialToCartesian(q + 1, r + 1)); //sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Radian(rotation), // Ogre::Vector3(0, .5, 1))); - sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation), + sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+180), Ogre::Vector3(0, 1, -1))); sceneNode1.Marked = true; @@ -59,7 +59,7 @@ class NucleusOrganelle : OrganelleComponent{ sceneNode2.Scale = Float3(HEX_SIZE, HEX_SIZE, HEX_SIZE); sceneNode2.Node.setPosition(Hex::axialToCartesian(q, r+.4)); - sceneNode2.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+10), + sceneNode2.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+190), Ogre::Vector3(0, 1, -1))); sceneNode2.Marked = true; diff --git a/scripts/microbe_stage/organelle_table.as b/scripts/microbe_stage/organelle_table.as index 6076900cf8f..0734a7ab1e7 100644 --- a/scripts/microbe_stage/organelle_table.as +++ b/scripts/microbe_stage/organelle_table.as @@ -256,7 +256,7 @@ void setupOrganelles(){ nucleusParameters.mesh = "nucleus.mesh"; nucleusParameters.chanceToCreate = 0; // Not randomly generated. nucleusParameters.prokaryoteChance = 0; // Not randomly generated. - nucleusParameters.mpCost = 0; //it's not supossed to be purchased. + nucleusParameters.mpCost = 100; //big evolution moment. nucleusParameters.initialComposition = { {"phosphates", 2}, {"ammonia", 2} diff --git a/scripts/microbe_stage/procedural_microbes.as b/scripts/microbe_stage/procedural_microbes.as index 1a3116e559a..4ab982b99e8 100644 --- a/scripts/microbe_stage/procedural_microbes.as +++ b/scripts/microbe_stage/procedural_microbes.as @@ -191,10 +191,10 @@ array@ positionOrganelles(const string &in stringCode){ const auto letter = CharacterToString(stringCode[i]); // LOG_WRITE(formatUInt(i) + ": " + letter); string name = string(organelleLetters[letter]); - //this places the nucleous + //this places the nucleus if(i == 0){ - @pos = OrganelleTemplatePlaced(name, 0, 0, 180); + @pos = OrganelleTemplatePlaced(name, 0, 0, 360); } else {