Skip to content

Commit f253378

Browse files
debug cheats converted
1 parent e76bfcf commit f253378

File tree

5 files changed

+46
-27
lines changed

5 files changed

+46
-27
lines changed

Assets/InputSystem/PlayerActions.inputactions

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@
184184
"processors": "",
185185
"interactions": "",
186186
"initialStateCheck": false
187+
},
188+
{
189+
"name": "ToggleCheats",
190+
"type": "Button",
191+
"id": "d406d43c-a802-4adc-8a61-c7f0745ed4df",
192+
"expectedControlType": "",
193+
"processors": "",
194+
"interactions": "",
195+
"initialStateCheck": false
187196
}
188197
],
189198
"bindings": [
@@ -714,6 +723,17 @@
714723
"action": "ToggleNetworkSimulator",
715724
"isComposite": false,
716725
"isPartOfComposite": false
726+
},
727+
{
728+
"name": "",
729+
"id": "9b456d39-4b33-4bed-b1aa-c4d648dd523c",
730+
"path": "<Keyboard>/slash",
731+
"interactions": "",
732+
"processors": "",
733+
"groups": "",
734+
"action": "ToggleCheats",
735+
"isComposite": false,
736+
"isPartOfComposite": false
717737
}
718738
]
719739
},

Assets/Prefabs/DebugCheatsManager.prefab

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ MonoBehaviour:
4545
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
4646
m_Name:
4747
m_EditorClassIdentifier:
48-
GlobalObjectIdHash: 951099334
48+
GlobalObjectIdHash: 3439787871
49+
InScenePlacedSourceGlobalObjectIdHash: 0
50+
DeferredDespawnTick: 0
51+
Ownership: 0
4952
AlwaysReplicateAsRoot: 0
5053
SynchronizeTransform: 0
5154
ActiveSceneSynchronization: 0
5255
SceneMigrationSynchronization: 1
56+
SpawnWithObservers: 1
5357
DontDestroyWithOwner: 0
5458
AutoObjectParentSync: 1
59+
SyncOwnerTransformWhenParented: 1
60+
AllowOwnerToParent: 0
5561
--- !u!114 &7241368247586282332
5662
MonoBehaviour:
5763
m_ObjectHideFlags: 0
@@ -64,7 +70,8 @@ MonoBehaviour:
6470
m_Script: {fileID: 11500000, guid: ab1e76745edfc434ab8154ad27efc5fd, type: 3}
6571
m_Name:
6672
m_EditorClassIdentifier:
73+
ShowTopMostFoldoutHeaderGroup: 1
6774
m_DebugCheatsPanel: {fileID: 0}
6875
m_EnemyPrefab: {fileID: 3713729372785093435, guid: 6cdd52f1fa2ed34469a487ae6477eded, type: 3}
6976
m_BossPrefab: {fileID: 3688950541947916326, guid: 365e94337fd10fe4ebde1906df413ac7, type: 3}
70-
m_OpenWindowKeyCode: 47
77+
m_ToggleCheatsAction: {fileID: -3765159069520908634, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}

Assets/Prefabs/UI/NetworkSimulator.prefab

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ MonoBehaviour:
777777
m_ScenariosButton: {fileID: 3849933660407801780}
778778
m_ScenariosButtonText: {fileID: 3849933660557125965}
779779
m_LagSpikeDuration: {fileID: 8516948734797190670}
780-
m_OpenWindowKeyCode: 9
781780
m_ToggleNetworkSimulatorAction: {fileID: 34288948611290012, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
782781
m_ConnectionsCycleConfigurations:
783782
- m_ClassPreset:
@@ -3304,7 +3303,7 @@ MonoBehaviour:
33043303
m_EditorClassIdentifier:
33053304
m_PresetAsset: {fileID: 0}
33063305
m_PresetReference:
3307-
rid: 2061385516771704978
3306+
rid: 2061385516771705142
33083307
m_Scenario:
33093308
rid: -2
33103309
m_IsScenarioSettingsFolded: 1
@@ -3314,7 +3313,7 @@ MonoBehaviour:
33143313
RefIds:
33153314
- rid: -2
33163315
type: {class: , ns: , asm: }
3317-
- rid: 2061385516771704978
3316+
- rid: 2061385516771705142
33183317
type: {class: NetworkSimulatorPreset, ns: Unity.Multiplayer.Tools.NetworkSimulator.Runtime, asm: Unity.Multiplayer.Tools.NetworkSimulator.Runtime}
33193318
data:
33203319
<Name>k__BackingField: None

Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Unity.Multiplayer.Samples.Utilities;
88
using Unity.Netcode;
99
using UnityEngine;
10+
using UnityEngine.InputSystem;
1011
using VContainer;
1112

1213
namespace Unity.BossRoom.DebugCheats
@@ -28,10 +29,10 @@ public class DebugCheatsManager : NetworkBehaviour
2829
[SerializeField]
2930
[Tooltip("Boss to spawn. Make sure this is included in the NetworkManager's list of prefabs!")]
3031
NetworkObject m_BossPrefab;
31-
32+
3233
[SerializeField]
33-
KeyCode m_OpenWindowKeyCode = KeyCode.Slash;
34-
34+
InputActionReference m_ToggleCheatsAction;
35+
3536
SwitchedDoor m_SwitchedDoor;
3637

3738
SwitchedDoor SwitchedDoor
@@ -46,33 +47,25 @@ SwitchedDoor SwitchedDoor
4647
}
4748
}
4849

49-
const int k_NbTouchesToOpenWindow = 4;
50-
5150
bool m_DestroyPortalsOnNextToggle = true;
5251

5352
[Inject]
5453
IPublisher<CheatUsedMessage> m_CheatUsedMessagePublisher;
5554

56-
void Update()
55+
void Start()
5756
{
58-
// TODO: make into action
59-
/*if (Input.touchCount == k_NbTouchesToOpenWindow && AnyTouchDown() ||
60-
m_OpenWindowKeyCode != KeyCode.None && Input.GetKeyDown(m_OpenWindowKeyCode))
61-
{
62-
m_DebugCheatsPanel.SetActive(!m_DebugCheatsPanel.activeSelf);
63-
}*/
57+
m_ToggleCheatsAction.action.performed += OnToggleCheatsActionPerformed;
6458
}
6559

66-
static bool AnyTouchDown()
60+
public override void OnDestroy()
6761
{
68-
foreach (var touch in Input.touches)
69-
{
70-
if (touch.phase == TouchPhase.Began)
71-
{
72-
return true;
73-
}
74-
}
75-
return false;
62+
base.OnDestroy();
63+
m_ToggleCheatsAction.action.performed -= OnToggleCheatsActionPerformed;
64+
}
65+
66+
void OnToggleCheatsActionPerformed(InputAction.CallbackContext obj)
67+
{
68+
m_DebugCheatsPanel.SetActive(!m_DebugCheatsPanel.activeSelf);
7669
}
7770

7871
public void SpawnEnemy()

Assets/Scripts/Gameplay/DebugCheats/Unity.BossRoom.DebugCheats.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Unity.BossRoom.ConnectionManagement",
99
"Unity.Multiplayer.Samples.Utilities",
1010
"VContainer",
11-
"VContainer.EnableCodeGen"
11+
"Unity.InputSystem"
1212
],
1313
"includePlatforms": [],
1414
"excludePlatforms": [],

0 commit comments

Comments
 (0)