~ruther/NosSmooth.Local

ref: 8a6eeb874448013c576ac7dea8477b66740bd64e NosSmooth.Local/src/Core/NosSmooth.LocalBinding/Structs/MapPlayerObj.cs -rw-r--r-- 1.3 KiB
8a6eeb87 — Rutherther chore: bump versions 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  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;

/// <summary>
/// NosTale Player object.
/// </summary>
public class MapPlayerObj : MapBaseObj
{
    private readonly IMemory _memory;

    /// <summary>
    /// Initializes a new instance of the <see cref="MapPlayerObj"/> class.
    /// </summary>
    /// <param name="memory">The memory.</param>
    /// <param name="mapObjPointer">The player object pointer.</param>
    public MapPlayerObj(IMemory memory, nuint mapObjPointer)
        : base(memory, mapObjPointer)
    {
        _memory = memory;
    }

    /// <summary>
    /// Gets the name of the player.
    /// </summary>
    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);
        }
    }
}
Do not follow this link