/// <summary> /// Create a Route. /// </summary> /// <param name="data">Parameters of the Route to construct.</param> /// <param name="routeSet">RouteSet the Route belongs to.</param> /// <param name="createNode">Function to create a RouteNode.</param> /// <param name="getRouteName">Function to get a Route's name.</param> /// <param name="generateNodeName">Function to generate a RouteNode name.</param> /// <returns>The constructed Route.</returns> private static Route Create(FoxLib.Tpp.RouteSet.Route data, RouteSet routeSet, CreateNodeDelegate createNode, TryUnhashDelegate <uint> getRouteName, GenerateNodeNameDelegate generateNodeName) { var gameObject = new GameObject(); var routeComponent = gameObject.AddComponent <Route>(); var routeNameContainer = getRouteName(data.Name); if (routeNameContainer.WasNameUnhashed) { gameObject.name = routeNameContainer.UnhashedString; } else { gameObject.name = routeNameContainer.Hash.ToString(); routeComponent.TreatNameAsHash = true; } routeComponent.Nodes = data.Nodes .Select((node, index) => createNode.Invoke(node, routeSet, routeComponent, generateNodeName(gameObject.name, index))) .ToList(); return(routeComponent); }
/// <summary> /// Create a function to create Routes. /// </summary> /// <param name="createNode">Function to create a RouteNode.</param> /// <param name="getRouteName">Function to get a Route's name.</param> /// <param name="generateNodeName">Function to generate a RouteNode name.</param> /// <returns>Function to construct Routes.</returns> public static CreateRouteDelegate CreateFactory(CreateNodeDelegate createNode, TryUnhashDelegate <uint> getRouteName, GenerateNodeNameDelegate generateNodeName) { return((data, routeSet) => Create(data, routeSet, createNode, getRouteName, generateNodeName)); }