//
// MapPlayerObj.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 System.Runtime.InteropServices;
using System.Text;
using Reloaded.Memory.Sources;
namespace NosSmooth.LocalBinding.Structs;
///
/// NosTale Player object.
///
public class MapPlayerObj : MapBaseObj
{
private readonly IMemory _memory;
///
/// Initializes a new instance of the class.
///
/// The memory.
/// The player object pointer.
public MapPlayerObj(IMemory memory, nuint mapObjPointer)
: base(memory, mapObjPointer)
{
_memory = memory;
}
///
/// Gets the name of the player.
///
public string? Name
{
get
{
_memory.SafeRead(Address + 0x1EC, out int nameAddress);
_memory.SafeRead((nuint)nameAddress - 4, out int nameLength);
byte[] data = new byte[nameLength];
_memory.SafeReadRaw((nuint)nameAddress, out data, nameLength);
return Encoding.ASCII.GetString(data);
}
}
}