Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // irrelevant sections of code excised, marked with //...
- // In Main.hx
- #if air
- if (Worker.current.isPrimordial)
- #end
- {
- //...
- #if air
- var mutex:Mutex = null;
- var worker:Worker = null;
- if (MULTI_THREADED_PARTICLES)
- {
- mutex = new Mutex();
- worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes, true);
- worker.setSharedProperty(INIT_MUTEX, mutex);
- worker.start();
- mutex.lock();
- }
- else
- worker = Worker.current;
- ParticleInterface.init(worker);
- #end
- {
- ParticleSystem.init();
- }
- ParticleInterface.setLayerSplit([0]);
- //...
- #if air
- if (mutex != null)
- mutex.unlock();
- #end
- //...
- }
- #if air
- else
- {
- //...
- ParticleSystem.init();
- }
- #end
- // In EveGame.hx
- private function gameUpdate(time:Float):Void
- {
- //...
- #if air
- ParticleInterface.receiveMessages();
- ++mUpdatePhase;
- #end
- }
- #if air
- private function particleDrawListener(e:ParticleSystemEvent):Void
- { ++mUpdatePhase; }
- private function drawParticles():Void
- {
- if (ParticleInterface.systemReady)
- ParticleInterface.draw();
- else
- ++mUpdatePhase;
- }
- private function checkUpdate(e:TimerEvent):Void
- {
- ParticleInterface.receiveMessages();
- if (mUpdatePhase >= 2)
- completeUpdate();
- }
- #else
- //...
- #end
- private function completeUpdate(?e:Event):Void
- {
- //...
- ParticleInterface.setCamera(GameProperties.camera);
- ParticleInterface.setZoom(mZoom);
- //...
- #if air
- mUpdatePhase = 0;
- ParticleInterface.progress(time);
- ParticleInterface.drawMutex.lock();
- ParticleInterface.draw();
- #else
- //...
- #end
- //...
- surface.copyPixels(ParticleInterface.layers[0], new Rectangle(0, 0, surface.width, surface.height), new Point(), null, null, true);
- surface.copyPixels(mDrawSurface, new Rectangle(0, 0, mDrawSurface.width, mDrawSurface.height), new Point(), null, null, true);
- surface.copyPixels(ParticleInterface.layers[1], new Rectangle(0, 0, surface.width, surface.height), new Point(), null, null, true);
- //...
- #if air
- ParticleInterface.drawMutex.unlock();
- #elseif cpp
- //...
- #end
- //...
- gameUpdate(time);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement