From 222940c5970499ef4b45406e7d3cd005e08ecace Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Wed, 27 Feb 2019 20:50:17 -0600 Subject: [PATCH] movement and osmoregulation costs are now based on hex instead of organelle length chunks are now base don hex size instead of organelle length editor now displays proper data at the bottom that corresponds to hex count instead of organelle length --- scripts/microbe_stage/microbe.as | 12 ++++++------ scripts/microbe_stage/microbe_ai.as | 2 +- .../microbe_stage/microbe_editor/microbe_editor.as | 14 ++++++++++++-- .../microbe_editor/microbe_editor_hud.as | 2 +- scripts/microbe_stage/microbe_operations.as | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/scripts/microbe_stage/microbe.as b/scripts/microbe_stage/microbe.as index afe7d2ec3c2..6ed4d4b0a6a 100644 --- a/scripts/microbe_stage/microbe.as +++ b/scripts/microbe_stage/microbe.as @@ -484,7 +484,7 @@ class MicrobeSystem : ScriptSystem{ world.GetScriptComponentHolder("MicrobeComponent").Find(microbeComponent.hostileEngulfer)); if ((hostileMicrobeComponent is null) || (!hostileMicrobeComponent.engulfMode) || (hostileMicrobeComponent.dead) || (ourPosition._Position - predatorPosition._Position).LengthSquared() >= - ((hostileMicrobeComponent.organelles.length()+3)*HEX_SIZE)+50){ + ((hostileMicrobeComponent.totalHexCountCache+3)*HEX_SIZE)+50){ microbeComponent.hostileEngulfer = NULL_OBJECT; microbeComponent.isBeingEngulfed = false; } @@ -499,7 +499,7 @@ class MicrobeSystem : ScriptSystem{ //TODO:It seems to happen no matter what (even if it takes away less atp then you generate per second), //we should probably make it take into account the amount of atp being generated so resources arent wasted //for now made it not take away if your atp amount is equal to your capacity - auto osmoCost = (microbeComponent.organelles.length()*ATP_COST_FOR_OSMOREGULATION)/(logicTime); + auto osmoCost = (microbeComponent.totalHexCountCache*ATP_COST_FOR_OSMOREGULATION)/(logicTime); //auto osmoCost = (microbeComponent.organelles.length()*2)/logicTime; double atpAmount = MicrobeOperations::getCompoundAmount(world, microbeEntity,SimulationParameters::compoundRegistry().getTypeId("atp")); @@ -576,9 +576,9 @@ class MicrobeSystem : ScriptSystem{ const Float3 velocity = physics.Body.GetVelocity(); // There should be no Y velocity so it should be zero - const Float3 drag(velocity.X * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.organelles.length())), - velocity.Y * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.organelles.length())), - velocity.Z * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.organelles.length()))); + const Float3 drag(velocity.X * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.totalHexCountCache)), + velocity.Y * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.totalHexCountCache)), + velocity.Z * (CELL_DRAG_MULTIPLIER+(CELL_SIZE_DRAG_MULTIPLIER*microbeComponent.totalHexCountCache))); // Only add drag if it is over CELL_REQUIRED_DRAG_BEFORE_APPLY if(abs(drag.X) >= CELL_REQUIRED_DRAG_BEFORE_APPLY){ @@ -630,7 +630,7 @@ class MicrobeSystem : ScriptSystem{ // microbeComponent.queuedMovementForce.Z); // There is an movement without flagella cost - auto cost = (BASE_MOVEMENT_ATP_COST*microbeComponent.organelles.length())/logicTime; + auto cost = (BASE_MOVEMENT_ATP_COST*microbeComponent.totalHexCountCache)/logicTime; // TODO: if there isn't enough energy this needs to scale the impulse MicrobeOperations::takeCompound(world, microbeEntity, diff --git a/scripts/microbe_stage/microbe_ai.as b/scripts/microbe_stage/microbe_ai.as index 0c0498ac7b8..edfae9d79aa 100644 --- a/scripts/microbe_stage/microbe_ai.as +++ b/scripts/microbe_stage/microbe_ai.as @@ -288,7 +288,7 @@ class MicrobeAISystem : ScriptSystem{ if (allMicrobes[i] != microbeEntity && (secondMicrobeComponent.speciesName != microbeComponent.speciesName) && !secondMicrobeComponent.dead){ if ((aiComponent.speciesAggression==MAX_SPECIES_AGRESSION) or ((((numberOfAgentVacuoles+microbeComponent.totalHexCountCache)*1.0f)*(aiComponent.speciesAggression/AGRESSION_DIVISOR)) > - (secondMicrobeComponent.organelles.totalHexCountCache*1.0f))){ + (secondMicrobeComponent.totalHexCountCache*1.0f))){ //You are non-threatening to me aiComponent.preyMicrobes.insertLast(allMicrobes[i]); } diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor.as b/scripts/microbe_stage/microbe_editor/microbe_editor.as index 76980186888..dfba787d236 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor.as @@ -874,21 +874,31 @@ class MicrobeEditor{ return editedMicrobe.length(); } + int getActualMicrobeSize() const + { + double lengthMicrobe = 0; + for(uint i = 0; i < editedMicrobe.length(); ++i){ + auto organelle = cast(editedMicrobe[i]); + lengthMicrobe+=organelle.organelle.getHexCount(); + } + return lengthMicrobe; + } // Make sure this is only called when you add organelles, as it is an expensive double getMicrobeSpeed() const { double finalSpeed = 0; int flagCount=0; - double lengthMicrobe = double(editedMicrobe.length()); + double lengthMicrobe = 0; for(uint i = 0; i < editedMicrobe.length(); ++i){ auto organelle = cast(editedMicrobe[i]); + lengthMicrobe+=organelle.organelle.getHexCount(); auto name = organelle.organelle.name; if (name=="flagellum"){ flagCount++; } } //This is complex, i Know - //LOG_INFO(""+flagCount); + //LOG_INFO(""+lengthMicrobe); finalSpeed= ((CELL_BASE_THRUST+((flagCount/(lengthMicrobe-flagCount))*FLAGELLA_BASE_FORCE))+ (CELL_DRAG_MULTIPLIER-(CELL_SIZE_DRAG_MULTIPLIER*lengthMicrobe))); return finalSpeed; diff --git a/scripts/microbe_stage/microbe_editor/microbe_editor_hud.as b/scripts/microbe_stage/microbe_editor/microbe_editor_hud.as index e244a025365..ddfe7e66d78 100644 --- a/scripts/microbe_stage/microbe_editor/microbe_editor_hud.as +++ b/scripts/microbe_stage/microbe_editor/microbe_editor_hud.as @@ -264,7 +264,7 @@ class MicrobeEditorHudSystem : ScriptSystem{ GenericEvent@ event = GenericEvent("SizeUpdated"); NamedVars@ vars = event.GetNamedVars(); - vars.AddValue(ScriptSafeVariableBlock("size", editor.getMicrobeSize())); + vars.AddValue(ScriptSafeVariableBlock("size", editor.getActualMicrobeSize())); GetEngine().GetEventHandler().CallEvent(event); } diff --git a/scripts/microbe_stage/microbe_operations.as b/scripts/microbe_stage/microbe_operations.as index 450d0b5255f..e4b96f6967c 100644 --- a/scripts/microbe_stage/microbe_operations.as +++ b/scripts/microbe_stage/microbe_operations.as @@ -1178,8 +1178,8 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity) - for(uint i = 0; i < max(1,microbeComponent.organelles.length()/CORPSE_CHUNK_DIVISER); ++i){ - double amount = max(1,microbeComponent.organelles.length()/CORPSE_CHUNK_DIVISER); + for(uint i = 0; i < max(1,microbeComponent.totalHexCountCache/CORPSE_CHUNK_DIVISER); ++i){ + double amount = max(1,microbeComponent.totalHexCountCache/CORPSE_CHUNK_DIVISER); // Chunk(should separate into own function) ObjectID chunkEntity = world.CreateEntity(); auto chunkPosition = world.Create_Position(chunkEntity, position._Position,