Skip to content

Commit e2b128d

Browse files
committed
feat(hooked singleton): enhance hook subscription validation and improve documentation
- Added validation to check for available hook subscription delegate types during singleton creation. - Improved method documentation for RunSubModels and CombatSubModels to clarify their purpose and parameters.
1 parent 1b2b6d8 commit e2b128d

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Models/HookedSingletonModel.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ protected HookedSingletonModel(bool receiveCombatHooks, bool receiveRunHooks)
4343
return;
4444
}
4545

46+
if ((receiveRunHooks && RunHookSubscriptionDelegateType == null) ||
47+
(receiveCombatHooks && CombatHookSubscriptionDelegateType == null))
48+
{
49+
RitsuLibFramework.Logger.Warn(
50+
$"[HookedSingletonModel] Singleton created but hook subscription delegate type is unavailable on this game branch: {GetType().FullName}");
51+
return;
52+
}
53+
4654
if (receiveRunHooks)
4755
SubscribeRunState.Invoke(null,
4856
[
@@ -69,12 +77,22 @@ protected HookedSingletonModel(bool receiveCombatHooks, bool receiveRunHooks)
6977
/// <inheritdoc />
7078
public override bool ShouldReceiveCombatHooks { get; }
7179

72-
private IEnumerable<AbstractModel> RunSubModels(RunState runState)
80+
/// <summary>
81+
/// Provides the run-scoped sub-models that should receive run-state hook callbacks for this singleton.
82+
/// </summary>
83+
/// <param name="runState">The current run state.</param>
84+
/// <returns>The models to subscribe for run hooks.</returns>
85+
protected IEnumerable<AbstractModel> RunSubModels(RunState runState)
7386
{
7487
return [this];
7588
}
7689

77-
private IEnumerable<AbstractModel> CombatSubModels(CombatState combatState)
90+
/// <summary>
91+
/// Provides the combat-scoped sub-models that should receive combat-state hook callbacks for this singleton.
92+
/// </summary>
93+
/// <param name="combatState">The current combat state.</param>
94+
/// <returns>The models to subscribe for combat hooks.</returns>
95+
protected IEnumerable<AbstractModel> CombatSubModels(CombatState combatState)
7896
{
7997
return [this];
8098
}

0 commit comments

Comments
 (0)