diff --git a/CMakeLists.txt b/CMakeLists.txt index f8434efcfc..0d8441dc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -435,11 +435,6 @@ install(DIRECTORY PATTERN "*.xml" ) -# Create directory tree that thrive requires -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/creations) -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/creations/microbe) -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/creations/multicellular) - # Install Runtime Libraries if(WIN32) diff --git a/assets/definitions/processes.xml b/assets/definitions/processes.xml index 10a2349f12..7c1621da79 100644 --- a/assets/definitions/processes.xml +++ b/assets/definitions/processes.xml @@ -10,7 +10,7 @@ - + diff --git a/scripts/microbe_editor/microbe_editor.lua b/scripts/microbe_editor/microbe_editor.lua index 5513d9cf63..a23a051c3f 100644 --- a/scripts/microbe_editor/microbe_editor.lua +++ b/scripts/microbe_editor/microbe_editor.lua @@ -15,6 +15,7 @@ function MicrobeEditor:__init(hudSystem) self.hudSystem = hudSystem self.nextMicrobeEntity = nil self.lockedMap = nil + self.mutationPoints = 100 self.placementFunctions = {["nucleus"] = MicrobeEditor.createNewMicrobe, ["flagelium"] = MicrobeEditor.addMovementOrganelle, ["mitochondria"] = MicrobeEditor.addProcessOrganelle, @@ -35,6 +36,7 @@ function MicrobeEditor:activate() Engine:playerData():setBool("edited_microbe", true) Engine:playerData():setActiveCreature(self.nextMicrobeEntity.id, GameState.MICROBE_EDITOR) end + self.mutationPoints = 100 end function MicrobeEditor:update(milliseconds) @@ -55,6 +57,16 @@ function MicrobeEditor:update(milliseconds) organelle:_updateHexColours() end end + self.hudSystem:updateMutationPoints() +end + +function MicrobeEditor:takeMutationPoints(amount) + if amount <= self.mutationPoints then + self.mutationPoints = self.mutationPoints - amount + return true + else + return false + end end function MicrobeEditor:performLocationAction() @@ -82,7 +94,7 @@ function MicrobeEditor:removeOrganelle() local q, r = self:getMouseHex() if not (q == 0 and r == 0) then -- Don't remove nucleus local organelle = self.currentMicrobe:getOrganelleAt(q,r) - if organelle then + if organelle and self:takeMutationPoints(10) then self.currentMicrobe:removeOrganelle(organelle.position.q ,organelle.position.r ) self.currentMicrobe.sceneNode.transform:touch() self.organelleCount = self.organelleCount - 1 @@ -94,7 +106,7 @@ end function MicrobeEditor:addStorageOrganelle(organelleType) -- self.currentMicrobe = Microbe(Entity("working_microbe", GameState.MICROBE)) local q, r = self:getMouseHex() - if self.currentMicrobe:getOrganelleAt(q, r) == nil then + if self.currentMicrobe:getOrganelleAt(q, r) == nil and self:takeMutationPoints(Organelle.mpCosts["vacuole"]) then self.currentMicrobe:addOrganelle(q, r, OrganelleFactory.make_vacuole({})) self.organelleCount = self.organelleCount + 1 end @@ -104,7 +116,7 @@ end function MicrobeEditor:addMovementOrganelle(organelleType) local q, r = self:getMouseHex() local data = {["q"]=q, ["r"]=r} - if self.currentMicrobe:getOrganelleAt(q, r) == nil then + if self.currentMicrobe:getOrganelleAt(q, r) == nil and self:takeMutationPoints(Organelle.mpCosts["flagellum"]) then self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.make_flagellum(data)) self.organelleCount = self.organelleCount + 1 end @@ -114,12 +126,10 @@ function MicrobeEditor:addProcessOrganelle(organelleType) local q, r = self:getMouseHex() if self.currentMicrobe:getOrganelleAt(q, r) == nil then - if organelleType == "mitochondria" then + if organelleType == "mitochondria" and self:takeMutationPoints(Organelle.mpCosts["mitochondrion"]) then self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.make_mitochondrion({})) - elseif organelleType == "chloroplast" then + elseif organelleType == "chloroplast" and self:takeMutationPoints(Organelle.mpCosts["chloroplast"]) then self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.make_chloroplast({})) - else - assert(false, "organelleType did not exist") end end self.organelleCount = self.organelleCount + 1 @@ -128,7 +138,7 @@ end function MicrobeEditor:addAgentVacuole(organelleType) if organelleType == "toxin" then local q, r = self:getMouseHex() - if self.currentMicrobe:getOrganelleAt(q, r) == nil then + if self.currentMicrobe:getOrganelleAt(q, r) == nil and self:takeMutationPoints(Organelle.mpCosts["oxytoxy"]) then self.currentMicrobe:addOrganelle(q, r, OrganelleFactory.make_oxytoxy({})) self.organelleCount = self.organelleCount + 1 end @@ -152,6 +162,7 @@ function MicrobeEditor:loadMicrobe(entityId) self.currentMicrobe.sceneNode.transform:touch() self.currentMicrobe.collisionHandler:addCollisionGroup("powerupable") Engine:playerData():setActiveCreature(entityId, GameState.MICROBE_EDITOR) + self.mutationPoints = 0 end function MicrobeEditor:createNewMicrobe() @@ -165,5 +176,6 @@ function MicrobeEditor:createNewMicrobe() self.currentMicrobe.sceneNode.transform:touch() self.currentMicrobe.collisionHandler:addCollisionGroup("powerupable") self:addNucleus() + self.mutationPoints = 100 Engine:playerData():setActiveCreature(self.currentMicrobe.entity.id, GameState.MICROBE_EDITOR) end diff --git a/scripts/microbe_editor/microbe_editor_hud.lua b/scripts/microbe_editor/microbe_editor_hud.lua index 6965aa5075..e15cdb760c 100644 --- a/scripts/microbe_editor/microbe_editor_hud.lua +++ b/scripts/microbe_editor/microbe_editor_hud.lua @@ -23,6 +23,8 @@ function MicrobeEditorHudSystem:init(gameState) sceneNode.meshName = "hex.mesh" self.hoverHex:addComponent(sceneNode) local root = gameState:rootGUIWindow() + self.mpLabel = root:getChild("BottomSection"):getChild("MutationPoints"):getChild("MPBar"):getChild("NumberLabel") + self.mpProgressBar = root:getChild("BottomSection"):getChild("MutationPoints"):getChild("MPBar") local nucleusButton = root:getChild("EditorTools"):getChild("NucleusItem") local flageliumButton = root:getChild("EditorTools"):getChild("FlageliumItem") local mitochondriaButton = root:getChild("EditorTools"):getChild("MitochondriaItem") @@ -139,6 +141,12 @@ function MicrobeEditorHudSystem:update(milliseconds) end +function MicrobeEditorHudSystem:updateMutationPoints() + self.mpProgressBar:progressbarSetProgress(self.editor.mutationPoints/100) + self.mpLabel:setText("" .. self.editor.mutationPoints) +end + + -- Event handlers function nucleusClicked() if global_activeMicrobeEditorHudSystem.activeButton ~= nil then diff --git a/scripts/microbe_stage/agent_vacuole.lua b/scripts/microbe_stage/agent_vacuole.lua index e9eab2fdf0..ee280c817f 100644 --- a/scripts/microbe_stage/agent_vacuole.lua +++ b/scripts/microbe_stage/agent_vacuole.lua @@ -80,6 +80,8 @@ function AgentVacuole:load(storage) self.process = process end +Organelle.mpCosts["oxytoxy"] = 40 + -- factory functions function OrganelleFactory.make_oxytoxy(data) local agentVacuole = AgentVacuole(CompoundRegistry.getCompoundId("oxytoxy"), global_processMap["OxyToxySynthesis"]) diff --git a/scripts/microbe_stage/camera.lua b/scripts/microbe_stage/camera.lua index a322ef2483..6a9e253968 100644 --- a/scripts/microbe_stage/camera.lua +++ b/scripts/microbe_stage/camera.lua @@ -3,6 +3,7 @@ class 'MicrobeCameraSystem' (System) function MicrobeCameraSystem:__init() System.__init(self) + -- The offset from player microbe to camera self.camera = nil self.cameraScenenode = nil end @@ -10,7 +11,6 @@ end function MicrobeCameraSystem:activate() local camera = Entity(CAMERA_NAME) self.camera = camera:getComponent(OgreCameraComponent.TYPE_ID) - -- The offset from player microbe to camera self.camera.properties.offset = Vector3(0, 0, 30) self.camera.properties:touch() self.cameraScenenode = camera:getComponent(OgreSceneNodeComponent.TYPE_ID) diff --git a/scripts/microbe_stage/microbe.lua b/scripts/microbe_stage/microbe.lua index 2c78028846..400847e523 100644 --- a/scripts/microbe_stage/microbe.lua +++ b/scripts/microbe_stage/microbe.lua @@ -719,7 +719,6 @@ end -- Copies this microbe. The new microbe will not have the stored compounds of this one. function Microbe:reproduce() - copy = Microbe.createMicrobeEntity(nil, true) for _, organelle in pairs(self.microbe.organelles) do local organelleStorage = organelle:storage() @@ -731,6 +730,9 @@ function Microbe:reproduce() copy.microbe:updateSafeAngles() copy.microbe:_resetCompoundPriorities() copy.entity:addComponent(SpawnedComponent()) + if self.microbe.isPlayerMicrobe then + showReproductionDialog() + end end diff --git a/scripts/microbe_stage/microbe_stage_hud.lua b/scripts/microbe_stage/microbe_stage_hud.lua index 6ba11d7f5e..38d73d8776 100644 --- a/scripts/microbe_stage/microbe_stage_hud.lua +++ b/scripts/microbe_stage/microbe_stage_hud.lua @@ -14,6 +14,7 @@ end global_if_already_displayed = false function HudSystem:activate() + global_activeMicrobeStageHudSystem = self -- Global reference for event handlers lockedMap = Engine:playerData():lockedMap() if lockedMap ~= nil and not lockedMap:isLocked("Toxin") and not ss and not global_if_already_displayed then showMessage("'E' Releases Toxin") @@ -30,16 +31,20 @@ function HudSystem:init(gameState) local menuButton = self.rootGuiWindow:getChild("BottomSection"):getChild("MenuButton") local helpButton = self.rootGuiWindow:getChild("BottomSection"):getChild("HelpButton") local editorButton = self.rootGuiWindow:getChild("MenuPanel"):getChild("EditorButton") + local editorButton2 = self.rootGuiWindow:getChild("ReproductionPanel"):getChild("EditorButton") local returnButton = self.rootGuiWindow:getChild("MenuPanel"):getChild("ReturnButton") local returnButton2 = self.rootGuiWindow:getChild("HelpPanel"):getChild("ReturnButton") local returnButton3 = self.rootGuiWindow:getChild("MessagePanel"):getChild("ReturnButton") + local returnButton4 = self.rootGuiWindow:getChild("ReproductionPanel"):getChild("ReturnButton") local quitButton = self.rootGuiWindow:getChild("MenuPanel"):getChild("QuitButton") menuButton:registerEventHandler("Clicked", menuButtonClicked) helpButton:registerEventHandler("Clicked", helpButtonClicked) editorButton:registerEventHandler("Clicked", editorButtonClicked) + editorButton2:registerEventHandler("Clicked", editorButtonClicked) returnButton:registerEventHandler("Clicked", returnButtonClicked) returnButton2:registerEventHandler("Clicked", returnButtonClicked) returnButton3:registerEventHandler("Clicked", returnButtonClicked) + returnButton4:registerEventHandler("Clicked", returnButtonClicked) quitButton:registerEventHandler("Clicked", quitButtonClicked) self.rootGuiWindow:getChild("MenuPanel"):getChild("MainMenuButton"):registerEventHandler("Clicked", menuMainMenuClicked) end @@ -83,6 +88,10 @@ function HudSystem:update(milliseconds) offset.z = newZVal end +function showReproductionDialog() + global_activeMicrobeStageHudSystem.rootGuiWindow:getChild("ReproductionPanel"):show() +end + function showMessage(msg) local messagePanel = Engine:currentGameState():rootGUIWindow():getChild("MessagePanel") messagePanel:getChild("MessageLabel"):setText(msg) @@ -115,6 +124,7 @@ function returnButtonClicked() if Engine:currentGameState():name() == "microbe" then Engine:currentGameState():rootGUIWindow():getChild("HelpPanel"):hide() Engine:currentGameState():rootGUIWindow():getChild("MessagePanel"):hide() + Engine:currentGameState():rootGUIWindow():getChild("ReproductionPanel"):hide() elseif Engine:currentGameState():name() == "microbe_editor" then Engine:currentGameState():rootGUIWindow():getChild("SaveLoadPanel"):hide() end diff --git a/scripts/microbe_stage/movement_organelle.lua b/scripts/microbe_stage/movement_organelle.lua index 0db386a6a0..c508e48ba0 100644 --- a/scripts/microbe_stage/movement_organelle.lua +++ b/scripts/microbe_stage/movement_organelle.lua @@ -131,6 +131,8 @@ function MovementOrganelle:update(microbe, milliseconds) self:_moveMicrobe(microbe, milliseconds) end +Organelle.mpCosts["flagellum"] = 25 + -- factory functions function OrganelleFactory.make_flagellum(data) -- Calculate the momentum of the movement organelle based on angle towards nucleus diff --git a/scripts/microbe_stage/organelle.lua b/scripts/microbe_stage/organelle.lua index 87f94325a0..3e89fa9bc9 100644 --- a/scripts/microbe_stage/organelle.lua +++ b/scripts/microbe_stage/organelle.lua @@ -1,6 +1,8 @@ -- Base class for microbe organelles class 'Organelle' +Organelle.mpCosts = {} + -- Factory function for organelles function Organelle.loadOrganelle(storage) local className = storage:get("className", "") diff --git a/scripts/microbe_stage/process_organelle.lua b/scripts/microbe_stage/process_organelle.lua index c99de51202..c5b5613bc7 100644 --- a/scripts/microbe_stage/process_organelle.lua +++ b/scripts/microbe_stage/process_organelle.lua @@ -290,6 +290,9 @@ end ------------------------------------------- -- factory functions for process organelles +Organelle.mpCosts["chloroplast"] = 20 +Organelle.mpCosts["mitochondrion"] = 20 + function OrganelleFactory.make_mitochondrion(data) local mito = ProcessOrganelle() mito:addProcess(global_processMap["Respiration"]) diff --git a/scripts/microbe_stage/setup.lua b/scripts/microbe_stage/setup.lua index e22d7a3e8b..9e9bfb2f8e 100644 --- a/scripts/microbe_stage/setup.lua +++ b/scripts/microbe_stage/setup.lua @@ -4,7 +4,6 @@ local function setupBackground() local skyplane = SkyPlaneComponent() skyplane.properties.plane.normal = Vector3(0, 0, 2000) skyplane.properties.materialName = "background/blue_01" - skyplane.properties.tiling = 7 skyplane.properties:touch() entity:addComponent(skyplane) diff --git a/scripts/microbe_stage/storage_organelle.lua b/scripts/microbe_stage/storage_organelle.lua index c49c03b04e..7f0cc5d562 100644 --- a/scripts/microbe_stage/storage_organelle.lua +++ b/scripts/microbe_stage/storage_organelle.lua @@ -36,6 +36,7 @@ function StorageOrganelle:onRemovedFromMicrobe(microbe, q, r) microbe:removeStorageOrganelle(self) end +Organelle.mpCosts["vacuole"] = 15 function OrganelleFactory.make_vacuole(data) local vacuole = StorageOrganelle(100.0)