44 lines
No EOL
1.5 KiB
C#
44 lines
No EOL
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using FNAF_Clone.GUI;
|
|
using Microsoft.Xna.Framework.Input;
|
|
using MonoGameLibrary.Input;
|
|
using PacketLib;
|
|
|
|
namespace FNAF_Clone;
|
|
|
|
public class CommandManager {
|
|
private static (string label, Keys key, Action action)[] keybinds = [
|
|
("Toggle Camera", Keys.Space, SendToggleCamera),
|
|
("Toggle left door", Keys.A, ToggleDoorLeft),
|
|
("Toggle centre door", Keys.W, ToggleDoorCentre),
|
|
("Toggle right door", Keys.D, ToggleDoorRight)
|
|
|
|
];
|
|
|
|
private static InputListenerHook toggleCamHook = new(true);
|
|
|
|
public static void InitInputListeners() {
|
|
Array.ForEach(keybinds, tuple => InputManager.AddListener(tuple.label, tuple.key, () => tuple.action(), InputTiming.PRESS, toggleCamHook));
|
|
}
|
|
|
|
private static void SendToggleCamera() {
|
|
Client.SendCommands([PlayerCommand.TOGGLE_MONITOR()]);
|
|
}
|
|
|
|
private static void ToggleDoorLeft() => SendToggleDoor(0);
|
|
private static void ToggleDoorCentre() => SendToggleDoor(1);
|
|
private static void ToggleDoorRight() => SendToggleDoor(2);
|
|
|
|
private static void SendToggleDoor(int id) {
|
|
if (Screen.CurrentScreen.Label == UIManager.ScreenTypes.CAMERAS){
|
|
//TODO: camera doors
|
|
return;
|
|
}
|
|
Client.SendCommands([PlayerCommand.TOGGLE_DOOR_OFFICE(id)]);
|
|
}
|
|
|
|
public static void SendChangeCamera(int idx, int idy) {
|
|
Client.SendCommands([PlayerCommand.SWITCH_CAM(idx, idy)]);
|
|
}
|
|
} |