Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -9,20 +9,20 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "forecast")]
|
||||
public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Forecast can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
ChangeForm(pokemon, pokemon.BattleData?.Battle.WeatherName);
|
||||
ChangeForm(pokemon, pokemon.Battle.WeatherName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -43,7 +43,7 @@ public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||
ChangeForm(_pokemon, null);
|
||||
}
|
||||
|
||||
private static void ChangeForm(IPokemon pokemon, StringKey? weather)
|
||||
private static void ChangeForm(IBattlePokemon pokemon, StringKey? weather)
|
||||
{
|
||||
if (pokemon.Species.Name != SpeciesNames.Castform)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user