From cea56112ea71a3568751070595b48ccd54a00dd7 Mon Sep 17 00:00:00 2001 From: Perry Date: Sat, 21 Feb 2026 18:42:44 +0100 Subject: [PATCH] =?UTF-8?q?Remote=20dve=C5=99e=20lze=20na=20map=C4=9B=20ot?= =?UTF-8?q?ev=C3=ADrat=20a=20zav=C3=ADrat.=20Office=20dve=C5=99e=20hr?= =?UTF-8?q?=C3=A1=C4=8De=20lze=20vid=C4=9Bt=20na=20map=C4=9B=20(ukazuj?= =?UTF-8?q?=C3=AD=20se=20ale=20pouze=20pro=20hr=C3=A1=C4=8De=201).=20Playe?= =?UTF-8?q?rCommandy,=20kter=C3=A9=20p=C5=99ep=C3=ADnaj=C3=AD=20mezi=20dv?= =?UTF-8?q?=C4=9Bma=20stavy=20maj=C3=AD=20p=C5=99idan=C3=BD=20parametr=20s?= =?UTF-8?q?tate=20-=20client=20tud=C3=AD=C5=BE=20ur=C4=8Duje=20jejich=20no?= =?UTF-8?q?v=C3=BD=20stav.=20Pokud=20se=20neshoduje=20stav=20v=20GameEvent?= =?UTF-8?q?u=20se=20stavem=20odeslan=C3=BDm=20v=20Commandu,=20zobraz=C3=AD?= =?UTF-8?q?=20se=20v=20konzoli=20varov=C3=A1n=C3=AD.=20Client=20ji=C5=BE?= =?UTF-8?q?=20ne=C4=8Dek=C3=A1=20na=20odpov=C4=9B=C4=8F=20serveru=20p?= =?UTF-8?q?=C5=99i=20zm=C4=9Bn=C4=9B=20UI.=20Connectory=20se=20neklonuj?= =?UTF-8?q?=C3=AD,=20oba=20tily=20pou=C5=BE=C3=ADvaj=C3=AD=20stejnou=20ins?= =?UTF-8?q?tanci.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FNAF_Clone/Client.cs | 21 ++++++----- FNAF_Clone/CommandManager.cs | 34 +++++++++++++----- .../Content/images/SpriteSheet_monitor.png | Bin 4683 -> 4683 bytes FNAF_Clone/GUI/UIManager.cs | 33 +++++++++++------ FNAF_Clone/GameMain.cs | 2 +- FNAF_Clone/Map/ClientMapManager.cs | 6 ++-- FNAF_Server/CommandProcessor.cs | 18 +++++++--- FNAF_Server/Map/MapManager.cs | 9 +++-- FNAF_Server/Map/TileConnector.cs | 1 - GlobalClassLib/Direction.cs | 3 +- GlobalClassLib/GlobalMapTile.cs | 4 +-- GlobalClassLib/GlobalTileConnector.cs | 17 +++++++++ PacketLib/GameEvent.cs | 4 ++- PacketLib/PlayerCommand.cs | 8 ++--- 14 files changed, 112 insertions(+), 48 deletions(-) diff --git a/FNAF_Clone/Client.cs b/FNAF_Clone/Client.cs index 30957df..6a7a344 100644 --- a/FNAF_Clone/Client.cs +++ b/FNAF_Clone/Client.cs @@ -79,7 +79,7 @@ public class Client { ClientMapManager.InitMap(); TileConnectorProjection[] connectors = connectorsData.Select(c => new TileConnectorProjection(ClientMapManager.Get(c.id1), ClientMapManager.Get(c.id2), c.type)).ToArray(); ClientMapManager.InitConnectors(connectors); - UIManager.SpawnDoors(connectors); + UIManager.SpawnDoors(connectors.Where(c => c.Type == ConnectorType.DOOR_REMOTE).ToArray()); } public static void Update() { @@ -99,21 +99,26 @@ public class Client { Console.WriteLine("E: Player left"); break; case 2: // switch cam - if (Player.state.pid == e.Args[0]){ - Player.state.camera = e.Args[1]; - } - Console.WriteLine($"E: player {e.Args[0]} switched to camera {e.Args[1]}-{e.Args[2]}"); + if (Player.state.pid != e.Args[0]) return; + if (Player.state.camera != e.Args[1]) Console.WriteLine("!!! DESYNC: CAMERA STATE"); + Console.WriteLine($"E: player {e.Args[0]} switched to camera {e.Args[1]}"); break; case 3: // toggle cam - Player.state.monitorUp = e.Args[1] == 1; + if (Player.state.monitorUp != (e.Args[1] == 1)) Console.WriteLine("!!! DESYNC: MONITOR STATE"); + UIManager.ChangeMonitorState(e.Args[1] == 1); Console.WriteLine($"E: Player {e.Args[0]} toggled monitor {(e.Args[1] == 0 ? "off" : "on")}"); break; case 4: // toggle door - Player.state.doorStates[e.Args[1]] = e.Args[2] == 1; - UIManager.ChangeDoorState((Direction)e.Args[1], e.Args[2] == 1); + if (Player.state.doorStates[e.Args[1]] != (e.Args[2] == 1)) Console.WriteLine("!!! DESYNC: DOOR STATE"); + + // UIManager.ChangeDoorState((Direction)e.Args[1], e.Args[2] == 1); Console.WriteLine($"E: Player {e.Args[0]} {(e.Args[2] == 1 ? "closed" : "opened")} door {e.Args[1]}"); break; + case 5: // toggle remote door + if (ClientMapManager.GetConnector((e.Args[1], e.Args[2])).Blocked != (e.Args[3] == 1)) Console.WriteLine("!!! DESYNC: REMOTE DOOR STATE"); + Console.WriteLine($"E: Player {e.Args[0]} {(e.Args[3] == 1 ? "closed" : "opened")} door {e.Args[1]}-{e.Args[2]}"); + break; case -1: // movement throw new NotImplementedException(); diff --git a/FNAF_Clone/CommandManager.cs b/FNAF_Clone/CommandManager.cs index 85e7f14..f817e3b 100644 --- a/FNAF_Clone/CommandManager.cs +++ b/FNAF_Clone/CommandManager.cs @@ -26,7 +26,8 @@ public class CommandManager { } private static void SendToggleCamera() { - Client.SendCommands([PlayerCommand.TOGGLE_MONITOR()]); + Client.Player.state.monitorUp = !Client.Player.state.monitorUp; + Client.SendCommands([PlayerCommand.SET_MONITOR(Client.Player.state.monitorUp)]); } private static void ToggleDoorLeft() => SendToggleDoor(Direction.EAST); @@ -34,23 +35,38 @@ public class CommandManager { private static void ToggleDoorRight() => SendToggleDoor(Direction.WEST); private static void ToggleDoorBack() => SendToggleDoor(Direction.SOUTH); + private static Dictionary currentDoorBinds = new(); private static void SendToggleDoor(Direction direction) { if (Screen.CurrentScreen.Label == UIManager.ScreenTypes.CAMERAS){ SendToggleRemoteDoor(direction); return; } - Client.SendCommands([PlayerCommand.TOGGLE_DOOR_OFFICE(direction)]); + Client.Player.state.doorStates[(int)direction] = !Client.Player.state.doorStates[(int)direction]; + UIManager.ChangeDoorState(direction, Client.Player.state.doorStates[(int)direction]); + Client.SendCommands([PlayerCommand.SET_DOOR_OFFICE(direction, Client.Player.state.doorStates[(int)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()]); + private static void SendToggleRemoteDoor(Direction direction) { + if (!currentDoorBinds.TryGetValue(direction, out var val)) return; + TileConnectorProjection connector = val; + connector.Blocked = !connector.Blocked; + Client.SendCommands([PlayerCommand.SET_DOOR_REMOTE(connector.Id, connector.Blocked)]); + UIManager.ChangeRemoteDoorState(connector.Id, connector.Blocked); + // Console.WriteLine("Changed door state to: " + (connector.Blocked ? "blocked" : "open") + " for door " + connector); + // add UIManager toggle door } - public static void SendChangeCamera(int idx, int idy) { - Client.SendCommands([PlayerCommand.SWITCH_CAM(idx, idy)]); + public static void SendChangeCamera(int id) { + Client.Player.state.camera = id; + Client.SendCommands([PlayerCommand.SWITCH_CAM(id)]); + MapTileProjection tile = ClientMapManager.Get(id); + // add UIManager switch camera + currentDoorBinds.Clear(); + foreach (var c in tile.GetAllConnectors().Where(c => c.Type == ConnectorType.DOOR_REMOTE)){ + Direction dir = c.GetDirection(tile); + if (dir == Direction.NONE) return; + currentDoorBinds.Add(dir, c); + } } } \ No newline at end of file diff --git a/FNAF_Clone/Content/images/SpriteSheet_monitor.png b/FNAF_Clone/Content/images/SpriteSheet_monitor.png index 4cfbf816a025a189ef98032b48642b20808f197b..bc67efebf14745a4c495a57671e272539178058e 100644 GIT binary patch delta 165 zcmX@Da$04BrJyoHg8`F3g2Q?_+lc*DUl!cBd9y#>CdR(*ram#*cU93v<# z*2BQU;89$>H|l=O`k2k^YG=xL4jB4Op2#O-%Ot>{0Fve?UjK!epV{v}|b^ouj-{;?D*K?8usJb`WtZd3QM;O~#4hgbRWC0X3d|Drm1BA<*DlK_Ll z*|T4>YK!+4ot2wmaNCgKxB(*z1BWt5+5#kfX743_28LP7GUIHk3O*z~`@a8Qq2ZHX z{qZ(7JN|{s*Vw=KWuPYPz|dflr^tFa-J0!zgxchTOpcS4ghWO93abqI^>W`b0D-5g KpUXO@geCwF$w86; diff --git a/FNAF_Clone/GUI/UIManager.cs b/FNAF_Clone/GUI/UIManager.cs index 60f486d..4ad81ab 100644 --- a/FNAF_Clone/GUI/UIManager.cs +++ b/FNAF_Clone/GUI/UIManager.cs @@ -48,11 +48,6 @@ public class UIManager { monitorScreen.AddElement("view-frame", new UIElement(monitorAtlas[1], new Point(62, 55))); monitorScreen.AddElement("map-frame", new UIElement(monitorAtlas[2], new Point(334, 135))); monitorScreen.AddElement("map", new UIElement(monitorAtlas[3], new Point(334, 135))); - - // Dictionary<(int,int),string> doorPositions = new(){ - // {(0, 0),"2-5"},{ (1, 0), "2-4" }, { (1, 1), "2-3" }, { (3, 0), "2-2" }, { (3, 1), "2-1" }, { (4, 0), "2-0" }, // TODO: generate this dynamically from server map info - // {(0, 3),"1-0"},{ (1, 3), "1-1" }, { (1, 2), "1-2" }, { (3, 3), "1-3" }, { (3, 2), "1-4" }, { (4, 3), "1-5" } - // }; for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server for (int j = 0; j < 5; j++){ @@ -61,7 +56,7 @@ public class UIManager { Point point1 = new Point(336 + (32 * i), 144 + (32 * j)); Point point2 = new Point(367 + (32 * i), 175 + (32 * j)); monitorScreen.AddElement($"room{MapTileProjection.CoordsToId(i, 4 - j)}", new UIElement(point1, point2) - {Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(i1, 4 - j1))}); + {Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(MapTileProjection.CoordsToId(i1, 4 - j1)))}); // // if (doorPositions.ContainsKey((i, j))){ // monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1)); @@ -79,24 +74,42 @@ public class UIManager { if (dpos.y == 1){ int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id; UIElement tile = monitorScreen["room"+targetId]; + monitorScreen.AddElement("door"+targetId+"-"+(targetId == door.Tiles.tile1.Id ? door.Tiles.tile2.Id : door.Tiles.tile1.Id), new UIElement([monitorAtlas[5], monitorAtlas[6]], tile.Bounds.Item1)); } } + + monitorScreen.AddElement("p1-office-door-left", new UIElement([monitorAtlas[7], monitorAtlas[8]], new Point(400, 272))); + monitorScreen.AddElement("p1-office-door-centre", new UIElement([monitorAtlas[9], monitorAtlas[10]], new Point(400, 272))); + monitorScreen.AddElement("p1-office-door-right", new UIElement([monitorAtlas[11], monitorAtlas[12]], new Point(400, 272))); + monitorScreen.AddElement("p2-office-door-right", new UIElement([monitorAtlas[13], monitorAtlas[14]], new Point(400, 144))); + monitorScreen.AddElement("p2-office-door-centre", new UIElement([monitorAtlas[15], monitorAtlas[16]], new Point(400, 144))); + monitorScreen.AddElement("p2-office-door-left", new UIElement([monitorAtlas[17], monitorAtlas[18]], new Point(400, 144))); + } - public static void ChangeDoorState(Direction dir, bool state) { + public static void ChangeDoorState(Direction dir, bool state) { // TODO: make this also change for p2 + int stateInt = state ? 1 : 0; + switch ((int)dir){ case 0: - officeScreen["office_left"].SetTexture(state ? 1 : 0); + officeScreen["office_left"].SetTexture(stateInt); + monitorScreen["p1-office-door-left"].SetTexture(stateInt); break; case 1: - officeScreen["office_centre"].SetTexture(state ? 1 : 0); + officeScreen["office_centre"].SetTexture(stateInt); + monitorScreen["p1-office-door-centre"].SetTexture(stateInt); break; case 2: - officeScreen["office_right"].SetTexture(state ? 1 : 0); + officeScreen["office_right"].SetTexture(stateInt); + monitorScreen["p1-office-door-right"].SetTexture(stateInt); break; } } + + public static void ChangeRemoteDoorState((int, int) id, bool state) { + monitorScreen["door"+Math.Max(id.Item1, id.Item2)+"-"+Math.Min(id.Item1, id.Item2)].SetTexture(state ? 1 : 0); + } public static void ChangeMonitorState(bool state) { Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE); diff --git a/FNAF_Clone/GameMain.cs b/FNAF_Clone/GameMain.cs index bb1d240..77eccac 100644 --- a/FNAF_Clone/GameMain.cs +++ b/FNAF_Clone/GameMain.cs @@ -20,7 +20,7 @@ public class GameMain() : Core("fnafkooo", 1280, 720, false) { Client.Connect("127.0.0.1", 9012); CommandManager.InitInputListeners(); - InputManager.AddListener(InputManager.MouseButton.LEFT, (() => Console.WriteLine("LMB pressed at: " + InputManager.MouseState.Position)), InputTiming.PRESS, new InputListenerHook(true)); + // InputManager.AddListener(InputManager.MouseButton.LEFT, (() => Console.WriteLine("LMB pressed at: " + InputManager.MouseState.Position)), InputTiming.PRESS, new InputListenerHook(true)); base.Initialize(); diff --git a/FNAF_Clone/Map/ClientMapManager.cs b/FNAF_Clone/Map/ClientMapManager.cs index eb4c962..3864fb2 100644 --- a/FNAF_Clone/Map/ClientMapManager.cs +++ b/FNAF_Clone/Map/ClientMapManager.cs @@ -4,7 +4,7 @@ namespace FNAF_Clone.Map; public class ClientMapManager { private static MapTileProjection[,] map = new MapTileProjection[5, 5]; - private static MapTileProjection Get((int x, int y) coords) => map[coords.x, coords.y]; + public static MapTileProjection Get((int x, int y) coords) => map[coords.x, coords.y]; public static MapTileProjection Get(int tileId) => Get(MapTileProjection.IdToCoords(tileId)); public static void InitMap() { for (int i = 0; i < 5; i++){ @@ -17,8 +17,6 @@ public class ClientMapManager { } } - - } public static void InitConnectors(TileConnectorProjection[] connectors) { @@ -29,7 +27,7 @@ public class ClientMapManager { } } - + public static TileConnectorProjection GetConnector((int, int) id) => Get(id.Item1).GetConnector(id.Item2); public static TileConnectorProjection[] GetConnectors(int tileId) => Get(MapTileProjection.IdToCoords(tileId)).GetAllConnectors(); } \ No newline at end of file diff --git a/FNAF_Server/CommandProcessor.cs b/FNAF_Server/CommandProcessor.cs index 1a0d48c..0565a67 100644 --- a/FNAF_Server/CommandProcessor.cs +++ b/FNAF_Server/CommandProcessor.cs @@ -1,3 +1,4 @@ +using FNAF_Server.Map; using PacketLib; namespace FNAF_Server; @@ -9,21 +10,28 @@ public class CommandProcessor { foreach (var playerCommand in commands){ switch (playerCommand.ID){ case 0: - Console.WriteLine($"C: Player {pid} switched to camera {playerCommand.Args[0]}-{playerCommand.Args[1]}"); - Server.SendUpdateToAll([GameEvent.SWITCH_CAM(pid, playerCommand.Args[0], playerCommand.Args[1])]); + Console.WriteLine($"C: Player {pid} switched to camera {playerCommand.Args[0]}"); + Server.SendUpdateToAll([GameEvent.SWITCH_CAM(pid, playerCommand.Args[0])]); break; case 1: - bool monitorState = !currentPlayer.state.monitorUp; + bool monitorState = playerCommand.Args[0] == 1; currentPlayer.state.monitorUp = monitorState; Console.WriteLine($"C: Player {pid} toggled camera {(monitorState ? "on" : "off")}"); Server.SendUpdateToAll([GameEvent.TOGGLE_MONITOR(pid, monitorState)]); break; case 2: - bool doorState = !currentPlayer.state.doorStates[playerCommand.Args[0]]; + bool doorState = playerCommand.Args[1] == 1; currentPlayer.state.doorStates[playerCommand.Args[0]] = doorState; - Console.WriteLine($" Player {pid} {(doorState ? "closed" : "opened")} door {playerCommand.Args[0]}"); + Console.WriteLine($"C: Player {pid} {(doorState ? "closed" : "opened")} door {playerCommand.Args[0]}"); Server.SendUpdateToAll([GameEvent.TOGGLE_DOOR_OFFICE(pid,playerCommand.Args[0] ,doorState)]); break; + case 3: + TileConnector? door = MapManager.Get(playerCommand.Args[0]).GetConnector(playerCommand.Args[1]); + if(door == null) return; + door.Blocked = playerCommand.Args[2] == 1; + Console.WriteLine($"C: Player {pid} {(door.Blocked ? "closed" : "opened")} door {(playerCommand.Args[0], playerCommand.Args[1])}"); + Server.SendUpdateToAll([GameEvent.TOGGLE_DOOR_REMOTE(pid, (playerCommand.Args[0], playerCommand.Args[1]), door.Blocked)]); + break; } } } diff --git a/FNAF_Server/Map/MapManager.cs b/FNAF_Server/Map/MapManager.cs index 4d8ee55..5354b9c 100644 --- a/FNAF_Server/Map/MapManager.cs +++ b/FNAF_Server/Map/MapManager.cs @@ -4,6 +4,10 @@ namespace FNAF_Server.Map; public static class MapManager { private static MapTile[,] map = new MapTile[5, 5]; + + public static MapTile Get((int x, int y) coords) => map[coords.x, coords.y]; + public static MapTile Get(int tileId) => Get(MapTile.IdToCoords(tileId)); + private static Dictionary<(int x1, int y1), (int x2, int y2, int value, ConnectorType type)[]> halfConnectors = new(){ [(0, 0)] =[(1, 0, 1, ConnectorType.HALL), (0, 1, 1, ConnectorType.DOOR_REMOTE)], @@ -53,8 +57,9 @@ public static class MapManager { for (int i = 0; i < 5; i++){ for (int j = 0; j < 5; j++){ - Array.ForEach(map[i, j].GetAllConnectors(), c => { - if(c.Tiles.tile1.Id < c.Tiles.tile2.Id) + MapTile tile = map[i, j]; + Array.ForEach(tile.GetAllConnectors(), c => { + if(tile.Id < c.OtherTile(tile).Id) connectors.Add(c); }); } diff --git a/FNAF_Server/Map/TileConnector.cs b/FNAF_Server/Map/TileConnector.cs index 1ee2a58..8b45a75 100644 --- a/FNAF_Server/Map/TileConnector.cs +++ b/FNAF_Server/Map/TileConnector.cs @@ -4,7 +4,6 @@ namespace FNAF_Server.Map; public class TileConnector : GlobalTileConnector { public int Value{ get; set; } - public bool Blocked { get; set; } public TileConnector(MapTile tile1, MapTile tile2, ConnectorType type, int value) : base(tile1, tile2, type) { Value = value; } diff --git a/GlobalClassLib/Direction.cs b/GlobalClassLib/Direction.cs index 181ef50..5c3f407 100644 --- a/GlobalClassLib/Direction.cs +++ b/GlobalClassLib/Direction.cs @@ -4,5 +4,6 @@ public enum Direction { EAST = 0, NORTH = 1, WEST = 2, - SOUTH = 3 + SOUTH = 3, + NONE = 4 } \ No newline at end of file diff --git a/GlobalClassLib/GlobalMapTile.cs b/GlobalClassLib/GlobalMapTile.cs index a3911dc..9f682c4 100644 --- a/GlobalClassLib/GlobalMapTile.cs +++ b/GlobalClassLib/GlobalMapTile.cs @@ -15,13 +15,13 @@ public abstract class GlobalMapTile where TCon : GlobalTileConnecto connector = connector.Clone(); connector.Tiles.tile1 = (TTile)this; connectors.Add(connector); - connector.Tiles.tile2._AddConnectorNoRepeat(connector.Clone()); + connector.Tiles.tile2._AddConnectorNoRepeat(connector); // connectors.Add(new TCon(this, tile, type)); // tile.connectors.Add(new GlobalTileConnector(tile, this, type)); } private void _AddConnectorNoRepeat(TCon connector) { - (connector.Tiles.tile1, connector.Tiles.tile2) = (connector.Tiles.tile2, connector.Tiles.tile1); + // (connector.Tiles.tile1, connector.Tiles.tile2) = (connector.Tiles.tile2, connector.Tiles.tile1); connectors.Add(connector); } diff --git a/GlobalClassLib/GlobalTileConnector.cs b/GlobalClassLib/GlobalTileConnector.cs index 97108b0..dcdc9e1 100644 --- a/GlobalClassLib/GlobalTileConnector.cs +++ b/GlobalClassLib/GlobalTileConnector.cs @@ -16,11 +16,28 @@ public abstract class GlobalTileConnector where TTile : GlobalMapTi } public (TTile tile1, TTile tile2) Tiles; + public bool Blocked { get; set; } + public (int, int) Id => (Tiles.tile1.Id, Tiles.tile2.Id); public ConnectorType Type { get; set; } public TTile OtherTile(TTile tile) => Tiles.Item1 == tile ? Tiles.Item2 : Tiles.Item1; + + public Direction GetDirection(TTile tile) { + if (tile != Tiles.tile1 && tile != Tiles.tile2) return Direction.NONE; + + TTile other = OtherTile(tile); + (int, int) dpos = (other.GridPosition.x - tile.GridPosition.x, other.GridPosition.y - tile.GridPosition.y); + + switch (dpos){ + case (0, 1): return Direction.NORTH; + case (1, 0): return Direction.EAST; + case (0, -1): return Direction.SOUTH; + case (-1, 0): return Direction.WEST; + default: return Direction.NONE; + } + } public override string ToString() => $"Con ({Tiles.Item1.PositionAsString} -> {Tiles.Item2.PositionAsString})"; diff --git a/PacketLib/GameEvent.cs b/PacketLib/GameEvent.cs index 10c8dbf..9be4def 100644 --- a/PacketLib/GameEvent.cs +++ b/PacketLib/GameEvent.cs @@ -7,9 +7,11 @@ namespace PacketLib; public struct GameEvent : INetSerializable{ public static GameEvent PLAYER_JOIN(int pid) => new(){ID = 0, Args = [pid] }; public static GameEvent PLAYER_LEAVE(int pid) => new(){ID = 1, Args = [pid] }; - public static GameEvent SWITCH_CAM(int pid, int idx, int idy) => new(){ID = 2, Args = [pid, idx, idy] }; + public static GameEvent SWITCH_CAM(int pid, int id) => new(){ID = 2, Args = [pid, id] }; public static GameEvent TOGGLE_MONITOR(int pid, bool state) => new(){ID = 3, Args = [pid, state ? 1 : 0]}; public static GameEvent TOGGLE_DOOR_OFFICE(int pid, int doorId, bool state) => new(){ID = 4, Args = [pid, doorId, state ? 1 : 0]}; + public static GameEvent TOGGLE_DOOR_REMOTE(int pid, (int, int) doorId, bool state) => new(){ID = 5, Args = [pid, doorId.Item1, doorId.Item2, state ? 1 : 0]}; + diff --git a/PacketLib/PlayerCommand.cs b/PacketLib/PlayerCommand.cs index 47f868f..37b7594 100644 --- a/PacketLib/PlayerCommand.cs +++ b/PacketLib/PlayerCommand.cs @@ -4,10 +4,10 @@ using LiteNetLib.Utils; namespace PacketLib; public struct PlayerCommand : INetSerializable { - public static PlayerCommand SWITCH_CAM(int idx, int idy) => new(){ID = 0, Args = [idx, idy] }; - public static PlayerCommand TOGGLE_MONITOR() => new(){ID = 1, Args = []}; - public static PlayerCommand TOGGLE_DOOR_OFFICE(Direction direction) => new(){ID = 2, Args = [(int)direction]}; - public static PlayerCommand TOGGLE_DOOR_REMOTE(int remoteDoorId) => new(){ID = 3, Args = [remoteDoorId]}; + public static PlayerCommand SWITCH_CAM(int id) => new(){ID = 0, Args = [id] }; + public static PlayerCommand SET_MONITOR(bool state) => new(){ID = 1, Args = [state ? 1 : 0]}; + public static PlayerCommand SET_DOOR_OFFICE(Direction direction, bool state) => new(){ID = 2, Args = [(int)direction, state ? 1 : 0]}; + public static PlayerCommand SET_DOOR_REMOTE((int, int) remoteDoorId, bool state) => new(){ID = 3, Args = [remoteDoorId.Item1, remoteDoorId.Item2, state ? 1 : 0]}; public int ID{ get; set; } public bool Hideable => ID < 0; public int[] Args{ get; private set; }