protected PBSEffectNode()
        {
            _standingController = new PBSStandingController <PBSEffectNode>(this)
            {
                AlwaysEnabled = true
            };
            _coreUseHandler = new CoreUseHandler <PBSEffectNode>(this, new EnergyStateFactory(this));

            _currentEffect = DynamicProperties.GetProperty <int>(k.currentEffect);
            _currentEffect.PropertyChanging += (property, value) =>
            {
                var effectType = (EffectType)value;

                if (effectType == EffectType.undefined)
                {
                    effectType = AvailableEffects.FirstOrDefault();
                }

                if (!AvailableEffects.Contains(effectType))
                {
                    Logger.Error("PBSEffectNode: invalid effect type! type:" + effectType);
                }

                RemoveCurrentEffect();
                return((int)effectType);
            };

            _currentEffect.PropertyChanged += property =>
            {
                OnEffectChanged();
            };
        }
        private void Init()
        {
            EffectType currentEffect;

            if (DynamicProperties.Contains(k.currentEffect))
            {
                currentEffect = (EffectType)DynamicProperties.GetOrAdd <int>(k.currentEffect);
            }
            else
            {
                currentEffect = AvailableEffects.FirstOrDefault();
            }

            CurrentEffectType = currentEffect;
        }
        private void UpdateAvailableTypes()
        {
            DataTable DT = new DataTable();

            DT.Columns.Add("Effect type", typeof(string));
            DT.Columns.Add("Source", typeof(string));
            Assembly A = System.Reflection.Assembly.GetExecutingAssembly();

            foreach (Type T in AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(IEffect).IsAssignableFrom(p) && !p.IsAbstract))
            {
                DT.Rows.Add(T.Name, (A == T.Assembly?"Built in":"Scripted"));
            }

            AvailableEffects.ClearSelection();
            AvailableEffects.Columns.Clear();
            AvailableEffects.AutoGenerateColumns = true;
            AvailableEffects.DataSource          = DT;
            AvailableEffects.Refresh();
            AvailableEffects.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

            UpdateTypeXml();
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes The Effect
 /// </summary>
 /// <param name="serviceProvider">The Service Provider for the Content</param>
 /// <param name="device">GraphicsDevice</param>
 /// <param name="options">For The Screenresolution</param>
 public void Initialize(IServiceProvider serviceProvider, GraphicsDevice device, Options options)
 {
     PresentationParameters pp = device.PresentationParameters;
     resolvedTex = new RenderTarget2D(
         device,
         pp.BackBufferWidth,
         pp.BackBufferHeight,
         false,
         SurfaceFormat.Color,
         DepthFormat.None,
         pp.MultiSampleCount,
         RenderTargetUsage.PreserveContents);
     content = new ContentManager(serviceProvider, "Data");
     position = new Vector2();
     type = InitializeEffect(device, options);
     if (type != AvailableEffects.None)
         effect = content.Load<Effect>(GameConstants.EffectsPath + type.ToString());
     SetEffectParameters();
     initialized = true;
     GraphicEffect.device = device;
 }