Remote dveře se renderují na mapě. Opravena chyba v GlobalMapTile.CoordsToId, která způsobovala desynchronizaci id místností

This commit is contained in:
Perry 2026-02-16 21:48:59 +01:00
parent 7e6b3d724b
commit 70b5debb22
7 changed files with 58 additions and 27 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using FNAF_Clone.Map;
using GlobalClassLib;
using Microsoft.Xna.Framework;
using MonoGameLibrary;
@ -22,6 +23,7 @@ public class UIManager {
private static TextureAtlas monitorAtlas;
public static int GlobalPixelMultiplier{ get; private set; }
private Dictionary<(int, int), UIElement> doorElements = new();
public static void InitUI() {
GlobalPixelMultiplier = Core.graphicsDevice.Viewport.Height / 360;
@ -47,10 +49,10 @@ public class UIManager {
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" }
};
// 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++){
@ -58,16 +60,28 @@ public class UIManager {
int j1 = j;
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
monitorScreen.AddElement($"room{i}-{4 - j}", new UIElement(point1, point2)
monitorScreen.AddElement($"room{MapTileProjection.CoordsToId(i, 4 - j)}", new UIElement(point1, point2)
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(i1, 4 - j1))});
if (doorPositions.ContainsKey((i, j))){
monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
}
//
// if (doorPositions.ContainsKey((i, j))){
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
// }
}
}
}
public static void SpawnDoors(TileConnectorProjection[] doors) {
foreach (var door in doors){
if(door.Type != ConnectorType.DOOR_REMOTE) continue;
(int x, int y) dpos = (Math.Abs(door.Tiles.tile1.GridPosition.x - door.Tiles.tile2.GridPosition.x), Math.Abs(door.Tiles.tile1.GridPosition.y - door.Tiles.tile2.GridPosition.y));
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));
}
}
}
public static void ChangeDoorState(Direction dir, bool state) {