//
// CombatCommands.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.ChatCommands;
using NosSmooth.Core.Client;
using NosSmooth.LocalBinding.Objects;
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Results;
namespace WalkCommands.Commands;
///
/// Represents command group for combat commands.
///
public class CombatCommands : CommandGroup
{
private readonly SceneManagerBinding _sceneManagerBinding;
private readonly PlayerManagerBinding _playerManagerBinding;
private readonly FeedbackService _feedbackService;
///
/// Initializes a new instance of the class.
///
/// The scene manager binding.
/// The character binding.
/// The feedback service.
public CombatCommands(SceneManagerBinding sceneManagerBinding, PlayerManagerBinding playerManagerBinding, FeedbackService feedbackService)
{
_sceneManagerBinding = sceneManagerBinding;
_playerManagerBinding = playerManagerBinding;
_feedbackService = feedbackService;
}
///
/// Focus the given entity.
///
/// The entity id to focus.
/// A task that may or may not have succeeded.
[Command("focus")]
public Task HandleFocusAsync(int entityId)
{
return Task.FromResult(_sceneManagerBinding.FocusEntity(entityId));
}
///
/// Follow the given entity.
///
/// The entity id to follow.
/// A task that may or may not have succeeded.
[Command("follow")]
public Task HandleFollowAsync(int entityId)
{
var entity = _sceneManagerBinding.FindEntity(entityId);
if (!entity.IsSuccess)
{
return Task.FromResult(Result.FromError(entity));
}
return Task.FromResult(_playerManagerBinding.FollowEntity(entity.Entity));
}
///
/// Stop following an entity.
///
/// A task that may or may not have succeeded.
[Command("unfollow")]
public Task HandleUnfollowAsync()
{
return Task.FromResult(_playerManagerBinding.UnfollowEntity());
}
}