Skip to content

Commit

Permalink
can now engulf cell chunks and iron chunks (if you are big enough)
Browse files Browse the repository at this point in the history
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Mar 15, 2019
1 parent 8647f84 commit 361d2f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,9 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity)
model.GraphicalObject.setCustomParameter(1, microbeComponent.speciesColour);
auto rigidBody = world.Create_Physics(chunkEntity, chunkPosition);
auto body = rigidBody.CreatePhysicsBody(world.GetPhysicalWorld(),
world.GetPhysicalWorld().CreateSphere(1), 10);
world.GetPhysicalWorld().CreateSphere(1), 10,
//engulfable
world.GetPhysicalMaterial("iron"));
body.ConstraintMovementAxises();
rigidBody.JumpTo(chunkPosition);
auto venter = world.Create_CompoundVenterComponent(chunkEntity);
Expand Down
28 changes: 27 additions & 1 deletion scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ void cellHitFloatingOrganelle(GameWorld@ world, ObjectID firstEntity, ObjectID s
}


// Will use this for food chunks now
void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
{
// Determine which is the iron
Expand All @@ -321,6 +322,31 @@ void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
floatingEntity = secondEntity;
cellEntity = firstEntity;
}
auto microbeComponent = MicrobeOperations::getMicrobeComponent(asCellWorld,cellEntity);

auto engulfableComponent = asCellWorld.GetComponent_EngulfableComponent(floatingEntity);

auto compoundBagComponent = asCellWorld.GetComponent_CompoundBagComponent(cellEntity);

auto floatBag = asCellWorld.GetComponent_CompoundBagComponent(floatingEntity);

if (microbeComponent !is null && engulfableComponent !is null
&& compoundBagComponent !is null && floatBag !is null)
{
if (microbeComponent.engulfMode && microbeComponent.organelles.length() >=
engulfableComponent.getSize()*ENGULF_HP_RATIO_REQ)
{
uint64 compoundCount = SimulationParameters::compoundRegistry().getSize();
for(uint compoundId = 0; compoundId < compoundCount; ++compoundId){
CompoundId realCompoundId = compoundId;
double amountToTake =
floatBag.takeCompound(realCompoundId,floatBag.getCompoundAmount(realCompoundId));
// Right now you get way too much compounds for engulfing the things but hey
compoundBagComponent.giveCompound(realCompoundId, amountToTake/2);
}
world.QueueDestroyEntity(floatingEntity);
}
}
}

// Cell Hit Oxytoxy
Expand Down Expand Up @@ -704,7 +730,7 @@ ObjectID createIron(CellStageWorld@ world, Float3 pos)
auto rigidBody = world.Create_Physics(ironEntity, position);
auto body = rigidBody.CreatePhysicsBody(world.GetPhysicalWorld(),
world.GetPhysicalWorld().CreateSphere(ironSize),100,
//iron
//engulfable
world.GetPhysicalMaterial("iron"));

body.ConstraintMovementAxises();
Expand Down

0 comments on commit 361d2f5

Please sign in to comment.