/// <summary> /// Create a RouteNode. /// </summary> /// <param name="data">Parameters of the RouteNode to construct.</param> /// <param name="getEventInstance">Function to get an existing RouteEvent instance.</param> /// <param name="registerEventInstance">Function to register a RouteEvent instance.</param> /// <param name="createEvent">Function to create a RouteEvent.</param> /// <returns>Function to create a RouteNode.</returns> private static FoxLib.Tpp.RouteSet.RouteNode Create(RouteNode data, TryGetEventInstanceDelegate getEventInstance, RegisterEventInstanceDelegate registerEventInstance, CreateEventDelegate createEvent) { FoxLib.Tpp.RouteSet.RouteEvent edgeEvent; if (!getEventInstance(data.EdgeEvent, out edgeEvent)) { edgeEvent = createEvent(data.EdgeEvent); registerEventInstance(data.EdgeEvent, edgeEvent); } List <FoxLib.Tpp.RouteSet.RouteEvent> eventInstances = new List <FoxLib.Tpp.RouteSet.RouteEvent>(); foreach (var @event in data.Events) { FoxLib.Tpp.RouteSet.RouteEvent eventInstance; if (!getEventInstance(@event, out eventInstance)) { var newInstance = createEvent(@event); registerEventInstance(@event, newInstance); eventInstances.Add(newInstance); continue; } eventInstances.Add(eventInstance); } return(new FoxLib.Tpp.RouteSet.RouteNode( FoxUtils.UnityToFox(data.transform.position), edgeEvent, eventInstances.ToArray() )); }
private static object ConvertValueToFox(Core.PropertyInfoType type, Func <Entity, ulong> getEntityAddress, Func <EntityLink, Core.EntityLink> convertEntityLink, object value) { switch (type) { case Core.PropertyInfoType.Int8: return(value); case Core.PropertyInfoType.UInt8: return(value); case Core.PropertyInfoType.Int16: return(value); case Core.PropertyInfoType.UInt16: return(value); case Core.PropertyInfoType.Int32: return(value); case Core.PropertyInfoType.UInt32: return(value); case Core.PropertyInfoType.Int64: return(value); case Core.PropertyInfoType.UInt64: return(value); case Core.PropertyInfoType.Float: return(value); case Core.PropertyInfoType.Double: return(value); case Core.PropertyInfoType.Bool: return(value); case Core.PropertyInfoType.String: return(value); case Core.PropertyInfoType.Path: return(FoxUtils.UnityPathToFoxPath(AssetDatabase.GetAssetPath(value as UnityEngine.Object))); case Core.PropertyInfoType.EntityPtr: return(getEntityAddress(value as Entity)); case Core.PropertyInfoType.Vector3: return(FoxUtils.UnityToFox((UnityEngine.Vector3)value)); case Core.PropertyInfoType.Vector4: return(FoxUtils.UnityToFox((UnityEngine.Vector4)value)); case Core.PropertyInfoType.Quat: return(FoxUtils.UnityToFox((UnityEngine.Quaternion)value)); case Core.PropertyInfoType.Matrix3: return(FoxUtils.UnityToFox((Matrix3x3)value)); case Core.PropertyInfoType.Matrix4: return(FoxUtils.UnityToFox((Matrix4x4)value)); case Core.PropertyInfoType.Color: return(FoxUtils.UnityColorToFoxColorRGBA((Color)value)); case Core.PropertyInfoType.FilePtr: return(FoxUtils.UnityPathToFoxPath(AssetDatabase.GetAssetPath(value as UnityEngine.Object))); case Core.PropertyInfoType.EntityHandle: return(getEntityAddress(value as Entity)); case Core.PropertyInfoType.EntityLink: return(convertEntityLink(value as EntityLink)); case Core.PropertyInfoType.PropertyInfo: Assert.IsTrue(false, "Attempting to convert value of type PropertyInfo. This should never happen."); break; case Core.PropertyInfoType.WideVector3: Assert.IsTrue(false, "Attempting to convert value of type WideVector3. This should never happen."); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(null); }