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

@ -0,0 +1,113 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using QuickGraph;
namespace GraphSharp.Contracts
{
/// <summary>
/// Contract class for the ICompoundGraph interface.
/// </summary>
/// <typeparam name="TVertex">
/// Type of the vertex.
/// </typeparam>
/// <typeparam name="TEdge">
/// Type of the edge.
/// </typeparam>
[ContractClassFor( typeof( ICompoundGraph<,> ) )]
internal sealed class ICompoundGraphContract<TVertex, TEdge>
: BidirectionalGraph<TVertex, TEdge>, ICompoundGraph<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
#region ICompoundGraph<TVertex,TEdge> Members
[Pure]
bool ICompoundGraph<TVertex, TEdge>.AddChildVertex( TVertex parent, TVertex child )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( !parent.Equals( default( TVertex ) ) );
Contract.Requires( ithis.ContainsVertex( parent ) );
return default( bool );
}
[Pure]
int ICompoundGraph<TVertex, TEdge>.AddChildVertexRange( TVertex parent, IEnumerable<TVertex> children )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( !parent.Equals( default( TVertex ) ) );
Contract.Requires( ithis.ContainsVertex( parent ) );
Contract.Ensures( Contract.Result<int>() >= 0 );
return default( int );
}
[Pure]
TVertex ICompoundGraph<TVertex, TEdge>.GetParent( TVertex vertex )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( !vertex.Equals( default( TVertex ) ) );
Contract.Requires( ithis.ContainsVertex( vertex ) );
//TODO this is a bug in the MS Contract, i think -- solve it
//Contract.Ensures( Contract.Result<TVertex>().Equals( default( TVertex ) ) || ithis.ContainsVertex( Contract.Result<TVertex>() ) );
return default( TVertex );
}
[Pure]
bool ICompoundGraph<TVertex, TEdge>.IsChildVertex( TVertex vertex )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( !vertex.Equals( default( TVertex ) ) );
Contract.Requires( ithis.ContainsVertex( vertex ) );
return default( bool );
}
[Pure]
IEnumerable<TVertex> ICompoundGraph<TVertex, TEdge>.GetChildrenVertices( TVertex vertex )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( !vertex.Equals( default( TVertex ) ) );
Contract.Requires( ithis.ContainsVertex( vertex ) );
return new List<TVertex>();
}
[Pure]
int ICompoundGraph<TVertex, TEdge>.GetChildrenCount( TVertex vertex )
{
ICompoundGraph<TVertex, TEdge> ithis = this;
Contract.Requires( ithis.ContainsVertex( vertex ) );
Contract.Ensures( Contract.Result<int>() >= 0 );
return default( int );
}
[Pure]
bool ICompoundGraph<TVertex, TEdge>.IsCompoundVertex( TVertex vertex )
{
Contract.Requires( vertex != null );
Contract.Requires( ContainsVertex( vertex ) );
return default( bool );
}
IEnumerable<TVertex> ICompoundGraph<TVertex, TEdge>.CompoundVertices
{
get
{
return null;
}
}
IEnumerable<TVertex> ICompoundGraph<TVertex, TEdge>.SimpleVertices
{
get
{
return null;
}
}
#endregion
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 570e5ae4b7a8ab441ab17a992af8f7ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
using System.Diagnostics.Contracts;
using System.Linq;
using QuickGraph;
using GraphSharp.Algorithms.Layout;
using GraphSharp.Algorithms.Layout.Contextual;
namespace GraphSharp.Contracts
{
[ContractClassFor( typeof( IContextualLayoutAlgorithmFactory<,,> ) )]
public class IContextualLayoutAlgorithmFactoryContract<TVertex, TEdge, TGraph> : ILayoutAlgorithmFactoryContract<TVertex, TEdge, TGraph>, IContextualLayoutAlgorithmFactory<TVertex, TEdge, TGraph>
where TVertex : class
where TEdge : IEdge<TVertex>
where TGraph : class, IBidirectionalGraph<TVertex, TEdge>
{
#region ILayoutAlgorithmFactory<TVertex,TEdge,TGraph> Members
ILayoutAlgorithm<TVertex, TEdge, TGraph> ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.CreateAlgorithm( string newAlgorithmType, ILayoutContext<TVertex, TEdge, TGraph> context, ILayoutParameters parameters )
{
Contract.Requires( newAlgorithmType != null );
Contract.Requires( context as ContextualLayoutContext<TVertex, TEdge, TGraph> != null );
var laf = (ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>)this;
Contract.Requires( laf.AlgorithmTypes.Contains( newAlgorithmType ) );
return default( ILayoutAlgorithm<TVertex, TEdge, TGraph> );
}
#endregion
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 495f549cb261f5a488962696d937028b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,76 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using GraphSharp.Algorithms.Layout;
using QuickGraph;
using System.Linq;
namespace GraphSharp.Contracts
{
[ContractClassFor( typeof( ILayoutAlgorithmFactory<,,> ) )]
public class ILayoutAlgorithmFactoryContract<TVertex, TEdge, TGraph> : ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>
where TVertex : class
where TEdge : IEdge<TVertex>
where TGraph : class, IBidirectionalGraph<TVertex, TEdge>
{
#region ILayoutAlgorithmFactory<TVertex,TEdge,TGraph> Members
IEnumerable<string> ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.AlgorithmTypes
{
get
{
Contract.Ensures( Contract.Result<IEnumerable<string>>() != null );
return default( IEnumerable<string> );
}
}
ILayoutAlgorithm<TVertex, TEdge, TGraph> ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.CreateAlgorithm( string newAlgorithmType, ILayoutContext<TVertex, TEdge, TGraph> context, ILayoutParameters parameters )
{
Contract.Requires( newAlgorithmType != null );
var laf = (ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>)this;
Contract.Requires( laf.AlgorithmTypes.Contains( newAlgorithmType ) );
Contract.Requires( context.Sizes != null );
return default( ILayoutAlgorithm<TVertex, TEdge, TGraph> );
}
ILayoutParameters ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.CreateParameters( string algorithmType, ILayoutParameters oldParameters )
{
Contract.Requires( algorithmType != null );
var laf = (ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>)this;
Contract.Requires( laf.AlgorithmTypes.Contains( algorithmType ) );
return default( ILayoutParameters );
}
bool ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.IsValidAlgorithm( string algorithmType )
{
Contract.Requires( algorithmType != null );
var laf = (ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>)this;
Contract.Ensures( Contract.Result<bool>() == laf.AlgorithmTypes.Contains( algorithmType ) );
return false;
}
string ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.GetAlgorithmType( ILayoutAlgorithm<TVertex, TEdge, TGraph> algorithm )
{
Contract.Requires( algorithm != null );
var laf = (ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>)this;
Contract.Ensures( Contract.Result<string>() == null || laf.AlgorithmTypes.Contains( Contract.Result<string>() ) );
return default( string );
}
bool ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.NeedEdgeRouting( string algorithmType )
{
return default( bool );
}
bool ILayoutAlgorithmFactory<TVertex, TEdge, TGraph>.NeedOverlapRemoval( string algorithmType )
{
return default( bool );
}
#endregion
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5ab398bf93b66ac4d9136c816ee82f5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using GraphSharp.Algorithms.Layout;
using QuickGraph;
using Unity.Mathematics;
using static Unity.Mathematics.math;
namespace GraphSharp.Contracts
{
[ContractClassFor( typeof( ILayoutContext<,,> ) )]
public class ILayoutContextContract<TVertex, TEdge, TGraph> : ILayoutContext<TVertex, TEdge, TGraph>
where TEdge : IEdge<TVertex>
where TGraph : class, IBidirectionalGraph<TVertex, TEdge>
{
[ContractInvariantMethod]
protected void Invariants()
{
var lc = (ILayoutContext<TVertex, TEdge, TGraph>)this;
Contract.Invariant( lc.Positions != null );
Contract.Invariant( lc.Graph != null );
Contract.Invariant( lc.Sizes != null );
}
#region ILayoutContext<TVertex,TEdge,TGraph> Members
IDictionary<TVertex, float2> ILayoutContext<TVertex, TEdge, TGraph>.Positions
{
get { return default( IDictionary<TVertex, float2> ); }
}
IDictionary<TVertex, float2> ILayoutContext<TVertex, TEdge, TGraph>.Sizes
{
get { return default( IDictionary<TVertex, float2> ); }
}
TGraph ILayoutContext<TVertex, TEdge, TGraph>.Graph
{
get { return default( TGraph ); }
}
LayoutMode ILayoutContext<TVertex, TEdge, TGraph>.Mode
{
get { return default( LayoutMode ); }
}
#endregion
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f3071b790eb3ad4a8dd2839ebfb6007
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: