Skip to content

Commit

Permalink
movement and osmoregulation costs are now based on hex instead of org…
Browse files Browse the repository at this point in the history
…anelle 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
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Mar 15, 2019
1 parent 2cf679e commit 222940c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
12 changes: 6 additions & 6 deletions scripts/microbe_stage/microbe.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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"));

Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/microbe_ai.as
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
14 changes: 12 additions & 2 deletions scripts/microbe_stage/microbe_editor/microbe_editor.as
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlacedOrganelle>(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<PlacedOrganelle>(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;
Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/microbe_editor/microbe_editor_hud.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 222940c

Please sign in to comment.