More abilities, refactor IPokemon.SetStatus to pass pokemon that caused the status change
All checks were successful
Build / Build (push) Successful in 50s
All checks were successful
Build / Build (push) Successful in 50s
This commit is contained in:
@@ -361,7 +361,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// <summary>
|
||||
/// Adds a non-volatile status to the Pokemon.
|
||||
/// </summary>
|
||||
bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default);
|
||||
bool SetStatus(StringKey status, IPokemon? originPokemon, EventBatchId batchId = default);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the current non-volatile status from the Pokemon.
|
||||
@@ -1186,7 +1186,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
public bool HasStatus(StringKey status) => StatusScript.Script?.Name == status;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SetStatus(StringKey status, bool selfInflicted, EventBatchId batchId = default)
|
||||
public bool SetStatus(StringKey status, IPokemon? originPokemon, EventBatchId batchId = default)
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {status} not found");
|
||||
@@ -1194,6 +1194,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
if (!StatusScript.IsEmpty)
|
||||
return false;
|
||||
var oldStatus = StatusScript.Script?.Name;
|
||||
var selfInflicted = originPokemon == this;
|
||||
|
||||
var preventStatus = false;
|
||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, selfInflicted, ref preventStatus));
|
||||
@@ -1206,6 +1207,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
this.RunScriptHook(script => script.OnAfterStatusChange(this, status, originPokemon));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user