~ruther/NosSmooth

b4fd7171977bc0bf810329340fb9f79ee3e4765f — František Boháček 3 years ago d45a014
feat(samples): add follow and unfollow command samples
1 files changed, 31 insertions(+), 1 deletions(-)

M Samples/WalkCommands/Commands/CombatCommands.cs
M Samples/WalkCommands/Commands/CombatCommands.cs => Samples/WalkCommands/Commands/CombatCommands.cs +31 -1
@@ 19,16 19,19 @@ namespace WalkCommands.Commands;
public class CombatCommands : CommandGroup
{
    private readonly SceneManagerBinding _sceneManagerBinding;
    private readonly CharacterBinding _characterBinding;
    private readonly FeedbackService _feedbackService;

    /// <summary>
    /// Initializes a new instance of the <see cref="CombatCommands"/> class.
    /// </summary>
    /// <param name="sceneManagerBinding">The scene manager binding.</param>
    /// <param name="characterBinding">The character binding.</param>
    /// <param name="feedbackService">The feedback service.</param>
    public CombatCommands(SceneManagerBinding sceneManagerBinding, FeedbackService feedbackService)
    public CombatCommands(SceneManagerBinding sceneManagerBinding, CharacterBinding characterBinding, FeedbackService feedbackService)
    {
        _sceneManagerBinding = sceneManagerBinding;
        _characterBinding = characterBinding;
        _feedbackService = feedbackService;
    }



@@ 42,4 45,31 @@ public class CombatCommands : CommandGroup
    {
        return Task.FromResult(_sceneManagerBinding.FocusEntity(entityId));
    }

    /// <summary>
    /// Follow the given entity.
    /// </summary>
    /// <param name="entityId">The entity id to follow.</param>
    /// <returns>A task that may or may not have succeeded.</returns>
    [Command("follow")]
    public Task<Result> HandleFollowAsync(int entityId)
    {
        var entity = _sceneManagerBinding.FindEntity(entityId);
        if (!entity.IsSuccess)
        {
            return Task.FromResult(Result.FromError(entity));
        }

        return Task.FromResult(_characterBinding.FollowEntity(entity.Entity));
    }

    /// <summary>
    /// Stop following an entity.
    /// </summary>
    /// <returns>A task that may or may not have succeeded.</returns>
    [Command("unfollow")]
    public Task<Result> HandleUnfollowAsync()
    {
        return Task.FromResult(_characterBinding.UnfollowEntity());
    }
}
\ No newline at end of file

Do not follow this link