//
// PetManagerList.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using NosSmooth.LocalBinding.Errors;
using NosSmooth.LocalBinding.Extensions;
using NosSmooth.LocalBinding.Options;
using Reloaded.Memory.Sources;
using Remora.Results;
using SharpDisasm.Udis86;
namespace NosSmooth.LocalBinding.Structs;
///
/// NosTale list of .
///
public class PetManagerList : NostaleList
{
///
/// Create instance.
///
/// The NosTale process browser.
/// The options.
/// The player manager or an error.
public static Result Create(NosBrowserManager nosBrowserManager, PetManagerOptions options)
{
var characterObjectAddress = nosBrowserManager.Scanner.CompiledFindPattern(options.PetManagerListPattern);
if (!characterObjectAddress.Found)
{
return new BindingNotFoundError(options.PetManagerListPattern, "PetManagerList");
}
if (nosBrowserManager.Process.MainModule is null)
{
return new NotFoundError("Cannot find the main module of the target process.");
}
int staticManagerAddress = (int)nosBrowserManager.Process.MainModule.BaseAddress + characterObjectAddress.Offset;
return new PetManagerList(nosBrowserManager.Memory, staticManagerAddress, options.PetManagerListOffsets);
}
///
/// Initializes a new instance of the class.
///
/// The memory.
/// The static pet manager address.
/// The offsets to follow to the pet manager list address.
public PetManagerList(IMemory memory, int staticPetManagerListAddress, int[] staticPetManagerOffsets)
: base(memory, memory.FollowStaticAddressOffsets(staticPetManagerListAddress, staticPetManagerOffsets))
{
}
}