This commit is contained in:
2025-11-07 13:34:56 +01:00
2 changed files with 132 additions and 93 deletions

File diff suppressed because one or more lines are too long

View File

@@ -31,6 +31,12 @@ namespace Levels
/// Data for this level switch (target scene, icon, etc). /// Data for this level switch (target scene, icon, etc).
/// </summary> /// </summary>
public LevelSwitchData switchData; public LevelSwitchData switchData;
/// <summary>
/// If true, skip save/load logic and start the game active (unlocked by default)
/// </summary>
[SerializeField] private bool startUnlocked = false;
private SpriteRenderer iconRenderer; private SpriteRenderer iconRenderer;
// Settings reference // Settings reference
@@ -52,6 +58,12 @@ namespace Levels
if (iconRenderer == null) if (iconRenderer == null)
iconRenderer = GetComponent<SpriteRenderer>(); iconRenderer = GetComponent<SpriteRenderer>();
// If startUnlocked is true, set isUnlocked and skip save/load logic
if (startUnlocked)
{
isUnlocked = true;
}
// Initialize settings reference // Initialize settings reference
interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>(); interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
ApplySwitchData(); ApplySwitchData();
@@ -61,7 +73,14 @@ namespace Levels
{ {
base.Start(); // Register with save system base.Start(); // Register with save system
// If not restoring from save, start inactive // If startUnlocked is true, always start active
if (startUnlocked)
{
gameObject.SetActive(true);
return;
}
// Otherwise, if not restoring from save, start inactive
if (!IsRestoringFromSave && !isUnlocked) if (!IsRestoringFromSave && !isUnlocked)
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
@@ -165,6 +184,10 @@ namespace Levels
protected override object GetSerializableState() protected override object GetSerializableState()
{ {
// Skip saving if startUnlocked is true
if (startUnlocked)
return null;
return new MinigameSwitchSaveData return new MinigameSwitchSaveData
{ {
isUnlocked = isUnlocked isUnlocked = isUnlocked
@@ -173,6 +196,10 @@ namespace Levels
protected override void ApplySerializableState(string serializedData) protected override void ApplySerializableState(string serializedData)
{ {
// Skip loading if startUnlocked is true
if (startUnlocked)
return;
MinigameSwitchSaveData data = JsonUtility.FromJson<MinigameSwitchSaveData>(serializedData); MinigameSwitchSaveData data = JsonUtility.FromJson<MinigameSwitchSaveData>(serializedData);
if (data == null) if (data == null)
{ {