TECH TREES WHOO

Implemented procedural tech tree generation by porting GraphSharp to Unity.
Also, some database editor convenience changes.
This commit is contained in:
hyperion51 2020-04-11 19:18:02 +01:00
commit d5f2e3734a
573 changed files with 31001 additions and 222 deletions

View file

@ -9,6 +9,7 @@ using MessagePack;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
using Unity.Tiny;
public static class Extensions
{
@ -67,7 +68,7 @@ public static class Extensions
private static Random? _random;
private static Random Random => (Random) (_random ?? (_random = new Random(1337)));
public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
//public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
public static float NextUnbounded(this Random random) => 1 / (1 - random.NextFloat()) - 1;
public static float NextUnbounded(this Random random, float bias, float power) => 1 / (1 - pow(random.NextFloat(), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
@ -284,6 +285,12 @@ public static class ObjectExtensions
{
return (T)Copy((Object)original);
}
public static bool IntersectsWith(this Rect r1, Rect r2)
{
return (r2.x + r2.width >= r1.x && r2.x <= r1.x + r1.width) &&
(r2.y + r2.height >= r1.y && r2.y <= r1.y + r1.height);
}
}
public class ReferenceEqualityComparer : EqualityComparer<Object>