[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
Next Next commit
Prototype unforgiving mode
  • Loading branch information
CI09 committed May 26, 2024
commit ba85ed56359e73fd7c3e94aa17078fabb40247d5
5 changes: 5 additions & 0 deletions src/general/NewGameSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public partial class NewGameSettings : ControlWithInput
private Button includeMulticellularButton = null!;
private Button easterEggsButton = null!;

[Export]
private Button unforgivingModeButton = null!;

// Other
private Container checkOptionsMenuAdviceContainer = null!;
#pragma warning restore CA2213
Expand Down Expand Up @@ -424,6 +427,7 @@ public void OpenFromDescendScreen(GameProperties currentGame)
lawkButton.ButtonPressed = false;

easterEggsButton.ButtonPressed = settings.EasterEggs;
unforgivingModeButton.ButtonPressed = settings.UnforgivingMode;
}

public void ReportValidityOfGameSeed(bool valid)
Expand Down Expand Up @@ -608,6 +612,7 @@ private void StartGame()

settings.IncludeMulticellular = includeMulticellularButton.ButtonPressed;
settings.EasterEggs = easterEggsButton.ButtonPressed;
settings.UnforgivingMode = unforgivingModeButton.ButtonPressed;

// Stop music for the video (stop is used instead of pause to stop the menu music playing a bit after the video
// before the stage music starts)
Expand Down
21 changes: 20 additions & 1 deletion src/general/NewGameSettings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ font = ExtResource("5_otvf3")

[sub_resource type="StyleBoxEmpty" id="4"]

[node name="NewGameSettings" type="Control"]
[node name="NewGameSettings" type="Control" node_paths=PackedStringArray("unforgivingModeButton")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand Down Expand Up @@ -82,6 +82,7 @@ IncludeMulticellularButtonPath = NodePath("CenterContainer/VBoxContainer/Advance
EasterEggsButtonPath = NodePath("CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer3/EasterEggs")
StartButtonPath = NodePath("CenterContainer/VBoxContainer/HBoxContainer/Start")
CheckOptionsMenuAdviceContainerPath = NodePath("CenterContainer/VBoxContainer/BasicOptions/Main/VBoxContainer/CheckPerformanceSettingsContainer")
unforgivingModeButton = NodePath("CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer4/UnforgivingMode")

[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 0
Expand Down Expand Up @@ -912,6 +913,23 @@ text = "EASTER_EGGS_EXPLANATION"
label_settings = ExtResource("5_rnvau")
autowrap_mode = 3

[node name="VBoxContainer4" type="VBoxContainer" parent="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer"]
layout_mode = 2

[node name="UnforgivingMode" type="CheckBox" parent="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer4"]
layout_mode = 2
size_flags_horizontal = 0
button_pressed = true
text = "UNFORGIVING_MODE"

[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer4"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 3
text = "UNFORGIVING_MODE_EXPLANATION"
label_settings = ExtResource("5_rnvau")
autowrap_mode = 3

[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
layout_mode = 2

Expand Down Expand Up @@ -988,6 +1006,7 @@ text = "START_GAME"
[connection signal="pressed" from="CenterContainer/VBoxContainer/AdvancedOptions/Planet/VBoxContainer/HBoxContainer3/HBoxContainer/RandomizeButtonAdvanced" to="." method="OnRandomisedGameSeedPressed"]
[connection signal="toggled" from="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer2/IncludeMulticellular" to="." method="OnIncludeMulticellularToggled"]
[connection signal="toggled" from="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer3/EasterEggs" to="." method="OnEasterEggsToggled"]
[connection signal="toggled" from="CenterContainer/VBoxContainer/AdvancedOptions/Misc/VBoxContainer/VBoxContainer4/UnforgivingMode" to="." method="OnEasterEggsToggled"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/Back" to="." method="OnBackPressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/Basic" to="." method="OnBasicPressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/Advanced" to="." method="OnAdvancedPressed"]
Expand Down
16 changes: 16 additions & 0 deletions src/general/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@ private void OpenLoadPressed()
{
GUICommon.Instance.PlayButtonPressSound();

if (GameProperties != null)
{
if (GameProperties.GameWorld.WorldSettings.UnforgivingMode)
{
return;
}
}

ActiveMenu = ActiveMenuType.Load;
}

Expand Down Expand Up @@ -545,6 +553,14 @@ private void OpenSavePressed()
{
GUICommon.Instance.PlayButtonPressSound();

if (GameProperties != null)
{
if (GameProperties.GameWorld.WorldSettings.UnforgivingMode)
{
return;
}
}

ActiveMenu = ActiveMenuType.Save;
}

Expand Down
6 changes: 6 additions & 0 deletions src/general/WorldGenerationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public enum LifeOrigin
/// </summary>
public bool EasterEggs { get; set; } = true;

/// <summary>
/// This thing right here... It is... unforgiving.
/// </summary>
public bool UnforgivingMode { get; set; } = false;

/// <summary>
/// The auto-evo configuration this world uses
/// </summary>
Expand Down Expand Up @@ -186,6 +191,7 @@ public override string ToString()
$", Day length: {DayLength}" +
$", Include multicellular: {IncludeMulticellular}" +
$", Easter eggs: {EasterEggs}" +
$", Unforgiving mode: {UnforgivingMode}" +
"]";
}
}
5 changes: 5 additions & 0 deletions src/general/base_stage/EditorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,11 @@ protected virtual void PerformQuickSave()
throw new GodotAbstractMethodNotOverriddenException();
}

protected virtual void PerformUnforgivingModeSave()
{
throw new GodotAbstractMethodNotOverriddenException();
}

protected virtual void SaveGame(string name)
{
throw new GodotAbstractMethodNotOverriddenException();
Expand Down
12 changes: 12 additions & 0 deletions src/microbe_stage/MicrobeStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,23 @@ protected override void PlayerExtinctInPatch()

protected override void AutoSave()
{
if (WorldSettings.UnforgivingMode)
{
// Name: CurrentGame.GameWorld.WorldSettings...
SaveHelper.UnforgivingModeSave("Hard", this);
return;
}

SaveHelper.AutoSave(this);
}

protected override void PerformQuickSave()
{
if (WorldSettings.UnforgivingMode)
{
return;
}

SaveHelper.QuickSave(this);
}

Expand Down
21 changes: 21 additions & 0 deletions src/microbe_stage/editor/MicrobeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,35 @@ protected override void OnRedoPerformed()

protected override void PerformAutoSave()
{
if (CurrentGame.GameWorld.WorldSettings.UnforgivingMode)
{
// Name: CurrentGame.GameWorld.WorldSettings...
SaveHelper.UnforgivingModeSave("Hard", this);
return;
}

SaveHelper.AutoSave(this);
}

protected override void PerformQuickSave()
{
if (CurrentGame.GameWorld.WorldSettings.UnforgivingMode)
{
return;
}

SaveHelper.QuickSave(this);
}

protected override void PerformUnforgivingModeSave()
{
if (!CurrentGame.GameWorld.WorldSettings.UnforgivingMode)
return;

// Name: CurrentGame.GameWorld.WorldSettings...
SaveHelper.UnforgivingModeSave("Hard", this);
}

protected override void SaveGame(string name)
{
SaveHelper.Save(name, this);
Expand Down
22 changes: 22 additions & 0 deletions src/saving/SaveHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using Godot;
using DirAccess = Godot.DirAccess;
using FileAccess = Godot.FileAccess;
Expand Down Expand Up @@ -220,6 +221,27 @@ public static QuickLoadError QuickLoad()
return QuickLoadError.None;
}

/// <summary>
/// Save the game into the main save (for unforgiving mode)
/// </summary>
public static void UnforgivingModeSave(string name, MicrobeStage state)
{
InternalSaveHelper(SaveInformation.SaveType.Manual, MainGameState.MicrobeStage, save =>
{
save.SavedProperties = state.CurrentGame;
save.MicrobeStage = state;
}, () => state, name);
}

public static void UnforgivingModeSave(string name, MicrobeEditor state)
{
InternalSaveHelper(SaveInformation.SaveType.Manual, MainGameState.MicrobeEditor, save =>
{
save.SavedProperties = state.CurrentGame;
save.MicrobeEditor = state;
}, () => state, name);
}

/// <summary>
/// Returns a list of all saves
/// </summary>
Expand Down