Updated data with sub-researches to have a more advanced Tech-tree and purpose to research.
This commit is contained in:
@@ -4,6 +4,8 @@ using Godot.Collections;
|
||||
public partial class ResearchList : PanelContainer
|
||||
{
|
||||
[Export] private GraphEdit researchGraph;
|
||||
private System.Collections.Generic.Dictionary<string, Vector2> nodePositions = new System.Collections.Generic.Dictionary<string, Vector2>();
|
||||
private bool hasArrangedNodes = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -13,10 +15,27 @@ public partial class ResearchList : PanelContainer
|
||||
|
||||
public void SetupGraph()
|
||||
{
|
||||
RememberNodePositions();
|
||||
ClearGraph();
|
||||
CreateResearchNodes();
|
||||
CreateResearchConnections();
|
||||
researchGraph.ArrangeNodes();
|
||||
|
||||
if (!hasArrangedNodes)
|
||||
{
|
||||
researchGraph.ArrangeNodes();
|
||||
hasArrangedNodes = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void RememberNodePositions()
|
||||
{
|
||||
foreach (Node child in researchGraph.GetChildren())
|
||||
{
|
||||
GraphNode node = child as GraphNode;
|
||||
if (node == null) continue;
|
||||
|
||||
nodePositions[node.Name] = node.PositionOffset;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearGraph()
|
||||
@@ -99,10 +118,15 @@ public partial class ResearchList : PanelContainer
|
||||
GraphNode node = new GraphNode
|
||||
{
|
||||
Name = id,
|
||||
Title = id,
|
||||
Title = Research.GetReadableName(id),
|
||||
SelfModulate = stateColor
|
||||
};
|
||||
|
||||
if (nodePositions.ContainsKey(id))
|
||||
{
|
||||
node.PositionOffset = nodePositions[id];
|
||||
}
|
||||
|
||||
node.SetSlot(
|
||||
0,
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user