Update methods to be internal, remove invocation bloat

This commit is contained in:
Michal Pikulski
2025-11-10 21:59:47 +01:00
parent 01caca1878
commit a049c6a750
42 changed files with 137 additions and 136 deletions

View File

@@ -133,7 +133,7 @@ namespace Core.Lifecycle
// Call OnManagedAwake immediately after registration (early initialization hook)
try
{
component.InvokeManagedAwake();
component.OnManagedAwake();
}
catch (Exception ex)
{
@@ -157,7 +157,7 @@ namespace Core.Lifecycle
LogDebug($"Late registration: Calling OnManagedStart immediately for {component.gameObject.name}");
try
{
component.InvokeManagedStart();
component.OnManagedStart();
HandleAutoRegistrations(component);
}
catch (Exception ex)
@@ -174,7 +174,7 @@ namespace Core.Lifecycle
LogDebug($"Late registration: Calling OnSceneReady immediately for {component.gameObject.name}");
try
{
component.InvokeSceneReady();
component.OnSceneReady();
}
catch (Exception ex)
{
@@ -240,7 +240,7 @@ namespace Core.Lifecycle
try
{
component.InvokeManagedStart();
component.OnManagedStart();
HandleAutoRegistrations(component);
}
catch (Exception ex)
@@ -292,7 +292,7 @@ namespace Core.Lifecycle
try
{
component.InvokeManagedStart();
component.OnManagedStart();
HandleAutoRegistrations(component);
LogDebug($"Processed batched component: {component.gameObject.name} (Priority: {component.ManagedAwakePriority})");
}
@@ -325,7 +325,7 @@ namespace Core.Lifecycle
{
try
{
component.InvokeSceneUnloading();
component.OnSceneUnloading();
}
catch (Exception ex)
{
@@ -361,7 +361,7 @@ namespace Core.Lifecycle
{
try
{
component.InvokeSceneReady();
component.OnSceneReady();
}
catch (Exception ex)
{
@@ -389,7 +389,7 @@ namespace Core.Lifecycle
try
{
string serializedData = component.InvokeSceneSaveRequested();
string serializedData = component.OnSceneSaveRequested();
if (!string.IsNullOrEmpty(serializedData))
{
string saveId = component.SaveId;
@@ -425,7 +425,7 @@ namespace Core.Lifecycle
try
{
string serializedData = component.InvokeGlobalSaveRequested();
string serializedData = component.OnGlobalSaveRequested();
if (!string.IsNullOrEmpty(serializedData))
{
saveData[component.SaveId] = serializedData;
@@ -465,7 +465,7 @@ namespace Core.Lifecycle
{
try
{
component.InvokeSceneRestoreRequested(serializedData);
component.OnSceneRestoreRequested(serializedData);
restoredCount++;
LogDebug($"Restored scene data to: {component.SaveId}");
}
@@ -496,7 +496,7 @@ namespace Core.Lifecycle
try
{
component.InvokeSceneRestoreCompleted();
component.OnSceneRestoreCompleted();
}
catch (Exception ex)
{
@@ -529,7 +529,7 @@ namespace Core.Lifecycle
{
try
{
component.InvokeGlobalRestoreRequested(serializedData);
component.OnGlobalRestoreRequested(serializedData);
restoredCount++;
LogDebug($"Restored global data to: {component.SaveId}");
}
@@ -561,7 +561,7 @@ namespace Core.Lifecycle
try
{
component.InvokeGlobalLoadCompleted();
component.OnGlobalLoadCompleted();
}
catch (Exception ex)
{
@@ -588,7 +588,7 @@ namespace Core.Lifecycle
try
{
component.InvokeGlobalSaveStarted();
component.OnGlobalSaveStarted();
}
catch (Exception ex)
{

View File

@@ -80,24 +80,6 @@ namespace Core.Lifecycle
#endregion
#region Public Accessors (for LifecycleManager)
// Public wrappers to invoke protected lifecycle methods
public void InvokeManagedAwake() => OnManagedAwake();
public void InvokeManagedStart() => OnManagedStart();
public void InvokeSceneUnloading() => OnSceneUnloading();
public void InvokeSceneReady() => OnSceneReady();
public string InvokeSceneSaveRequested() => OnSceneSaveRequested();
public void InvokeSceneRestoreRequested(string data) => OnSceneRestoreRequested(data);
public void InvokeSceneRestoreCompleted() => OnSceneRestoreCompleted();
public string InvokeGlobalSaveRequested() => OnGlobalSaveRequested();
public void InvokeGlobalRestoreRequested(string data) => OnGlobalRestoreRequested(data);
public void InvokeManagedDestroy() => OnManagedDestroy();
public void InvokeGlobalLoadCompleted() => OnGlobalLoadCompleted();
public void InvokeGlobalSaveStarted() => OnGlobalSaveStarted();
#endregion
#region Private Fields
private bool _isRegistered;
@@ -157,8 +139,9 @@ namespace Core.Lifecycle
/// Use for early initialization such as setting singleton instances.
/// TIMING: Fires during component's Awake(), no execution order guarantees between components.
/// NOT priority-ordered - fires whenever Unity calls this component's Awake().
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnManagedAwake()
internal virtual void OnManagedAwake()
{
// Override in derived classes
}
@@ -169,8 +152,9 @@ namespace Core.Lifecycle
/// For boot-time components: Called during LifecycleManager.BroadcastManagedStart (priority ordered).
/// For late-registered components: Called immediately upon registration (bootstrap already complete).
/// Use for initialization that depends on other systems.
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnManagedStart()
internal virtual void OnManagedStart()
{
// Override in derived classes
}
@@ -179,8 +163,9 @@ namespace Core.Lifecycle
/// Called before the scene this component belongs to is unloaded.
/// Called in REVERSE priority order (higher values execute first).
/// Use for scene-specific cleanup.
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnSceneUnloading()
internal virtual void OnSceneUnloading()
{
// Override in derived classes
}
@@ -189,8 +174,9 @@ namespace Core.Lifecycle
/// Called after the scene this component belongs to has finished loading.
/// Called in priority order (lower values execute first).
/// Use for scene-specific initialization.
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnSceneReady()
internal virtual void OnSceneReady()
{
// Override in derived classes
}
@@ -204,8 +190,10 @@ namespace Core.Lifecycle
/// - Called BEFORE scene unload during scene transitions
/// - Frequency: Every scene transition
/// - Use for: Level progress, object positions, puzzle states
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual string OnSceneSaveRequested()
internal virtual string OnSceneSaveRequested()
{
return null; // Default: no data to save
}
@@ -222,8 +210,10 @@ namespace Core.Lifecycle
/// - Called AFTER scene load, during OnSceneReady phase
/// - Frequency: Every scene transition
/// - Use for: Restoring level progress, object positions, puzzle states
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnSceneRestoreRequested(string serializedData)
internal virtual void OnSceneRestoreRequested(string serializedData)
{
// Default: no-op
}
@@ -245,8 +235,10 @@ namespace Core.Lifecycle
/// COMMON PATTERN:
/// Use this to perform actions that depend on whether data was restored or not.
/// Example: Play one-time audio only if it hasn't been played before (_hasPlayed == false).
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnSceneRestoreCompleted()
internal virtual void OnSceneRestoreCompleted()
{
// Default: no-op
}
@@ -259,8 +251,10 @@ namespace Core.Lifecycle
/// - Called ONCE on game boot after save file is read
/// - NOT called during scene transitions
/// - Use for: Player inventory, unlocked features, card collections
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnGlobalRestoreRequested(string serializedData)
internal virtual void OnGlobalRestoreRequested(string serializedData)
{
// Default: no-op
}
@@ -274,8 +268,10 @@ namespace Core.Lifecycle
/// - Called ONCE before save file is written (on quit, manual save, etc.)
/// - NOT called during scene transitions
/// - Use for: Player inventory, unlocked features, card collections
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual string OnGlobalSaveRequested()
internal virtual string OnGlobalSaveRequested()
{
return null; // Default: no data to save
}
@@ -289,8 +285,10 @@ namespace Core.Lifecycle
/// - Called ONCE on game boot after all restore operations complete
/// - NOT called during scene transitions
/// - Use for: Triggering UI updates, broadcasting load events
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnGlobalLoadCompleted()
internal virtual void OnGlobalLoadCompleted()
{
// Default: no-op
}
@@ -304,8 +302,10 @@ namespace Core.Lifecycle
/// - Called ONCE before save file is written
/// - NOT called during scene transitions
/// - Use for: Final validation, cleanup operations
///
/// NOTE: Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnGlobalSaveStarted()
internal virtual void OnGlobalSaveStarted()
{
// Default: no-op
}
@@ -315,8 +315,9 @@ namespace Core.Lifecycle
/// Called in REVERSE priority order (higher values execute first).
/// NOTE: Most cleanup is automatic (managed events, auto-registrations).
/// Only override if you need custom cleanup logic.
/// Internal visibility allows LifecycleManager to call directly. Override in derived classes.
/// </summary>
protected virtual void OnManagedDestroy()
internal virtual void OnManagedDestroy()
{
// Override in derived classes
}