[go: nahoru, domu]

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

Hardcore mode #5160

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
30-seconds interval auto-save and saves on player death
  • Loading branch information
CI09 committed May 27, 2024
commit 78013be373be675cbd000b69169cd9141624824c
2 changes: 2 additions & 0 deletions simulation_parameters/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,8 @@ public static class Constants
/// </summary>
public const float MICROBE_MIN_ABSORB_RADIUS = 3;

public const float HARDCORE_AUTOSAVE_INTERVAL = 60;

public const float PROCEDURAL_CACHE_CLEAN_INTERVAL = 9.3f;
public const float PROCEDURAL_CACHE_MEMBRANE_KEEP_TIME = 500;
public const float PROCEDURAL_CACHE_MICROBE_SHAPE_TIME = 7000;
Expand Down
2 changes: 1 addition & 1 deletion src/general/WorldGenerationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public enum LifeOrigin
/// <summary>
/// This thing right here... It is... unforgiving.
/// </summary>
public bool HardcoreMode { get; set; } = false;
public bool HardcoreMode { get; set; }

/// <summary>
/// Unchangeable name for hardcore mode save
Expand Down
17 changes: 17 additions & 0 deletions src/general/base_stage/StageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public partial class StageBase : NodeWithInput, IStageBase, IGodotEarlyNodeResol
/// </summary>
private double elapsedSinceLightLevelUpdate = 1;

/// <summary>
/// Hardcore mode auto-saves during gameplay regularly.
/// </summary>
private double hardcoreModeAutosaveTimer = 2;
protected StageBase()
{
}
Expand Down Expand Up @@ -127,6 +131,19 @@ public override void _Process(double delta)
wantsToSave = false;
}

if (CurrentGame != null)
{
if (CurrentGame.GameWorld.WorldSettings.HardcoreMode)
{
hardcoreModeAutosaveTimer -= delta;
if (hardcoreModeAutosaveTimer <= 0)
{
hardcoreModeAutosaveTimer = Constants.HARDCORE_AUTOSAVE_INTERVAL;
AutoSave();
}
}
}

GameWorld.Process((float)delta);

elapsedSinceLightLevelUpdate += delta;
Expand Down
3 changes: 3 additions & 0 deletions src/microbe_stage/MicrobeStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,9 @@ private void OnPlayerDied(Entity player)
if (!engulfed)
TutorialState.SendEvent(TutorialEventType.MicrobePlayerDied, EventArgs.Empty, this);

if (CurrentGame!.GameWorld.WorldSettings.HardcoreMode)
AutoSave();

// Don't clear the player object here as we want to wait until the player entity is deleted before creating
// a new one to avoid having two player entities existing at the same time
}
Expand Down