Clear array passed to PokemonParty to assert dominance and take ownership of it.

This commit is contained in:
Deukhoofd 2020-08-24 19:52:14 +02:00
parent 8a7872cf3a
commit b1f134c2a1
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling namespace PkmnLibSharp.Battling
@ -14,9 +15,12 @@ namespace PkmnLibSharp.Battling
public PokemonParty(byte size = 6) : base(Creaturelib.Generated.CreatureParty.ConstructWithSize(size)) public PokemonParty(byte size = 6) : base(Creaturelib.Generated.CreatureParty.ConstructWithSize(size))
{} {}
public PokemonParty(Pokemon[] pokemon) : base( public PokemonParty(Pokemon?[] pokemon) : base(
Creaturelib.Generated.CreatureParty.ConstructFromArray(pokemon.ArrayPtr(), (ulong) pokemon.Length)) Creaturelib.Generated.CreatureParty.ConstructFromArray(pokemon.ArrayPtr(), (ulong) pokemon.Length))
{} {
for (var index = 0; index < pokemon.Length; index++)
pokemon[index] = null;
}
public virtual Pokemon this[int i] => GetAtIndex((ulong) i); public virtual Pokemon this[int i] => GetAtIndex((ulong) i);