Remote dveře lze na mapě otevírat a zavírat. Office dveře hráče lze vidět na mapě (ukazují se ale pouze pro hráče 1). PlayerCommandy, které přepínají mezi dvěma stavy mají přidaný parametr state - client tudíž určuje jejich nový stav. Pokud se neshoduje stav v GameEventu se stavem odeslaným v Commandu, zobrazí se v konzoli varování. Client již nečeká na odpověď serveru při změně UI. Connectory se neklonují, oba tily používají stejnou instanci.

This commit is contained in:
Perry 2026-02-21 18:42:44 +01:00
parent 70b5debb22
commit cea56112ea
14 changed files with 112 additions and 48 deletions

View file

@ -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<Direction, TileConnectorProjection> 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);
}
}
}