Skip to content

Commit

Permalink
debug cheats converted
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando-cortez committed Jan 10, 2025
1 parent e76bfcf commit f253378
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
20 changes: 20 additions & 0 deletions Assets/InputSystem/PlayerActions.inputactions
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "ToggleCheats",
"type": "Button",
"id": "d406d43c-a802-4adc-8a61-c7f0745ed4df",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
Expand Down Expand Up @@ -714,6 +723,17 @@
"action": "ToggleNetworkSimulator",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "9b456d39-4b33-4bed-b1aa-c4d648dd523c",
"path": "<Keyboard>/slash",
"interactions": "",
"processors": "",
"groups": "",
"action": "ToggleCheats",
"isComposite": false,
"isPartOfComposite": false
}
]
},
Expand Down
11 changes: 9 additions & 2 deletions Assets/Prefabs/DebugCheatsManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 951099334
GlobalObjectIdHash: 3439787871
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 0
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 0
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
SyncOwnerTransformWhenParented: 1
AllowOwnerToParent: 0
--- !u!114 &7241368247586282332
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -64,7 +70,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ab1e76745edfc434ab8154ad27efc5fd, type: 3}
m_Name:
m_EditorClassIdentifier:
ShowTopMostFoldoutHeaderGroup: 1
m_DebugCheatsPanel: {fileID: 0}
m_EnemyPrefab: {fileID: 3713729372785093435, guid: 6cdd52f1fa2ed34469a487ae6477eded, type: 3}
m_BossPrefab: {fileID: 3688950541947916326, guid: 365e94337fd10fe4ebde1906df413ac7, type: 3}
m_OpenWindowKeyCode: 47
m_ToggleCheatsAction: {fileID: -3765159069520908634, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
5 changes: 2 additions & 3 deletions Assets/Prefabs/UI/NetworkSimulator.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ MonoBehaviour:
m_ScenariosButton: {fileID: 3849933660407801780}
m_ScenariosButtonText: {fileID: 3849933660557125965}
m_LagSpikeDuration: {fileID: 8516948734797190670}
m_OpenWindowKeyCode: 9
m_ToggleNetworkSimulatorAction: {fileID: 34288948611290012, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_ConnectionsCycleConfigurations:
- m_ClassPreset:
Expand Down Expand Up @@ -3304,7 +3303,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PresetAsset: {fileID: 0}
m_PresetReference:
rid: 2061385516771704978
rid: 2061385516771705142
m_Scenario:
rid: -2
m_IsScenarioSettingsFolded: 1
Expand All @@ -3314,7 +3313,7 @@ MonoBehaviour:
RefIds:
- rid: -2
type: {class: , ns: , asm: }
- rid: 2061385516771704978
- rid: 2061385516771705142
type: {class: NetworkSimulatorPreset, ns: Unity.Multiplayer.Tools.NetworkSimulator.Runtime, asm: Unity.Multiplayer.Tools.NetworkSimulator.Runtime}
data:
<Name>k__BackingField: None
Expand Down
35 changes: 14 additions & 21 deletions Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Unity.Multiplayer.Samples.Utilities;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using VContainer;

namespace Unity.BossRoom.DebugCheats
Expand All @@ -28,10 +29,10 @@ public class DebugCheatsManager : NetworkBehaviour
[SerializeField]
[Tooltip("Boss to spawn. Make sure this is included in the NetworkManager's list of prefabs!")]
NetworkObject m_BossPrefab;

[SerializeField]
KeyCode m_OpenWindowKeyCode = KeyCode.Slash;

InputActionReference m_ToggleCheatsAction;
SwitchedDoor m_SwitchedDoor;

SwitchedDoor SwitchedDoor
Expand All @@ -46,33 +47,25 @@ SwitchedDoor SwitchedDoor
}
}

const int k_NbTouchesToOpenWindow = 4;

bool m_DestroyPortalsOnNextToggle = true;

[Inject]
IPublisher<CheatUsedMessage> m_CheatUsedMessagePublisher;

void Update()
void Start()
{
// TODO: make into action
/*if (Input.touchCount == k_NbTouchesToOpenWindow && AnyTouchDown() ||
m_OpenWindowKeyCode != KeyCode.None && Input.GetKeyDown(m_OpenWindowKeyCode))
{
m_DebugCheatsPanel.SetActive(!m_DebugCheatsPanel.activeSelf);
}*/
m_ToggleCheatsAction.action.performed += OnToggleCheatsActionPerformed;
}

static bool AnyTouchDown()
public override void OnDestroy()
{
foreach (var touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
return true;
}
}
return false;
base.OnDestroy();
m_ToggleCheatsAction.action.performed -= OnToggleCheatsActionPerformed;
}

void OnToggleCheatsActionPerformed(InputAction.CallbackContext obj)
{
m_DebugCheatsPanel.SetActive(!m_DebugCheatsPanel.activeSelf);
}

public void SpawnEnemy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Unity.BossRoom.ConnectionManagement",
"Unity.Multiplayer.Samples.Utilities",
"VContainer",
"VContainer.EnableCodeGen"
"Unity.InputSystem"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down

0 comments on commit f253378

Please sign in to comment.