private void CreateDoor(MapBlock _mapBlock, ETerrains _floor, IEnumerable <Point> _borderPoints) { var doorCoords = Room.RoomRectangle.Center; var prevPoint = doorCoords; var direction = World.Rnd.GetRandomDirection(); var delta = direction.GetDelta(); while (!_borderPoints.Contains(doorCoords)) { prevPoint = doorCoords; doorCoords += delta; } var nextPoint = doorCoords + delta; var borders = direction.GetBorders().ToArray(); DoorWorldCoords = _mapBlock.ToWorldCoords(doorCoords); OutDoorWorldCoords = new[] { nextPoint + borders[0].Key, nextPoint, nextPoint + borders[1].Key }.Select(_mapBlock.ToWorldCoords).ToArray(); InDoorWorldCoords = new[] { prevPoint + borders[0].Key, prevPoint, prevPoint + borders[1].Key }.Select(_mapBlock.ToWorldCoords).ToArray(); _mapBlock.Map[doorCoords.X, doorCoords.Y] = _floor; var doors = EssenceHelper.GetAllThings <ClosedDoor>().ToArray(); _mapBlock.AddEssence(doors[0], doorCoords); }
private void CreateDoor(MapBlock _mapBlock, ETerrains _floor, IEnumerable<Point> _borderPoints) { var doorCoords = Room.RoomRectangle.Center; var prevPoint = doorCoords; var direction = World.Rnd.GetRandomDirection(); var delta = direction.GetDelta(); while (!_borderPoints.Contains(doorCoords)) { prevPoint = doorCoords; doorCoords += delta; } var nextPoint = doorCoords + delta; var borders = direction.GetBorders().ToArray(); DoorWorldCoords = _mapBlock.ToWorldCoords(doorCoords); OutDoorWorldCoords = new[] {nextPoint + borders[0].Key, nextPoint, nextPoint + borders[1].Key}.Select(_mapBlock.ToWorldCoords).ToArray(); InDoorWorldCoords = new[] {prevPoint + borders[0].Key, prevPoint, prevPoint + borders[1].Key}.Select(_mapBlock.ToWorldCoords).ToArray(); _mapBlock.Map[doorCoords.X, doorCoords.Y] = _floor; var doors = EssenceHelper.GetAllThings<ClosedDoor>().ToArray(); _mapBlock.AddEssence(doors[0], doorCoords); }