Skip to content

Commit

Permalink
729 engulf 2 (Revolutionary-Games#750)
Browse files Browse the repository at this point in the history
* Get species of microbe and reduce hexCount by 50% if bacteria

* Added caching of isBacteria

* Update the isBacteria cache on restoreOrganelleLayout

* Ran formatting
  • Loading branch information
turoni authored and hhyyrylainen committed Mar 14, 2019
1 parent b06cc3f commit 57043ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/microbe_stage/microbe.as
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MicrobeComponent : ScriptComponent{
this.speciesName = species.name;
}
this.isPlayerMicrobe = isPlayerMicrobe;
this.isBacteria = species.isBacteria;
this.engulfMode = false;
this.isBeingEngulfed = false;
this.hostileEngulfer = NULL_OBJECT;
Expand Down Expand Up @@ -165,6 +166,7 @@ class MicrobeComponent : ScriptComponent{
double stored = 0;
bool initialized = false;
bool isPlayerMicrobe = false;
bool isBacteria = false;
float maxBandwidth = 10.0 * BANDWIDTH_PER_ORGANELLE; // wtf is a bandwidth anyway?
float remainingBandwidth = 0.0;
uint compoundCollectionTimer = EXCESS_COMPOUND_COLLECTION_INTERVAL;
Expand Down
14 changes: 14 additions & 0 deletions scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ void cellOnCellActualContact(GameWorld@ world, ObjectID firstEntity, ObjectID se
// Get microbe sizes here
int firstMicrobeComponentHexCount = firstMicrobeComponent.totalHexCountCache;
int secondMicrobeComponentHexCount = secondMicrobeComponent.totalHexCountCache;

if(firstMicrobeComponent.isBacteria)
firstMicrobeComponentHexCount /= 2;

if(secondMicrobeComponent.isBacteria)
secondMicrobeComponentHexCount /= 2;

if (firstMicrobeComponent.engulfMode)
{
if(firstMicrobeComponentHexCount >
Expand Down Expand Up @@ -427,6 +434,13 @@ bool beingEngulfed(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity
// Get microbe sizes here
int firstMicrobeComponentHexCount = firstMicrobeComponent.totalHexCountCache;
int secondMicrobeComponentHexCount = secondMicrobeComponent.totalHexCountCache;

if(firstMicrobeComponent.isBacteria)
firstMicrobeComponentHexCount /= 2;

if(secondMicrobeComponent.isBacteria)
secondMicrobeComponentHexCount /= 2;

// If either cell is engulfing we need to do things
//return false;
//LOG_INFO(""+firstMicrobeComponent.engulfMode);
Expand Down
3 changes: 3 additions & 0 deletions scripts/microbe_stage/species_system.as
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,9 @@ void restoreOrganelleLayout(CellStageWorld@ world, ObjectID microbeEntity,

MicrobeOperations::addOrganelle(world, microbeEntity, organelle, editShape);
}

// cache isBacteria from species
microbeComponent.isBacteria = species.isBacteria;
}

void initProcessorComponent(CellStageWorld@ world, ObjectID entity,
Expand Down

0 comments on commit 57043ad

Please sign in to comment.