When a move is changed through the ChangeMove hook, update the script
This commit is contained in:
parent
45439a20a4
commit
06ce7fd38d
|
@ -22,7 +22,16 @@ internal static class MoveTurnExecutor
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"The move was changed to '{moveDataName}' by a script, but this move does not exist.");
|
$"The move was changed to '{moveDataName}' by a script, but this move does not exist.");
|
||||||
}
|
}
|
||||||
// FIXME: Change the script on the move when it is changed.
|
var secondaryEffect = moveData.SecondaryEffect;
|
||||||
|
if (secondaryEffect != null)
|
||||||
|
{
|
||||||
|
if (moveChoice.User.Library.ScriptResolver.TryResolve(ScriptCategory.Move, secondaryEffect.Name, out var script))
|
||||||
|
{
|
||||||
|
moveChoice.Script.Set(script);
|
||||||
|
script.OnInitialize(moveChoice.User.Library, secondaryEffect.Parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetType = moveData.Target;
|
var targetType = moveData.Target;
|
||||||
|
|
|
@ -49,10 +49,7 @@ public class ScriptContainer : IEnumerable<ScriptContainer>
|
||||||
/// <param name="script"></param>
|
/// <param name="script"></param>
|
||||||
public void Set(Script script)
|
public void Set(Script script)
|
||||||
{
|
{
|
||||||
if (Script is not null)
|
Script?.OnRemove();
|
||||||
{
|
|
||||||
Script.OnRemove();
|
|
||||||
}
|
|
||||||
Script = script;
|
Script = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue