| | 1 | | // Copyright (c) 2020-2022 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | |
|
| | 7 | | namespace GDX.Developer |
| | 8 | | { |
| | 9 | | #if UNITY_2022_2_OR_NEWER |
| | 10 | | public abstract class ConsoleCommandBase |
| | 11 | | { |
| 2 | 12 | | public static Guid PlayerConnectionGuid = new Guid("5bccf3e4-1f16-4500-95c9-060e9c3d61c0"); |
| | 13 | |
|
| | 14 | |
|
| | 15 | | /// <summary> |
| | 16 | | /// Executes the logic for the command. |
| | 17 | | /// </summary> |
| | 18 | | /// <returns> |
| | 19 | | /// Returns false it means this is blocking further progression through |
| | 20 | | /// the queue of outstanding commands. |
| | 21 | | /// </returns> |
| | 22 | | public abstract bool Evaluate(float deltaTime); |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Returns the minimum access level required to execute a command. |
| | 26 | | /// </summary> |
| | 27 | | /// <remarks>Overrideable, but defaults to having user level access.</remarks> |
| | 28 | | /// <returns>The required user access level to utilize a given command.</returns> |
| | 29 | | public virtual Console.ConsoleAccessLevel GetAccessLevel() |
| 0 | 30 | | { |
| 0 | 31 | | return Console.ConsoleAccessLevel.User; |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | public abstract string GetKeyword(); |
| | 35 | |
|
| | 36 | | public virtual string GetHelpUsage() |
| 0 | 37 | | { |
| 0 | 38 | | return GetKeyword(); |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | public abstract string GetHelpMessage(); |
| | 42 | |
|
| | 43 | | public virtual string[] GetArgumentAutoCompleteSuggestions(string hint, string[] existingSet = null) |
| 0 | 44 | | { |
| 0 | 45 | | return null; |
| 0 | 46 | | } |
| | 47 | |
|
| | 48 | | public virtual bool IsEditorOnly() |
| 0 | 49 | | { |
| 0 | 50 | | return false; |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Gets the instance of the work to be added to the <see cref="Console" />'s command buffer. |
| | 55 | | /// </summary> |
| | 56 | | /// <remarks> |
| | 57 | | /// This work is processed later so in the case where context is needed, a new instance should be returned, |
| | 58 | | /// however if it is a pure functionality you can just return the existing instance, which is the default |
| | 59 | | /// non-overridden behaviour. |
| | 60 | | /// </remarks> |
| | 61 | | /// <param name="context">Unique information needed to configure a newly created instance.</param> |
| | 62 | | /// <returns>A qualified instance of the class ready to be executed, null if something went wrong.</returns> |
| | 63 | | public virtual ConsoleCommandBase GetInstance(string context) |
| 0 | 64 | | { |
| 0 | 65 | | return this; |
| 0 | 66 | | } |
| | 67 | | } |
| | 68 | | #endif // UNITY_2022_2_OR_NEWER |
| | 69 | | } |