Exemplo n.º 1
0
        public void FlushParticles()
        {
            List <int> ids = new List <int>(MyParticlesLibrary.GetParticleEffectsIDs());

            foreach (var id in ids)
            {
                MyParticlesLibrary.RemoveParticleEffect(id);
            }
        }
Exemplo n.º 2
0
 public void FlushParticles()
 {
     using (List <string> .Enumerator enumerator = new List <string>(MyParticlesLibrary.GetParticleEffectsNames()).GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             MyParticlesLibrary.RemoveParticleEffect(enumerator.Current, true);
         }
     }
 }
Exemplo n.º 3
0
        public void RemoveSmokeEffects(string subtypename)
        {
            var effect = MyParticlesLibrary.GetParticleEffect("Smoke_Missile");

            var generations = effect.GetGenerations();

            for (int i = 0; i < generations.Count; ++i)
            {
                effect.RemoveGeneration(i);
            }
        }
Exemplo n.º 4
0
 public MaterialProperties(MySoundPair soundCue, string particleEffectName, ContactPropertyParticleProperties effectProperties)
 {
     Sound = soundCue;
     ParticleEffectProperties = effectProperties;
     if (particleEffectName != null)
     {
         MyParticlesLibrary.GetParticleEffectsID(
             particleEffectName, out ParticleEffectID);
     }
     else
     {
         ParticleEffectID = -1;
     }
 }
Exemplo n.º 5
0
 protected void CreateEffects(MyWeaponDefinition.WeaponEffectAction action)
 {
     if (dummies != null && dummies.Count > 0 && WeaponProperties.WeaponDefinition.WeaponEffects.Length > 0)
     {
         for (int i = 0; i < WeaponProperties.WeaponDefinition.WeaponEffects.Length; i++)
         {
             if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Action == action)
             {
                 MyModelDummy dummy;
                 if (dummies.TryGetValue(WeaponProperties.WeaponDefinition.WeaponEffects[i].Dummy, out dummy))
                 {
                     MyParticleEffect effect;
                     bool             add = true;
                     int effectId         = -1;
                     MyParticlesLibrary.GetParticleEffectsID(WeaponProperties.WeaponDefinition.WeaponEffects[i].Particle, out effectId);
                     if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Loop)
                     {
                         for (int j = 0; j < m_activeEffects.Count; j++)
                         {
                             if (m_activeEffects[j].Dummy == dummy && m_activeEffects[j].EffectId == effectId)
                             {
                                 add = false;
                                 break;
                             }
                         }
                     }
                     if (add && MyParticlesManager.TryCreateParticleEffect(effectId, out effect))
                     {
                         if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Loop)
                         {
                             m_activeEffects.Add(new WeaponEffect(dummy, effectId, action, effect));
                         }
                         else
                         {
                             effect.WorldMatrix = MatrixD.Multiply(MatrixD.Normalize(dummy.Matrix), WorldMatrix);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 public void LoadParticlesLibrary(string file)
 {
     if (file.Contains(".mwl"))
     {
         MyParticlesLibrary.Deserialize(file);
     }
     else
     {
         MyDataIntegrityChecker.HashInFile(file);
         MyObjectBuilder_Definitions objectBuilder = null;
         MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Definitions>(file, out objectBuilder);
         if ((objectBuilder != null) && (objectBuilder.ParticleEffects != null))
         {
             MyParticlesLibrary.Close();
             foreach (MyObjectBuilder_ParticleEffect effect in objectBuilder.ParticleEffects)
             {
                 MyParticleEffect local1 = MyParticlesManager.EffectsPool.Allocate(false);
                 local1.DeserializeFromObjectBuilder(effect);
                 MyParticlesLibrary.AddParticleEffect(local1);
             }
         }
     }
 }
Exemplo n.º 7
0
 public MyCubeBlockParticleEffect(CubeBlockEffect effectData, MyEntity entity)
 {
     MyParticlesLibrary.GetParticleEffectsID(effectData.Name, out m_particleId);
     if (m_particleId == -1)
     {
         m_canBeDeleted = true;
     }
     else
     {
         m_loop         = effectData.Loop;
         m_delay        = effectData.Delay;
         m_spawnTimeMin = Math.Max(0f, effectData.SpawnTimeMin);
         m_spawnTimeMax = Math.Max(m_spawnTimeMin, effectData.SpawnTimeMax);
         m_timer        = m_delay;
         m_entity       = entity;
         m_originPoint  = GetEffectOrigin(effectData.Origin);
         m_duration     = effectData.Duration;
         if (m_spawnTimeMax > 0f)
         {
             m_timer += MyUtils.GetRandomFloat(m_spawnTimeMin, m_spawnTimeMax);
         }
     }
 }
        void RemoveSmokeEffects()
        {
            try
            {
                var effect = MyParticlesLibrary.GetParticleEffect("Smoke_Missile");
                if (effect == null)
                {
                    return;
                }

                var generations = effect.GetGenerations();
                if (generations == null)
                {
                    return;
                }

                for (int i = 0; i < generations.Count; ++i)
                {
                    effect.RemoveGeneration(i);
                }
            }
            catch (Exception e)
            { Debug.HandleException(e); }
        }
Exemplo n.º 9
0
 public void SaveParticlesLibrary(string file)
 {
     MyParticlesLibrary.Serialize(file);
 }
Exemplo n.º 10
0
 public IEnumerable <MyParticleEffect> GetLibraryEffects()
 {
     return(MyParticlesLibrary.GetParticleEffects());
 }
Exemplo n.º 11
0
 public void RemoveParticleFromLibrary(int ID)
 {
     MyParticlesLibrary.RemoveParticleEffect(ID);
 }
Exemplo n.º 12
0
 public void UpdateParticleLibraryID(int ID)
 {
     MyParticlesLibrary.UpdateParticleEffectID(ID);
 }
Exemplo n.º 13
0
 public void AddParticleToLibrary(MyParticleEffect effect)
 {
     MyParticlesLibrary.AddParticleEffect(effect);
 }
Exemplo n.º 14
0
 public void RemoveParticle(MyParticleEffect effect)
 {
     MyParticlesLibrary.RemoveParticleEffectInstance(effect);
 }
Exemplo n.º 15
0
        public MyParticleEffect CreateParticle(int id)
        {
            MyParticleEffect effect = MyParticlesLibrary.CreateParticleEffect(id);

            return(effect);
        }
Exemplo n.º 16
0
 public void LoadParticlesLibrary(string file)
 {
     // Before Loading Particles Library the definitions need to initialized first!
     MyDefinitionManager.Static.LoadData(new List <Sandbox.Common.ObjectBuilders.MyObjectBuilder_Checkpoint.ModItem>());
     MyParticlesLibrary.Deserialize(file);
 }
Exemplo n.º 17
0
 public IReadOnlyDictionary <string, MyParticleEffect> GetParticleEffectsByName()
 {
     return(MyParticlesLibrary.GetParticleEffectsByName());
 }
Exemplo n.º 18
0
 public void LoadParticlesLibrary(string file)
 {
     MyParticlesLibrary.Deserialize(file);
 }
Exemplo n.º 19
0
        void CreateControls(Vector2 controlsOrigin, Vector2 sliderOffset)
        {
            m_nameLabel = new MyGuiControlLabel(this, controlsOrigin - new Vector2(0, 2 * CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Name,
                                                MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            m_nameTextBox = new MyGuiControlTextbox(this, controlsOrigin - new Vector2(-0.2f, 2 * CONTROLS_DELTA.Y), MyGuiControlPreDefinedSize.MEDIUM,
                                                    DummyPoint.Name ?? String.Empty, 512, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL);
            m_nameTextBox.TextChanged = OnTextChange;

            Controls.Add(m_nameLabel);
            Controls.Add(m_nameTextBox);

            m_typeComboBox = new MyGuiControlCombobox(this, controlsOrigin - new Vector2(-0.25f, CONTROLS_DELTA.Y), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            m_typeComboBox.AddItem(0, new StringBuilder("Box"));
            m_typeComboBox.AddItem(1, new StringBuilder("Sphere"));
            m_typeComboBox.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_typeComboBox_OnSelect);
            Controls.Add(m_typeComboBox);
            MyGuiControlLabel typeLabel = new MyGuiControlLabel(this, controlsOrigin - new Vector2(-0.0f, CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Width, MyGuiConstants.LABEL_TEXT_COLOR,
                                                                MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            typeLabel.UpdateText("Type");
            Controls.Add(typeLabel);

            float checkBoxOffset = 0.507f;

            //Enabled
            Controls.Add(new MyGuiControlLabel(this, controlsOrigin - new Vector2(-checkBoxOffset, 2 * CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Enabled, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_enabled          = new MyGuiControlCheckbox(this, controlsOrigin - new Vector2(-checkBoxOffset, 2 * CONTROLS_DELTA.Y) + new Vector2(0.1f, 0f), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR);
            m_enabled.OnCheck += OnEnabledChange;
            Controls.Add(m_enabled);

            // Active
            AddActivatedCheckbox(controlsOrigin - new Vector2(-checkBoxOffset, CONTROLS_DELTA.Y), DummyPoint.Activated);

            float sliderMax = 50000;

            //Width slider
            m_widthSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f), new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Width), MyGuiSizeEnumFlags.All, sliderOffset.X);
            m_widthSize.OnValueChange += OnWidthChange;
            Controls.Add(m_widthSize);

            //Height slider
            m_heightSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f) + 1 * CONTROLS_DELTA, new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Height), MyGuiSizeEnumFlags.All, sliderOffset.X);
            m_heightSize.OnValueChange += OnHeightChange;
            Controls.Add(m_heightSize);

            //Depth slider
            m_depthSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f) + 2 * CONTROLS_DELTA, new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Depth), MyGuiSizeEnumFlags.All, sliderOffset.X);
            m_depthSize.OnValueChange += OnDepthChange;
            Controls.Add(m_depthSize);

            MyGuiControlLabel idLabel = new MyGuiControlLabel(this, controlsOrigin + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Depth, MyGuiConstants.LABEL_TEXT_COLOR,
                                                              MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            Controls.Add(idLabel);
            idLabel.UpdateText("ID: " + m_entity.EntityId.ToString());

            int controlsDelta = 4;

            // Flags
            m_colorArea          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta++ *CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_colorArea.OnCheck += OnFlagChange;
            m_colorAreaLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ColorArea,
                                                         MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_colorArea);
            Controls.Add(m_colorAreaLabel);

            m_playerStart          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_playerStart.OnCheck += OnPlayerStartFlagChange;
            m_playerStartLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.PlayerStart,
                                                           MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_playerStart);
            Controls.Add(m_playerStartLabel);

            m_mothershipStart          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_mothershipStart.OnCheck += OnMothershipStartFlagChange;
            m_mothershipStartLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.MothershipStart,
                                                               MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_mothershipStart);
            Controls.Add(m_mothershipStartLabel);

            m_detector          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_detector.OnCheck += OnFlagChange;
            m_detectorLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.Detector,
                                                        MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_detector);
            Controls.Add(m_detectorLabel);

            m_sideMission          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_sideMission.OnCheck += OnFlagChange;
            m_sideMissionLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SideMission,
                                                           MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_sideMission);
            Controls.Add(m_sideMissionLabel);

            m_particleEffect          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_particleEffect.OnCheck += OnFlagChange;
            m_particleEffectLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.ParticleEffect,
                                                              MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_particleEffectLabel);
            Controls.Add(m_particleEffect);

            m_respawnPoint          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_respawnPoint.OnCheck += OnFlagChange;
            m_respawnPointLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.RespawnPoint,
                                                            MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_respawnPointLabel);
            Controls.Add(m_respawnPoint);

            m_safeArea          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_safeArea.OnCheck += OnFlagChange;
            m_safeAreaLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SafeArea,
                                                        MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_safeArea);
            Controls.Add(m_safeAreaLabel);

            m_survivePrefabDestruction          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_survivePrefabDestruction.OnCheck += OnFlagChange;
            m_survivePrefabDestructionLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SurvivePrefabDestruction,
                                                                        MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_survivePrefabDestructionLabel);
            Controls.Add(m_survivePrefabDestruction);

            m_textureQuad          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_textureQuad.OnCheck += OnFlagChange;
            m_textureQuadLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.TextureQuad,
                                                           MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_textureQuad);
            Controls.Add(m_textureQuadLabel);

            m_note          = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR);
            m_note.OnCheck += OnFlagChange;
            m_noteLabel     = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.Note,
                                                    MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            Controls.Add(m_note);
            Controls.Add(m_noteLabel);

            Vector2 columnOffset      = new Vector2(0.15f, 0);
            Vector2 labelColumnOffset = new Vector2(0.18f, 0);

            // Red slider
            m_redSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Red, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_redSlider      = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 4 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH,
                                                      MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                      new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
            m_redSlider.OnChange = OnComponentChange;
            Controls.Add(m_redSliderLabel);
            Controls.Add(m_redSlider);

            // Green slider
            m_greenSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Green, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_greenSlider      = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 5 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH,
                                                        MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                        new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
            m_greenSlider.OnChange = OnComponentChange;
            Controls.Add(m_greenSliderLabel);
            Controls.Add(m_greenSlider);

            // Blue slider
            m_blueSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Blue, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_blueSlider      = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 6 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH,
                                                       MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                       new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
            m_blueSlider.OnChange = OnComponentChange;
            Controls.Add(m_blueSliderLabel);
            Controls.Add(m_blueSlider);

            // Alpha slider
            m_alphaSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 7 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Alpha, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_alphaSlider      = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 7 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH,
                                                        MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                        new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
            m_alphaSlider.OnChange  = OnComponentChange;
            m_alphaSliderValueLabel = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 7 * CONTROLS_DELTA + new Vector2(0.4f, 0), null, new StringBuilder("0"), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            // scale slider
            m_userScaleSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 8 * CONTROLS_DELTA, null, MyTextsWrapperEnum.UserScale, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_userScaleSlider      = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 8 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH,
                                                            0.01f, 3.9f, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                            new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
            m_userScaleSlider.OnChange = OnComponentChange;
            m_userScaleLabel           = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 8 * CONTROLS_DELTA + new Vector2(0.4f, 0), null, new StringBuilder("0"), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            Controls.Add(m_alphaSliderLabel);
            Controls.Add(m_alphaSliderValueLabel);
            Controls.Add(m_alphaSlider);

            Controls.Add(m_userScaleSliderLabel);
            Controls.Add(m_userScaleSlider);
            Controls.Add(m_userScaleLabel);

            // Particle effect
            //m_particleNameLabel = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ParticleEffect, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_particleCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 9 * CONTROLS_DELTA + sliderOffset, MyGuiControlPreDefinedSize.MEDIUM,
                                                       MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 5, false, false, false);
            foreach (var p in MyParticlesLibrary.GetParticleEffects())
            {
                m_particleCombo.AddItem(p.GetID(), new StringBuilder(p.Name));
                m_particleCombo.SortItemsByValueText();
            }
            m_particleCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_particleCombo_OnSelect);
            //Controls.Add(m_particleNameLabel);
            Controls.Add(m_particleCombo);

            m_respawnPointCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 10 * CONTROLS_DELTA + sliderOffset,
                                                           MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 4);
            foreach (MyMwcObjectBuilder_FactionEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_ShipFactionNationalityEnumValues)
            {
                MyGuiHelperBase factionNationalityHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipFactionNationality(enumValue);
                m_respawnPointCombo.AddItem((int)enumValue, null, factionNationalityHelper.Description);
            }
            m_respawnPointCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_repawnPointCombo_OnSelect);
            Controls.Add(m_respawnPointCombo);

            m_secretCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 7 * CONTROLS_DELTA + sliderOffset,
                                                     MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 4);

            m_secretCombo.AddItem(0, null, new StringBuilder("No secret"));
            foreach (var room in MySecretRooms.SecretRooms)
            {
                m_secretCombo.AddItem(room.Key, null, new StringBuilder(room.Value));
            }
            m_secretCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_secretCombo_OnSelect);
            Controls.Add(m_secretCombo);

            UpdateValues();
        }
Exemplo n.º 20
0
 public IReadOnlyDictionary <int, MyParticleEffect> GetLibraryEffects() =>
 MyParticlesLibrary.GetParticleEffectsById();
Exemplo n.º 21
0
 public void RemoveParticleFromLibrary(string name)
 {
     MyParticlesLibrary.RemoveParticleEffect(name, true);
 }
Exemplo n.º 22
0
        public MyParticleEffect CreateParticle(string name, MatrixD worldMatrix)
        {
            Vector3D translation = worldMatrix.Translation;

            return(MyParticlesLibrary.CreateParticleEffect(name, ref worldMatrix, ref translation, uint.MaxValue));
        }
Exemplo n.º 23
0
        public override void DoDamage(float damage, int itemInstanceId, Vector3D position, Vector3 normal, MyStringHash type)
        {
            MyEnvironmentItemData itemData = m_itemsData[itemInstanceId];
            MyDefinitionId        id       = new MyDefinitionId(Definition.ItemDefinitionType, itemData.SubtypeId);
            var itemDefinition             = (MyTreeDefinition)MyDefinitionManager.Static.GetEnvironmentItemDefinition(id);


            int effectId;

            if (itemDefinition.CutEffect != null && MyParticlesLibrary.GetParticleEffectsID(itemDefinition.CutEffect, out effectId))
            {
                MyParticleEffect effect;
                if (MyParticlesManager.TryCreateParticleEffect(effectId, out effect))
                {
                    effect.WorldMatrix = MatrixD.CreateWorld(position, Vector3.CalculatePerpendicularVector(normal), normal);
                    effect.AutoDelete  = true;
                }
            }

            if (!Sync.IsServer)
            {
                return;
            }

            MyCutTreeInfo cutTreeInfo = default(MyCutTreeInfo);
            int           index       = -1;

            for (int i = 0; i < m_cutTreeInfos.Count; ++i)
            {
                cutTreeInfo = m_cutTreeInfos[i];
                if (itemInstanceId == cutTreeInfo.ItemInstanceId)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)
            {
                cutTreeInfo = new MyCutTreeInfo();
                cutTreeInfo.ItemInstanceId = itemInstanceId;

                cutTreeInfo.MaxPoints = cutTreeInfo.HitPoints = itemDefinition.HitPoints;

                index = m_cutTreeInfos.Count;
                m_cutTreeInfos.Add(cutTreeInfo);
            }

            cutTreeInfo.LastHit    = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            cutTreeInfo.HitPoints -= damage;

            if (cutTreeInfo.Progress >= 1)
            {
                CutTree(itemInstanceId, position, normal, type == MyDamageType.Drill ? 1.0f : 4.0f);
                m_cutTreeInfos.RemoveAtFast(index);
            }
            else
            {
                m_cutTreeInfos[index] = cutTreeInfo;
            }

            return;
        }
Exemplo n.º 24
0
 public IReadOnlyDictionary <int, MyParticleEffect> GetLibraryEffects()
 {
     return(MyParticlesLibrary.GetParticleEffects());
 }