diff --git a/Assets/Prefabs/Game/EnemySpawner.prefab b/Assets/Prefabs/Game/EnemySpawner.prefab
index 9d776c394..0e18d957f 100644
--- a/Assets/Prefabs/Game/EnemySpawner.prefab
+++ b/Assets/Prefabs/Game/EnemySpawner.prefab
@@ -466,8 +466,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_BreakableElements: []
m_DormantCooldown: 180
- IsBroken:
- m_InternalValue: 0
+ m_Breakable: {fileID: 5343699662503375493}
+ m_WaveSpawner: {fileID: 4844841199312666291}
--- !u!114 &5343699662503375493
MonoBehaviour:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs b/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
index 00aa20303..246811311 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
@@ -45,7 +45,6 @@ public class Breakable : NetworkBehaviour, IDamageable, ITargetable
[SerializeField]
private GameObject[] m_UnbrokenGameObjects;
-
///
/// Is the item broken or not?
///
@@ -158,10 +157,12 @@ private void OnBreakableStateChanged(bool wasBroken, bool isBroken)
private void PerformBreakVisualization(bool onStart)
{
- foreach (var gameObject in m_UnbrokenGameObjects)
+ foreach (var unbrokenGameObject in m_UnbrokenGameObjects)
{
- if (gameObject)
- gameObject.SetActive(false);
+ if (unbrokenGameObject)
+ {
+ unbrokenGameObject.SetActive(false);
+ }
}
if (m_CurrentBrokenVisualization)
@@ -180,10 +181,12 @@ private void PerformUnbreakVisualization()
{
Destroy(m_CurrentBrokenVisualization);
}
- foreach (var gameObject in m_UnbrokenGameObjects)
+ foreach (var unbrokenGameObject in m_UnbrokenGameObjects)
{
- if (gameObject)
- gameObject.SetActive(true);
+ if (unbrokenGameObject)
+ {
+ unbrokenGameObject.SetActive(true);
+ }
}
}
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/EnemyPortal.cs b/Assets/Scripts/Gameplay/GameplayObjects/EnemyPortal.cs
index 399c5d1a8..ffed31f2f 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/EnemyPortal.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/EnemyPortal.cs
@@ -30,27 +30,20 @@ public class EnemyPortal : NetworkBehaviour, ITargetable
[Tooltip("When all breakable elements are broken, wait this long before respawning them (and reactivating)")]
float m_DormantCooldown;
-
- ///
- /// Is the item broken or not?
- ///
- public NetworkVariable IsBroken;
+ [SerializeField]
+ Breakable m_Breakable;
public bool IsNpc { get { return true; } }
- public bool IsValidTarget { get { return !IsBroken.Value; } }
+ public bool IsValidTarget { get { return !m_Breakable.IsBroken.Value; } }
// cached reference to our components
+ [SerializeField]
ServerWaveSpawner m_WaveSpawner;
// currently active "wait X seconds and then restart" coroutine
Coroutine m_CoroDormant;
- private void Awake()
- {
- m_WaveSpawner = GetComponent();
- }
-
public override void OnNetworkSpawn()
{
if (!IsServer)
@@ -97,7 +90,7 @@ private void MaintainState()
}
}
- IsBroken.Value = !hasUnbrokenBreakables;
+ m_Breakable.IsBroken.Value = !hasUnbrokenBreakables;
m_WaveSpawner.SetSpawnerEnabled(hasUnbrokenBreakables);
if (!hasUnbrokenBreakables && m_CoroDormant == null)
{
@@ -124,7 +117,7 @@ void Restart()
}
}
- IsBroken.Value = false;
+ m_Breakable.IsBroken.Value = false;
m_WaveSpawner.SetSpawnerEnabled(true);
m_CoroDormant = null;
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d59190ffc..1a722fa23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).
## [unreleased] - yyyy-mm-dd
+### Fixed
+* EnemyPortals' VFX get disabled and re-enabled once the breakable crystals are broken (#784)
## [2.0.4] - 2022-12-13
### Changed