Dont lose references to libraries

This commit is contained in:
Deukhoofd 2020-09-04 21:01:18 +02:00
parent 471c082527
commit ce54b8c2c2
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 15 additions and 1 deletions

View File

@ -10,6 +10,7 @@ namespace PkmnLibSharp.Battling
private StatCalculator? _statCalculator;
private DamageLibrary? _damageLibrary;
private MiscLibrary? _miscLibrary;
private ScriptResolver? _scriptResolver;
private ExperienceLibrary? _experienceLibrary;
public PokemonLibrary StaticLibrary
@ -89,6 +90,12 @@ namespace PkmnLibSharp.Battling
Pkmnlib.Generated.BattleLibrary.Construct(ref ptr, staticLibrary.Ptr, statCalculator.Ptr, damageLibrary.Ptr,
experienceLibrary.Ptr, scriptResolver.Ptr, miscLibrary.Ptr).Assert();
Initialize(ptr);
_static = staticLibrary;
_statCalculator = statCalculator;
_damageLibrary = damageLibrary;
_experienceLibrary = experienceLibrary;
_scriptResolver = scriptResolver;
_miscLibrary = miscLibrary;
}
protected override void DeletePtr()

View File

@ -115,7 +115,7 @@ namespace PkmnLibSharp.Library
}
internal PokemonLibrary(IntPtr ptr) : base(ptr)
public PokemonLibrary(IntPtr ptr) : base(ptr)
{
}
@ -127,6 +127,13 @@ namespace PkmnLibSharp.Library
Pkmnlib.Generated.PokemonLibrary.Construct(ref ptr, settings.Ptr, species.Ptr, moves.Ptr, items.Ptr,
growthRates.Ptr, types.Ptr, natures.Ptr).Assert();
Initialize(ptr);
_settings = settings;
_species = species;
_moves = moves;
_items = items;
_growthRateLibrary = growthRates;
_typeLibrary = types;
_natureLibrary = natures;
}
protected override void DeletePtr()