Rework of base interactables and managed behaviors
This commit is contained in:
committed by
Michal Pikulski
parent
00e1746ac4
commit
f88bd0e2c9
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Bootstrap;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
@@ -14,7 +14,7 @@ namespace Cinematics
|
||||
/// <summary>
|
||||
/// Handles loading, playing and unloading cinematics
|
||||
/// </summary>
|
||||
public class CinematicsManager : MonoBehaviour
|
||||
public class CinematicsManager : ManagedBehaviour
|
||||
{
|
||||
public event System.Action OnCinematicStarted;
|
||||
public event System.Action OnCinematicStopped;
|
||||
@@ -37,20 +37,21 @@ namespace Cinematics
|
||||
|
||||
public PlayableDirector playableDirector;
|
||||
|
||||
private void Awake()
|
||||
public override int ManagedAwakePriority => 170; // Cinematic systems
|
||||
|
||||
private new void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
base.Awake(); // CRITICAL: Register with LifecycleManager!
|
||||
|
||||
// Register for post-boot initialization
|
||||
BootCompletionService.RegisterInitAction(InitializePostBoot);
|
||||
// Set instance immediately so it's available before OnManagedAwake() is called
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
private void InitializePostBoot()
|
||||
protected override void OnManagedAwake()
|
||||
{
|
||||
// Initialize any dependencies that require other services to be ready
|
||||
// For example, subscribe to SceneManagerService events if needed
|
||||
Logging.Debug("[CinematicsManager] Post-boot initialization complete");
|
||||
Logging.Debug("[CinematicsManager] Initialized");
|
||||
}
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Bootstrap;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
using Input;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cinematics
|
||||
{
|
||||
public class SkipCinematic : MonoBehaviour, ITouchInputConsumer
|
||||
public class SkipCinematic : ManagedBehaviour, ITouchInputConsumer
|
||||
{
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private float holdDuration = 2.0f;
|
||||
@@ -17,39 +17,28 @@ namespace Cinematics
|
||||
private bool _skipPerformed;
|
||||
private bool _initialized = false;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// Register for post-boot initialization
|
||||
BootCompletionService.RegisterInitAction(InitializePostBoot);
|
||||
}
|
||||
public override int ManagedAwakePriority => 180; // Cinematic UI
|
||||
|
||||
void Start()
|
||||
protected override void OnManagedAwake()
|
||||
{
|
||||
// Reset the progress bar
|
||||
if (radialProgressBar != null)
|
||||
{
|
||||
radialProgressBar.fillAmount = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
// Clean up subscriptions regardless of initialization state
|
||||
UnsubscribeFromCinematicsEvents();
|
||||
}
|
||||
|
||||
private void InitializePostBoot()
|
||||
{
|
||||
// Safe initialization of manager dependencies after boot is complete
|
||||
if (_initialized)
|
||||
return;
|
||||
|
||||
_initialized = true;
|
||||
|
||||
// Subscribe to CinematicsManager events now that boot is complete
|
||||
SubscribeToCinematicsEvents();
|
||||
|
||||
Logging.Debug("[SkipCinematic] Post-boot initialization complete");
|
||||
Logging.Debug("[SkipCinematic] Initialized");
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Clean up subscriptions
|
||||
UnsubscribeFromCinematicsEvents();
|
||||
}
|
||||
|
||||
private void SubscribeToCinematicsEvents()
|
||||
|
||||
Reference in New Issue
Block a user