Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/microbe_stage/components/CellProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ public static float EjectCompound(this ref CellProperties cellProperties, ref Wo
{
float amount = compounds.TakeCompound(compound, maxAmount);

cellProperties.SpawnEjectedCompound(ref cellPosition, compoundCloudSystem, compound, amount, direction,
displacement);
if (!cellProperties.SpawnEjectedCompound(ref cellPosition, compoundCloudSystem, compound, amount, direction,
displacement))
{
// If membrane was not ready, we didn't eject anything
return 0;
}

return amount;
}

Expand Down Expand Up @@ -352,7 +357,7 @@ public static bool SpawnEjectedCompound(this ref CellProperties cellProperties,

if (cellProperties.CreatedMembrane == null)
{
GD.PrintErr($"{nameof(SpawnEjectedCompound)} called before membrane is created, ignoring eject");
GD.Print($"{nameof(SpawnEjectedCompound)} called before membrane is created, ignoring eject");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/microbe_stage/systems/EngulfedDigestionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private void HandleDigestion(in Entity entity, ref Engulfer engulfer, ref Organe
var takenAdjusted = taken * efficiency;
var added = compounds.AddCompound(compound, takenAdjusted);

// Eject excess
// Eject excess (we just want to get rid of it, we don't care if the eject failed)
cellProperties.SpawnEjectedCompound(ref position, compoundCloudSystem, compound,
takenAdjusted - added, Vector3.Back);
}
Expand Down
10 changes: 7 additions & 3 deletions src/microbe_stage/systems/MicrobeEmissionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ private void HandleSlimeSecretion(in Entity entity, ref MicrobeControl control,
// Activate all jets, which will constantly secrete slime until we turn them off
foreach (var jet in organelles.SlimeJets)
{
// Make sure this is animating
jet.Active = true;

// Secrete the slime
float slimeToSecrete = Math.Min(Constants.COMPOUNDS_TO_VENT_PER_SECOND * delta,
compounds.GetCompoundAmount(Compound.Mucilage));
Expand All @@ -341,6 +338,13 @@ private void HandleSlimeSecretion(in Entity entity, ref MicrobeControl control,
slimeToSecrete = cellProperties.EjectCompound(ref worldPosition, compounds, clouds, Compound.Mucilage,
slimeToSecrete, -direction, 2);

// If we couldn't emit (due to no membrane yet), then skip for now
if (slimeToSecrete <= 0)
continue;

// Make sure this is animating
jet.Active = true;

// Queue movement force to be used by the movement system based on the amount of slime ejected
jet.AddQueuedForce(entity, slimeToSecrete);
}
Expand Down