diff --git a/scripts/microbe_stage/agent_vacuole.lua b/scripts/microbe_stage/agent_vacuole.lua index 8343ae22c74..95d9fc6cd75 100644 --- a/scripts/microbe_stage/agent_vacuole.lua +++ b/scripts/microbe_stage/agent_vacuole.lua @@ -79,3 +79,11 @@ function AgentVacuole:load(storage) process:load(storage:get("process", 0)) self.process = process end + +-- factory functions +function OrganelleFactory.makeOxytoxyVacuole() + local agentVacuole = AgentVacuole(CompoundRegistry.getCompoundId("oxytoxy"), global_processMap["OxyToxySynthesis"]) + agentVacuole:addHex(0, 0) + agentVacuole:setColour(ColourValue(0, 1, 1, 0)) + return agentVacuole +end diff --git a/scripts/microbe_stage/movement_organelle.lua b/scripts/microbe_stage/movement_organelle.lua index d2c5fbd6089..9f49071f77b 100644 --- a/scripts/microbe_stage/movement_organelle.lua +++ b/scripts/microbe_stage/movement_organelle.lua @@ -131,3 +131,21 @@ function MovementOrganelle:update(microbe, milliseconds) self:_moveMicrobe(microbe, milliseconds) end +-- factory functions +function OrganelleFactory.makeFlagellum(q,r) + -- Calculate the momentum of the movement organelle based on angle towards nucleus + local organelleX, organelleY = axialToCartesian(q, r) + local nucleusX, nucleusY = axialToCartesian(0, 0) + local deltaX = nucleusX - organelleX + local deltaY = nucleusY - organelleY + local dist = math.sqrt(deltaX^2 + deltaY^2) -- For normalizing vector + local momentumX = deltaX / dist * FLAGELIUM_MOMENTUM + local momentumY = deltaY / dist * FLAGELIUM_MOMENTUM + local flagellum = MovementOrganelle( + Vector3(momentumX, momentumY, 0.0), + 300 + ) + flagellum:setColour(ColourValue(0.8, 0.3, 0.3, 1)) + flagellum:addHex(0, 0) + return flagellum +end diff --git a/scripts/microbe_stage/organelle.lua b/scripts/microbe_stage/organelle.lua index b5bfbd56002..f4d73f63e18 100644 --- a/scripts/microbe_stage/organelle.lua +++ b/scripts/microbe_stage/organelle.lua @@ -248,3 +248,20 @@ end function Organelle:updateHexColours() self._needsColourUpdate = true end + +-- The basic organelle maker +class 'OrganelleFactory' + +-- OrganelleFactory:makeFoo() should be defined in the appropriate file +-- for example, OrganelleFactory:makeMitochondrion() should be defined in process_organelle.lua +-- each factory function should return an organelle that's ready to be inserted into a microbe +-- example: + +function OrganelleFactory.makeNucleus() + local nucleus = NucleusOrganelle() + nucleus:addHex(0, 0) + nucleus:setColour(ColourValue(0.8, 0.2, 0.8, 1)) + nucleus:addProcess(global_processMap["ReproductaseSynthesis"]) + nucleus:addProcess(global_processMap["AminoAcidSynthesis"]) + return nucleus +end diff --git a/scripts/microbe_stage/process_organelle.lua b/scripts/microbe_stage/process_organelle.lua index fb56f65f709..fcab4dab442 100644 --- a/scripts/microbe_stage/process_organelle.lua +++ b/scripts/microbe_stage/process_organelle.lua @@ -285,3 +285,14 @@ function ProcessOrganelle:load(storage) self:addProcess(process) end end + +------------------------------------------- +-- factory functions for process organelles + +function OrganelleFactory.makeMitochondrion() + local mito = ProcessOrganelle() + mito:addProcess(global_processMap["Respiration"]) + mito:addHex(0, 0) + mito:setColour(ColourValue(0.8, 0.4, 0.5, 0)) + return mito +end diff --git a/scripts/microbe_stage/storage_organelle.lua b/scripts/microbe_stage/storage_organelle.lua index a43ebf5732d..5a0488bc212 100644 --- a/scripts/microbe_stage/storage_organelle.lua +++ b/scripts/microbe_stage/storage_organelle.lua @@ -36,3 +36,10 @@ function StorageOrganelle:onRemovedFromMicrobe(microbe, q, r) microbe:removeStorageOrganelle(self) end + +function OrganelleFactory.makeVacuole() + local vacuole = StorageOrganelle(100.0) + vacuole:addHex(0, 0) + vacuole:setColour(ColourValue(0, 1, 0, 1)) + return vacuole +end