Move OnInitialize to interface
This commit is contained in:
@@ -54,13 +54,6 @@ public abstract class Script : IDeepCloneable
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is ran when this script starts being in effect.
|
||||
/// </summary>
|
||||
public virtual void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is ran when this script is added to a parent.
|
||||
/// </summary>
|
||||
@@ -848,4 +841,17 @@ public interface IScriptOnBeforeAnyHookInvoked
|
||||
/// of scripts. This is useful for example to prevent certain effects from running.
|
||||
/// </summary>
|
||||
void OnBeforeAnyHookInvoked(ref List<ScriptCategory>? suppressedCategories);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface is used to allow scripts to run when they are initialized. This allows for
|
||||
/// setting up the script with parameters that are passed to it.
|
||||
/// </summary>
|
||||
public interface IScriptOnInitialize
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is ran when the script is initialized. This allows for setting up the script
|
||||
/// with parameters that are passed to it.
|
||||
/// </summary>
|
||||
void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters);
|
||||
}
|
||||
@@ -34,7 +34,8 @@ public class ScriptResolver
|
||||
}
|
||||
|
||||
script = scriptCtor();
|
||||
script.OnInitialize(parameters);
|
||||
if (script is IScriptOnInitialize scriptOnInitialize)
|
||||
scriptOnInitialize.OnInitialize(parameters);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user