-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20e21ff
commit 5ca4749
Showing
35 changed files
with
1,752 additions
and
1,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using UnityEngine; | ||
|
||
public struct CellData { | ||
public HexCoordinates Coordinates { get; set; } | ||
public int Index { get; set; } | ||
public int ColumnIndex { get; set; } | ||
public CellShaderData CellShaderData { get; set; } | ||
public bool IsExplorable { get; set; } | ||
public Vector3 WorldPosition { get; set; } | ||
public HexGridChunk HexGridChunk { get; set; } | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...untime/ScriptableObjects/CellData.cs.meta → ...unitycsharp/Runtime/Core/CellData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
Assets/rootgen-unitycsharp/Runtime/Core/DenseArray.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
198 changes: 198 additions & 0 deletions
198
Assets/rootgen-unitycsharp/Runtime/Core/HexAdjacencyGraph.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
using QuikGraph; | ||
using System.Collections.Generic; | ||
|
||
public class HexAdjacencyGraph : AdjacencyGraph<HexCell, HexEdge> { | ||
|
||
/// <summary> | ||
/// Returns true if the given cell in the graph has a river. | ||
/// </summary> | ||
/// <param name="cell"> | ||
/// The cell which is the subject of the query. | ||
/// </param> | ||
/// <returns> | ||
/// A boolean value representing whether the query cell has a river. | ||
/// </returns> | ||
public bool CellHasRiver(HexCell cell) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (TryGetOutEdges(cell, out edges)) { | ||
foreach(HexEdge edge in edges) { | ||
if (edge.HasRiver) | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if the given cell in the graph has a road. | ||
/// </summary> | ||
/// <param name="cell"> | ||
/// The cell which is the subject of the query. | ||
/// </param> | ||
/// <returns> | ||
/// A boolean value representing whether the query cell has a road. | ||
/// </returns> | ||
public bool CellHasRoad(HexCell cell) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (TryGetOutEdges(cell, out edges)) { | ||
foreach(HexEdge edge in edges) { | ||
if (edge.HasRoad) | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if the given cell in the graph contains | ||
/// the termination of a river. | ||
/// </summary> | ||
/// <param name="cell"> | ||
/// The cell which is the subject of the query. | ||
/// </param> | ||
/// <returns> | ||
/// A boolean value representing whether the query cell | ||
/// contains the termination of a river. | ||
/// </returns> | ||
public bool CellHasRiverTerminus( | ||
HexCell cell | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (TryGetOutEdges(cell, out edges)) { | ||
int count = 0; | ||
foreach(HexEdge edge in edges) { | ||
if (edge.HasRiver) | ||
count++; | ||
|
||
if (count > 2) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public bool CellHasIncomingRiver( | ||
HexCell cell | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (TryGetOutEdges(cell, out edges)) { | ||
foreach(HexEdge edge in edges) { | ||
if (edge.HasRoad) | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public IEnumerable<HexEdge> TryGetOutEdgesInDirection( | ||
HexCell cell, | ||
HexDirection direction | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
List<HexEdge> result = new List<HexEdge>(); | ||
|
||
if (!TryGetOutEdges(cell, out edges)) { | ||
|
||
foreach(HexEdge edge in edges) { | ||
if (edge.Direction == direction) | ||
result.Add(edge); | ||
} | ||
} | ||
else { | ||
throw new System.ArgumentException( | ||
"HexCell did not exist in graph or had no out edges." | ||
); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public HexEdge GetHexDirectionOppositeEdge( | ||
HexEdge edge | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (!TryGetOutEdges(edge.Source, out edges)) { | ||
foreach(HexEdge currentEdge in edges) { | ||
if (currentEdge.Direction == edge.Direction.Opposite()) { | ||
return currentEdge; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public HexEdge GetHexDirectionNextEdge( | ||
HexEdge edge | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (!TryGetOutEdges(edge.Source, out edges)) { | ||
foreach(HexEdge currentEdge in edges) { | ||
if (currentEdge.Direction == edge.Direction.Next()) { | ||
return currentEdge; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public HexEdge GetHexDirectionPreviousEdge( | ||
HexEdge edge | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (!TryGetOutEdges(edge.Source, out edges)) { | ||
foreach(HexEdge currentEdge in edges) { | ||
if (currentEdge.Direction == edge.Direction.Previous()) { | ||
return currentEdge; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public HexEdge GetHexDirectionNext2Edge( | ||
HexEdge edge | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (!TryGetOutEdges(edge.Source, out edges)) { | ||
foreach(HexEdge currentEdge in edges) { | ||
if (currentEdge.Direction == edge.Direction.Next2()) { | ||
return currentEdge; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public HexEdge GetHexDirectionPrevious2Edge( | ||
HexEdge edge | ||
) { | ||
IEnumerable<HexEdge> edges; | ||
|
||
if (!TryGetOutEdges(edge.Source, out edges)) { | ||
foreach(HexEdge currentEdge in edges) { | ||
if (currentEdge.Direction == edge.Direction.Previous2()) { | ||
return currentEdge; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/rootgen-unitycsharp/Runtime/Core/HexAdjacencyGraph.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.