Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -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;