Stat Effects and Tech Tree Improvements

Tech tree layout is now correct thanks to MSAGL
Blueprint stat effects can now target item stats
Durability is now a PerformanceStat
This commit is contained in:
hyperion51 2020-04-16 03:08:18 +01:00
commit d8ff1e2289
23 changed files with 356 additions and 210 deletions

View file

@ -72,6 +72,12 @@ public class TechTreeMsagl : MonoBehaviour
public BlueprintData[] Blueprints { get; set; }
void Start()
{
if(TestMode)
Initialize();
}
public void Initialize()
{
_icons = Resources.LoadAll<Texture2D>(IconsPath);
}
@ -159,18 +165,21 @@ public class TechTreeMsagl : MonoBehaviour
foreach (var sourceBlueprint in Blueprints.Where(sb =>
targetBlueprint.Dependencies.Any(dep => sb.ID == dep)))
{
graph.Edges.Add(new Edge(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]));
var edge = new Edge(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]);
graph.Edges.Add(edge);
var splitName = sourceBlueprint.Name.Split(' ');
if (splitName.Length > 1)
{
var nameStart = string.Join(" ", splitName.Take(splitName.Length - 1));
if(targetBlueprint.Name.StartsWith(nameStart))
settings.AddSameLayerNeighbors(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]);
edge.Weight *= 10;
}
}
}
}
settings.BrandesThreshold = 9999;
var islands = graph.GetClusteredConnectedComponents();
var islandMap =
graph.Nodes.ToDictionary(n => n, n => islands.Find(c => c.Nodes.Any(cn => cn.UserData == n)));