Oprava spawnování monster, optimalizace v CommandProcessor a EventProcessor. Přesunutí některých tříd do vlastních namespaců, pročištění kódu, úpravy formátování, odstranění nepoužívaných souborů a zakomentovaného kódu
This commit is contained in:
parent
e5d746d597
commit
243f071a43
62 changed files with 873 additions and 1217 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using GlobalClassLib;
|
||||
using ONDServer.Net;
|
||||
|
||||
namespace ONDServer.Map;
|
||||
|
||||
|
|
@ -10,9 +11,16 @@ public static class MapManager {
|
|||
|
||||
public static MapTile Get((int x, int y) coords) => map[coords.x, coords.y];
|
||||
public static MapTile Get(int tileId) => Get(IdToCoords(tileId));
|
||||
|
||||
public static MapTile? TryGet(int tileId) {
|
||||
try{
|
||||
return Get(tileId);
|
||||
}
|
||||
catch (Exception){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<(int x1, int y1), (int x2, int y2, int value, ConnectorType type)[]> halfConnectors = new(){
|
||||
private static readonly 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)],
|
||||
[(1, 0)] =[(2, 0, 1, ConnectorType.DOOR_OFFICE), (1, 1, 1, ConnectorType.DOOR_REMOTE)],
|
||||
[(3, 0)] =[(2, 0, 1, ConnectorType.DOOR_OFFICE), (4, 0, 1, ConnectorType.HALL), (3, 1, 1, ConnectorType.DOOR_REMOTE)],
|
||||
|
|
@ -23,14 +31,14 @@ public static class MapManager {
|
|||
[(3, 1)] =[(3, 2, 1, ConnectorType.DOOR_REMOTE), (4, 1, 1, ConnectorType.HALL)]
|
||||
};
|
||||
|
||||
private static Dictionary<(int x1, int y1), (int x2, int y2, int value)[]> mainHallwayConnectors = new(){
|
||||
private static readonly Dictionary<(int x1, int y1), (int x2, int y2, int value)[]> mainHallwayConnectors = new(){
|
||||
[(0,2)] = [(1,2,1)],
|
||||
[(1,2)] = [(2,2,1)],
|
||||
[(2,2)] = [(3,2,1)],
|
||||
[(3,2)] = [(4,2,1)]
|
||||
};
|
||||
|
||||
private static (int x, int y)[] ventTiles =[(0, 1), (4, 1), (2, 2), (0, 3), (4, 3)];
|
||||
private static readonly (int x, int y)[] ventTiles =[(0, 1), (4, 1), (2, 2), (0, 3), (4, 3)];
|
||||
|
||||
public static void InitMap() {
|
||||
for (int i = 0; i < 5; i++){
|
||||
|
|
@ -94,10 +102,10 @@ public static class MapManager {
|
|||
|
||||
return tiles.ToArray();
|
||||
}
|
||||
|
||||
public const int ID_X_OFFSET = 5; // map grid height
|
||||
public static int CoordsToId(int x, int y) => x * ID_X_OFFSET + y;
|
||||
public static (int, int) IdToCoords(int id) => (id / ID_X_OFFSET, id % ID_X_OFFSET);
|
||||
|
||||
private const int MAP_SIDE_LENGTH_X = 5;
|
||||
public static int CoordsToId(int x, int y) => x * MAP_SIDE_LENGTH_X + y;
|
||||
public static (int, int) IdToCoords(int id) => (id / MAP_SIDE_LENGTH_X, id % MAP_SIDE_LENGTH_X);
|
||||
|
||||
public static TileConnector[] GetDoors() => doors.ToArray();
|
||||
public static TileConnector[] GetDoors(ServerPlayer player) => player == Server.P1 ? doorsP1.ToArray() : doorsP2.ToArray();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue