Skip to content

Commit

Permalink
Chunks are now all normal sizedd orgaenlles, but it makes many of the…
Browse files Browse the repository at this point in the history
…m and it takes their organelle meshes directly from the cell itself, and they will rot away at different rates to create a illusion of actual decomposition., they are probably still a bit OP

Balanced chunks, fixed mismatch error, added more configuration options

fixed conversion error in editor
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Mar 15, 2019
1 parent 2610183 commit 205f647
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
7 changes: 4 additions & 3 deletions scripts/microbe_stage/configs.as
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const auto DEFAULT_SPAWN_DENSITY = 1/25000.f;
const auto STARTING_SPAWN_DENSITY = 45000.0f;
const auto MAX_SPAWN_DENSITY = 20000.0f;
//Corpse info
const auto CORPSE_COMPOUND_COMPENSATION = 2.0f;
const auto CORPSE_CHUNK_DIVISER = 9.0f;
const auto CHUNK_ENGULF_COMPOUND_DIVISOR = 7.0f;
const auto CORPSE_COMPOUND_COMPENSATION = 8.0f;
const int CORPSE_CHUNK_DIVISER = 3;
const auto CORPSE_CHUNK_AMOUNT_DIVISER = 3.0f;
const auto CHUNK_ENGULF_COMPOUND_DIVISOR = 30.0f;

// Cell Spawn Variation
const auto MIN_SPAWN_DISTANCE = -5000.0f;
Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/microbe_editor/microbe_editor.as
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ class MicrobeEditor{

int getActualMicrobeSize() const
{
double lengthMicrobe = 0;
int lengthMicrobe = 0;
for(uint i = 0; i < editedMicrobe.length(); ++i){
auto organelle = cast<PlacedOrganelle>(editedMicrobe[i]);
lengthMicrobe+=organelle.organelle.getHexCount();
Expand Down
45 changes: 25 additions & 20 deletions scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -1179,24 +1179,37 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity)



for(uint i = 0; i < max(1,microbeComponent.totalHexCountCache/CORPSE_CHUNK_DIVISER); ++i){
double amount = max(1,microbeComponent.totalHexCountCache/CORPSE_CHUNK_DIVISER);
for(uint i = 0; i < uint(max(1,microbeComponent.totalHexCountCache/CORPSE_CHUNK_DIVISER)); ++i){
//Amount of compound in one chunk
double amount = double(microbeComponent.totalHexCountCache)/CORPSE_CHUNK_AMOUNT_DIVISER;
// Chunk(should separate into own function)
ObjectID chunkEntity = world.CreateEntity();
auto chunkPosition = world.Create_Position(chunkEntity, position._Position,
auto positionAdded = Float3(GetEngine().GetRandom().GetFloat(-2.0f, 2.0f),0,
GetEngine().GetRandom().GetFloat(-2.0f, 2.0f));
auto chunkPosition = world.Create_Position(chunkEntity, position._Position+positionAdded,
Ogre::Quaternion(Ogre::Degree(GetEngine().GetRandom().GetNumber(0, 360)),
Ogre::Vector3(0,1,1)));

auto renderNode = world.Create_RenderNode(chunkEntity);
renderNode.Scale = Float3(amount*0.5f, amount*0.5f, amount*0.5f);
renderNode.Scale = Float3(1.0f, 1.0f, 1.0f);
renderNode.Marked = true;
renderNode.Node.setOrientation(Ogre::Quaternion(
Ogre::Degree(GetEngine().GetRandom().GetNumber(0, 360)), Ogre::Vector3(0,1,1)));
renderNode.Node.setPosition(chunkPosition._Position);
// temp model for testing
auto model = world.Create_Model(chunkEntity, renderNode.Node, "mitochondrion.mesh");
// Color chunk based on cell
model.GraphicalObject.setCustomParameter(1, microbeComponent.speciesColour);
// Grab random organelle from cell and use that
auto organelleIndex = GetEngine().GetRandom().GetNumber(0, microbeComponent.organelles.length()-1);
string mesh = microbeComponent.organelles[organelleIndex].organelle.mesh;
if (mesh != "")
{
auto model = world.Create_Model(chunkEntity, renderNode.Node, mesh);
// Color chunk based on cell
model.GraphicalObject.setCustomParameter(1, microbeComponent.speciesColour);
}
else {
auto model = world.Create_Model(chunkEntity, renderNode.Node, "mitochondrion.mesh");
// Color chunk based on cell
model.GraphicalObject.setCustomParameter(1, microbeComponent.speciesColour);
}
auto rigidBody = world.Create_Physics(chunkEntity, chunkPosition);
auto body = rigidBody.CreatePhysicsBody(world.GetPhysicalWorld(),
world.GetPhysicalWorld().CreateSphere(1), 10,
Expand All @@ -1207,7 +1220,7 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity)
auto venter = world.Create_CompoundVenterComponent(chunkEntity);
//Engulfable
auto engulfable = world.Create_EngulfableComponent(chunkEntity);
engulfable.setSize(amount);
engulfable.setSize(2);
// So that larger iron chunks give out more compounds
venter.setVentAmount(3);
venter.setDoDissolve(true);
Expand All @@ -1216,22 +1229,14 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity)
for(uint64 compoundID = 0; compoundID <
SimulationParameters::compoundRegistry().getSize(); ++compoundID)
{
bag.setCompound(compoundID, (float(compoundsToRelease[formatUInt(compoundID)])/amount)*CORPSE_COMPOUND_COMPENSATION);
//Randomize compound amount a bit so things "rot away"
bag.setCompound(compoundID, (float(compoundsToRelease[formatUInt(compoundID)])/
GetEngine().GetRandom().GetFloat(amount/3.0f, amount)*CORPSE_COMPOUND_COMPENSATION));
}
}
// Play the death sound
playSoundWithDistance(world, "Data/Sound/soundeffects/microbe-death.ogg", microbeEntity);

//TODO: Get this working
//auto deathAnimationEntity = world.CreateEntity();
//auto lifeTimeComponent = world.Create_TimedLifeComponent(deathAnimationEntity, 4000);
//auto deathAnimSceneNode = world.Create_RenderNode(deathAnimationEntity);
//auto deathAnimModel = world.Create_Model(deathAnimationEntity, deathAnimSceneNode.Node,
// "MicrobeDeath.mesh");
//deathAnimSceneNode.Node.setPosition(position._Position);

//LOG_WRITE("TODO: play animation deathAnimModel");
// deathAnimModel.GraphicalObject.playAnimation("Death", false);
//subtract population
auto playerSpecies = MicrobeOperations::getSpeciesComponent(world, "Default");
if (!microbeComponent.isPlayerMicrobe &&
Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
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/CHUNK_ENGULF_COMPOUND_DIVISOR);
compoundBagComponent.giveCompound(realCompoundId, (amountToTake/CHUNK_ENGULF_COMPOUND_DIVISOR));
}
world.QueueDestroyEntity(floatingEntity);
}
Expand Down
2 changes: 1 addition & 1 deletion src/microbe_stage/compound_venter_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void
}

// If you did not vent anything this step and the venter component
// is flagged to dissolve tyou, dissolve you
// is flagged to dissolve you, dissolve you
if(vented == false && venter.getDoDissolve()) {
world.QueueDestroyEntity(value.first);
}
Expand Down

0 comments on commit 205f647

Please sign in to comment.