Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk26g committed Dec 13, 2024
1 parent c9eb9cb commit e698eea
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/microbe_stage/systems/MicrobeAISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor

ref var control = ref entity.Get<MicrobeControl>();

ref var cellHealth = ref entity.Get<Health>();

ref var compoundStorage = ref entity.Get<CompoundStorage>();

var compounds = compoundStorage.Compounds;
Expand Down Expand Up @@ -330,24 +332,30 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor
control.SetMucocystState(ref organelles, ref compoundStorage, entity, false);
}

float atpLevel = compounds.GetCompoundAmount(Compound.ATP);

// If this microbe is out of ATP, pick an amount of time to rest
if (compounds.GetCompoundAmount(Compound.ATP) < 1.0f)
if (atpLevel < 1.0f)
{
// Keep the maximum at 95% full, as there is flickering when near full
ai.ATPThreshold = 0.95f * speciesFocus / Constants.MAX_SPECIES_FOCUS;
}

if (ai.ATPThreshold > MathUtils.EPSILON)
{
if (compounds.GetCompoundAmount(Compound.ATP) <
compounds.GetCapacityForCompound(Compound.ATP) * ai.ATPThreshold)
if (atpLevel < atpLevel * ai.ATPThreshold)
{
// even if we are out of ATP and there is microbe nearby, engulf them
bool isMicrobeHunting = CheckForHuntingConditions(ref ai, ref position, ref organelles, ref ourSpecies,
ref engulfer, ref cellProperties, ref control, entity, compounds, speciesFocus, speciesAggression,
speciesActivity, speciesOpportunism, strain, random, true);
if (isMicrobeHunting)
return;
if (cellHealth.CurrentHealth > 2 * Constants.ENGULF_NO_ATP_DAMAGE)
{
// even if we are out of ATP and there is microbe nearby, engulf them.
// make sure engulfing doesn't kill the cell
bool isMicrobeHunting = CheckForHuntingConditions(ref ai, ref position, ref organelles,
ref ourSpecies, ref engulfer, ref cellProperties, ref control, entity, compounds,
speciesFocus, speciesAggression, speciesActivity, speciesOpportunism, strain,
random, true);
if (isMicrobeHunting)
return;
}

bool outOfSomething = false;
foreach (var compound in compounds.Compounds)
Expand Down

0 comments on commit e698eea

Please sign in to comment.