Added final features for this release. Now only polishing (if needed) remains.

Features: Sacrifice-Node, Maintain-Node, Options for screen type, lightcolor and soundvolume, tied in sound effects, game pause when menu is open, visibly open up gate when opening it.
This commit is contained in:
2026-05-10 14:09:14 +02:00
parent 228e81ab4e
commit 8170b700b2
28 changed files with 797 additions and 14 deletions
+19
View File
@@ -62,6 +62,25 @@ public class FileHandler
return file.GetAsText();
}
public static bool DeleteProgram(string name)
{
CreateScriptDirectory();
string path = GetProgramPath(name);
if (!FileAccess.FileExists(path))
{
return false;
}
DirAccess dir = DirAccess.Open(ScriptDirectory);
if (dir == null)
{
return false;
}
return dir.Remove($"{name}{ScriptExtension}") == Error.Ok;
}
private static string GetProgramPath(string filename)
{
return $"{ScriptDirectory}/{filename}{ScriptExtension}";
+23
View File
@@ -25,9 +25,12 @@ public partial class GameData
public static Dictionary<int, List<Ingredient>> gateUnlocks;
public static bool loadSaveOnStart = false;
public static bool showTutorial = true;
public static bool isPaused = false;
public static Color primaryColor = new Color("#276ac2");
public static Color lightColor = new Color("#7efff5");
public static int screenMode = 2;
public static float soundVolume = 0.8f;
public static int ruinSize = 10;
public static int layerSize = 20;
@@ -44,12 +47,14 @@ public partial class GameData
robotStats = new RobotStats();
inventory = new Inventory();
availableResearch = ResourceLoader.LoadResearch();
map = null;
robots.Clear();
currentLayer = 0;
visibleLayer = 0;
lowestLayer = 0;
maxRobotCount = 10;
canMove = true;
isPaused = false;
}
public static void RebuildRobotStatsFromResearch()
@@ -65,4 +70,22 @@ public partial class GameData
}
}
}
public static bool HasSpawnableRobotInInventory()
{
foreach (Item item in inventory.items)
{
if (robotStats.RobotTypes.ContainsKey(item.data.Id) && item.currentAmount > 0)
{
return true;
}
}
return false;
}
public static bool HasNoRobotRecovery()
{
return robots.Count <= 0 && !HasSpawnableRobotInInventory();
}
}
+3 -1
View File
@@ -74,7 +74,9 @@ public partial class ResourceLoader
{ new ElseNode(), GD.Load<PackedScene>("res://Prefabs/DSL/ElseNode.tscn") },
{ new UntilNode(), GD.Load<PackedScene>("res://Prefabs/DSL/UntilNode.tscn") },
{ new ForNode(), GD.Load<PackedScene>("res://Prefabs/DSL/ForNode.tscn") },
{ new WhileNode(), GD.Load<PackedScene>("res://Prefabs/DSL/WhileNode.tscn") }
{ new WhileNode(), GD.Load<PackedScene>("res://Prefabs/DSL/WhileNode.tscn") },
{ new MaintainNode(), GD.Load<PackedScene>("res://Prefabs/DSL/MaintainNode.tscn") },
{ new SacrificeNode(), GD.Load<PackedScene>("res://Prefabs/DSL/SacrificeNode.tscn") }
};
return nodes;
}
+11
View File
@@ -8,6 +8,7 @@ public class SaveGameData
public int LowestLayer { get; set; }
public int MaxRobotCount { get; set; }
public bool CanMove { get; set; }
public SettingsSaveData Settings { get; set; }
public SurvivalSaveData Survival { get; set; }
public List<ItemSaveData> Inventory { get; set; }
public List<ResearchSaveData> Research { get; set; }
@@ -15,6 +16,16 @@ public class SaveGameData
public List<RobotSaveData> Robots { get; set; }
}
public class SettingsSaveData
{
public int ScreenMode { get; set; }
public float SoundVolume { get; set; }
public float LightColorR { get; set; }
public float LightColorG { get; set; }
public float LightColorB { get; set; }
public float LightColorA { get; set; }
}
public class SurvivalSaveData
{
public float Hunger { get; set; }
+54 -1
View File
@@ -61,6 +61,7 @@ public static class SaveGameManager
LowestLayer = GameData.lowestLayer,
MaxRobotCount = GameData.maxRobotCount,
CanMove = GameData.canMove,
Settings = CreateSettingsSaveData(),
Survival = CreateSurvivalSaveData(),
Inventory = CreateInventorySaveData(),
Research = CreateResearchSaveData(),
@@ -80,6 +81,7 @@ public static class SaveGameManager
GameData.maxRobotCount = saveGame.MaxRobotCount;
GameData.canMove = saveGame.CanMove;
ApplySettingsData(saveGame.Settings);
ApplySurvivalData(saveGame.Survival);
ApplyInventoryData(saveGame.Inventory);
ApplyResearchData(saveGame.Research);
@@ -100,6 +102,19 @@ public static class SaveGameManager
};
}
private static SettingsSaveData CreateSettingsSaveData()
{
return new SettingsSaveData
{
ScreenMode = GameData.screenMode,
SoundVolume = GameData.soundVolume,
LightColorR = GameData.lightColor.R,
LightColorG = GameData.lightColor.G,
LightColorB = GameData.lightColor.B,
LightColorA = GameData.lightColor.A
};
}
private static List<ItemSaveData> CreateInventorySaveData()
{
List<ItemSaveData> result = new List<ItemSaveData>();
@@ -201,6 +216,7 @@ public static class SaveGameManager
LowestLayer = saveGame.LowestLayer,
MaxRobotCount = saveGame.MaxRobotCount,
CanMove = saveGame.CanMove,
Settings = saveGame.Settings,
Survival = saveGame.Survival,
Inventory = saveGame.Inventory,
Research = new List<ResearchSaveData>(),
@@ -286,6 +302,43 @@ public static class SaveGameManager
GameData.survival.elapsedSeconds = survival.ElapsedSeconds;
}
private static void ApplySettingsData(SettingsSaveData settings)
{
if (settings == null) return;
GameData.screenMode = settings.ScreenMode;
GameData.soundVolume = settings.SoundVolume;
GameData.lightColor = new Color(
settings.LightColorR,
settings.LightColorG,
settings.LightColorB,
settings.LightColorA
);
ApplyScreenMode(settings.ScreenMode);
SoundManager.SetMasterVolume(settings.SoundVolume);
LightHandler.RedrawLights(GameData.lightColor);
}
private static void ApplyScreenMode(int screenMode)
{
switch (screenMode)
{
case 0:
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
break;
case 1:
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
break;
case 2:
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, true);
break;
}
}
private static void ApplyInventoryData(List<ItemSaveData> savedItems)
{
GameData.inventory = new Inventory();
@@ -353,7 +406,7 @@ public static class SaveGameManager
tile.containsResource = savedTile.ContainsResource;
tile.wasVisited = savedTile.WasVisited;
tile.resource = savedTile.Resource == null ? null : GameResource.FromSaveData(savedTile.Resource);
tile.ContentNode.Visible = savedTile.WasVisited || tile.collapsedMesh == "gate";
tile.ContentNode.Visible = savedTile.WasVisited || (tile.collapsedMesh == "gate" && !layer.isGateOpen);
}
}
}
+44
View File
@@ -0,0 +1,44 @@
using Godot;
public partial class SoundManager : Node
{
private static SoundManager instance;
[Export] private AudioStreamPlayer buttonSound;
[Export] private AudioStreamPlayer miningSound;
public override void _Ready()
{
instance = this;
}
public override void _ExitTree()
{
if (instance == this)
{
instance = null;
}
}
public static void PlayButton()
{
if (instance == null || instance.buttonSound == null) return;
instance.buttonSound.Play();
}
public static void PlayMining()
{
if (instance == null || instance.miningSound == null) return;
instance.miningSound.Play();
}
public static void SetMasterVolume(float percent)
{
percent = Mathf.Clamp(percent, 0f, 1f);
int busIndex = AudioServer.GetBusIndex("Master");
AudioServer.SetBusVolumeDb(busIndex, Mathf.LinearToDb(percent));
AudioServer.SetBusMute(busIndex, percent <= 0f);
}
}
+1
View File
@@ -0,0 +1 @@
uid://gvy12mefkwax