private void LateUpdate() { bool flag = false; for (int i = 0; i < cells.Count; i++) { if (m_fireData.ContainsKey(cells[i])) { EnflamedGrassData enflamedGrassData = m_fireData[cells[i]]; enflamedGrassData.fireTime += BraveTime.DeltaTime; enflamedGrassData.ParticleTimer -= BraveTime.DeltaTime; if (!m_fireData[cells[i]].hasEnflamedNeighbors && m_fireData[cells[i]].fireTime > 0.1f) { IgniteCell(cells[i] + IntVector2.North); IgniteCell(cells[i] + IntVector2.East); IgniteCell(cells[i] + IntVector2.South); IgniteCell(cells[i] + IntVector2.West); enflamedGrassData.hasEnflamedNeighbors = true; } if (m_fireData[cells[i]].fireTime > 2.6f && m_tiledSpritePool.ContainsKey(cells[i])) { DestroyPatch(cells[i]); } if (enflamedGrassData.HasPlayedFireOutro && enflamedGrassData.ParticleTimer <= 0f) { RemovePosition(cells[i]); i--; } else { enflamedGrassData = DoParticleAtPosition(cells[i], enflamedGrassData); m_fireData[cells[i]] = enflamedGrassData; } } } if (flag && !m_isPlayingFireAudio) { m_isPlayingFireAudio = true; AkSoundEngine.PostEvent("Play_ENV_oilfire_ignite_01", GameManager.Instance.PrimaryPlayer.gameObject); } }
private EnflamedGrassData DoParticleAtPosition(IntVector2 worldPos, EnflamedGrassData fireData) { if (m_fireSystem != null && fireData.ParticleTimer <= 0f) { bool ContainsCell = cells.Contains(worldPos + IntVector2.South); for (int X = 0; X < 2; X++) { for (int Y = 0; Y < 2; Y++) { if (ContainsCell || Y != 0) { float num = UnityEngine.Random.Range(1f, 1.5f); float num2 = UnityEngine.Random.Range(0.75f, 1f); Vector2 vector = worldPos.ToVector3() + new Vector3(0.33f + 0.33f * X, 0.33f + 0.33f * Y, 0f); vector += UnityEngine.Random.insideUnitCircle / 5f; if (!fireData.HasPlayedFireOutro) { if (!fireData.HasPlayedFireOutro && fireData.fireTime > 3f && m_fireOutroSystem != null) { num = num2; ParticleSystem.EmitParams emitParams = new ParticleSystem.EmitParams { position = vector, velocity = Vector3.zero, startSize = m_fireSystem.main.startSize.constant, startLifetime = num2, startColor = m_fireSystem.main.startColor.color, randomSeed = (uint)(UnityEngine.Random.value * 4.2949673E+09f) }; m_fireOutroSystem.Emit(emitParams, 1); if (X == 1 && Y == 1) { fireData.HasPlayedFireOutro = true; } } else if (!fireData.HasPlayedFireIntro && m_fireIntroSystem != null) { num = UnityEngine.Random.Range(0.75f, 1f); ParticleSystem.EmitParams emitParams2 = new ParticleSystem.EmitParams { position = vector, velocity = Vector3.zero, startSize = m_fireSystem.main.startSize.constant, startLifetime = num, startColor = m_fireSystem.main.startColor.color, randomSeed = (uint)(UnityEngine.Random.value * 4.2949673E+09f) }; m_fireIntroSystem.Emit(emitParams2, 1); if (X == 1 && Y == 1) { fireData.HasPlayedFireIntro = true; } } else if (UnityEngine.Random.value < 0.5f) { ParticleSystem.EmitParams emitParams3 = new ParticleSystem.EmitParams { position = vector, velocity = Vector3.zero, startSize = m_fireSystem.main.startSize.constant, startLifetime = num, startColor = m_fireSystem.main.startColor.color, randomSeed = (uint)(UnityEngine.Random.value * 4.2949673E+09f) }; m_fireSystem.Emit(emitParams3, 1); } } if (X == 1 && Y == 1) { fireData.ParticleTimer = num - 0.125f; } } } } } return(fireData); }