diff --git a/Assets/Editor/Tools/DebugSaveIds.cs b/Assets/Editor/Tools/DebugSaveIds.cs new file mode 100644 index 00000000..06b351fe --- /dev/null +++ b/Assets/Editor/Tools/DebugSaveIds.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using UnityEditor; +using Core.Lifecycle; + +namespace Editor.Tools +{ + /// + /// Editor utility to debug SaveIds for all ManagedBehaviours in the scene + /// + public class DebugSaveIds : EditorWindow + { + [MenuItem("Tools/Debug/Log All SaveIds")] + public static void LogAllSaveIds() + { + var allManaged = FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); + + Debug.Log($"=== Found {allManaged.Length} ManagedBehaviours ==="); + + foreach (var managed in allManaged) + { + if (managed.AutoRegisterForSave) + { + Debug.Log($"GameObject: {managed.gameObject.name} | Component: {managed.GetType().Name} | SaveID: {managed.SaveId}"); + } + } + + Debug.Log("=== End SaveIds ==="); + } + } +} + diff --git a/Assets/Editor/Tools/DebugSaveIds.cs.meta b/Assets/Editor/Tools/DebugSaveIds.cs.meta new file mode 100644 index 00000000..c8f54a3c --- /dev/null +++ b/Assets/Editor/Tools/DebugSaveIds.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a34fbba4efbb4acd85d79a99abf00a08 +timeCreated: 1762358959 \ No newline at end of file diff --git a/Assets/Scenes/Levels/Quarry.unity b/Assets/Scenes/Levels/Quarry.unity index d5ab79ca..7f1908bc 100644 --- a/Assets/Scenes/Levels/Quarry.unity +++ b/Assets/Scenes/Levels/Quarry.unity @@ -1902,7 +1902,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 111903060} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &111903060 MonoBehaviour: m_ObjectHideFlags: 0 @@ -430692,7 +430692,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 244965524} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &244965524 MonoBehaviour: m_ObjectHideFlags: 0 @@ -431154,7 +431154,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 268725217} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &268725217 MonoBehaviour: m_ObjectHideFlags: 0 @@ -431473,7 +431473,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 1d09d0bd473edd744a5c98fb45f159ec, type: 3} audioSource: {fileID: 272306129} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &272306129 MonoBehaviour: m_ObjectHideFlags: 0 @@ -432362,7 +432362,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 289703785} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &289703783 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -432774,7 +432774,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 302630994} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &302630992 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -433484,7 +433484,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 325464635} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &325464633 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -438220,7 +438220,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 570413072} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &570413070 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -440309,7 +440309,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 696969637} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &696969635 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -440721,7 +440721,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 702911171} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &702911169 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -441391,7 +441391,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 6104d2de1cbe86846b0e152caace38c1, type: 3} audioSource: {fileID: 719693379} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &719693379 MonoBehaviour: m_ObjectHideFlags: 0 @@ -441417,7 +441417,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 726450010} - m_Layer: 10 + m_Layer: 0 m_Name: AnimContainer m_TagString: Untagged m_Icon: {fileID: 0} @@ -442264,7 +442264,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 779867987} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &779867985 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -444462,7 +444462,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 914558071} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &914558071 MonoBehaviour: m_ObjectHideFlags: 0 @@ -445513,7 +445513,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 982160414} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &982160412 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -447305,7 +447305,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1057088622} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1057088620 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -448008,7 +448008,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1073825572} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1073825570 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -454144,7 +454144,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1378408888} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1378408886 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -454504,10 +454504,22 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 368957768} m_Modifications: + - target: {fileID: 22512726373136855, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_Layer + value: 0 + objectReference: {fileID: 0} - target: {fileID: 588897581313790951, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: m_Name value: SoundBird_Slot objectReference: {fileID: 0} + - target: {fileID: 588897581313790951, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_Layer + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 588897581313790951, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 2433130051631076285, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: onCorrectItemSlotted.m_PersistentCalls.m_Calls.Array.size value: 2 @@ -454523,7 +454535,7 @@ PrefabInstance: - target: {fileID: 2433130051631076285, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: onCorrectItemSlotted.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: - objectReference: {fileID: 1399567338} + objectReference: {fileID: 0} - target: {fileID: 2433130051631076285, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: onCorrectItemSlotted.m_PersistentCalls.m_Calls.Array.data[1].m_Target value: @@ -454562,11 +454574,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2523333015159032981, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: m_LocalPosition.x - value: 0.11 + value: 0.04 objectReference: {fileID: 0} - target: {fileID: 2523333015159032981, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: m_LocalPosition.y - value: 0.73 + value: -0.22 objectReference: {fileID: 0} - target: {fileID: 2523333015159032981, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} propertyPath: m_LocalPosition.z @@ -454600,53 +454612,66 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - m_RemovedComponents: [] + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalScale.x + value: 0.336075 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalScale.y + value: 0.336075 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalScale.z + value: 0.336075 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalPosition.x + value: -0.27 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalPosition.y + value: 2.37 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalRotation.w + value: 0.9971517 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalRotation.z + value: -0.075422555 + objectReference: {fileID: 0} + - target: {fileID: 3907351184805552114, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: -8.651 + objectReference: {fileID: 0} + m_RemovedComponents: + - {fileID: 2433130051631076285, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + - {fileID: 5057760771402457000, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: - targetCorrespondingSourceObject: {fileID: 2523333015159032981, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} insertIndex: -1 addedObject: {fileID: 726450010} - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 588897581313790951, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} - insertIndex: -1 - addedObject: {fileID: 1399567338} - - targetCorrespondingSourceObject: {fileID: 588897581313790951, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} - insertIndex: -1 - addedObject: {fileID: 1399567337} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} --- !u!4 &1399567330 stripped Transform: m_CorrespondingSourceObject: {fileID: 2523333015159032981, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} m_PrefabInstance: {fileID: 1399567329} m_PrefabAsset: {fileID: 0} ---- !u!114 &1399567337 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} +--- !u!212 &1399567344 stripped +SpriteRenderer: + m_CorrespondingSourceObject: {fileID: 8875860401447896107, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + m_PrefabInstance: {fileID: 1399567329} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 985170802} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1101f6c4eb04423b89dc78dc7c9f1aae, type: 3} - m_Name: - m_EditorClassIdentifier: AppleHillsScripts::PuzzleS.ObjectiveStepBehaviour - stepData: {fileID: 11400000, guid: 37409d749a15970438d761d1d658d7a6, type: 2} - puzzleIndicator: {fileID: 287904383} - drawPromptRangeGizmo: 1 ---- !u!114 &1399567338 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 985170802} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b6a41511eddc628479b46152f9042034, type: 3} - m_Name: - m_EditorClassIdentifier: AppleHillsScripts::soundBird_CanFly - canFly: 1 --- !u!4 &1413812638 stripped Transform: m_CorrespondingSourceObject: {fileID: 2064225848720495177, guid: 0bbded61e58193848ac59c8eea761bcc, type: 3} @@ -454949,7 +454974,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1421238381} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &1421238381 MonoBehaviour: m_ObjectHideFlags: 0 @@ -456421,7 +456446,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1498457922} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1498457920 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -457455,7 +457480,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1539536035} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1539536033 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -460080,6 +460105,11 @@ Transform: m_CorrespondingSourceObject: {fileID: 5145306031820616614, guid: fbbe1f4baf226904b96f839fe0c00181, type: 3} m_PrefabInstance: {fileID: 1700499946} m_PrefabAsset: {fileID: 0} +--- !u!212 &1707349194 stripped +SpriteRenderer: + m_CorrespondingSourceObject: {fileID: 6941190210788968874, guid: 9ad58c5e86338824db8a6daebdb432b5, type: 3} + m_PrefabInstance: {fileID: 1399567329} + m_PrefabAsset: {fileID: 0} --- !u!4 &1707431187 stripped Transform: m_CorrespondingSourceObject: {fileID: 9067462609398217044, guid: 6cbcaf4eb20e63e4fb462f6fb1ada3a7, type: 3} @@ -460900,7 +460930,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 1754168044} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1754168042 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -462191,6 +462221,23 @@ Transform: m_CorrespondingSourceObject: {fileID: 5145306031820616614, guid: fbbe1f4baf226904b96f839fe0c00181, type: 3} m_PrefabInstance: {fileID: 1827605008} m_PrefabAsset: {fileID: 0} +--- !u!1 &1831642003 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} + m_PrefabInstance: {fileID: 7530821580781571560} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1831642012 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1831642003} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a5c5614fc04140cb81e5bda7451f7b14, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::Core.SaveablePlayableDirector --- !u!4 &1831700627 stripped Transform: m_CorrespondingSourceObject: {fileID: 2064225848720495177, guid: 0bbded61e58193848ac59c8eea761bcc, type: 3} @@ -463926,16 +463973,184 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1923065564} - - component: {fileID: 1923065563} - - component: {fileID: 1923065565} - m_Layer: 6 - m_Name: LureSpotD + - component: {fileID: 1923065570} + - component: {fileID: 1923065569} + - component: {fileID: 1923065567} + - component: {fileID: 1923065566} + - component: {fileID: 1923065571} + m_Layer: 10 + m_Name: SoundBird_Slot m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!212 &1923065563 +--- !u!4 &1923065564 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923065562} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -63.09, y: 69.38, z: 0} + m_LocalScale: {x: 0.37, y: 0.37, z: 0.37} + m_ConstrainProportionsScale: 1 + m_Children: [] + m_Father: {fileID: 123989455} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1923065566 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923065562} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1101f6c4eb04423b89dc78dc7c9f1aae, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::PuzzleS.ObjectiveStepBehaviour + stepData: {fileID: 11400000, guid: 37409d749a15970438d761d1d658d7a6, type: 2} + puzzleIndicator: {fileID: 287904383} + drawPromptRangeGizmo: 1 +--- !u!114 &1923065567 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923065562} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ec1a2e6e32f746c4990c579e13b79104, type: 3} + m_Name: + m_EditorClassIdentifier: + isOneTime: 0 + cooldown: -1 + characterToInteract: 2 + interactionStarted: + m_PersistentCalls: + m_Calls: [] + interactionInterrupted: + m_PersistentCalls: + m_Calls: [] + characterArrived: + m_PersistentCalls: + m_Calls: [] + interactionComplete: + m_PersistentCalls: + m_Calls: [] + itemData: {fileID: 11400000, guid: d28f5774afad9d14f823601707150700, type: 2} + iconRenderer: {fileID: 1399567344} + slottedItemRenderer: {fileID: 1707349194} + onItemSlotted: + m_PersistentCalls: + m_Calls: [] + onItemSlotRemoved: + m_PersistentCalls: + m_Calls: [] + onCorrectItemSlotted: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1923065571} + m_TargetAssemblyTypeName: soundBird_CanFly, AppleHillsScripts + m_MethodName: birdCanHear + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 2078227529} + m_TargetAssemblyTypeName: StateMachines.Quarry.AnneLise.AnneLiseBushBehaviour, + AppleHillsScripts + m_MethodName: TakePhoto + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + onIncorrectItemSlotted: + m_PersistentCalls: + m_Calls: [] + onForbiddenItemSlotted: + m_PersistentCalls: + m_Calls: [] +--- !u!60 &1923065569 +PolygonCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923065562} + m_Enabled: 1 + serializedVersion: 3 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_CompositeOperation: 0 + m_CompositeOrder: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.85} + oldSize: {x: 28.54, y: 11.7699995} + newSize: {x: 5.75, y: 2.78} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + m_Points: + m_Paths: + - - {x: 0.9456428, y: 7.9031587} + - {x: -0.9287431, y: 7.9689703} + - {x: -2.3989377, y: 7.7114477} + - {x: -1.8791801, y: 4.213721} + - {x: -2.6891537, y: 0.7473569} + - {x: -3.2678564, y: -2.19693} + - {x: -6.1268663, y: -3.3027384} + - {x: -6.289084, y: -4.801543} + - {x: -5.221405, y: -5.489919} + - {x: -3.1789913, y: -5.9068346} + - {x: -0.48813522, y: -5.198251} + - {x: 0.81940895, y: -5.7292156} + - {x: 3.5745897, y: -5.666696} + - {x: 5.177432, y: -4.946728} + - {x: 5.02834, y: -3.0319362} + - {x: 3.1599524, y: -1.4057614} + - {x: 2.0294929, y: 0.9580931} + - {x: 1.0456197, y: 4.7535105} + m_UseDelaunayMesh: 0 +--- !u!212 &1923065570 SpriteRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -463993,67 +464208,19 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 1 ---- !u!4 &1923065564 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1923065562} - serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -63.09, y: 69.38, z: 0} - m_LocalScale: {x: 0.37, y: 0.37, z: 0.37} - m_ConstrainProportionsScale: 1 - m_Children: [] - m_Father: {fileID: 123989455} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!61 &1923065565 -BoxCollider2D: +--- !u!114 &1923065571 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1923065562} m_Enabled: 1 - serializedVersion: 3 - m_Density: 1 - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_ForceSendLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ForceReceiveLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_ContactCaptureLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_CallbackLayers: - serializedVersion: 2 - m_Bits: 4294967295 - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_CompositeOperation: 0 - m_CompositeOrder: 0 - m_Offset: {x: 0, y: -0.76} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.85} - oldSize: {x: 28.54, y: 11.7699995} - newSize: {x: 5.75, y: 2.78} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - m_Size: {x: 6.3, y: 3.5} - m_EdgeRadius: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b6a41511eddc628479b46152f9042034, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::soundBird_CanFly + canFly: 1 --- !u!1 &1925761599 GameObject: m_ObjectHideFlags: 0 @@ -465257,7 +465424,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 702911171} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &1967124852 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -466884,7 +467051,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 2054236281} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!4 &2054236279 stripped Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} @@ -467907,7 +468074,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 2086965023} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &2086965023 MonoBehaviour: m_ObjectHideFlags: 0 @@ -469000,7 +469167,7 @@ MonoBehaviour: enterSound: {fileID: 8300000, guid: 975d8d57c80dbbd478eff9545f015f8f, type: 3} audioSource: {fileID: 2145742837} soundBirdSMRef: {fileID: 368957774} - soundbirdHearingCheck: {fileID: 1399567338} + soundbirdHearingCheck: {fileID: 1923065571} --- !u!114 &2145742837 MonoBehaviour: m_ObjectHideFlags: 0 @@ -469178,7 +469345,7 @@ PrefabInstance: objectReference: {fileID: 708284665} - target: {fileID: 2519051890178917637, guid: fc42c3bdda1c86d49b0bf80c28e5d372, type: 3} propertyPath: m_LocalPosition.x - value: 6.11 + value: -5.01 objectReference: {fileID: 0} - target: {fileID: 5418919921209364345, guid: fc42c3bdda1c86d49b0bf80c28e5d372, type: 3} propertyPath: m_Name @@ -470068,7 +470235,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5415533004257413878, guid: 3fa494ec083cbe54a86c3a1b107a90c0, type: 3} propertyPath: m_LocalPosition.x - value: 6.5 + value: -4.57 objectReference: {fileID: 0} - target: {fileID: 6239236866170444314, guid: 3fa494ec083cbe54a86c3a1b107a90c0, type: 3} propertyPath: dialogueGraph @@ -470174,7 +470341,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} + insertIndex: -1 + addedObject: {fileID: 1831642012} m_SourcePrefab: {fileID: 100100000, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} --- !u!1001 &7638743433705074736 PrefabInstance: diff --git a/Assets/Scripts/Animation/BirdEyesBehavior.cs b/Assets/Scripts/Animation/BirdEyesBehavior.cs index 65f5a541..1f800902 100644 --- a/Assets/Scripts/Animation/BirdEyesBehavior.cs +++ b/Assets/Scripts/Animation/BirdEyesBehavior.cs @@ -1,44 +1,82 @@ +using Core.Lifecycle; using Core.SaveLoad; using UnityEngine; -using Pixelplacement; -public class BirdEyesBehavior : MonoBehaviour +public class BirdEyesBehavior : ManagedBehaviour { - private AppleMachine statemachine; - private Animator animator; + // Animator Hashes + private static readonly int RightGuess = Animator.StringToHash("RightGuess"); + private static readonly int WrongGuess = Animator.StringToHash("WrongGuess"); + private static readonly int NoGuess = Animator.StringToHash("NoGuess"); + private static readonly int Wolterisout = Animator.StringToHash("wolterisout"); + + private AppleMachine _statemachine; + private Animator _animator; public bool correctItemIsIn; [SerializeField] private Animator bushAnimator; // Assign in Inspector + + // Save state + private bool _wolterisoutTriggered; + + // Enable save/load participation + public override bool AutoRegisterForSave => true; + // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { - statemachine = GetComponent(); - animator = GetComponentInChildren(); + _statemachine = GetComponent(); + _animator = GetComponentInChildren(); } public void CorrectItem() { correctItemIsIn = true; - animator.SetTrigger("RightGuess"); + _animator.SetTrigger(RightGuess); BirdReveal(); } public void IncorrectItem() { correctItemIsIn = false; - animator.SetTrigger("WrongGuess"); + _animator.SetTrigger(WrongGuess); } + public void NoItem() { - animator.SetTrigger("NoGuess"); + _animator.SetTrigger(NoGuess); } + public void BirdReveal() { if (bushAnimator != null) { - bushAnimator.SetTrigger("wolterisout"); - statemachine.ChangeState("BirdSpawned"); - return; + bushAnimator.SetTrigger(Wolterisout); + _wolterisoutTriggered = true; } - statemachine.ChangeState ("BirdSpawned"); + _statemachine.ChangeState("BirdSpawned"); + } + + protected override void OnSceneRestoreRequested(string serializedData) + { + base.OnSceneRestoreRequested(serializedData); + + if (!string.IsNullOrEmpty(serializedData)) + { + if (bool.TryParse(serializedData, out bool wasTriggered)) + { + _wolterisoutTriggered = wasTriggered; + + // If it was triggered before, set it again on restore + if (_wolterisoutTriggered && bushAnimator != null) + { + bushAnimator.SetTrigger(Wolterisout); + } + } + } + } + + protected override string OnSceneSaveRequested() + { + return _wolterisoutTriggered.ToString(); } } diff --git a/Assets/Scripts/Core/Lifecycle/LifecycleManager.cs b/Assets/Scripts/Core/Lifecycle/LifecycleManager.cs index 0aed8370..82bbd221 100644 --- a/Assets/Scripts/Core/Lifecycle/LifecycleManager.cs +++ b/Assets/Scripts/Core/Lifecycle/LifecycleManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using UnityEngine; @@ -382,8 +382,9 @@ namespace Core.Lifecycle string serializedData = component.InvokeSceneSaveRequested(); if (!string.IsNullOrEmpty(serializedData)) { - saveData[component.SaveId] = serializedData; - LogDebug($"Collected scene save data from: {component.SaveId}"); + string saveId = component.SaveId; + saveData[saveId] = serializedData; + LogDebug($"Collected scene save data from: {saveId} (Type: {component.GetType().Name})"); } } catch (Exception ex) diff --git a/Assets/Scripts/Core/Lifecycle/ManagedBehaviour.cs b/Assets/Scripts/Core/Lifecycle/ManagedBehaviour.cs index 199f9260..085797be 100644 --- a/Assets/Scripts/Core/Lifecycle/ManagedBehaviour.cs +++ b/Assets/Scripts/Core/Lifecycle/ManagedBehaviour.cs @@ -66,7 +66,7 @@ namespace Core.Lifecycle /// /// Unique identifier for this component in the save system. - /// Default: "SceneName/GameObjectName" + /// Default: "SceneName/GameObjectName/ComponentType" /// Override ONLY for special cases (e.g., singletons like "PlayerController", or custom IDs). /// public virtual string SaveId @@ -74,7 +74,8 @@ namespace Core.Lifecycle get { string sceneName = gameObject.scene.IsValid() ? gameObject.scene.name : "UnknownScene"; - return $"{sceneName}/{gameObject.name}"; + string componentType = GetType().Name; + return $"{sceneName}/{gameObject.name}/{componentType}"; } } diff --git a/Assets/Scripts/Core/SaveLoad/AppleMachine.cs b/Assets/Scripts/Core/SaveLoad/AppleMachine.cs index 99f44848..18479b37 100644 --- a/Assets/Scripts/Core/SaveLoad/AppleMachine.cs +++ b/Assets/Scripts/Core/SaveLoad/AppleMachine.cs @@ -123,9 +123,8 @@ namespace Core.SaveLoad return $"{sceneName}/{customSaveId}"; } - // Auto-generate from hierarchy path - string hierarchyPath = GetHierarchyPath(); - return $"{sceneName}/StateMachine_{hierarchyPath}"; + // Match ManagedBehaviour convention: SceneName/GameObjectName/ComponentType + return $"{sceneName}/{gameObject.name}/AppleMachine"; } private string GetSceneName() @@ -133,19 +132,6 @@ namespace Core.SaveLoad return gameObject.scene.name; } - private string GetHierarchyPath() - { - string path = gameObject.name; - Transform parent = transform.parent; - - while (parent != null) - { - path = parent.name + "/" + path; - parent = parent.parent; - } - - return path; - } public string SerializeState() { diff --git a/Assets/Scripts/Core/SaveablePlayableDirector.cs b/Assets/Scripts/Core/SaveablePlayableDirector.cs new file mode 100644 index 00000000..fbbadc3f --- /dev/null +++ b/Assets/Scripts/Core/SaveablePlayableDirector.cs @@ -0,0 +1,148 @@ +using UnityEngine; +using UnityEngine.Playables; +using Core.Lifecycle; + +namespace Core +{ + /// + /// Saveable data for PlayableDirector state + /// + [System.Serializable] + public class PlayableDirectorSaveData + { + public bool wasPlayed; // Has the timeline been played? + public bool wasCompleted; // Did it complete playback? + public double playbackTime; // Current playback position + } + + /// + /// Makes a PlayableDirector (Timeline) saveable. + /// On load, if the timeline was completed, it seeks to the end to ensure + /// all timeline-activated objects are in their final state. + /// + [RequireComponent(typeof(PlayableDirector))] + public class SaveablePlayableDirector : ManagedBehaviour + { + private PlayableDirector _director; + private bool _hasPlayed = false; + private bool _hasCompleted = false; + + // Enable save/load participation + public override bool AutoRegisterForSave => true; + + protected override void Awake() + { + base.Awake(); + + _director = GetComponent(); + if (_director != null) + { + _director.stopped += OnDirectorStopped; + _director.played += OnDirectorPlayed; + } + } + + protected override void OnDestroy() + { + base.OnDestroy(); + + if (_director != null) + { + _director.stopped -= OnDirectorStopped; + _director.played -= OnDirectorPlayed; + } + } + + private void OnDirectorPlayed(PlayableDirector director) + { + _hasPlayed = true; + } + + private void OnDirectorStopped(PlayableDirector director) + { + _hasCompleted = true; + } + + #region Save/Load Implementation + + protected override string OnSceneSaveRequested() + { + var saveData = new PlayableDirectorSaveData + { + wasPlayed = _hasPlayed, + wasCompleted = _hasCompleted, + playbackTime = _director != null ? _director.time : 0 + }; + + return JsonUtility.ToJson(saveData); + } + + protected override void OnSceneRestoreRequested(string serializedData) + { + if (string.IsNullOrEmpty(serializedData)) + { + Debug.LogWarning($"[SaveablePlayableDirector] No save data to restore for {gameObject.name}"); + return; + } + + var saveData = JsonUtility.FromJson(serializedData); + if (saveData == null || _director == null) + return; + + _hasPlayed = saveData.wasPlayed; + _hasCompleted = saveData.wasCompleted; + + if (_hasCompleted) + { + // Seek to the end of the timeline to apply all final states + // This ensures objects activated/deactivated by the timeline are in correct state + _director.time = _director.duration; + _director.Evaluate(); // Force evaluation to apply the state + + Debug.Log($"[SaveablePlayableDirector] Restored completed timeline '{gameObject.name}' - seeked to end"); + } + else if (_hasPlayed && saveData.playbackTime > 0) + { + // If it was playing but not completed, restore the playback position + _director.time = saveData.playbackTime; + _director.Evaluate(); + + Debug.Log($"[SaveablePlayableDirector] Restored timeline '{gameObject.name}' at time {saveData.playbackTime}"); + } + else + { + // Timeline hasn't been played yet, ensure it's at the start + _director.time = 0; + _director.Evaluate(); + + Debug.Log($"[SaveablePlayableDirector] Timeline '{gameObject.name}' not yet played - at start"); + } + } + + #endregion + + #region Public API + + /// + /// Check if this timeline has been played + /// + public bool HasPlayed => _hasPlayed; + + /// + /// Check if this timeline completed playback + /// + public bool HasCompleted => _hasCompleted; + + /// + /// Manually mark the timeline as completed (useful for triggering completion via code) + /// + public void MarkAsCompleted() + { + _hasCompleted = true; + _hasPlayed = true; + } + + #endregion + } +} + diff --git a/Assets/Scripts/Core/SaveablePlayableDirector.cs.meta b/Assets/Scripts/Core/SaveablePlayableDirector.cs.meta new file mode 100644 index 00000000..8d6bdc09 --- /dev/null +++ b/Assets/Scripts/Core/SaveablePlayableDirector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a5c5614fc04140cb81e5bda7451f7b14 +timeCreated: 1762360145 \ No newline at end of file diff --git a/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/AnneLiseBehaviour.cs b/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/AnneLiseBehaviour.cs index 37bdc90c..73cda8ba 100644 --- a/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/AnneLiseBehaviour.cs +++ b/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/AnneLiseBehaviour.cs @@ -1,9 +1,9 @@ using UnityEngine; -using System; using System.Collections; using Core; using Pathfinding; +// TODO: Remove movement based logic public class AnneLiseBehaviour : MonoBehaviour { [SerializeField] public float moveSpeed; diff --git a/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/LureSpot.cs b/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/LureSpot.cs index 6a71a26e..cc4fd92b 100644 --- a/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/LureSpot.cs +++ b/Assets/Scripts/DamianExperiments/AnnaLiseAnd Lurespots/LureSpot.cs @@ -1,5 +1,6 @@ using UnityEngine; +// TODO: Remove this public class LureSpot : MonoBehaviour { [SerializeField] public GameObject luredBird; diff --git a/Assets/Scripts/DamianExperiments/SoundBirdPuzzleSection/soundBird_CanFly.cs b/Assets/Scripts/DamianExperiments/SoundBirdPuzzleSection/soundBird_CanFly.cs index af018881..0193018a 100644 --- a/Assets/Scripts/DamianExperiments/SoundBirdPuzzleSection/soundBird_CanFly.cs +++ b/Assets/Scripts/DamianExperiments/SoundBirdPuzzleSection/soundBird_CanFly.cs @@ -1,23 +1,51 @@ using UnityEngine; +using Core.Lifecycle; -public class soundBird_CanFly : MonoBehaviour +[System.Serializable] +public class SoundBirdSaveData +{ + public bool canFly; +} + +public class soundBird_CanFly : ManagedBehaviour { public bool canFly = true; - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - - } - + + // Enable save/load participation + public override bool AutoRegisterForSave => true; + public void birdCanHear(bool canhear) { - if (canhear) + canFly = canhear; + } + + #region Save/Load Implementation + + protected override string OnSceneSaveRequested() + { + var saveData = new SoundBirdSaveData { - canFly = true; + canFly = this.canFly + }; + + return JsonUtility.ToJson(saveData); + } + + protected override void OnSceneRestoreRequested(string serializedData) + { + if (string.IsNullOrEmpty(serializedData)) + { + Debug.LogWarning($"[soundBird_CanFly] No save data to restore for {gameObject.name}"); + return; } - else + + var saveData = JsonUtility.FromJson(serializedData); + if (saveData != null) { - canFly = false; + canFly = saveData.canFly; + Debug.Log($"[soundBird_CanFly] Restored canFly state: {canFly}"); } } + + #endregion } diff --git a/Assets/Scripts/Interactions/ItemSlot.cs b/Assets/Scripts/Interactions/ItemSlot.cs index 41863ada..28a27574 100644 --- a/Assets/Scripts/Interactions/ItemSlot.cs +++ b/Assets/Scripts/Interactions/ItemSlot.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using System; // for Action @@ -357,7 +357,27 @@ namespace Interactions // Try to find the item in the scene by its save ID via ItemManager GameObject slottedObject = ItemManager.Instance?.FindPickupBySaveId(slottedItemSaveId); - if (slottedObject == null) + if (slottedObject == null && !string.IsNullOrEmpty(expectedItemDataId)) + { + // Item not found in scene - it might be a dynamically spawned combined item + // Try to spawn it from the itemDataId + Debug.Log($"[ItemSlot] Slotted item not found in scene: {slottedItemSaveId}, attempting to spawn from itemId: {expectedItemDataId}"); + + GameObject prefab = interactionSettings?.FindPickupPrefabByItemId(expectedItemDataId); + if (prefab != null) + { + // Spawn the item (inactive, since it will be slotted) + slottedObject = Instantiate(prefab, transform.position, Quaternion.identity); + slottedObject.SetActive(false); + Debug.Log($"[ItemSlot] Successfully spawned combined item for slot: {expectedItemDataId}"); + } + else + { + Debug.LogWarning($"[ItemSlot] Could not find prefab for itemId: {expectedItemDataId}"); + return; + } + } + else if (slottedObject == null) { Debug.LogWarning($"[ItemSlot] Could not find slotted item with save ID: {slottedItemSaveId}"); return; @@ -382,12 +402,16 @@ namespace Interactions if (slottedData == null) { Debug.LogWarning($"[ItemSlot] Pickup {pickup.gameObject.name} has null itemData! Expected itemId: {expectedItemDataId}"); + if (slottedObject != null) + Destroy(slottedObject); return; } } else { Debug.LogWarning($"[ItemSlot] Slotted object has no Pickup component: {slottedObject.name}"); + if (slottedObject != null) + Destroy(slottedObject); return; } diff --git a/Assets/Scripts/Interactions/SaveableInteractable.cs b/Assets/Scripts/Interactions/SaveableInteractable.cs index 34cd41e0..d6c457c9 100644 --- a/Assets/Scripts/Interactions/SaveableInteractable.cs +++ b/Assets/Scripts/Interactions/SaveableInteractable.cs @@ -9,7 +9,7 @@ namespace Interactions public abstract class SaveableInteractable : InteractableBase { [Header("Save System")] - [SerializeField] + [SerializeField] // Save system configuration public override bool AutoRegisterForSave => true;