~ruther/NosSmooth

ref: 18763fe567377741ff1330cb6ae6940cc3bd899b NosSmooth/Data/NosSmooth.Data.NOSFiles/Infos/MapInfo.cs -rw-r--r-- 1.5 KiB
18763fe5 — František Boháček tests(game): add raid tests 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
46
47
48
49
50
51
52
53
54
55
56
57
58
//
//  MapInfo.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.Data.Abstractions.Infos;
using NosSmooth.Data.Abstractions.Language;

namespace NosSmooth.Data.NOSFiles.Infos;

/// <inheritdoc />
internal class MapInfo : IMapInfo
{
    private readonly byte[] _data;

    /// <summary>
    /// Initializes a new instance of the <see cref="MapInfo"/> class.
    /// </summary>
    /// <param name="id">The VNum.</param>
    /// <param name="name">The name of the map.</param>
    /// <param name="width">The width.</param>
    /// <param name="height">The height.</param>
    /// <param name="grid">The grid data.</param>
    public MapInfo(int id, TranslatableString name, short width, short height, byte[] grid)
    {
        Id = id;
        Name = name;
        Width = width;
        Height = height;
        _data = grid;
    }

    /// <inheritdoc />
    public int Id { get; }

    /// <inheritdoc />
    public TranslatableString Name { get; }

    /// <inheritdoc />
    public short Width { get; }

    /// <inheritdoc />
    public short Height { get; }

    /// <inheritdoc />
    public byte GetData(short x, short y)
    {
        return _data[(y * Width) + x];
    }

    /// <inheritdoc />
    public bool IsWalkable(short x, short y)
    {
        var val = GetData(x, y);
        return val == 0 || val == 2 || (val >= 16 && val <= 19);
    }
}
Do not follow this link