OneNightDuel/FNAF_Clone/CommandManager.cs

56 lines
2.1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using FNAF_Clone.GUI;
using FNAF_Clone.Map;
using GlobalClassLib;
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),
("Toggle back door", Keys.S, ToggleDoorBack)
];
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(Direction.EAST);
private static void ToggleDoorCentre() => SendToggleDoor(Direction.NORTH);
private static void ToggleDoorRight() => SendToggleDoor(Direction.WEST);
private static void ToggleDoorBack() => SendToggleDoor(Direction.SOUTH);
private static void SendToggleDoor(Direction direction) {
if (Screen.CurrentScreen.Label == UIManager.ScreenTypes.CAMERAS){
SendToggleRemoteDoor(direction);
return;
}
Client.SendCommands([PlayerCommand.TOGGLE_DOOR_OFFICE(direction)]);
}
private static void SendToggleRemoteDoor(Direction direction) { // WIP
TileConnectorProjection[] connectors = ClientMapManager.GetConnectors(Client.Player.state.camera).Where(c => c.Type == ConnectorType.DOOR_REMOTE).ToArray();
// Client.SendCommands([PlayerCommand.TOGGLE_DOOR_REMOTE()]);
}
public static void SendChangeCamera(int idx, int idy) {
Client.SendCommands([PlayerCommand.SWITCH_CAM(idx, idy)]);
}
}