public void OnLoad(ConfigNode node) { IsLoaded = false; // Depots need to be loaded first! if (node.HasNode(DEPOTS_NODE_NAME)) { var wolfNode = node.GetNode(DEPOTS_NODE_NAME); var depotNodes = wolfNode.GetNodes(); foreach (var depotNode in depotNodes) { var bodyValue = depotNode.GetValue("Body"); var biomeValue = depotNode.GetValue("Biome"); var depot = new Depot(bodyValue, biomeValue); depot.OnLoad(depotNode); Depots.Add(depot); } } if (node.HasNode(CREW_ROUTES_NODE_NAME)) { var wolfNode = node.GetNode(CREW_ROUTES_NODE_NAME); var crewRouteNodes = wolfNode.GetNodes(); foreach (var crewRouteNode in crewRouteNodes) { var route = new CrewRoute(this); route.OnLoad(crewRouteNode); CrewRoutes.Add(route); } } if (node.HasNode(HOPPERS_NODE_NAME)) { var wolfNode = node.GetNode(HOPPERS_NODE_NAME); var hoppersNode = wolfNode.GetNodes(); foreach (var hopperNode in hoppersNode) { var bodyValue = hopperNode.GetValue("Body"); var biomeValue = hopperNode.GetValue("Biome"); var depot = Depots.FirstOrDefault(d => d.Body == bodyValue && d.Biome == biomeValue); if (depot != null) { var hopper = new HopperMetadata(depot); hopper.OnLoad(hopperNode); Hoppers.Add(hopper); } } } if (node.HasNode(ROUTES_NODE_NAME)) { var wolfNode = node.GetNode(ROUTES_NODE_NAME); var routeNodes = wolfNode.GetNodes(); foreach (var routeNode in routeNodes) { var route = new Route(this); route.OnLoad(routeNode); Routes.Add(route); } } if (node.HasNode(TERMINALS_NODE_NAME)) { var wolfNode = node.GetNode(TERMINALS_NODE_NAME); var terminalNodes = wolfNode.GetNodes(); foreach (var terminalNode in terminalNodes) { var terminal = new TerminalMetadata(); terminal.OnLoad(terminalNode); Terminals.Add(terminal); } } IsLoaded = true; }