Work on state machines
This commit is contained in:
committed by
Michal Pikulski
parent
bb68d1fd31
commit
199480447e
3
Assets/Editor/Lifecycle.meta
Normal file
3
Assets/Editor/Lifecycle.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5d626da49844592981ef14524e3a308
|
||||
timeCreated: 1762332131
|
||||
144
Assets/Editor/Lifecycle/EditorLifecycleBootstrap.cs
Normal file
144
Assets/Editor/Lifecycle/EditorLifecycleBootstrap.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Core.Lifecycle;
|
||||
using Core.SaveLoad;
|
||||
using AppleHills.Core.Settings;
|
||||
using Bootstrap;
|
||||
|
||||
namespace Editor.Lifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor-only bootstrap that ensures OnSceneReady is triggered when playing directly from a scene in Unity Editor.
|
||||
///
|
||||
/// PROBLEM: When you press Play in the editor without going through the scene manager:
|
||||
/// - CustomBoot runs and triggers OnBootCompletionTriggered (which broadcasts OnManagedAwake)
|
||||
/// - But BroadcastSceneReady is NEVER called for the initial scene
|
||||
/// - Components in the scene never receive their OnSceneReady() callback
|
||||
///
|
||||
/// SOLUTION: After boot completes, detect the active scene and broadcast OnSceneReady for it.
|
||||
/// This only runs in editor mode and mimics what SceneManagerService does during normal scene transitions.
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public static class EditorLifecycleBootstrap
|
||||
{
|
||||
private static bool hasTriggeredInitialSceneReady = false;
|
||||
private static int framesSincePlayMode = 0;
|
||||
private const int MaxFramesToWait = 300; // 5 seconds at 60fps
|
||||
|
||||
static EditorLifecycleBootstrap()
|
||||
{
|
||||
// Subscribe to play mode state changes
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
}
|
||||
|
||||
private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
// Reset flag when exiting play mode
|
||||
if (state == PlayModeStateChange.ExitingPlayMode || state == PlayModeStateChange.EnteredEditMode)
|
||||
{
|
||||
hasTriggeredInitialSceneReady = false;
|
||||
framesSincePlayMode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// When we enter play mode, wait for boot to complete then trigger scene ready
|
||||
if (state == PlayModeStateChange.EnteredPlayMode)
|
||||
{
|
||||
hasTriggeredInitialSceneReady = false;
|
||||
framesSincePlayMode = 0;
|
||||
|
||||
// Use EditorApplication.update to poll until boot completes
|
||||
EditorApplication.update += WaitForBootAndTriggerSceneReady;
|
||||
}
|
||||
}
|
||||
|
||||
private static void WaitForBootAndTriggerSceneReady()
|
||||
{
|
||||
framesSincePlayMode++;
|
||||
|
||||
// Safety timeout - if boot hasn't completed after 5 seconds, something is wrong
|
||||
if (framesSincePlayMode > MaxFramesToWait)
|
||||
{
|
||||
Debug.LogError($"[EditorLifecycleBootstrap] Timed out waiting for boot completion after {MaxFramesToWait} frames. " +
|
||||
"CustomBoot may have failed to initialize properly.");
|
||||
EditorApplication.update -= WaitForBootAndTriggerSceneReady;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if boot has completed
|
||||
if (!CustomBoot.Initialised)
|
||||
return;
|
||||
|
||||
// Check if LifecycleManager exists
|
||||
if (LifecycleManager.Instance == null)
|
||||
{
|
||||
Debug.LogWarning("[EditorLifecycleBootstrap] LifecycleManager instance not found. " +
|
||||
"Lifecycle may not be properly initialized.");
|
||||
EditorApplication.update -= WaitForBootAndTriggerSceneReady;
|
||||
return;
|
||||
}
|
||||
|
||||
// Only trigger once per play session
|
||||
if (hasTriggeredInitialSceneReady)
|
||||
{
|
||||
EditorApplication.update -= WaitForBootAndTriggerSceneReady;
|
||||
return;
|
||||
}
|
||||
|
||||
hasTriggeredInitialSceneReady = true;
|
||||
EditorApplication.update -= WaitForBootAndTriggerSceneReady;
|
||||
|
||||
// Get the active scene
|
||||
Scene activeScene = SceneManager.GetActiveScene();
|
||||
|
||||
if (!activeScene.isLoaded)
|
||||
{
|
||||
Debug.LogWarning($"[EditorLifecycleBootstrap] Active scene '{activeScene.name}' is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip bootstrap scene - it doesn't need scene ready
|
||||
// Note: BootstrapScene is the infrastructure scene, not a gameplay scene
|
||||
if (activeScene.name == "BootstrapScene" || activeScene.name == "Bootstrap")
|
||||
{
|
||||
Debug.Log($"[EditorLifecycleBootstrap] Skipping OnSceneReady for infrastructure scene: {activeScene.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"<color=cyan>[EditorLifecycleBootstrap] Triggering lifecycle for initial scene: {activeScene.name}</color>");
|
||||
|
||||
// Broadcast scene ready for the initial scene
|
||||
// This mimics what SceneManagerService does during scene transitions (Phase 10)
|
||||
try
|
||||
{
|
||||
LifecycleManager.Instance.BroadcastSceneReady(activeScene.name);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"[EditorLifecycleBootstrap] Error broadcasting SceneReady: {ex.Message}\n{ex.StackTrace}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Restore scene-specific data via SaveLoadManager
|
||||
// This mimics SceneManagerService Phase 11
|
||||
if (SaveLoadManager.Instance != null)
|
||||
{
|
||||
var debugSettings = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>();
|
||||
if (debugSettings.useSaveLoadSystem)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Log($"[EditorLifecycleBootstrap] Restoring scene data for: {activeScene.name}");
|
||||
SaveLoadManager.Instance.RestoreSceneData();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"[EditorLifecycleBootstrap] Error restoring scene data: {ex.Message}\n{ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
Assets/Editor/Lifecycle/EditorLifecycleBootstrap.cs.meta
Normal file
9
Assets/Editor/Lifecycle/EditorLifecycleBootstrap.cs.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f3e8a9c4d5b6e7f8a9b0c1d2e3f4a5b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Editor.Tools
|
||||
private string searchTypeName = "Select a Component...";
|
||||
private string replaceTypeName = "Select a Component...";
|
||||
private List<Type> allMonoBehaviourTypes = new List<Type>();
|
||||
private bool includeDerivedTypes = true;
|
||||
|
||||
[MenuItem("Tools/Component Search & Replace")]
|
||||
public static void ShowWindow()
|
||||
@@ -102,6 +103,15 @@ namespace Editor.Tools
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
// Include Derived Types checkbox
|
||||
includeDerivedTypes = EditorGUILayout.Toggle(
|
||||
new GUIContent("Include Derived Types",
|
||||
"When enabled, searches for the selected type and all types that inherit from it. " +
|
||||
"When disabled, searches only for the exact type."),
|
||||
includeDerivedTypes);
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(selectedSearchType == null);
|
||||
if (GUILayout.Button("Search Scene", GUILayout.Height(30)))
|
||||
{
|
||||
@@ -242,7 +252,20 @@ namespace Editor.Tools
|
||||
|
||||
foreach (var go in allObjects)
|
||||
{
|
||||
var component = go.GetComponent(selectedSearchType);
|
||||
Component component = null;
|
||||
|
||||
if (includeDerivedTypes)
|
||||
{
|
||||
// Search for the type and all derived types
|
||||
component = go.GetComponent(selectedSearchType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search for exact type only
|
||||
var components = go.GetComponents<Component>();
|
||||
component = components.FirstOrDefault(c => c != null && c.GetType() == selectedSearchType);
|
||||
}
|
||||
|
||||
if (component != null)
|
||||
{
|
||||
foundComponents.Add(new ComponentInfo
|
||||
@@ -256,7 +279,8 @@ namespace Editor.Tools
|
||||
|
||||
foundComponents = foundComponents.OrderBy(c => c.hierarchyPath).ToList();
|
||||
|
||||
Debug.Log($"Found {foundComponents.Count} objects with component type '{selectedSearchType.Name}'");
|
||||
string searchMode = includeDerivedTypes ? "including derived types" : "exact type only";
|
||||
Debug.Log($"Found {foundComponents.Count} objects with component type '{selectedSearchType.Name}' ({searchMode})");
|
||||
Repaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ GameObject:
|
||||
- component: {fileID: 3487003259787903584}
|
||||
- component: {fileID: 2277261512137882881}
|
||||
m_Layer: 10
|
||||
m_Name: LureSpotA
|
||||
m_Name: LureSpotA_Slot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -260,9 +260,9 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: aaf36cd26cf74334e9c7db6c1b03b3fb, type: 2}
|
||||
iconRenderer: {fileID: 6258593095132504700}
|
||||
slottedItemRenderer: {fileID: 4110666412151536905}
|
||||
onItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@@ -314,7 +314,6 @@ MonoBehaviour:
|
||||
onForbiddenItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
slottedItemRenderer: {fileID: 4110666412151536905}
|
||||
--- !u!114 &3487003259787903584
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1069,7 +1069,7 @@ GameObject:
|
||||
- component: {fileID: 3093816592344978065}
|
||||
- component: {fileID: 8758136668472096799}
|
||||
m_Layer: 10
|
||||
m_Name: LureSpotB
|
||||
m_Name: LureSpotB_Slot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -1168,9 +1168,9 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: f97b9e24d6dceb145b56426c1152ebeb, type: 2}
|
||||
iconRenderer: {fileID: 2343214996212089369}
|
||||
slottedItemRenderer: {fileID: 7990414055343410434}
|
||||
onItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@@ -1234,7 +1234,6 @@ MonoBehaviour:
|
||||
onForbiddenItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
slottedItemRenderer: {fileID: 7990414055343410434}
|
||||
--- !u!114 &8758136668472096799
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -247,7 +247,7 @@ GameObject:
|
||||
- component: {fileID: 3169137887822749614}
|
||||
- component: {fileID: 8370367816617117734}
|
||||
m_Layer: 10
|
||||
m_Name: LureSpotC
|
||||
m_Name: LureSpotC_Slot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -346,9 +346,9 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: c68dea945fecbf44094359769db04f31, type: 2}
|
||||
iconRenderer: {fileID: 2825253017896168654}
|
||||
slottedItemRenderer: {fileID: 3806274462998212361}
|
||||
onItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@@ -412,7 +412,6 @@ MonoBehaviour:
|
||||
onForbiddenItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
slottedItemRenderer: {fileID: 3806274462998212361}
|
||||
--- !u!114 &6535246856440349519
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -44,10 +44,10 @@ GameObject:
|
||||
- component: {fileID: 5057760771402457000}
|
||||
- component: {fileID: 2433130051631076285}
|
||||
- component: {fileID: 7290110366808972859}
|
||||
- component: {fileID: 4831635791684479552}
|
||||
- component: {fileID: 9196152289301358918}
|
||||
- component: {fileID: 2596311128101197840}
|
||||
m_Layer: 10
|
||||
m_Name: SoundBird
|
||||
m_Name: SoundBird_Slot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -201,9 +201,9 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: d28f5774afad9d14f823601707150700, type: 2}
|
||||
iconRenderer: {fileID: 8875860401447896107}
|
||||
slottedItemRenderer: {fileID: 6941190210788968874}
|
||||
onItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@@ -231,7 +231,6 @@ MonoBehaviour:
|
||||
onForbiddenItemSlotted:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
slottedItemRenderer: {fileID: 6941190210788968874}
|
||||
--- !u!114 &7290110366808972859
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -246,18 +245,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
luredBird: {fileID: 4624889622840393752}
|
||||
annaLiseSpot: {fileID: 22512726373136855}
|
||||
--- !u!114 &4831635791684479552
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 588897581313790951}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: eaefd3d5a2a864ca5b5d9ec5f2a7040f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!95 &9196152289301358918
|
||||
Animator:
|
||||
serializedVersion: 7
|
||||
@@ -280,6 +267,18 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!114 &2596311128101197840
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 588897581313790951}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
||||
--- !u!1 &4624889622840393752
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -140,6 +140,5 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: 43f22dbbb4c0eec4f8108d0f0eea43c2, type: 2}
|
||||
iconRenderer: {fileID: 4055726361761331703}
|
||||
|
||||
@@ -140,6 +140,5 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: a8baa800efa25a344a95b190cf349e2d, type: 2}
|
||||
iconRenderer: {fileID: 4774534086162962138}
|
||||
|
||||
@@ -140,6 +140,5 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: 560ba2059ce14dc4da580e2f43b2e65f, type: 2}
|
||||
iconRenderer: {fileID: 4986096986936361008}
|
||||
|
||||
@@ -140,6 +140,5 @@ MonoBehaviour:
|
||||
interactionComplete:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
itemData: {fileID: 11400000, guid: 3b1f3472171abc943bb099ce31d6fc7c, type: 2}
|
||||
iconRenderer: {fileID: 4266110216568578813}
|
||||
|
||||
@@ -221,12 +221,12 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2071071585578300598}
|
||||
- component: {fileID: 1454372124634854912}
|
||||
- component: {fileID: 4122067414526815177}
|
||||
- component: {fileID: 2314863751758196186}
|
||||
- component: {fileID: 2741639361616064442}
|
||||
- component: {fileID: 4903273501345439385}
|
||||
- component: {fileID: 1054459649399154791}
|
||||
- component: {fileID: 7319925080429004531}
|
||||
m_Layer: 10
|
||||
m_Name: Hidden
|
||||
m_TagString: Untagged
|
||||
@@ -252,18 +252,6 @@ Transform:
|
||||
- {fileID: 852327051512792946}
|
||||
m_Father: {fileID: 8259693476957892150}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1454372124634854912
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1011363502278351410}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: eaefd3d5a2a864ca5b5d9ec5f2a7040f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: PixelplacementAssembly::Pixelplacement.State
|
||||
--- !u!61 &4122067414526815177
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -463,6 +451,18 @@ MonoBehaviour:
|
||||
audioSource: {fileID: 0}
|
||||
clipPriority: 0
|
||||
sourcePriority: 1
|
||||
--- !u!114 &7319925080429004531
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1011363502278351410}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
||||
--- !u!1 &1674229500073894281
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -777,11 +777,11 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 8259693476957892150}
|
||||
- component: {fileID: 2995561023563842343}
|
||||
- component: {fileID: 7053055077639234121}
|
||||
- component: {fileID: 578146208477020881}
|
||||
- component: {fileID: 1193493154550576580}
|
||||
- component: {fileID: 7652960462502122104}
|
||||
- component: {fileID: 989520896849684110}
|
||||
- component: {fileID: 5862718108034728596}
|
||||
m_Layer: 0
|
||||
m_Name: AnneLiseBaseBush
|
||||
m_TagString: Untagged
|
||||
@@ -818,42 +818,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 55938fb1577dd4ad3af7e994048c86f6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: PixelplacementAssembly::Pixelplacement.Initialization
|
||||
--- !u!114 &7053055077639234121
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5943355783477523754}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9e0b24e2f2ad54cc09940c320ed3cf4b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: PixelplacementAssembly::Pixelplacement.StateMachine
|
||||
defaultState: {fileID: 1011363502278351410}
|
||||
currentState: {fileID: 0}
|
||||
_unityEventsFolded: 0
|
||||
verbose: 0
|
||||
allowReentry: 0
|
||||
returnToDefaultOnDisable: 1
|
||||
OnStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnFirstStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnFirstStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnLastStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnLastStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &578146208477020881
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1001,6 +965,43 @@ MonoBehaviour:
|
||||
audioSource: {fileID: 0}
|
||||
clipPriority: 0
|
||||
sourcePriority: 0
|
||||
--- !u!114 &5862718108034728596
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5943355783477523754}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6f56763d30b94bf6873d395a6c116eb5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleMachine
|
||||
defaultState: {fileID: 1011363502278351410}
|
||||
currentState: {fileID: 0}
|
||||
_unityEventsFolded: 0
|
||||
verbose: 0
|
||||
allowReentry: 0
|
||||
returnToDefaultOnDisable: 1
|
||||
OnStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnFirstStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnFirstStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnLastStateEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnLastStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
--- !u!1 &6948354193133336628
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -11,7 +11,7 @@ GameObject:
|
||||
- component: {fileID: 2326086342663433936}
|
||||
- component: {fileID: 243176356944356711}
|
||||
- component: {fileID: 6657093817085841540}
|
||||
- component: {fileID: 7932498922414502976}
|
||||
- component: {fileID: 2239999147194587249}
|
||||
m_Layer: 0
|
||||
m_Name: BirdEyes
|
||||
m_TagString: Untagged
|
||||
@@ -48,6 +48,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 13d59d3c42170824b8f92557822d9bf0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
correctItemIsIn: 0
|
||||
bushAnimator: {fileID: 0}
|
||||
--- !u!114 &6657093817085841540
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -60,7 +62,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 55938fb1577dd4ad3af7e994048c86f6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &7932498922414502976
|
||||
--- !u!114 &2239999147194587249
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -69,9 +71,9 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1370564349707122423}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9e0b24e2f2ad54cc09940c320ed3cf4b, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 6f56763d30b94bf6873d395a6c116eb5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleMachine
|
||||
defaultState: {fileID: 3532512445619884959}
|
||||
currentState: {fileID: 0}
|
||||
_unityEventsFolded: 0
|
||||
@@ -96,6 +98,7 @@ MonoBehaviour:
|
||||
OnLastStateExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
customSaveId:
|
||||
--- !u!1 &3532512445619884959
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -107,7 +110,7 @@ GameObject:
|
||||
- component: {fileID: 4477179922705334961}
|
||||
- component: {fileID: 3013218424693156287}
|
||||
- component: {fileID: 7343439013600968102}
|
||||
- component: {fileID: 3842054004304041864}
|
||||
- component: {fileID: 4451815010323250894}
|
||||
m_Layer: 0
|
||||
m_Name: BirdHiding
|
||||
m_TagString: Untagged
|
||||
@@ -150,6 +153,8 @@ SpriteRenderer:
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@@ -171,6 +176,7 @@ SpriteRenderer:
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 2
|
||||
@@ -207,7 +213,7 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!114 &3842054004304041864
|
||||
--- !u!114 &4451815010323250894
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -216,9 +222,9 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 3532512445619884959}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: eaefd3d5a2a864ca5b5d9ec5f2a7040f, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
||||
--- !u!1 &8828658103663197825
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -230,7 +236,7 @@ GameObject:
|
||||
- component: {fileID: 7698905571408300091}
|
||||
- component: {fileID: 5210033153524231666}
|
||||
- component: {fileID: 4408373410605328204}
|
||||
- component: {fileID: 3873868413538144635}
|
||||
- component: {fileID: 2709364368411520279}
|
||||
m_Layer: 0
|
||||
m_Name: BirdSpawned
|
||||
m_TagString: Untagged
|
||||
@@ -273,6 +279,8 @@ SpriteRenderer:
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@@ -294,6 +302,7 @@ SpriteRenderer:
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 2
|
||||
@@ -330,7 +339,7 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!114 &3873868413538144635
|
||||
--- !u!114 &2709364368411520279
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -339,6 +348,6 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 8828658103663197825}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: eaefd3d5a2a864ca5b5d9ec5f2a7040f, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
||||
|
||||
@@ -1,66 +1,108 @@
|
||||
using Core.SaveLoad;
|
||||
using Input;
|
||||
using Pixelplacement;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Events;
|
||||
using static Input.PlayerTouchController;
|
||||
using System;
|
||||
|
||||
|
||||
public class TakePhotoState : State
|
||||
namespace StateMachines.Quarry.AnneLise
|
||||
{
|
||||
|
||||
public Transform playerTargetObject;
|
||||
private GameObject playerCharacter;
|
||||
private PlayerTouchController playerTouchController;
|
||||
private Vector3 newPlayerPosition;
|
||||
|
||||
public UnityEvent animFlash;
|
||||
public UnityEvent animStart;
|
||||
|
||||
void OnEnable()
|
||||
public class TakePhotoState : AppleState
|
||||
{
|
||||
playerCharacter = GameObject.FindWithTag("Player");
|
||||
playerTouchController = playerCharacter.GetComponent<PlayerTouchController>();
|
||||
playerTouchController.OnArrivedAtTarget += PlayerHasArrived;
|
||||
public Transform playerTargetObject;
|
||||
private GameObject _playerCharacter;
|
||||
private PlayerTouchController _playerTouchController;
|
||||
private Vector3 _newPlayerPosition;
|
||||
|
||||
newPlayerPosition = new Vector3(playerTargetObject.transform.position.x, playerTargetObject.transform.position.y, playerTargetObject.transform.position.z);
|
||||
playerTouchController.InterruptMoveTo();
|
||||
playerTouchController.MoveToAndNotify(newPlayerPosition);
|
||||
InputManager.Instance.SetInputMode(InputMode.InputDisabled);
|
||||
public UnityEvent animFlash;
|
||||
public UnityEvent animStart;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Find references that are needed regardless of enter/restore
|
||||
_playerCharacter = GameObject.FindWithTag("Player");
|
||||
_playerTouchController = _playerCharacter.GetComponent<PlayerTouchController>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when entering this state during normal gameplay.
|
||||
/// Initiates player movement and triggers photo-taking sequence.
|
||||
/// </summary>
|
||||
public override void OnEnterState()
|
||||
{
|
||||
// Subscribe to player arrival event
|
||||
_playerTouchController.OnArrivedAtTarget += PlayerHasArrived;
|
||||
|
||||
// Move player to photo position
|
||||
_newPlayerPosition = new Vector3(
|
||||
playerTargetObject.transform.position.x,
|
||||
playerTargetObject.transform.position.y,
|
||||
playerTargetObject.transform.position.z);
|
||||
|
||||
_playerTouchController.InterruptMoveTo();
|
||||
_playerTouchController.MoveToAndNotify(_newPlayerPosition);
|
||||
|
||||
// Disable input during photo sequence
|
||||
InputManager.Instance.SetInputMode(InputMode.InputDisabled);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when restoring this state from save data.
|
||||
/// Skips player movement and animations - just sets up the restored state.
|
||||
/// </summary>
|
||||
/// <param name="data">Serialized state data (currently unused for this state)</param>
|
||||
public override void OnRestoreState(string data)
|
||||
{
|
||||
// When restoring, we don't want to move the player or play animations
|
||||
// The state is restored silently - player stays where they are
|
||||
// Input mode will be restored by the input system's own save/load
|
||||
|
||||
// If we needed to restore any internal state data, we'd deserialize it here
|
||||
// For now, this state has no persistent data beyond being active
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize this state's data for saving.
|
||||
/// Currently this state has no additional data to save beyond being active.
|
||||
/// </summary>
|
||||
/// <returns>Serialized state data as JSON string</returns>
|
||||
public override string SerializeState()
|
||||
{
|
||||
// This state doesn't have internal data to save
|
||||
// The fact that it's the active state is saved by AppleMachine
|
||||
return "";
|
||||
}
|
||||
|
||||
// When the player has arrived at the bush do Animator.SetTrigger(Takephoto) and whatevs
|
||||
|
||||
public void PhotoTaken()
|
||||
{
|
||||
ChangeState("Hidden");
|
||||
InputManager.Instance.SetInputMode(InputMode.Game);
|
||||
}
|
||||
|
||||
void PlayerHasArrived()
|
||||
{
|
||||
GetComponent<Animator>().SetTrigger("TakePhoto");
|
||||
_playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Cleanup: Unsubscribe from events
|
||||
if (_playerTouchController != null)
|
||||
{
|
||||
_playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimStarted()
|
||||
{
|
||||
animStart.Invoke();
|
||||
}
|
||||
|
||||
public void Flash()
|
||||
{
|
||||
animFlash.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// When the player has arrived at the bush do Animator.SetTrigger(Takephoto) and whatevs
|
||||
|
||||
public void PhotoTaken()
|
||||
{
|
||||
ChangeState("Hidden");
|
||||
InputManager.Instance.SetInputMode(InputMode.Game);
|
||||
}
|
||||
|
||||
void PlayerHasArrived()
|
||||
{
|
||||
GetComponent<Animator>().SetTrigger("TakePhoto");
|
||||
playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
playerTouchController.OnArrivedAtTarget -= PlayerHasArrived;
|
||||
|
||||
}
|
||||
|
||||
public void AnimStarted()
|
||||
{
|
||||
animStart.Invoke();
|
||||
}
|
||||
|
||||
public void Flash()
|
||||
{
|
||||
animFlash.Invoke();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
8
Assets/_Recovery.meta
Normal file
8
Assets/_Recovery.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21ea3de9e8c22e449bf12522c31b27ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2069
Assets/_Recovery/0.unity
Normal file
2069
Assets/_Recovery/0.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/_Recovery/0.unity.meta
Normal file
7
Assets/_Recovery/0.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c9ee06300474fb41b711f1c49f72d94
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user