From f4629e1709798d995ba0b0f2fd9bec9668a4f488 Mon Sep 17 00:00:00 2001 From: "Nuno \"Omega Leo\" Diogo" Date: Wed, 3 Jul 2024 21:58:23 +0100 Subject: [PATCH] v1.0.0 Release (#1) * Fixed dependency * Updates to NeoDictionary --- .../Extensions/ArrayExtensions.cs | 2 +- OmegaLeo.HelperLib/Models/NeoDictionary.cs | 24 +++++++++++++++++++ OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj | 4 +++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/OmegaLeo.HelperLib/Extensions/ArrayExtensions.cs b/OmegaLeo.HelperLib/Extensions/ArrayExtensions.cs index 00ad8a4..fc4a942 100644 --- a/OmegaLeo.HelperLib/Extensions/ArrayExtensions.cs +++ b/OmegaLeo.HelperLib/Extensions/ArrayExtensions.cs @@ -1,4 +1,4 @@ -using UnityFlow.DocumentationHelper.Library.Attributes; +using NetFlow.DocumentationHelper.Library.Attributes; namespace GameDevLibrary.Extensions { diff --git a/OmegaLeo.HelperLib/Models/NeoDictionary.cs b/OmegaLeo.HelperLib/Models/NeoDictionary.cs index af3ba14..12861fb 100644 --- a/OmegaLeo.HelperLib/Models/NeoDictionary.cs +++ b/OmegaLeo.HelperLib/Models/NeoDictionary.cs @@ -2,11 +2,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using NetFlow.DocumentationHelper.Library.Attributes; namespace GameDevLibrary.Models { // Inspiration: https://www.youtube.com/watch?v=x-ejym1WdjE [Serializable] + [Documentation("NeoDictionary", "Dictionary like class created to make it easier to display dictionaries in game engines like Unity")] public class NeoDictionary { public List> Items = new List>(); @@ -66,6 +68,28 @@ namespace GameDevLibrary.Models public bool Any() => Items.Any(); public bool Any(Func, bool> predicate) => Items.Any(predicate); + + public IEnumerable> Where(Func, bool> predicate) => + Items.Where(predicate); + + public NeoDictionaryItem? FirstOrDefault() => Items.FirstOrDefault(); + + public NeoDictionaryItem? FirstOrDefault(Func, bool> predicate) => + Items.FirstOrDefault(predicate); + + public NeoDictionaryItem? LastOrDefault() => Items.LastOrDefault(); + + public NeoDictionaryItem? LastOrDefault(Func, bool> predicate) => + Items.LastOrDefault(predicate); + + public void Remove(TKey key) + { + var index = Items.FindIndex(x => x.Key.Equals(key)); + + Items.RemoveAt(index); + } + + public void RemoveAt(int index) => Items.RemoveAt(index); } [Serializable] diff --git a/OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj b/OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj index 1e91962..cd876f5 100644 --- a/OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj +++ b/OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj @@ -7,10 +7,12 @@ 0.0.2 Omega Leo's Helper Library Nuno "Omega Leo" Diogo + https://github.com/omegaleo/HelperLib + https://github.com/omegaleo/HelperLib - +