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
+15 -15
View File
@@ -9,7 +9,7 @@
], ],
"research": "basics", "research": "basics",
"texture": "res://Assets/Images/Buildings/Workbench.png", "texture": "res://Assets/Images/Buildings/Workbench.png",
"crafttime": 1.0, "crafttime": 3.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -26,7 +26,7 @@
], ],
"research": "heat_control", "research": "heat_control",
"texture": "res://Assets/Images/Buildings/Furnace.png", "texture": "res://Assets/Images/Buildings/Furnace.png",
"crafttime": 1.0, "crafttime": 10.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -47,7 +47,7 @@
], ],
"research": "basic_machines", "research": "basic_machines",
"texture": "res://Assets/Images/Buildings/Crusher.png", "texture": "res://Assets/Images/Buildings/Crusher.png",
"crafttime": 1.0, "crafttime": 8.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -64,7 +64,7 @@
], ],
"research": "basic_machines", "research": "basic_machines",
"texture": "res://Assets/Images/Buildings/Press.png", "texture": "res://Assets/Images/Buildings/Press.png",
"crafttime": 1.0, "crafttime": 6.5,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -81,7 +81,7 @@
], ],
"research": "basic_machines", "research": "basic_machines",
"texture": "res://Assets/Images/Buildings/Anvil.png", "texture": "res://Assets/Images/Buildings/Anvil.png",
"crafttime": 1.0, "crafttime": 7.5,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -98,7 +98,7 @@
], ],
"research": "textiles", "research": "textiles",
"texture": "res://Assets/Images/Buildings/Loom.png", "texture": "res://Assets/Images/Buildings/Loom.png",
"crafttime": 1.0, "crafttime": 12.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -119,7 +119,7 @@
], ],
"research": "basic_electricity", "research": "basic_electricity",
"texture": "res://Assets/Images/Buildings/SteamGeneratorv1.png", "texture": "res://Assets/Images/Buildings/SteamGeneratorv1.png",
"crafttime": 1.0, "crafttime": 18.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -136,7 +136,7 @@
], ],
"research": "stone_storage", "research": "stone_storage",
"texture": "res://Assets/Images/Buildings/StoneChest.png", "texture": "res://Assets/Images/Buildings/StoneChest.png",
"crafttime": 1.0, "crafttime": 5.5,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -153,7 +153,7 @@
], ],
"research": "metalworking", "research": "metalworking",
"texture": "res://Assets/Images/Buildings/CopperChest.png", "texture": "res://Assets/Images/Buildings/CopperChest.png",
"crafttime": 1.0, "crafttime": 9.5,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -170,7 +170,7 @@
], ],
"research": "bronze_storage", "research": "bronze_storage",
"texture": "res://Assets/Images/Buildings/BronzeChest.png", "texture": "res://Assets/Images/Buildings/BronzeChest.png",
"crafttime": 1.0, "crafttime": 14.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -187,7 +187,7 @@
], ],
"research": "iron_machining", "research": "iron_machining",
"texture": "res://Assets/Images/Buildings/IronChest.png", "texture": "res://Assets/Images/Buildings/IronChest.png",
"crafttime": 1.0, "crafttime": 17.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -208,7 +208,7 @@
], ],
"research": "advanced_power", "research": "advanced_power",
"texture": "res://Assets/Images/Buildings/SteamGeneratorv2.png", "texture": "res://Assets/Images/Buildings/SteamGeneratorv2.png",
"crafttime": 1.0, "crafttime": 28.0,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -225,7 +225,7 @@
], ],
"research": "glass_work", "research": "glass_work",
"texture": "res://Assets/Images/Buildings/WaterPurifier.png", "texture": "res://Assets/Images/Buildings/WaterPurifier.png",
"crafttime": 1.0, "crafttime": 12.5,
"stacksize": 1 "stacksize": 1
}, },
{ {
@@ -246,7 +246,7 @@
], ],
"research": "glass_work", "research": "glass_work",
"texture": "res://Assets/Images/Buildings/Glassblower.png", "texture": "res://Assets/Images/Buildings/Glassblower.png",
"crafttime": 1.0, "crafttime": 13.5,
"stacksize": 1 "stacksize": 1
} }
] ]
+423 -423
View File
File diff suppressed because it is too large Load Diff
+201 -25
View File
@@ -19,7 +19,7 @@
} }
], ],
"research": "basics", "research": "basics",
"crafttime": 1.0, "crafttime": 4.0,
"texture": "res://Assets/Images/Research/StoneageSymbol.png" "texture": "res://Assets/Images/Research/StoneageSymbol.png"
}, },
{ {
@@ -35,7 +35,7 @@
} }
], ],
"research": "stoneage", "research": "stoneage",
"crafttime": 1.0, "crafttime": 5.0,
"texture": "res://Assets/Images/Items/StoneGearSymbol.png" "texture": "res://Assets/Images/Items/StoneGearSymbol.png"
}, },
{ {
@@ -55,7 +55,7 @@
} }
], ],
"research": "stone_tools", "research": "stone_tools",
"crafttime": 1.0, "crafttime": 7.0,
"texture": "res://Assets/Images/Items/StoneGearSymbol.png" "texture": "res://Assets/Images/Items/StoneGearSymbol.png"
}, },
{ {
@@ -71,7 +71,7 @@
} }
], ],
"research": "basic_machines", "research": "basic_machines",
"crafttime": 1.0, "crafttime": 8.0,
"texture": "res://Assets/Images/Items/Heaterv1Symbol.png" "texture": "res://Assets/Images/Items/Heaterv1Symbol.png"
}, },
{ {
@@ -91,7 +91,7 @@
} }
], ],
"research": "heat_control", "research": "heat_control",
"crafttime": 1.0, "crafttime": 9.0,
"texture": "res://Assets/Images/Items/GlassSymbol.png" "texture": "res://Assets/Images/Items/GlassSymbol.png"
}, },
{ {
@@ -107,7 +107,7 @@
} }
], ],
"research": "basic_machines", "research": "basic_machines",
"crafttime": 1.0, "crafttime": 6.0,
"texture": "res://Assets/Images/Items/StonePlateSymbol.png" "texture": "res://Assets/Images/Items/StonePlateSymbol.png"
}, },
{ {
@@ -123,9 +123,35 @@
} }
], ],
"research": "stone_tools", "research": "stone_tools",
"crafttime": 1.0, "crafttime": 8.0,
"texture": "res://Assets/Images/Items/StoneRobotSymbol.png" "texture": "res://Assets/Images/Items/StoneRobotSymbol.png"
}, },
{
"id": "joint_tuning",
"inputs": [
{
"item": "stone_gear",
"amount": 3
},
{
"item": "rope",
"amount": 4
}
],
"research": "stone_robotics",
"crafttime": 10.0,
"texture": "res://Assets/Images/Items/StoneGearSymbol.png",
"effects": [
{
"stat": "robot_speed_bonus",
"value": 0.1
},
{
"stat": "robot_minimum_efficiency_bonus",
"value": 0.05
}
]
},
{ {
"id": "copperage", "id": "copperage",
"inputs": [ "inputs": [
@@ -139,7 +165,7 @@
} }
], ],
"research": "heat_control", "research": "heat_control",
"crafttime": 1.0, "crafttime": 12.0,
"texture": "res://Assets/Images/Research/CopperageSymbol.png" "texture": "res://Assets/Images/Research/CopperageSymbol.png"
}, },
{ {
@@ -155,7 +181,7 @@
} }
], ],
"research": "copperage", "research": "copperage",
"crafttime": 1.0, "crafttime": 13.0,
"texture": "res://Assets/Images/Items/CopperIngotSymbol.png" "texture": "res://Assets/Images/Items/CopperIngotSymbol.png"
}, },
{ {
@@ -171,7 +197,7 @@
} }
], ],
"research": "copper_smelting", "research": "copper_smelting",
"crafttime": 1.0, "crafttime": 14.0,
"texture": "res://Assets/Images/Items/TinIngotSymbol.png" "texture": "res://Assets/Images/Items/TinIngotSymbol.png"
}, },
{ {
@@ -191,7 +217,7 @@
} }
], ],
"research": "tin_working", "research": "tin_working",
"crafttime": 1.0, "crafttime": 16.0,
"texture": "res://Assets/Images/Items/CopperGearSymbol.png" "texture": "res://Assets/Images/Items/CopperGearSymbol.png"
}, },
{ {
@@ -211,7 +237,7 @@
} }
], ],
"research": "metalworking", "research": "metalworking",
"crafttime": 1.0, "crafttime": 15.0,
"texture": "res://Assets/Images/Items/RopeSymbol.png" "texture": "res://Assets/Images/Items/RopeSymbol.png"
}, },
{ {
@@ -235,7 +261,7 @@
} }
], ],
"research": "metalworking", "research": "metalworking",
"crafttime": 1.0, "crafttime": 18.0,
"texture": "res://Assets/Images/Items/Batteryv1Symbol.png" "texture": "res://Assets/Images/Items/Batteryv1Symbol.png"
}, },
{ {
@@ -255,9 +281,69 @@
} }
], ],
"research": "basic_electricity", "research": "basic_electricity",
"crafttime": 1.0, "crafttime": 20.0,
"texture": "res://Assets/Images/Items/CopperRobotSymbol.png" "texture": "res://Assets/Images/Items/CopperRobotSymbol.png"
}, },
{
"id": "efficient_actuators",
"inputs": [
{
"item": "battery_v1",
"amount": 1
},
{
"item": "copper_wire",
"amount": 6
},
{
"item": "copper_gear",
"amount": 2
}
],
"research": "copper_robotics",
"crafttime": 22.0,
"texture": "res://Assets/Images/Items/CopperWireSymbol.png",
"effects": [
{
"stat": "robot_energy_use_reduction",
"value": 0.12
},
{
"stat": "robot_speed_bonus",
"value": 0.08
}
]
},
{
"id": "cooling_channels",
"inputs": [
{
"item": "copper_plate",
"amount": 3
},
{
"item": "water",
"amount": 6
},
{
"item": "heating_element_v1",
"amount": 1
}
],
"research": "efficient_actuators",
"crafttime": 21.0,
"texture": "res://Assets/Images/Resources/WaterSymbol.png",
"effects": [
{
"stat": "robot_heat_gain_reduction",
"value": 0.15
},
{
"stat": "robot_cooling_bonus",
"value": 0.25
}
]
},
{ {
"id": "bronzeage", "id": "bronzeage",
"inputs": [ "inputs": [
@@ -271,7 +357,7 @@
} }
], ],
"research": "basic_electricity", "research": "basic_electricity",
"crafttime": 1.0, "crafttime": 24.0,
"texture": "res://Assets/Images/Research/BronzeageSymbol.png" "texture": "res://Assets/Images/Research/BronzeageSymbol.png"
}, },
{ {
@@ -291,7 +377,7 @@
} }
], ],
"research": "bronzeage", "research": "bronzeage",
"crafttime": 1.0, "crafttime": 26.0,
"texture": "res://Assets/Images/Items/BronzeIngotSymbol.png" "texture": "res://Assets/Images/Items/BronzeIngotSymbol.png"
}, },
{ {
@@ -307,7 +393,7 @@
} }
], ],
"research": "bronze_smelting", "research": "bronze_smelting",
"crafttime": 1.0, "crafttime": 29.0,
"texture": "res://Assets/Images/Items/BronzeGearSymbol.png" "texture": "res://Assets/Images/Items/BronzeGearSymbol.png"
}, },
{ {
@@ -323,7 +409,7 @@
} }
], ],
"research": "bronze_machining", "research": "bronze_machining",
"crafttime": 1.0, "crafttime": 27.0,
"texture": "res://Assets/Images/Items/BronzePlateSymbol.png" "texture": "res://Assets/Images/Items/BronzePlateSymbol.png"
}, },
{ {
@@ -343,9 +429,39 @@
} }
], ],
"research": "bronze_machining", "research": "bronze_machining",
"crafttime": 1.0, "crafttime": 32.0,
"texture": "res://Assets/Images/Items/BronzeRobotSymbol.png" "texture": "res://Assets/Images/Items/BronzeRobotSymbol.png"
}, },
{
"id": "sealed_bearings",
"inputs": [
{
"item": "bronze_gear",
"amount": 3
},
{
"item": "bronze_plate",
"amount": 4
},
{
"item": "glass_bottles",
"amount": 2
}
],
"research": "bronze_robotics",
"crafttime": 35.0,
"texture": "res://Assets/Images/Items/BronzeGearSymbol.png",
"effects": [
{
"stat": "robot_maintenance_loss_reduction",
"value": 0.2
},
{
"stat": "robot_minimum_efficiency_bonus",
"value": 0.08
}
]
},
{ {
"id": "ironage", "id": "ironage",
"inputs": [ "inputs": [
@@ -363,7 +479,7 @@
} }
], ],
"research": "bronze_robotics", "research": "bronze_robotics",
"crafttime": 1.0, "crafttime": 38.0,
"texture": "res://Assets/Images/Research/IronageSymbol.png" "texture": "res://Assets/Images/Research/IronageSymbol.png"
}, },
{ {
@@ -379,7 +495,7 @@
} }
], ],
"research": "ironage", "research": "ironage",
"crafttime": 1.0, "crafttime": 40.0,
"texture": "res://Assets/Images/Items/IronIngotSymbol.png" "texture": "res://Assets/Images/Items/IronIngotSymbol.png"
}, },
{ {
@@ -395,7 +511,7 @@
} }
], ],
"research": "iron_smelting", "research": "iron_smelting",
"crafttime": 1.0, "crafttime": 44.0,
"texture": "res://Assets/Images/Items/IronGearSymbol.png" "texture": "res://Assets/Images/Items/IronGearSymbol.png"
}, },
{ {
@@ -415,7 +531,7 @@
} }
], ],
"research": "iron_machining", "research": "iron_machining",
"crafttime": 1.0, "crafttime": 48.0,
"texture": "res://Assets/Images/Items/Batteryv2Symbol.png" "texture": "res://Assets/Images/Items/Batteryv2Symbol.png"
}, },
{ {
@@ -435,7 +551,67 @@
} }
], ],
"research": "advanced_power", "research": "advanced_power",
"crafttime": 1.0, "crafttime": 54.0,
"texture": "res://Assets/Images/Items/IronRobotSymbol.png" "texture": "res://Assets/Images/Items/IronRobotSymbol.png"
},
{
"id": "regulated_power_cores",
"inputs": [
{
"item": "battery_v2",
"amount": 2
},
{
"item": "dynamo_v2",
"amount": 1
},
{
"item": "iron_rod",
"amount": 4
}
],
"research": "iron_robotics",
"crafttime": 58.0,
"texture": "res://Assets/Images/Items/Batteryv2Symbol.png",
"effects": [
{
"stat": "robot_energy_use_reduction",
"value": 0.18
},
{
"stat": "robot_heat_gain_reduction",
"value": 0.12
}
]
},
{
"id": "precision_drive_train",
"inputs": [
{
"item": "iron_gear",
"amount": 4
},
{
"item": "iron_plate",
"amount": 4
},
{
"item": "battery_v2",
"amount": 1
}
],
"research": "regulated_power_cores",
"crafttime": 62.0,
"texture": "res://Assets/Images/Items/IronGearSymbol.png",
"effects": [
{
"stat": "robot_speed_bonus",
"value": 0.18
},
{
"stat": "robot_maintenance_loss_reduction",
"value": 0.12
}
]
} }
] ]
+2 -1
View File
@@ -15,12 +15,13 @@ public partial class GameData
public static bool canMove = true; public static bool canMove = true;
public static int maxRobotCount = 1000; public static int maxRobotCount = 1000;
public static List<Robot> robots = new List<Robot>(); public static List<Robot> robots = new List<Robot>();
public static float robotSpeed = 20f; public static float robotSpeed = 10f;
public static float tileWidth = 6; public static float tileWidth = 6;
public static float tileHeight = 4; public static float tileHeight = 4;
public static SortedDictionary<string, ItemData> availableItems = ResourceLoader.LoadItems(); public static SortedDictionary<string, ItemData> availableItems = ResourceLoader.LoadItems();
public static Dictionary<string, Research> availableResearch = ResourceLoader.LoadResearch(); public static Dictionary<string, Research> availableResearch = ResourceLoader.LoadResearch();
public static SurvivalState survival = new SurvivalState(); public static SurvivalState survival = new SurvivalState();
public static RobotStats robotStats = new RobotStats();
public static Color primaryColor = new Color("#276ac2"); public static Color primaryColor = new Color("#276ac2");
public static Color lightColor = new Color("#7efff5"); public static Color lightColor = new Color("#7efff5");
+9 -2
View File
@@ -25,13 +25,20 @@ public class Research
elapsedResearchTime += delta; elapsedResearchTime += delta;
if (elapsedResearchTime >= data.CraftTime) if (elapsedResearchTime >= data.CraftTime)
{ {
state = ResearchState.RESEARCHED; Complete();
return ResearchResult.FINISHED; return ResearchResult.FINISHED;
} }
return ResearchResult.RESEARCHING; return ResearchResult.RESEARCHING;
} }
public void Complete()
{
if (state == ResearchState.RESEARCHED) return;
state = ResearchState.RESEARCHED;
GameData.robotStats.Apply(data.Effects);
}
public static string GetReadableName(string input) public static string GetReadableName(string input)
{ {
string noUnderscore = input.Replace("_", " ").ToLower(); string noUnderscore = input.Replace("_", " ").ToLower();
@@ -18,6 +18,9 @@ public class ResearchData
[JsonPropertyName("texture")] [JsonPropertyName("texture")]
public string Texture { get; set; } public string Texture { get; set; }
[JsonPropertyName("effects")]
public List<ResearchEffect> Effects { get; set; }
public string GetReadableName() public string GetReadableName()
{ {
string noUnderscore = Id.Replace("_", " ").ToLower(); string noUnderscore = Id.Replace("_", " ").ToLower();
@@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
public class ResearchEffect
{
[JsonPropertyName("stat")]
public string Stat { get; set; }
[JsonPropertyName("value")]
public float Value { get; set; }
public string GetDisplayText()
{
return Stat switch
{
"robot_speed_bonus" => $"Robot speed +{Value * 100f:0}%",
"robot_energy_use_reduction" => $"Robot energy use -{Value * 100f:0}%",
"robot_heat_gain_reduction" => $"Robot heat gain -{Value * 100f:0}%",
"robot_cooling_bonus" => $"Robot cooling +{Value * 100f:0}%",
"robot_maintenance_loss_reduction" => $"Robot maintenance loss -{Value * 100f:0}%",
"robot_minimum_efficiency_bonus" => $"Damaged robot efficiency +{Value * 100f:0}%",
_ => Stat
};
}
}
@@ -0,0 +1 @@
uid://c6k1b1inavgyj
+2 -1
View File
@@ -3,5 +3,6 @@ public enum ResearchState
UNDEFINED, UNDEFINED,
RESEARCHED, RESEARCHED,
AVAILABLE, AVAILABLE,
LOCKED LOCKED,
RESEARCHING
} }
+8 -7
View File
@@ -49,7 +49,7 @@ public partial class Robot : Node3D
} }
else if (currentMessage.Length <= 0) else if (currentMessage.Length <= 0)
{ {
CoolDown(delta, IdleHeatLossPerSecond); CoolDown(delta, GameData.robotStats.GetCoolingRate(IdleHeatLossPerSecond));
currentMessage = "No script executing"; currentMessage = "No script executing";
} }
@@ -68,7 +68,7 @@ public partial class Robot : Node3D
public float GetMovementSpeed() public float GetMovementSpeed()
{ {
return GameData.robotSpeed * GetWorkEfficiency(); return GameData.robotStats.GetMovementSpeed(GameData.robotSpeed) * GetWorkEfficiency();
} }
public float GetWorkEfficiency() public float GetWorkEfficiency()
@@ -76,7 +76,8 @@ public partial class Robot : Node3D
if (isBroken) return 0f; if (isBroken) return 0f;
if (maintenance >= 50f) return 1f; if (maintenance >= 50f) return 1f;
return Math.Clamp(0.35f + maintenance / 100f, 0.35f, 1f); float minimumEfficiency = GameData.robotStats.GetMinimumEfficiency();
return Math.Clamp(minimumEfficiency + maintenance / 100f, minimumEfficiency, 1f);
} }
public void Maintain() public void Maintain()
@@ -102,19 +103,19 @@ public partial class Robot : Node3D
if (isCoolingDown) if (isCoolingDown)
{ {
CoolDown(delta, ActiveHeatLossPerSecond); CoolDown(delta, GameData.robotStats.GetCoolingRate(ActiveHeatLossPerSecond));
currentMessage = $"Cooling down ({heat:0}%)"; currentMessage = $"Cooling down ({heat:0}%)";
return false; return false;
} }
if (!GameData.survival.TryConsumeEnergy(EnergyUsePerSecond * (float)delta)) if (!GameData.survival.TryConsumeEnergy(GameData.robotStats.GetEnergyUse(EnergyUsePerSecond) * (float)delta))
{ {
currentMessage = "Not enough energy"; currentMessage = "Not enough energy";
return false; return false;
} }
heat = Math.Clamp(heat + HeatGainPerSecond * (float)delta, 0f, 100f); heat = Math.Clamp(heat + GameData.robotStats.GetHeatGain(HeatGainPerSecond) * (float)delta, 0f, 100f);
maintenance = Math.Clamp(maintenance - MaintenanceLossPerSecond * (float)delta, 0f, 100f); maintenance = Math.Clamp(maintenance - GameData.robotStats.GetMaintenanceLoss(MaintenanceLossPerSecond) * (float)delta, 0f, 100f);
if (heat >= 100f) if (heat >= 100f)
{ {
+81
View File
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
public class RobotStats
{
private const float BaseMinimumEfficiency = 0.35f;
private float speedBonus = 0f;
private float energyUseReduction = 0f;
private float heatGainReduction = 0f;
private float coolingBonus = 0f;
private float maintenanceLossReduction = 0f;
private float minimumEfficiencyBonus = 0f;
public float GetMovementSpeed(float baseSpeed)
{
return baseSpeed * (1f + speedBonus);
}
public float GetEnergyUse(float baseEnergyUse)
{
return baseEnergyUse * (1f - Math.Clamp(energyUseReduction, 0f, 0.8f));
}
public float GetHeatGain(float baseHeatGain)
{
return baseHeatGain * (1f - Math.Clamp(heatGainReduction, 0f, 0.8f));
}
public float GetCoolingRate(float baseCoolingRate)
{
return baseCoolingRate * (1f + coolingBonus);
}
public float GetMaintenanceLoss(float baseMaintenanceLoss)
{
return baseMaintenanceLoss * (1f - Math.Clamp(maintenanceLossReduction, 0f, 0.8f));
}
public float GetMinimumEfficiency()
{
return Math.Clamp(BaseMinimumEfficiency + minimumEfficiencyBonus, BaseMinimumEfficiency, 0.85f);
}
public void Apply(List<ResearchEffect> effects)
{
if (effects == null) return;
foreach (ResearchEffect effect in effects)
{
Apply(effect);
}
}
private void Apply(ResearchEffect effect)
{
if (effect == null) return;
switch (effect.Stat)
{
case "robot_speed_bonus":
speedBonus += effect.Value;
break;
case "robot_energy_use_reduction":
energyUseReduction += effect.Value;
break;
case "robot_heat_gain_reduction":
heatGainReduction += effect.Value;
break;
case "robot_cooling_bonus":
coolingBonus += effect.Value;
break;
case "robot_maintenance_loss_reduction":
maintenanceLossReduction += effect.Value;
break;
case "robot_minimum_efficiency_bonus":
minimumEfficiencyBonus += effect.Value;
break;
}
}
}
@@ -0,0 +1 @@
uid://djuorq37m01xc
+57 -3
View File
@@ -1,5 +1,7 @@
using Godot; using Godot;
using Godot.Collections; using Godot.Collections;
using System.Collections.Generic;
using System.Text;
public partial class ResearchList : PanelContainer 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 System.Collections.Generic.Dictionary<string, Vector2> nodePositions = new System.Collections.Generic.Dictionary<string, Vector2>();
private bool hasArrangedNodes = false; private bool hasArrangedNodes = false;
private List<Research> currentResearch = new List<Research>();
private List<Research> toDelete = new List<Research>();
public override void _Ready() public override void _Ready()
{ {
RecalculateResearchStates(); RecalculateResearchStates();
if (Visible) SetupGraph(); 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() public void SetupGraph()
{ {
RememberNodePositions(); RememberNodePositions();
@@ -98,6 +121,7 @@ public partial class ResearchList : PanelContainer
{ {
Texture2D texture = GD.Load<Texture2D>(texturePath); Texture2D texture = GD.Load<Texture2D>(texturePath);
Color stateColor = GetColorByState(state); Color stateColor = GetColorByState(state);
string tooltipText = GetResearchTooltip(GameData.availableResearch[id]);
TextureRect icon = new TextureRect TextureRect icon = new TextureRect
{ {
@@ -110,7 +134,8 @@ public partial class ResearchList : PanelContainer
Button button = new Button Button button = new Button
{ {
Text = "Research", Text = "Research",
Disabled = state != ResearchState.AVAILABLE Disabled = state != ResearchState.AVAILABLE,
TooltipText = tooltipText
}; };
button.Pressed += () => OnResearchPressed(id); button.Pressed += () => OnResearchPressed(id);
@@ -119,7 +144,8 @@ public partial class ResearchList : PanelContainer
{ {
Name = id, Name = id,
Title = Research.GetReadableName(id), Title = Research.GetReadableName(id),
SelfModulate = stateColor SelfModulate = stateColor,
TooltipText = tooltipText
}; };
if (nodePositions.ContainsKey(id)) if (nodePositions.ContainsKey(id))
@@ -145,11 +171,33 @@ public partial class ResearchList : PanelContainer
private void OnResearchPressed(string id) private void OnResearchPressed(string id)
{ {
GameData.availableResearch[id].state = ResearchState.RESEARCHED; GameData.availableResearch[id].state = ResearchState.RESEARCHING;
currentResearch.Add(GameData.availableResearch[id]);
RecalculateResearchStates(); RecalculateResearchStates();
SetupGraph(); 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() private void RecalculateResearchStates()
{ {
bool changedState = true; bool changedState = true;
@@ -182,6 +230,11 @@ public partial class ResearchList : PanelContainer
return ResearchState.RESEARCHED; return ResearchState.RESEARCHED;
} }
if (research.state == ResearchState.RESEARCHING)
{
return ResearchState.RESEARCHING;
}
if (GameData.availableResearch[research.data.Research].state == ResearchState.RESEARCHED) if (GameData.availableResearch[research.data.Research].state == ResearchState.RESEARCHED)
{ {
return ResearchState.AVAILABLE; return ResearchState.AVAILABLE;
@@ -197,6 +250,7 @@ public partial class ResearchList : PanelContainer
ResearchState.AVAILABLE => Colors.White, ResearchState.AVAILABLE => Colors.White,
ResearchState.LOCKED => new Color(0.6f, 0.6f, 0.6f, 0.5f), ResearchState.LOCKED => new Color(0.6f, 0.6f, 0.6f, 0.5f),
ResearchState.RESEARCHED => new Color(0.7f, 1f, 0.7f, 1f), ResearchState.RESEARCHED => new Color(0.7f, 1f, 0.7f, 1f),
ResearchState.RESEARCHING => new Color(0.3f, 1f, 0.3f, 1f),
_ => Colors.Red _ => Colors.Red
}; };
} }
+1
View File
@@ -94,6 +94,7 @@ public partial class World : Node3D
private void ResetRunState() private void ResetRunState()
{ {
survival = new SurvivalState(); survival = new SurvivalState();
robotStats = new RobotStats();
inventory = new Inventory(); inventory = new Inventory();
availableResearch = ResourceLoader.LoadResearch(); availableResearch = ResourceLoader.LoadResearch();
robots.Clear(); robots.Clear();