Files
AppleHillsProduction/Assets/Scripts/DamianExperiments/SoundBirdPuzzleSection/soundBird_CanFly.cs
Michal Pikulski 3ebbecc277 Clean up logging
2025-11-10 13:03:36 +01:00

53 lines
1.2 KiB
C#

using Core;
using UnityEngine;
using Core.Lifecycle;
[System.Serializable]
public class SoundBirdSaveData
{
public bool canFly;
}
public class soundBird_CanFly : ManagedBehaviour
{
public bool canFly = true;
// Enable save/load participation
public override bool AutoRegisterForSave => true;
public void birdCanHear(bool canhear)
{
canFly = canhear;
}
#region Save/Load Implementation
protected override string OnSceneSaveRequested()
{
var saveData = new SoundBirdSaveData
{
canFly = this.canFly
};
return JsonUtility.ToJson(saveData);
}
protected override void OnSceneRestoreRequested(string serializedData)
{
if (string.IsNullOrEmpty(serializedData))
{
Logging.Warning($"[soundBird_CanFly] No save data to restore for {gameObject.name}");
return;
}
var saveData = JsonUtility.FromJson<SoundBirdSaveData>(serializedData);
if (saveData != null)
{
canFly = saveData.canFly;
Logging.Debug($"[soundBird_CanFly] Restored canFly state: {canFly}");
}
}
#endregion
}