// // 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; using NosSmooth.LocalBinding.Objects; using NosSmooth.LocalBinding.Structs; 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 UnitManagerBinding _unitManagerBinding; private readonly SceneManager _sceneManager; private readonly PlayerManagerBinding _playerManagerBinding; private readonly FeedbackService _feedbackService; /// /// Initializes a new instance of the class. /// /// The scene manager binding. /// The scene manager. /// The character binding. /// The feedback service. public CombatCommands ( UnitManagerBinding unitManagerBinding, SceneManager sceneManager, PlayerManagerBinding playerManagerBinding, FeedbackService feedbackService ) { _unitManagerBinding = unitManagerBinding; _sceneManager = sceneManager; _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) { var entityResult = _sceneManager.FindEntity(entityId); if (!entityResult.IsSuccess) { return Task.FromResult(Result.FromError(entityResult)); } return Task.FromResult(_unitManagerBinding.FocusEntity(entityResult.Entity)); } /// /// 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 entityResult = _sceneManager.FindEntity(entityId); if (!entityResult.IsSuccess) { return Task.FromResult(Result.FromError(entityResult)); } return Task.FromResult(_playerManagerBinding.FollowEntity(entityResult.Entity)); } /// /// Stop following an entity. /// /// A task that may or may not have succeeded. [Command("unfollow")] public Task HandleUnfollowAsync() { return Task.FromResult(_playerManagerBinding.UnfollowEntity()); } }