コード例 #1
0
        public void Destroy()
        {
            foreach (var frbEmitter in _frbEmitters)
            {
                _emitterRenderGroup.RemoveEmitter(frbEmitter.Emitter);
                frbEmitter.Emitter.Dispose();
            }

            _frbEmitters.Clear();
            _frbEmittersWaitingToBeKilled.Clear();
        }
コード例 #2
0
        private void UpdateEmitter(EmitterSettings settings)
        {
            Vector2?previousCameraOffset = null;

            if (_emitter != null)
            {
                previousCameraOffset = _camera.Origin - _emitter.WorldCoordinates;

                _emitterRenderGroup.RemoveEmitter(_emitter);
                _emitter.Dispose();
                _emitter = null;
            }

            if (settings != null)
            {
                var code = EmitterLogicClassGenerator.Generate(settings, "Parme.Editor", "Test", true);

                var scriptOptions = ScriptOptions.Default
                                    .WithReferences(typeof(IEmitterLogic).Assembly);

                var logicClass = CSharpScript.EvaluateAsync <IEmitterLogic>(code, scriptOptions).GetAwaiter().GetResult();

                _emitter = new MonoGameEmitter(logicClass, _particlePool, GraphicsDevice, _textureFileLoader, _random);
                _emitterRenderGroup.AddEmitter(_emitter);
                _emitter.IsEmittingNewParticles = true;

                // Don't reset the camera if we don't have a moving emitter.  Without a moving emitter then this will
                // just frustrate the user, as they've positioned the camera in that spot for a reason
                if (_uiController.EmitterVelocity != Vector2.Zero)
                {
                    ResetCamera(resetOriginTo: previousCameraOffset);
                }
            }

            ResetRenderTarget();
            ResetCameraBounds();
            if (_applicationState.AutoSaveOnChange)
            {
                _appOperationQueue.Enqueue(new SaveEmitterRequested(_applicationState.ActiveFileName, settings));
            }
        }