From b4fd7171977bc0bf810329340fb9f79ee3e4765f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Fri, 21 Jan 2022 00:20:45 +0100 Subject: [PATCH] feat(samples): add follow and unfollow command samples --- .../WalkCommands/Commands/CombatCommands.cs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Samples/WalkCommands/Commands/CombatCommands.cs b/Samples/WalkCommands/Commands/CombatCommands.cs index 1b29202..5107e88 100644 --- a/Samples/WalkCommands/Commands/CombatCommands.cs +++ b/Samples/WalkCommands/Commands/CombatCommands.cs @@ -19,16 +19,19 @@ namespace WalkCommands.Commands; public class CombatCommands : CommandGroup { private readonly SceneManagerBinding _sceneManagerBinding; + private readonly CharacterBinding _characterBinding; 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, 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)); } + + /// + /// 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(_characterBinding.FollowEntity(entity.Entity)); + } + + /// + /// Stop following an entity. + /// + /// A task that may or may not have succeeded. + [Command("unfollow")] + public Task HandleUnfollowAsync() + { + return Task.FromResult(_characterBinding.UnfollowEntity()); + } } \ No newline at end of file -- 2.49.0