//
// Map.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.Diagnostics.CodeAnalysis;
using NosSmooth.Data.Abstractions.Infos;
using NosSmooth.Game.Data.Info;
namespace NosSmooth.Game.Data.Maps;
///
/// Represents nostale map.
///
/// The id of the map.
/// The type of the map.
/// The information about the map obtained from data assembly.
/// The entities on the map.
/// The portals on the map.
public record Map
(
long Id,
byte Type,
IMapInfo? Info,
MapEntities Entities,
IReadOnlyList Portals
)
{
///
/// Gets whether the given position lies on a portal.
///
/// The position.
/// The portal the position is on, if any.
/// Whether there was a portal at the specified position.
public bool IsOnPortal(Position position, [NotNullWhen(true)] out Portal? portal)
{
foreach (var p in Portals)
{
// TODO: figure out the distance
if (p.Position.DistanceSquared(position) < 3)
{
portal = p;
return true;
}
}
portal = null;
return false;
}
}