Exemplo n.º 1
0
        /// <summary>
        /// Add a new key to the manager
        /// </summary>
        /// <param name="key">The key to add</param>
        /// <returns>The task</returns>
        public static async Task AddKeyAsync(Key key)
        {
            // Lock the method
            using (await AsyncLock.LockAsync())
            {
                // Check if it's the following key in any of the available codes
                if (Codes.All(x => x.Key.Length <= CurrentInput.Count || x.Key[CurrentInput.Count] != key))
                {
                    if (CurrentInput.Any())
                    {
                        CurrentInput.Clear();
                        RL.Logger?.LogDebugSource("The secret code inputs were reset due to an invalid key being pressed");
                    }

                    return;
                }

                // Add the key to the list
                CurrentInput.Add(key);

                // Attempt to get a completed code
                var task = Codes.FindItem(x => x.Key.SequenceEqual(CurrentInput)).Value;

                if (task == null)
                {
                    return;
                }

                CurrentInput.Clear();
                RL.Logger?.LogDebugSource("The secret code inputs were reset due to a valid code having been entered");

                // Run the task
                await task();
            }
        }
Exemplo n.º 2
0
 public void UpgradeConverterOutputResource(string resource)
 {
     if (InputOutputMapping.ContainsKey(resource))
     {
         return;
     }
     InputOutputMapping.Add(resource, new List <ResourceAmount>());
     CurrentInput.Add(new ResourceAmount(resource, 0));
 }
Exemplo n.º 3
0
 // it may be useful to store the current input, maybe...
 public void UpdateInput(T input)
 {
     CurrentInput.Clear();
     input.ForEach(e => CurrentInput.Add(e));
 }