Remove public empty constructors for pointer arrays, implements basic evolutions.
This commit is contained in:
@@ -15,6 +15,8 @@ namespace PkmnLibSharp.Library
|
||||
|
||||
public class EffectParameter : PointerWrapper
|
||||
{
|
||||
internal EffectParameter(IntPtr ptr) : base(ptr){}
|
||||
|
||||
public EffectParameter(string s) : base(Creaturelib.Generated.EffectParameter.FromString(s.ToPtr()))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,11 +8,7 @@ namespace PkmnLibSharp.Library
|
||||
public byte MaximalLevel => Creaturelib.Generated.LibrarySettings.GetMaximalLevel(Ptr);
|
||||
public byte MaximalMoves => Creaturelib.Generated.LibrarySettings.GetMaximalMoves(Ptr);
|
||||
public ushort ShinyRate => Pkmnlib.Generated.LibrarySettings.GetShinyRate(Ptr);
|
||||
|
||||
internal LibrarySettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
internal LibrarySettings(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
49
PkmnLibSharp/Library/Species/Evolution/EvolutionData.cs
Normal file
49
PkmnLibSharp/Library/Species/Evolution/EvolutionData.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Library.Evolution
|
||||
{
|
||||
public class EvolutionData : PointerWrapper
|
||||
{
|
||||
private EvolutionData(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public static EvolutionData CreateLevelEvolution(byte level, Species into)
|
||||
{
|
||||
return new EvolutionData(Pkmnlib.Generated.EvolutionData.CreateLevelEvolution(level, into.Ptr));
|
||||
}
|
||||
|
||||
public EvolutionMethod Method => (EvolutionMethod) Pkmnlib.Generated.EvolutionData.GetMethod(Ptr);
|
||||
|
||||
public Species NewSpecies
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_species != null) return _species;
|
||||
var ptr = Pkmnlib.Generated.EvolutionData.GetNewSpecies(Ptr);
|
||||
if (TryResolvePointer(ptr, out _species))
|
||||
return _species!;
|
||||
_species = new Species(ptr);
|
||||
return _species;
|
||||
}
|
||||
}
|
||||
|
||||
public ulong DataLength => Pkmnlib.Generated.EvolutionData.GetDataCount(Ptr);
|
||||
|
||||
public EffectParameter GetData(ulong index)
|
||||
{
|
||||
var ptr = IntPtr.Zero;
|
||||
Pkmnlib.Generated.EvolutionData.GetData(Ptr, index, ref ptr).Assert();
|
||||
if (TryResolvePointer(ptr, out EffectParameter? parameter))
|
||||
return parameter!;
|
||||
return new EffectParameter(ptr);
|
||||
}
|
||||
|
||||
private Species? _species;
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
PkmnLibSharp/Library/Species/Evolution/EvolutionMethod.cs
Normal file
19
PkmnLibSharp/Library/Species/Evolution/EvolutionMethod.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace PkmnLibSharp.Library.Evolution
|
||||
{
|
||||
public enum EvolutionMethod
|
||||
{
|
||||
Level = 0,
|
||||
HighFriendship = 1,
|
||||
KnownMove = 2,
|
||||
LocationBased = 3,
|
||||
TimeBased = 4,
|
||||
HoldsItem = 5,
|
||||
IsGenderAndLevel = 6,
|
||||
EvolutionItemUse = 7,
|
||||
EvolutionItemUseWithGender = 8,
|
||||
Trade = 9,
|
||||
TradeWithHeldItem = 10,
|
||||
TradeWithSpecificPokemon = 11,
|
||||
Custom = 12,
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Creaturelib.Generated;
|
||||
using Pkmnlib;
|
||||
using Pkmnlib.Generated;
|
||||
using PkmnLibSharp.Utilities;
|
||||
using EvolutionData = PkmnLibSharp.Library.Evolution.EvolutionData;
|
||||
using Gender = PkmnLibSharp.Battling.Gender;
|
||||
using Random = PkmnLibSharp.Utilities.Random;
|
||||
|
||||
@@ -11,11 +12,19 @@ namespace PkmnLibSharp.Library
|
||||
{
|
||||
public class Species : PointerWrapper
|
||||
{
|
||||
private string? _name;
|
||||
private string? _growthRate;
|
||||
internal Species(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Forme> _formes =
|
||||
new Dictionary<string, Forme>(StringComparer.InvariantCultureIgnoreCase);
|
||||
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate,
|
||||
byte captureRate, byte baseHappiness)
|
||||
{
|
||||
var ptr = IntPtr.Zero;
|
||||
PokemonSpecies.Construct(ref ptr, id, name.ToPtr(), defaultForme.Ptr, genderRatio,
|
||||
growthRate.ToPtr(), captureRate, baseHappiness).Assert();
|
||||
_formes.Add("default", defaultForme);
|
||||
Initialize(ptr);
|
||||
}
|
||||
|
||||
public ushort Id => CreatureSpecies.GetId(Ptr);
|
||||
public float GenderRate => CreatureSpecies.GetGenderRate(Ptr);
|
||||
@@ -23,6 +32,19 @@ namespace PkmnLibSharp.Library
|
||||
public string Name => _name ??= CreatureSpecies.GetName(Ptr).PtrString()!;
|
||||
public string GrowthRate => _growthRate ??= CreatureSpecies.GetGrowthRate(Ptr).PtrString()!;
|
||||
|
||||
public ReadOnlyNativePtrArray<EvolutionData> Evolutions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_evolutions != null) return _evolutions;
|
||||
var ptr = IntPtr.Zero;
|
||||
PokemonSpecies.GetEvolutions(Ptr, ref ptr);
|
||||
var length = PokemonSpecies.GetEvolutionCount(Ptr);
|
||||
_evolutions = new ReadOnlyNativePtrArray<EvolutionData>(ptr, (int) length);
|
||||
return _evolutions;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasForme(string s)
|
||||
{
|
||||
return CreatureSpecies.HasVariant(Ptr, s.ToPtr()) == MarshalHelper.True;
|
||||
@@ -76,20 +98,18 @@ namespace PkmnLibSharp.Library
|
||||
return (Gender) CreatureSpecies.GetRandomGender(Ptr, random.Ptr);
|
||||
}
|
||||
|
||||
|
||||
internal Species(IntPtr ptr) : base(ptr)
|
||||
public void AddEvolution(EvolutionData evolutionData)
|
||||
{
|
||||
Pkmnlib.Generated.PokemonSpecies.AddEvolution(Ptr, evolutionData.Ptr);
|
||||
}
|
||||
|
||||
private string? _name;
|
||||
private string? _growthRate;
|
||||
|
||||
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate,
|
||||
byte captureRate, byte baseHappiness)
|
||||
{
|
||||
var ptr = IntPtr.Zero;
|
||||
PokemonSpecies.Construct(ref ptr, id, name.ToPtr(), defaultForme.Ptr, genderRatio,
|
||||
growthRate.ToPtr(), captureRate, baseHappiness).Assert();
|
||||
_formes.Add("default", defaultForme);
|
||||
Initialize(ptr);
|
||||
}
|
||||
private readonly Dictionary<string, Forme> _formes =
|
||||
new Dictionary<string, Forme>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
private ReadOnlyNativePtrArray<EvolutionData>? _evolutions;
|
||||
|
||||
protected internal override void MarkAsDeleted()
|
||||
{
|
||||
Reference in New Issue
Block a user