Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Assets/Prefabs/Game/EnemySpawner.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class Breakable : NetworkBehaviour, IDamageable, ITargetable
[SerializeField]
private GameObject[] m_UnbrokenGameObjects;


/// <summary>
/// Is the item broken or not?
/// </summary>
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
}

Expand Down
19 changes: 6 additions & 13 deletions Assets/Scripts/Gameplay/GameplayObjects/EnemyPortal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/// <summary>
/// Is the item broken or not?
/// </summary>
public NetworkVariable<bool> 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<ServerWaveSpawner>();
}

public override void OnNetworkSpawn()
{
if (!IsServer)
Expand Down Expand Up @@ -97,7 +90,7 @@ private void MaintainState()
}
}

IsBroken.Value = !hasUnbrokenBreakables;
m_Breakable.IsBroken.Value = !hasUnbrokenBreakables;
m_WaveSpawner.SetSpawnerEnabled(hasUnbrokenBreakables);
if (!hasUnbrokenBreakables && m_CoroDormant == null)
{
Expand All @@ -124,7 +117,7 @@ void Restart()
}
}

IsBroken.Value = false;
m_Breakable.IsBroken.Value = false;
m_WaveSpawner.SetSpawnerEnabled(true);
m_CoroDormant = null;
}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down