Skip to content

Commit

Permalink
Update microbe digestion at only 30 times per second (#4143)
Browse files Browse the repository at this point in the history
Update microbe digestion only at 30 times per second
  • Loading branch information
athariqk committed Feb 21, 2023
1 parent 582ea7e commit b836660
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions simulation_parameters/Constants.cs
Expand Up @@ -117,6 +117,8 @@ public static class Constants

public const float MICROBE_MOVEMENT_SOUND_EMIT_COOLDOWN = 1.3f;

public const float MICROBE_DIGESTION_UPDATE_INTERVAL = 0.0333f;

public const float CELL_BASE_ROTATION = 0.2f;
public const float CELL_MAX_ROTATION = 0.40f;
public const float CELL_MIN_ROTATION = 0.005f;
Expand Down
7 changes: 6 additions & 1 deletion src/microbe_stage/Microbe.Interior.cs
Expand Up @@ -90,6 +90,7 @@ public partial class Microbe
private bool allOrganellesDivided;

private float timeUntilChemoreceptionUpdate = Constants.CHEMORECEPTOR_COMPOUND_UPDATE_INTERVAL;
private float timeUntilDigestionUpdate = Constants.MICROBE_DIGESTION_UPDATE_INTERVAL;

private bool organelleMaxRenderPriorityDirty = true;
private int cachedOrganelleMaxRenderPriority;
Expand Down Expand Up @@ -1410,9 +1411,13 @@ private void HandleChemoreceptorLines(float delta)
/// </summary>
private void HandleDigestion(float delta)
{
if (Dead)
timeUntilDigestionUpdate -= delta;

if (timeUntilDigestionUpdate > 0 || Dead)
return;

timeUntilDigestionUpdate = Constants.MICROBE_DIGESTION_UPDATE_INTERVAL;

var compoundTypes = SimulationParameters.Instance.GetAllCompounds();
var oxytoxy = SimulationParameters.Instance.GetCompound("oxytoxy");

Expand Down

0 comments on commit b836660

Please sign in to comment.