//
// 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;
///
internal class MapInfo : IMapInfo
{
private readonly byte[] _data;
///
/// Initializes a new instance of the class.
///
/// The VNum.
/// The name of the map.
/// The width.
/// The height.
/// The grid data.
public MapInfo(int id, TranslatableString name, short width, short height, byte[] grid)
{
Id = id;
Name = name;
Width = width;
Height = height;
_data = grid;
}
///
public int Id { get; }
///
public TranslatableString Name { get; }
///
public short Width { get; }
///
public short Height { get; }
///
public byte GetData(short x, short y)
{
return _data[(y * Width) + x];
}
///
public bool IsWalkable(short x, short y)
{
var val = GetData(x, y);
return val == 0 || val == 2 || (val >= 16 && val <= 19);
}
}