Skip to content

Commit 2f97def

Browse files
committed
feat: created asset
1 parent 34c3df1 commit 2f97def

30 files changed

Lines changed: 197 additions & 486 deletions

.gitignore

Lines changed: 0 additions & 418 deletions
This file was deleted.

HelperMethods.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

LICENSE.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# CsharpExtensionMethods
2+
23
As the name implies, useful extension methods for C#.

README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
using YoukaiFox.CsharpExtensions;
2-
using YoukaiFox.CsharpExtensions.Helper;
1+
using SoftBoiledGames.CsharpExtensionMethods;
32

4-
namespace YoukaiFox.CsharpExtensions
3+
namespace SoftBoiledGames.CsharpExtensionMethods
54
{
65
public static class ArrayExtensions
76
{
8-
// Author: Youkai Fox Studio
7+
// Author: Soft Boiled Games
98
/// <summary>
109
/// Shuffles the collection using the Fisher-Yates method.
1110
/// </summary>
1211
public static void Shuffle<T>(this T[] items)
1312
{
1413
if (items.Length == 0)
14+
{
1515
return;
16+
}
1617

1718
System.Random rng = new System.Random();
18-
int n = items.Length;
19+
var n = items.Length;
1920

2021
for (int i = 0; i < n; i++)
2122
{
2223
int randomInt = rng.Next(0, i);
23-
HelperMethods.Swap(ref items[i], ref items[randomInt]);
24+
var temp = items[i];
25+
items[i] = items[randomInt];
26+
items[randomInt] = temp;
2427
}
2528
}
2629

27-
// Author: Youkai Fox Studio
30+
// Author: Soft Boiled Games
2831
/// <summary>
2932
/// Shuffles the collection using the Fisher-Yates method
3033
/// providing a seed for the random number generator.
@@ -33,27 +36,28 @@ public static void Shuffle<T>(this T[] items)
3336
public static void Shuffle<T>(this T[] items, int seed)
3437
{
3538
if (items.Length == 0)
39+
{
3640
return;
41+
}
3742

3843
System.Random rng = new System.Random(seed);
3944

4045
for (int i = items.Length - 1; i > 0; i--)
4146
{
4247
int r = rng.Next(i + 1);
43-
HelperMethods.Swap(ref items[i], ref items[r]);
48+
var temp = items[i];
49+
items[i] = items[r];
50+
items[r] = temp;
4451
}
4552
}
4653

47-
// Author: Youkai Fox Studio
54+
// Author: Soft Boiled Games
4855
/// <summary>
4956
/// Get the first valid index in the collection.
5057
/// </summary>
5158
public static int FirstValidIndex<T>(this T[] items)
5259
{
53-
if (items.Length > 0)
54-
return 0;
55-
56-
return -1;
60+
return items.Length > 0 ? 0 : -1;
5761
}
5862

5963
// Author: github.com/dracolytch/DracoSoftwareExtensionsForUnity
@@ -69,19 +73,23 @@ public static void ForEachComponent<T>(this T[] array, System.Action<T> callback
6973
}
7074
}
7175

72-
// Author: Youkai Fox Studio
76+
// Author: Soft Boiled Games
7377
/// <summary>
7478
/// Returns true if array <paramref name="self"/> contains <paramref name="element"/>.
7579
/// </summary>
7680
public static bool Contains<T>(this T[] self, T element)
7781
{
7882
if (self.Length == 0)
83+
{
7984
return false;
85+
}
8086

81-
foreach(T item in self)
87+
foreach (T item in self)
8288
{
83-
if(item.Equals(element))
89+
if (item.Equals(element))
90+
{
8491
return true;
92+
}
8593
}
8694

8795
return false;

Runtime/ArrayExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
namespace YoukaiFox.CsharpExtensions
1+
namespace SoftBoiledGames.CsharpExtensionMethods
22
{
33
public static class BoolExtensions
44
{
5-
// Author: Youkai Fox Studio
5+
// Author: Soft Boiled Games
66
/// <summary>
77
/// Converts the boolean to an int value, as in C language.
88
/// </summary>

Runtime/BoolExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)