Skip to content

Commit 6b3c568

Browse files
committed
fix(misc): small fixes with smoke VFX
1 parent 931618b commit 6b3c568

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

‎Assets/Scripts/Managers/VFXManager.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ public void Start()
2525

2626
_vfxPools = new Dictionary<VfxType, Transform>();
2727

28-
GameObject g;
29-
Transform smokePool = Instantiate(poolPrefab).transform;
28+
Transform smokePool = Instantiate(poolPrefab, transform).transform;
3029
smokePool.gameObject.name = "Smoke";
3130
_vfxPools[VfxType.Smoke] = smokePool;
32-
smokePool.SetParent(transform);
3331
Transform smokeStockParent = smokePool.Find("Stock");
3432
for (int i = 0; i < SMOKE_EFFECT_POOL_SIZE; i++)
3533
{
36-
g = Instantiate(smokeEffectPrefabs[Random.Range(0, smokeEffectPrefabs.Length)]);
37-
g.transform.SetParent(smokeStockParent);
34+
Instantiate(
35+
smokeEffectPrefabs[Random.Range(0, smokeEffectPrefabs.Length)],
36+
smokeStockParent);
3837
}
3938
}
4039

‎Assets/Scripts/Units/Buildings/Building.cs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,16 @@ public void RemoveConstructor(int index)
152152
_constructors.RemoveAt(index);
153153
EventManager.TriggerEvent("UpdatedConstructors", this);
154154

155-
// when removing last constructor, remove smoke VFX
156-
foreach (Transform vfx in _smokeVfx)
157-
VFXManager.instance.Unspawn(VfxType.Smoke, vfx);
158-
_smokeVfx.Clear();
159-
// stop construction sound
160-
_buildingManager.ambientSource.Pause();
155+
// when removing last constructor:
156+
if (_constructors.Count == 0)
157+
{
158+
// - remove smoke VFX
159+
foreach (Transform vfx in _smokeVfx)
160+
VFXManager.instance.Unspawn(VfxType.Smoke, vfx);
161+
_smokeVfx.Clear();
162+
// - stop construction sound
163+
_buildingManager.ambientSource.Pause();
164+
}
161165
}
162166

163167
private void _SetAlive(bool fromSavedData = false)

0 commit comments

Comments
 (0)