예제 #1
0
        public OverviewPresenter(IAppContext context, IBroadcasterService broadcaster,
                                 OverviewDockPanel overviewDockPanel, MainPlugin plugin)
            : base(overviewDockPanel)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (broadcaster == null)
            {
                throw new ArgumentNullException("broadcaster");
            }
            if (overviewDockPanel == null)
            {
                throw new ArgumentNullException("legendDockPanel");
            }

            _context               = context;
            _broadcaster           = broadcaster;
            _overviewDockPanel     = overviewDockPanel;
            _Plugin                = plugin;
            _Plugin.ProjectOpened += _Plugin_ProjectOpened;


            //View.LegendKeyDown += OnLegendKeyDown;
        }
 public LightShaftsProcessor(MainPlugin mainPlugin, RenderTargetsPlugin mainTargetPlugin, RenderPass lightShaftsPass)
     : base(new PropertyKey[] { LightShaftsComponent.Key, LightComponent.Key })
 {
     this.mainPlugin       = mainPlugin;
     this.mainTargetPlugin = mainTargetPlugin;
     this.lightShaftsPass  = lightShaftsPass;
 }
예제 #3
0
        public MainPluginListener(
            IAppContext context,
            MainPlugin plugin,
            IConfigService configService,
            IBroadcasterService broadcaster)
        {
            Logger.Current.Trace("In MainPluginListener");
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            if (configService == null)
            {
                throw new ArgumentNullException("configService");
            }
            if (broadcaster == null)
            {
                throw new ArgumentNullException("broadcaster");
            }

            _context       = context;
            _plugin        = plugin;
            _configService = configService;
            _broadcaster   = broadcaster;
        }
예제 #4
0
        public MainPluginListener(
            IAppContext context,
            MainPlugin plugin,
            IConfigService configService,
            IBroadcasterService broadcaster)
        {
            Logger.Current.Trace("In MainPluginListener");
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            if (configService == null)
            {
                throw new ArgumentNullException("configService");
            }
            if (broadcaster == null)
            {
                throw new ArgumentNullException("broadcaster");
            }

            _context       = context;
            _plugin        = plugin;
            _configService = configService;
            _broadcaster   = broadcaster;

            plugin.BeforeLayerAdded += BeforeLayerAdded;
            plugin.LayerAdded       += plugin_LayerAdded;
            plugin.GroupDoubleClick += plugin_GroupDoubleClick;
        }
예제 #5
0
 public void OnDamageInflictedServer(DamageReport damageReport)
 {
     if (damageReport.attacker == owner)
     {
         var ownerDebuffs = MainPlugin.ReturnBuffs(damageReport.attackerBody, true, false);
         if (ownerDebuffs.Length > 0)
         {
             foreach (var buff in ownerDebuffs)
             {
                 MainPlugin.AddBuffAndDot(buff, 5f, 1, damageReport.attackerBody);
             }
         }
     }
 }
예제 #6
0
        private IEnumerable <Lazy <IPlugin, IPluginMetadata> > _mefPlugins; // found by MEF
#pragma warning restore 649

        /// <summary>
        /// Initializes a new instance of the <see cref="PluginManager"/> class.
        /// </summary>
        public PluginManager(IApplicationContainer container, MainPlugin mainPlugin)
        {
            Logger.Current.Trace("In PluginManager");
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            if (mainPlugin == null)
            {
                throw new ArgumentNullException("mainPlugin");
            }

            _container  = container;
            _mainPlugin = mainPlugin;
        }
예제 #7
0
        public RepositoryPresenter(
            IAppContext context,
            RepositoryDockPanel view,
            TmsImporter tmsImporter,
            ILayerService layerService,
            IRepository repository,
            MainPlugin plugin)
            : base(view)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (tmsImporter == null)
            {
                throw new ArgumentNullException("tmsImporter");
            }
            if (layerService == null)
            {
                throw new ArgumentNullException("layerService");
            }
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }

            _context      = context;
            _layerService = layerService;
            _repository   = repository;
            _view         = view;
            _tmsImporter  = tmsImporter;

            _view.ItemDoubleClicked += ViewItemDoubleClicked;
            _view.RepositoryKeyDown += OnRepositoryKeyDown;
            view.Tree.UpdateTmsState(_context.Map.Tiles.ProviderId);

            plugin.TmsProviderChanged += OnTmsProviderChanged;
        }
예제 #8
0
 internal void HideTab(MainPlugin mainPlugin)
 {
     throw new NotImplementedException();
 }
예제 #9
0
 internal void ShowTabForEntity(EntitySave currentEntitySave, MainPlugin mainPlugin)
 {
     throw new NotImplementedException();
 }
예제 #10
0
        public void Initialize(IServiceRegistry registry, string effectFilename = null, string[] optionalFeatures = null)
        {
            // Missing features compared to before: ZInverse support, Picking/Wireframe, Heat Shimmering and light shafts bounding boxes.
            // Other stuff to implement: Enable features by RenderPipeline, reloading, access of plugins through a flexible interface, yebis config.
            renderSystem          = registry.GetSafeServiceAs <IRenderSystem>();
            graphicsDeviceService = registry.GetSafeServiceAs <IGraphicsDeviceService>();
            this.effectSystemOld  = registry.GetSafeServiceAs <IEffectSystemOld>();
            entitySystem          = registry.GetSafeServiceAs <IEntitySystem>();

            var rootRenderPass = renderSystem.RootRenderPass;
            var dataContext    = RenderConfigContext = renderSystem.ConfigContext;
            var graphicsDevice = graphicsDeviceService.GraphicsDevice;

            if (effectFilename == null)
            {
                effectFilename = Path.Combine("/shaders/effects.xml");
            }

            var context          = new XenkoXamlSchemaContext(dataContext);
            var xamlObjectWriter = new XamlObjectWriter(context);

            using (var fileStream = VirtualFileSystem.OpenStream(effectFilename, VirtualFileMode.Open, VirtualFileAccess.Read))
                XamlServices.Transform(new XamlXmlReader(fileStream, context), xamlObjectWriter);

            var effectConfig = (RenderConfig)xamlObjectWriter.Result;

            foreach (var renderPass in effectConfig.Content.OfType <RenderPass>())
            {
                dataContext.RenderPasses.Add(renderPass.Name, renderPass);
                rootRenderPass.AddPass(renderPass);
            }

            foreach (var item in effectConfig.Content)
            {
                var plugin = item as RenderPassPlugin;
                if (plugin != null)
                {
                    dataContext.RenderPassPlugins.Add(plugin.Name, plugin);
                }

                var setter = item as Setter;
                if (setter != null)
                {
                    PropertyPath.SetNextValue(setter.Target, setter.Property, setter.Value);
                }
            }

            MainPlugin       = dataContext.RenderPassPlugins.Select(x => x.Value).OfType <MainPlugin>().First();
            MainTargetPlugin = dataContext.RenderPassPlugins.Select(x => x.Value).OfType <RenderTargetsPlugin>().FirstOrDefault(x => x.Name == "MainTargetPlugin");

            var mainBackBuffer = graphicsDevice.BackBuffer;

            MainPlugin.RenderTarget = graphicsDevice.BackBuffer;

            // Depth Stencil target needs to be shader resource only if Yebis or GBuffer is active (need more robust way to decide)
            var depthStencilTexture = Texture.New2D(graphicsDevice, mainBackBuffer.Width, mainBackBuffer.Height, PixelFormat.D32_Float,
                                                    (RenderConfigContext.RenderPassPlugins.Any(x => x.Value is YebisPlugin || x.Value is GBufferPlugin) ? TextureFlags.ShaderResource : 0) | TextureFlags.DepthStencil);

            MainPlugin.DepthStencil = depthStencilTexture.ToDepthStencilBuffer(false);

            if (DepthStencilBuffer.IsReadOnlySupported(graphicsDevice))
            {
                MainPlugin.DepthStencilReadOnly = depthStencilTexture.ToDepthStencilBuffer(true);
            }

            // TODO: Temporary setup (should be done through an Entity and its Manager)
            HeatShimmerPlugin heatShimmerPlugin;

            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("HeatShimmerPlugin", out heatShimmerPlugin))
            {
                throw new NotImplementedException();
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(8200, 3000, 1500) * Matrix.Translation(2700, 0, 300) } } });
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(2000, 2000, 3500) * Matrix.RotationZ(0.5f) * Matrix.Translation(-7000, -4000, 1500) } } });
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(2000, 3000, 3500) * Matrix.Translation(-7800, 900, 1500) } } });
            }

            // Generates intermediate render targets
            var plugins = dataContext.RenderPassPlugins
                          .OrderBy(x => rootRenderPass.Passes.IndexOf(x.Value.RenderPass)).ToArray();

            // Weave render targets from last to first plugin.
            // TODO: Instead of guessing through interface and non-null/null values, it would be better if plugin had flags to inform of its intentions.
            var currentTarget = mainBackBuffer;

            for (int i = plugins.Length - 1; i >= 0; --i)
            {
                var plugin = plugins[i];

                var targetPlugin = plugin.Value as IRenderPassPluginTarget;
                if (targetPlugin != null)
                {
                    if (targetPlugin.RenderTarget == null)
                    {
                        targetPlugin.RenderTarget = currentTarget;
                    }

                    currentTarget = targetPlugin.RenderTarget;
                }

                var sourcePlugin = plugin.Value as IRenderPassPluginSource;
                if (sourcePlugin != null)
                {
                    if (sourcePlugin.RenderSource == null)
                    {
                        sourcePlugin.RenderSource = Texture.New2D(graphicsDevice, mainBackBuffer.Width, mainBackBuffer.Height, PixelFormat.R16G16B16A16_Float, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
                    }

                    currentTarget = sourcePlugin.RenderSource.ToRenderTarget();
                }
            }

            foreach (var plugin in dataContext.RenderPassPlugins)
            {
                renderSystem.RenderPassPlugins.Add(plugin.Value);
            }

            foreach (var effectBuilder in effectConfig.Content.OfType <EffectBuilder>())
            {
                foreach (var plugin in effectBuilder.Plugins)
                {
                    plugin.Services = registry;
                }
                this.effectSystemOld.Effects.Add(effectBuilder);
            }

#if XENKO_YEBIS
            YebisPlugin yebisPlugin;
            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("YebisPlugin", out yebisPlugin))
            {
                yebisPlugin.AntiAlias = true;

                yebisPlugin.ToneMap.Gamma = 2.2f;
                yebisPlugin.ToneMap.Type  = ToneMapType.SensiToMetric;
                yebisPlugin.ToneMap.AutoExposure.Enable                    = true;
                yebisPlugin.ToneMap.AutoExposure.MiddleGray                = 0.25f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationSensitivity     = 0.5f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationScale           = 0.8f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationSpeedLimit      = 4.0f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationSensitivity = 0.9f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationScale       = 0.6f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationSpeedLimit  = 4.0f;
                yebisPlugin.ToneMap.AutoExposure.LightDarkExposureBorder   = 1.0f;

                yebisPlugin.Glare.Enable = true;
                //yebisPlugin.Glare.RemapFactor = 1.0f;
                //yebisPlugin.Glare.Threshold = 0.0f;

                yebisPlugin.Lens.Vignette.Enable = true;

                yebisPlugin.Lens.Distortion.Enable         = false;
                yebisPlugin.Lens.Distortion.Power          = 0.2f;
                yebisPlugin.Lens.Distortion.EdgeSmoothness = 0.2f;

                yebisPlugin.DepthOfField.Enable            = true;
                yebisPlugin.DepthOfField.AutoFocus         = true;
                yebisPlugin.DepthOfField.Aperture          = 2.0f;
                yebisPlugin.DepthOfField.ImageSensorHeight = 40.0f;

                //yebisPlugin.ColorCorrection.ColorTemperature = 4500;

                yebisPlugin.HeatShimmer.Enable = false;
                //YebisPlugin.LightShaft.Enable = true;
                //YebisPlugin.LightShaft.ScreenPosition = new Vector2(0.5f, 0.1f);
            }
#endif

            // Adds the particle system if the ParticlePlugin is used in the config
            ParticlePlugin particlePlugin;
            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("ParticlePlugin", out particlePlugin))
            {
                var particleSystem = new ParticleProcessor(particlePlugin);
                entitySystem.Processors.Add(particleSystem);
            }
        }
예제 #11
0
        private IEnumerable <Lazy <IPlugin, IPluginMetadata> > _mefPlugins;  // found by MEF
#pragma warning restore 649

        /// <summary>
        /// Initializes a new instance of the <see cref="PluginManager"/> class.
        /// </summary>
        public PluginManager(IApplicationContainer container, MainPlugin mainPlugin)
        {
            Logger.Current.Trace("In PluginManager");
            _container  = container ?? throw new ArgumentNullException("container");
            _mainPlugin = mainPlugin ?? throw new ArgumentNullException("mainPlugin");
        }