Added survival mechanic that consumes inventory items if needed.

This commit is contained in:
2026-05-09 12:22:04 +02:00
parent 8a79a3474e
commit 9f32152fb8
11 changed files with 356 additions and 25 deletions
+18
View File
@@ -16,6 +16,10 @@ public partial class UIHandler : Control
[Export] PanelContainer inventory;
[Export] ResearchList researchList;
[Export] TextureRect robotAlarm;
[Export] RichTextLabel energyLabel;
[Export] RichTextLabel waterLabel;
[Export] RichTextLabel hungerLabel;
[Export] RichTextLabel survivalStatus;
private bool receivedRobotJumpSignal = false;
public override void _Ready()
@@ -89,6 +93,7 @@ public partial class UIHandler : Control
double memory = Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024);
string memoryDisplay = memory > 1024 ? Math.Round(memory / 1024, 2).ToString() + " GB" : memory.ToString() + " MB";
RAM.Text = memoryDisplay;
DisplaySurvivalStats();
}
public void ExitGame()
@@ -121,6 +126,11 @@ public partial class UIHandler : Control
private void DisplayRobotAlarm()
{
string messages = "";
if (GameData.survival.isDead)
{
messages += GameData.survival.currentStatus + "\r";
}
foreach (Robot robot in GameData.robots)
{
if (robot.currentMessage.Length > 0)
@@ -141,4 +151,12 @@ public partial class UIHandler : Control
codingWindow.SetRobot(robot);
OpenUIElement(codingWindow);
}
private void DisplaySurvivalStats()
{
energyLabel.Text = $"Energy: {GameData.survival.energy:0}/{GameData.survival.maxEnergy:0}";
waterLabel.Text = $"Water: {GameData.survival.thirst:0}/{GameData.survival.maxThirst:0}";
hungerLabel.Text = $"Food: {GameData.survival.hunger:0}/{GameData.survival.maxHunger:0}";
survivalStatus.Text = GameData.survival.currentStatus;
}
}