Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update microbe digestion at only 30 times per second #4143

Merged
merged 1 commit into from Feb 21, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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