Dev changes (#3)
* Fixed dependency * Updates to NeoDictionary * Changes to NeoDictionary * Started working on a Git implementation to integrate into Game Engines in the future * Added commit functionality to the git library * New changes * Added select for NeoDictionary.cs * Fixed issue with previous new method * Added a Benchmarking Tool to be used mostly in game engines * Added IndexOf to NeoDictionary.cs * Added new method for BenchmarkUtility.cs * added an instacedobject class * Added a new shuffle method for lists * fixed return type * Added new Changelog generator
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
namespace GameDevLibrary.Models
|
||||
{
|
||||
public abstract class InstancedObject<T> where T : class
|
||||
{
|
||||
public static T Instance { get; private set; }
|
||||
|
||||
protected InstancedObject()
|
||||
{
|
||||
if (Instance != null)
|
||||
{
|
||||
throw new InvalidOperationException($"An instance of {typeof(T).Name} already exists.");
|
||||
}
|
||||
|
||||
Instance = this as T;
|
||||
if (Instance == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Failed to cast {GetType().Name} to {typeof(T).Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
~InstancedObject()
|
||||
{
|
||||
if (Instance == this)
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user