public DataSetHandler(Dictionary <string, Type> entityTypeTable, ConcurrentDictionary <string, FoxEntity> unimplementedTypeTable, IUnityThreadCommandDispatcher unityThreadCommandDispatcher) { entityTypes = entityTypeTable; this.unimplementedTypeTable = unimplementedTypeTable; commandDispatcher = unityThreadCommandDispatcher; }
private static void LoadBlock(string blockPath, IUnityThreadCommandDispatcher commandDispatcher) { // Create scene to contain the new block. var newScene = CreateSceneForBlock(); SceneManager.SetActiveScene(newScene); var relativePath = FindAssetsDirectory(blockPath); var scenePath = relativePath + "/" + Path.GetFileNameWithoutExtension(blockPath) + ".unity"; Directory.CreateDirectory(Path.GetDirectoryName(scenePath)); var blockController = InitializeScene(newScene, scenePath); // Read DataSet files. var assetPath = Application.dataPath; var formatHandlerProvider = MakeFormatHandlerProvider(assetPath, commandDispatcher); var task = new Task( delegate() { LoadDataSets(formatHandlerProvider, blockPath); }); task.Start(); }
public ModelHandler(string assetPath, IUnityThreadCommandDispatcher unityThreadDispacher) { this.assetPath = assetPath; this.unityThreadDispacher = unityThreadDispacher; }
public static Entity MakeEntity(FoxEntity foxData, Dictionary <string, Type> entityTypes, ConcurrentDictionary <string, FoxEntity> unimplementedTypeTable, IUnityThreadCommandDispatcher unityThreadDispatcher, IEntityReferenceResolver entityReferenceResolver) { // Get Entity type. Type entityType; if (!entityTypes.TryGetValue(foxData.ClassName, out entityType) && !unimplementedTypeTable.ContainsKey(foxData.ClassName)) { Debug.LogWarning("Class '" + foxData.ClassName + "' not found in entityTypes."); unimplementedTypeTable.TryAdd(foxData.ClassName, foxData); return(null); } // Get new Entity instance. // We can't make new GameObjects outside the main thread, so dispatch a request for one to the Unity thread. Entity entityInstance = null; var waitEvent = unityThreadDispatcher.DispatchCommand(new CreateEntity(entityType, newEntity => entityInstance = newEntity)); // Wait for our command to be executed by the Unity thread. waitEvent.WaitOne(); entityReferenceResolver.RegisterReference(foxData.Address, entityInstance); // Load properties. ImportEntityProperties(entityInstance, foxData, entityReferenceResolver); return(entityInstance); }
public LocatorArrayHandler(string assetPath, IUnityThreadCommandDispatcher dispatcher) { this.assetPath = assetPath; hashManager = new HashManager(); // TODO Set up dict this.dispatcher = dispatcher; }
private static FormatHandlerProvider MakeFormatHandlerProvider(string assetPath, IUnityThreadCommandDispatcher dispatcher) { var unimplementedTypeTable = new ConcurrentDictionary <string, FoxEntity>(); var handlers = new HashSet <IFoxAssetHandler> { // TODO ArchiveHandler new DataSetHandler(MakeEntityTypeTable(), unimplementedTypeTable, dispatcher), new LuaScriptHandler(assetPath), new ModelHandler(assetPath, dispatcher), //new LocatorArrayHandler(assetPath, dispatcher) }; return(new FormatHandlerProvider(handlers)); }