Esempio n. 1
0
 public MaterialProperties(MySoundPair soundCue, string particleEffectName, ContactPropertyParticleProperties effectProperties)
 {
     Sound = soundCue;
     ParticleEffectProperties = effectProperties;
     if (particleEffectName != null)
     {
         MyParticlesLibrary.GetParticleEffectsID(
             particleEffectName, out ParticleEffectID);
     }
     else
     {
         ParticleEffectID = -1;
     }
 }
Esempio n. 2
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);
                         }
                     }
                 }
             }
         }
     }
 }
 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);
         }
     }
 }
Esempio n. 4
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;
        }