v1.0.0 Release #1

Merged
omegaleo merged 2 commits from dev into main 2024-07-03 20:58:23 +00:00
3 changed files with 28 additions and 2 deletions
@@ -1,4 +1,4 @@
using UnityFlow.DocumentationHelper.Library.Attributes; using NetFlow.DocumentationHelper.Library.Attributes;
namespace GameDevLibrary.Extensions namespace GameDevLibrary.Extensions
{ {
@@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using NetFlow.DocumentationHelper.Library.Attributes;
namespace GameDevLibrary.Models namespace GameDevLibrary.Models
{ {
// Inspiration: https://www.youtube.com/watch?v=x-ejym1WdjE // Inspiration: https://www.youtube.com/watch?v=x-ejym1WdjE
[Serializable] [Serializable]
[Documentation("NeoDictionary", "Dictionary like class created to make it easier to display dictionaries in game engines like Unity")]
public class NeoDictionary<TKey,TValue> public class NeoDictionary<TKey,TValue>
{ {
public List<NeoDictionaryItem<TKey, TValue>> Items = new List<NeoDictionaryItem<TKey, TValue>>(); public List<NeoDictionaryItem<TKey, TValue>> Items = new List<NeoDictionaryItem<TKey, TValue>>();
@@ -66,6 +68,28 @@ namespace GameDevLibrary.Models
public bool Any() => Items.Any(); public bool Any() => Items.Any();
public bool Any(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) => Items.Any(predicate); public bool Any(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) => Items.Any(predicate);
public IEnumerable<NeoDictionaryItem<TKey, TValue>> Where(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) =>
Items.Where(predicate);
public NeoDictionaryItem<TKey, TValue>? FirstOrDefault() => Items.FirstOrDefault();
public NeoDictionaryItem<TKey, TValue>? FirstOrDefault(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) =>
Items.FirstOrDefault(predicate);
public NeoDictionaryItem<TKey, TValue>? LastOrDefault() => Items.LastOrDefault();
public NeoDictionaryItem<TKey, TValue>? LastOrDefault(Func<NeoDictionaryItem<TKey, TValue>, 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] [Serializable]
+3 -1
View File
@@ -7,10 +7,12 @@
<Version>0.0.2</Version> <Version>0.0.2</Version>
<Title>Omega Leo's Helper Library</Title> <Title>Omega Leo's Helper Library</Title>
<Authors>Nuno "Omega Leo" Diogo</Authors> <Authors>Nuno "Omega Leo" Diogo</Authors>
<PackageProjectUrl>https://github.com/omegaleo/HelperLib</PackageProjectUrl>
<RepositoryUrl>https://github.com/omegaleo/HelperLib</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="UnityFlow.DocumentationHelper.Library" Version="1.1.2" /> <PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>