Skip to content

Commit

Permalink
[Fix] Enemy.ModifyBehaviour works properly now
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoConKvass committed Dec 16, 2024
1 parent bbcb42b commit 494697a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions RL2.API/APIEndpoints/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ internal static void ModifyData_Invoke(EnemyType type, EnemyRank rank, EnemyData
/// <param name="rank">Enemy rank</param>
/// <param name="aiScript">Enemy's AI script object</param>
/// <param name="logicController_SO">Enemy's logic controller scriptable object. Handles chances of behaviour</param>
public delegate void ModifyBehaviour_delegate(EnemyType type, EnemyRank rank, BaseAIScript aiScript, LogicController_SO logicController_SO);
public delegate void ModifyBehaviour_delegate(EnemyType type, EnemyRank rank, ref BaseAIScript aiScript, ref LogicController_SO logicController_SO);

/// <inheritdoc cref="ModifyBehaviour_delegate"/>
public static event ModifyBehaviour_delegate? ModifyBehaviour;

internal static void ModifyBehaviour_Invoke(EnemyType type, EnemyRank rank, BaseAIScript aiScript, LogicController_SO logicController_SO) {
ModifyBehaviour?.Invoke(type, rank, aiScript, logicController_SO);
internal static void ModifyBehaviour_Invoke(EnemyType type, EnemyRank rank, ref BaseAIScript aiScript, ref LogicController_SO logicController_SO) {
ModifyBehaviour?.Invoke(type, rank, ref aiScript, ref logicController_SO);
}
#endregion
}
6 changes: 4 additions & 2 deletions RL2.API/Hooks/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ internal static bool ModifyClassDataMethod(EnemyClassDataDictionary_TryGetValue
if (found) {
foreach (EnemyRank rank in Enum.GetValues(typeof(EnemyRank))) {
Enemy.ModifyData_Invoke(type, rank, data.GetEnemyData(rank));
Enemy.ModifyBehaviour_Invoke(type, rank, data.GetAIScript(rank), data.GetLogicController());
}
Enemy.ModifyBehaviour_Invoke(type, EnemyRank.Basic, ref data.m_basicAIScript, ref data.m_enemyLogicController);
Enemy.ModifyBehaviour_Invoke(type, EnemyRank.Advanced, ref data.m_advancedAIScript, ref data.m_enemyLogicController);
Enemy.ModifyBehaviour_Invoke(type, EnemyRank.Expert, ref data.m_expertAIScript, ref data.m_enemyLogicController);
Enemy.ModifyBehaviour_Invoke(type, EnemyRank.Miniboss, ref data.m_minibossAIScript, ref data.m_enemyLogicController);
}

return found;
}
#endregion
Expand Down

0 comments on commit 494697a

Please sign in to comment.