Ejemplo n.º 1
0
        public void Update(float dt)
        {
            float   s      = 3.5f * MathUtils.Saturate(0.07f * ((float)m_subsystemGameInfo.TotalElapsedGameTime - 6f));
            Matrix  matrix = m_componentFrame.Matrix;
            Vector3 vector = Quaternion.CreateFromRotationMatrix(matrix).ToYawPitchRoll();

            vector.X                  = Heading;
            vector.Y                  = 0.05f * MathUtils.Sin((float)MathUtils.NormalizeAngle(0.77 * m_subsystemTime.GameTime + 1.0));
            vector.Z                  = 0.12f * MathUtils.Sin((float)MathUtils.NormalizeAngle(1.12 * m_subsystemTime.GameTime + 2.0));
            matrix                    = Matrix.CreateFromYawPitchRoll(vector.X, vector.Y, vector.Z) * Matrix.CreateTranslation(matrix.Translation);
            matrix.Translation       += s * matrix.Forward * new Vector3(1f, 0f, 1f) * dt;
            m_componentFrame.Position = matrix.Translation;
            m_componentFrame.Rotation = Quaternion.CreateFromRotationMatrix(matrix);
            m_componentModel.SetBoneTransform(m_componentModel.Model.RootBone.Index, matrix);
            if (m_subsystemTime.GameTime - m_creationTime > 10.0 && m_subsystemViews.CalculateDistanceFromNearestView(matrix.Translation) > m_subsystemSky.VisibilityRange + 30f)
            {
                base.Project.RemoveEntity(base.Entity, disposeEntity: true);
            }
        }
Ejemplo n.º 2
0
        public void DestroyCell(int toolLevel, int x, int y, int z, int newValue, bool noDrop, bool noParticleSystem)
        {
            int   cellValue = Terrain.GetCellValue(x, y, z);
            int   num       = Terrain.ExtractContents(cellValue);
            Block block     = BlocksManager.Blocks[num];

            if (num != 0)
            {
                bool showDebris = true;
                if (!noDrop)
                {
                    m_dropValues.Clear();
                    block.GetDropValues(this, cellValue, newValue, toolLevel, m_dropValues, out showDebris);
                    for (int i = 0; i < m_dropValues.Count; i++)
                    {
                        BlockDropValue dropValue = m_dropValues[i];
                        if (dropValue.Count > 0)
                        {
                            SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(Terrain.ExtractContents(dropValue.Value));
                            for (int j = 0; j < blockBehaviors.Length; j++)
                            {
                                blockBehaviors[j].OnItemHarvested(x, y, z, cellValue, ref dropValue, ref newValue);
                            }
                            if (dropValue.Count > 0 && Terrain.ExtractContents(dropValue.Value) != 0)
                            {
                                Vector3 position = new Vector3(x, y, z) + new Vector3(0.5f);
                                m_subsystemPickables.AddPickable(dropValue.Value, dropValue.Count, position, null, null);
                            }
                        }
                    }
                }
                if (showDebris && !noParticleSystem && m_subsystemViews.CalculateDistanceFromNearestView(new Vector3(x, y, z)) < 16f)
                {
                    m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(this, new Vector3((float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f), cellValue, 1f));
                }
            }
            ChangeCell(x, y, z, newValue);
        }
 public void Update(float dt)
 {
     if (m_firePointsCopy.Count == 0)
     {
         m_firePointsCopy.Count += m_fireData.Count;
         m_fireData.Keys.CopyTo(m_firePointsCopy.Array, 0);
         m_copyIndex        = 0;
         m_lastScanDuration = (float)(m_subsystemTime.GameTime - m_lastScanTime);
         m_lastScanTime     = m_subsystemTime.GameTime;
         if (m_firePointsCopy.Count == 0)
         {
             m_fireSoundVolume = 0f;
         }
     }
     if (m_firePointsCopy.Count > 0)
     {
         float num  = MathUtils.Min(1f * dt * (float)m_firePointsCopy.Count + m_remainderToScan, 50f);
         int   num2 = (int)num;
         m_remainderToScan = num - (float)num2;
         int num3 = MathUtils.Min(m_copyIndex + num2, m_firePointsCopy.Count);
         while (m_copyIndex < num3)
         {
             if (m_fireData.TryGetValue(m_firePointsCopy.Array[m_copyIndex], out FireData value))
             {
                 int x    = value.Point.X;
                 int y    = value.Point.Y;
                 int z    = value.Point.Z;
                 int num4 = Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(x, y, z));
                 m_fireSoundIntensity += 1f / (m_subsystemAudio.CalculateListenerDistanceSquared(new Vector3(x, y, z)) + 0.01f);
                 if ((num4 & 1) != 0)
                 {
                     value.Time0 -= m_lastScanDuration;
                     if (value.Time0 <= 0f)
                     {
                         QueueBurnAway(x, y, z + 1, value.FireExpandability * 0.85f);
                     }
                     foreach (KeyValuePair <Point3, float> expansionProbability in m_expansionProbabilities)
                     {
                         if (m_random.Float(0f, 1f) < expansionProbability.Value * m_lastScanDuration * value.FireExpandability)
                         {
                             m_toExpand[new Point3(x + expansionProbability.Key.X, y + expansionProbability.Key.Y, z + 1 + expansionProbability.Key.Z)] = value.FireExpandability * 0.85f;
                         }
                     }
                 }
                 if ((num4 & 2) != 0)
                 {
                     value.Time1 -= m_lastScanDuration;
                     if (value.Time1 <= 0f)
                     {
                         QueueBurnAway(x + 1, y, z, value.FireExpandability * 0.85f);
                     }
                     foreach (KeyValuePair <Point3, float> expansionProbability2 in m_expansionProbabilities)
                     {
                         if (m_random.Float(0f, 1f) < expansionProbability2.Value * m_lastScanDuration * value.FireExpandability)
                         {
                             m_toExpand[new Point3(x + 1 + expansionProbability2.Key.X, y + expansionProbability2.Key.Y, z + expansionProbability2.Key.Z)] = value.FireExpandability * 0.85f;
                         }
                     }
                 }
                 if ((num4 & 4) != 0)
                 {
                     value.Time2 -= m_lastScanDuration;
                     if (value.Time2 <= 0f)
                     {
                         QueueBurnAway(x, y, z - 1, value.FireExpandability * 0.85f);
                     }
                     foreach (KeyValuePair <Point3, float> expansionProbability3 in m_expansionProbabilities)
                     {
                         if (m_random.Float(0f, 1f) < expansionProbability3.Value * m_lastScanDuration * value.FireExpandability)
                         {
                             m_toExpand[new Point3(x + expansionProbability3.Key.X, y + expansionProbability3.Key.Y, z - 1 + expansionProbability3.Key.Z)] = value.FireExpandability * 0.85f;
                         }
                     }
                 }
                 if ((num4 & 8) != 0)
                 {
                     value.Time3 -= m_lastScanDuration;
                     if (value.Time3 <= 0f)
                     {
                         QueueBurnAway(x - 1, y, z, value.FireExpandability * 0.85f);
                     }
                     foreach (KeyValuePair <Point3, float> expansionProbability4 in m_expansionProbabilities)
                     {
                         if (m_random.Float(0f, 1f) < expansionProbability4.Value * m_lastScanDuration * value.FireExpandability)
                         {
                             m_toExpand[new Point3(x - 1 + expansionProbability4.Key.X, y + expansionProbability4.Key.Y, z + expansionProbability4.Key.Z)] = value.FireExpandability * 0.85f;
                         }
                     }
                 }
                 if (num4 == 0)
                 {
                     value.Time5 -= m_lastScanDuration;
                     if (value.Time5 <= 0f)
                     {
                         QueueBurnAway(x, y - 1, z, value.FireExpandability * 0.85f);
                     }
                 }
             }
             m_copyIndex++;
         }
         if (m_copyIndex >= m_firePointsCopy.Count)
         {
             m_fireSoundVolume = 0.75f * m_fireSoundIntensity;
             m_firePointsCopy.Clear();
             m_fireSoundIntensity = 0f;
         }
     }
     if (m_subsystemTime.PeriodicGameTimeEvent(5.0, 0.0))
     {
         int num5 = 0;
         int num6 = 0;
         foreach (KeyValuePair <Point3, float> item in m_toBurnAway)
         {
             Point3 key    = item.Key;
             float  value2 = item.Value;
             base.SubsystemTerrain.ChangeCell(key.X, key.Y, key.Z, Terrain.ReplaceContents(0, 0));
             if (value2 > 0.25f)
             {
                 for (int i = 0; i < 5; i++)
                 {
                     Point3 point = CellFace.FaceToPoint3(i);
                     SetCellOnFire(key.X + point.X, key.Y + point.Y, key.Z + point.Z, value2);
                 }
             }
             float num7 = m_subsystemViews.CalculateDistanceFromNearestView(new Vector3(key));
             if (num5 < 15 && num7 < 24f)
             {
                 m_subsystemParticles.AddParticleSystem(new BurntDebrisParticleSystem(base.SubsystemTerrain, key.X, key.Y, key.Z));
                 num5++;
             }
             if (num6 < 4 && num7 < 16f)
             {
                 m_subsystemAudio.PlayRandomSound("Audio/Sizzles", 1f, m_random.Float(-0.25f, 0.25f), new Vector3(key.X, key.Y, key.Z), 3f, autoDelay: true);
                 num6++;
             }
         }
         foreach (KeyValuePair <Point3, float> item2 in m_toExpand)
         {
             SetCellOnFire(item2.Key.X, item2.Key.Y, item2.Key.Z, item2.Value);
         }
         m_toBurnAway.Clear();
         m_toExpand.Clear();
     }
     m_subsystemAmbientSounds.FireSoundVolume = MathUtils.Max(m_subsystemAmbientSounds.FireSoundVolume, m_fireSoundVolume);
 }