~ruther/NosSmooth

ref: a90b9c10b4731ad72d35f1b012c52db37c3e3a94 NosSmooth/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkCommandHandler.cs -rw-r--r-- 1.1 KiB
a90b9c10 — František Boháček feat: implement walk command handler 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
//  WalkCommandHandler.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.Core.Commands;
using NosSmoothCore;
using Remora.Results;

namespace NosSmooth.LocalClient.CommandHandlers;

/// <summary>
/// Handles <see cref="WalkCommand"/>.
/// </summary>
public class WalkCommandHandler : ICommandHandler<WalkCommand>
{
    private readonly NosClient _nosClient;

    /// <summary>
    /// Initializes a new instance of the <see cref="WalkCommandHandler"/> class.
    /// </summary>
    /// <param name="nosClient">The local client.</param>
    public WalkCommandHandler(NosClient nosClient)
    {
        _nosClient = nosClient;
    }

    /// <inheritdoc/>
    public Task<Result> HandleCommand(WalkCommand command, CancellationToken ct = default)
    {
        _nosClient.GetCharacter().Walk(command.TargetX, command.TargetY);
        return Task.Delay(1000).ContinueWith(_ => Result.FromSuccess()); // TODO: Wait for the move to finish
    }
}
Do not follow this link