Changed craft times for all items,buildings, researches and added research that can change game stats/effects.

This commit is contained in:
2026-05-09 13:27:01 +02:00
parent 9f32152fb8
commit 677d8595db
14 changed files with 828 additions and 477 deletions
+57 -3
View File
@@ -1,5 +1,7 @@
using Godot;
using Godot.Collections;
using System.Collections.Generic;
using System.Text;
public partial class ResearchList : PanelContainer
{
@@ -7,12 +9,33 @@ public partial class ResearchList : PanelContainer
private System.Collections.Generic.Dictionary<string, Vector2> nodePositions = new System.Collections.Generic.Dictionary<string, Vector2>();
private bool hasArrangedNodes = false;
private List<Research> currentResearch = new List<Research>();
private List<Research> toDelete = new List<Research>();
public override void _Ready()
{
RecalculateResearchStates();
if (Visible) SetupGraph();
}
public override void _Process(double delta)
{
if(currentResearch.Count > 0) toDelete = new List<Research>();
foreach (Research research in currentResearch)
{
if (research.Execute(delta) == ResearchResult.FINISHED)
{
toDelete.Add(research);
RecalculateResearchStates();
SetupGraph();
}
}
foreach (Research delete in toDelete)
{
currentResearch.Remove(delete);
}
}
public void SetupGraph()
{
RememberNodePositions();
@@ -98,6 +121,7 @@ public partial class ResearchList : PanelContainer
{
Texture2D texture = GD.Load<Texture2D>(texturePath);
Color stateColor = GetColorByState(state);
string tooltipText = GetResearchTooltip(GameData.availableResearch[id]);
TextureRect icon = new TextureRect
{
@@ -110,7 +134,8 @@ public partial class ResearchList : PanelContainer
Button button = new Button
{
Text = "Research",
Disabled = state != ResearchState.AVAILABLE
Disabled = state != ResearchState.AVAILABLE,
TooltipText = tooltipText
};
button.Pressed += () => OnResearchPressed(id);
@@ -119,7 +144,8 @@ public partial class ResearchList : PanelContainer
{
Name = id,
Title = Research.GetReadableName(id),
SelfModulate = stateColor
SelfModulate = stateColor,
TooltipText = tooltipText
};
if (nodePositions.ContainsKey(id))
@@ -145,11 +171,33 @@ public partial class ResearchList : PanelContainer
private void OnResearchPressed(string id)
{
GameData.availableResearch[id].state = ResearchState.RESEARCHED;
GameData.availableResearch[id].state = ResearchState.RESEARCHING;
currentResearch.Add(GameData.availableResearch[id]);
RecalculateResearchStates();
SetupGraph();
}
private string GetResearchTooltip(Research research)
{
if (research.data.Effects == null || research.data.Effects.Count <= 0)
{
return Research.GetReadableName(research.data.Id);
}
StringBuilder tooltip = new StringBuilder(Research.GetReadableName(research.data.Id));
tooltip.AppendLine();
tooltip.AppendLine();
tooltip.AppendLine("Effects:");
foreach (ResearchEffect effect in research.data.Effects)
{
tooltip.Append("- ");
tooltip.AppendLine(effect.GetDisplayText());
}
return tooltip.ToString();
}
private void RecalculateResearchStates()
{
bool changedState = true;
@@ -182,6 +230,11 @@ public partial class ResearchList : PanelContainer
return ResearchState.RESEARCHED;
}
if (research.state == ResearchState.RESEARCHING)
{
return ResearchState.RESEARCHING;
}
if (GameData.availableResearch[research.data.Research].state == ResearchState.RESEARCHED)
{
return ResearchState.AVAILABLE;
@@ -197,6 +250,7 @@ public partial class ResearchList : PanelContainer
ResearchState.AVAILABLE => Colors.White,
ResearchState.LOCKED => new Color(0.6f, 0.6f, 0.6f, 0.5f),
ResearchState.RESEARCHED => new Color(0.7f, 1f, 0.7f, 1f),
ResearchState.RESEARCHING => new Color(0.3f, 1f, 0.3f, 1f),
_ => Colors.Red
};
}