Skip to content

Commit e49fa3d

Browse files
authored
Bugfix: testing commands created monsters that were not destroyed on new scene (#291)
* Ensure entities spawned by the testing hotkeys are correctly destroyed when scene changes * Update ServerTestingHotkeys.cs * remove #if check
1 parent 07b118b commit e49fa3d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Assets/BossRoom/Scripts/Server/ServerTestingHotkeys.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ namespace BossRoom.Server
55
{
66
/// <summary>
77
/// Provides various special commands that the Host can use while developing and
8-
/// debugging the game. These are not compiled into release builds. (If you want
9-
/// to disable them for debug builds, disable or remove this component from the
10-
/// BossRoomState prefab.)
8+
/// debugging the game. To disable them, just disable or remove this component from the
9+
/// BossRoomState prefab.
1110
/// </summary>
1211
public class ServerTestingHotkeys : NetworkBehaviour
1312
{
14-
#if UNITY_EDITOR || DEVELOPMENT_BUILD
1513
[SerializeField]
1614
[Tooltip("Enemy to spawn. Make sure this is included in the NetworkManager's list of prefabs!")]
1715
private NetworkObject m_EnemyPrefab;
@@ -50,19 +48,18 @@ private void Update()
5048
if (m_SpawnEnemyKeyCode != KeyCode.None && Input.GetKeyDown(m_SpawnEnemyKeyCode))
5149
{
5250
var newEnemy = Instantiate(m_EnemyPrefab);
53-
newEnemy.SpawnWithOwnership(NetworkManager.Singleton.LocalClientId);
51+
newEnemy.SpawnWithOwnership(NetworkManager.Singleton.LocalClientId, null, true);
5452
}
5553
if (m_SpawnBossKeyCode != KeyCode.None && Input.GetKeyDown(m_SpawnBossKeyCode))
5654
{
5755
var newEnemy = Instantiate(m_BossPrefab);
58-
newEnemy.SpawnWithOwnership(NetworkManager.Singleton.LocalClientId);
56+
newEnemy.SpawnWithOwnership(NetworkManager.Singleton.LocalClientId, null, true);
5957
}
6058
if (m_InstantQuitKeyCode != KeyCode.None && Input.GetKeyDown(m_InstantQuitKeyCode))
6159
{
6260
GameStateRelay.SetRelayObject(false); // indicate to the post-game screen that the game was lost
6361
MLAPI.SceneManagement.NetworkSceneManager.SwitchScene("PostGame");
6462
}
6563
}
66-
#endif
6764
}
6865
}

0 commit comments

Comments
 (0)