Dev Improvements (#4)
* 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 * Added new Game logic library to assist with game projects * Added Web Project * Added Nuget package configs * Add workflow for publishing game library NuGet package * Add README for OmegaLeo's Helper Library * Updated Website to reflect all libraries * Fixed missing library in Changelog * Added Contributing and Code of Conduct
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
public class ConsoleCommand
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public Action<string[]> Action { get; }
|
||||
public int MinArgs { get; }
|
||||
public int MaxArgs { get; }
|
||||
|
||||
public ConsoleCommand(string name, string description, Action<string[]> action, int minArgs = 0, int maxArgs = -1)
|
||||
{
|
||||
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||
Description = description ?? "No description";
|
||||
Action = action ?? throw new ArgumentNullException(nameof(action));
|
||||
MinArgs = minArgs;
|
||||
MaxArgs = maxArgs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
internal class DelayedAction
|
||||
{
|
||||
public float TimeRemaining { get; set; }
|
||||
public float InitialDelay { get; }
|
||||
public Action Action { get; }
|
||||
public bool IsRepeating { get; }
|
||||
public bool IsCancelled { get; set; }
|
||||
|
||||
public DelayedAction(float delay, Action action, bool isRepeating)
|
||||
{
|
||||
TimeRemaining = delay;
|
||||
InitialDelay = delay;
|
||||
Action = action;
|
||||
IsRepeating = isRepeating;
|
||||
IsCancelled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Loot<T>
|
||||
{
|
||||
public T Item { get; set; }
|
||||
public float Weight { get; set; }
|
||||
|
||||
public Loot(T item, float quantity)
|
||||
{
|
||||
Item = item;
|
||||
Weight = quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
public class LootTable<T>
|
||||
{
|
||||
public List<Loot<T>> Loot = new List<Loot<T>>();
|
||||
|
||||
public void Add(T item, float weight)
|
||||
{
|
||||
Loot.Add(new Loot<T>(item, weight));
|
||||
}
|
||||
|
||||
public T Roll(RandomNumberGenerator rng)
|
||||
{
|
||||
float total = Loot.Sum(e => e.Weight);
|
||||
float roll = rng.Range(0f, total);
|
||||
|
||||
foreach (var e in Loot)
|
||||
{
|
||||
roll -= e.Weight;
|
||||
if (roll <= 0)
|
||||
return e.Item;
|
||||
}
|
||||
|
||||
return Loot.Last().Item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
public class RandomNumberGenerator
|
||||
{
|
||||
private readonly Random _random;
|
||||
|
||||
public int Seed { get; }
|
||||
|
||||
public RandomNumberGenerator(int? seed = null)
|
||||
{
|
||||
Seed = seed ?? Environment.TickCount;
|
||||
_random = new Random(Seed);
|
||||
}
|
||||
|
||||
public float NextFloat() =>
|
||||
(float)_random.NextDouble();
|
||||
|
||||
public float Range(float min, float max) =>
|
||||
min + NextFloat() * (max - min);
|
||||
|
||||
public int Range(int min, int max) =>
|
||||
_random.Next(min, max);
|
||||
|
||||
public bool Chance(float probability) =>
|
||||
NextFloat() <= probability;
|
||||
|
||||
public bool Percent(float percent) =>
|
||||
Chance(percent / 100f);
|
||||
|
||||
public bool OneIn(int x) =>
|
||||
Range(0, x) == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Game.Models
|
||||
{
|
||||
[Serializable]
|
||||
public class SaveData
|
||||
{
|
||||
public Guid Id;
|
||||
|
||||
public SaveData()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user