Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanstudioroot committed May 23, 2020
1 parent 981e3c5 commit d9da6ea
Show file tree
Hide file tree
Showing 37 changed files with 1,994 additions and 1,634 deletions.
54 changes: 54 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"path": "/c:/Users/jnelsis/home/repos/project_root/RootGen-UnityCSharp/Library/EditorInstance.json",
"request": "launch"
},
{
"name": "Windows Player",
"type": "unity",
"request": "launch"
},
{
"name": "OSX Player",
"type": "unity",
"request": "launch"
},
{
"name": "Linux Player",
"type": "unity",
"request": "launch"
},
{
"name": "iOS Player",
"type": "unity",
"request": "launch"
},
{
"name": "Android Player",
"type": "unity",
"request": "launch"
},
{
"name": "Xbox One Player",
"type": "unity",
"request": "launch"
},
{
"name": "PS4 Player",
"type": "unity",
"request": "launch"
},
{
"name": "SwitchPlayer",
"type": "unity",
"request": "launch"
}
]
}
15 changes: 6 additions & 9 deletions Assets/rootgen-unitycsharp/Runtime/Camera/HexGridCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class HexGridCamera : MonoBehaviour
public float rotationSpeed = 180;

// ~~ private
private HexMap _grid;
private Transform _swivel;
private Transform _stick;
private float _zoom = 1f;
Expand Down Expand Up @@ -150,9 +149,7 @@ public Transform Stick {
}

public HexMap TargetGrid {
set {
_grid = value;
}
get; set;
}

public bool SuspendInput {
Expand Down Expand Up @@ -270,7 +267,7 @@ float hexOuterRadius
StopSteadyPan();
_steadyPan =
SteadyPanCoroutine(
_grid,
TargetGrid,
direction,
seconds,speed,
hexOuterRadius
Expand All @@ -286,7 +283,7 @@ float hexOuterRadius
) {
StopSteadyPan();
_steadyPan = SteadyPanCoroutine(
_grid,
TargetGrid,
direction,
-1,
speed,
Expand Down Expand Up @@ -320,8 +317,8 @@ public void SetYRotation(float angle) {
private void Awake() { }

private void Update() {
if (_grid)
ValidatePosition(_grid, _hexOuterRadius);
if (TargetGrid)
ValidatePosition(TargetGrid, _hexOuterRadius);
else
return;

Expand Down Expand Up @@ -349,7 +346,7 @@ private void ProcessInput(float hexOuterRadius) {

if (xDelta != 0f || zDelta != 0f) {
AdjustPosition(
_grid,
TargetGrid,
xDelta,
zDelta,
hexOuterRadius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class FeatureContainer : MonoBehaviour

public Transform[] special;

public HexMesh walls;
public HexMeshFacade walls;
public Transform wallTower;
public Transform bridge;

private Transform _container;

public static FeatureContainer GetFeatureContainer(HexMesh walls) {
public static FeatureContainer GetFeatureContainer(HexMeshFacade walls) {
GameObject resultObj = new GameObject("Feature Container");
FeatureContainer resultMono = resultObj.AddComponent<FeatureContainer>();
resultMono.urbanCollections = new FeatureCollection[3];
Expand Down Expand Up @@ -122,7 +122,7 @@ public void Clear() {
}

public void Apply() {
walls.Apply();
walls.Draw();
}

public void AddFeature(
Expand Down
49 changes: 16 additions & 33 deletions Assets/rootgen-unitycsharp/Runtime/Collections/PriorityQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* with the same priority and put it in this class.
*/
public class PriorityQueue<T> {
private List<T> _list = new List<T>();
private int _highestPriority = int.MaxValue;
private int _clearThreshold;
private Dictionary<int, Queue<T>> _priorityQueue = new Dictionary<int, Queue<T>>();
public int Count { get { return _priorityQueue.Count; } }

public PriorityQueue(int clearThreshold = 10) {
_clearThreshold = 10;
private Dictionary<int, Queue<T>> _priorityQueue =
new Dictionary<int, Queue<T>>();
public int Count {
get {
return _priorityQueue.Count;
}
}

/// <summary>
Expand All @@ -35,8 +35,7 @@ public void Enqueue(T item, int priority) {
_priorityQueue.Add(priority, queue);
}

if (priority > _highestPriority)
{
if (priority < _highestPriority) {
_highestPriority = priority;
}
}
Expand All @@ -48,38 +47,22 @@ public T Dequeue() {
);
}

RefreshHighestPriority();

T result = _priorityQueue[_highestPriority].Dequeue();

if (_priorityQueue[_highestPriority].Count == 0) {
_priorityQueue.Remove(_highestPriority);
foreach(KeyValuePair <int, Queue<T>> pair in _priorityQueue) {
if (pair.Key < _highestPriority) {
_highestPriority = pair.Key;
}
}
}

return result;
}

public void Clear() {
_priorityQueue.Clear();
_highestPriority = int.MaxValue;
}

private void ClearEmptyQueues() {
foreach (int key in _priorityQueue.Keys) {
if (_priorityQueue[key].Count == 0) {
_priorityQueue.Remove(key);
}
}
}

private void RefreshHighestPriority() {
ClearEmptyQueues();

if (Count == 0)
return;

while(
!_priorityQueue.ContainsKey(_highestPriority) ||
_priorityQueue[_highestPriority] == null ||
_priorityQueue[_highestPriority].Peek() == null
) {
--_highestPriority;
}
}
}
12 changes: 0 additions & 12 deletions Assets/rootgen-unitycsharp/Runtime/Core/CellData.cs

This file was deleted.

Loading

0 comments on commit d9da6ea

Please sign in to comment.