64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using LiteDB;
|
|
using System.Globalization;
|
|
using static AGRoomRuntimeConfig;
|
|
using static DeluxeBackend.Enums;
|
|
namespace DeluxeBackend.Models
|
|
{
|
|
public class SubRoom
|
|
{
|
|
[BsonId]
|
|
public long Id { get; set; }
|
|
[BsonRef("rooms")]
|
|
public required Room Room { get; set; }
|
|
public required string LocationId { get; set; }
|
|
public required string Name { get; set; }
|
|
public bool IsSandbox { get; set; } = false;
|
|
public int MaxPlayers { get; set; } = 8;
|
|
public bool CanMatchmakeInto { get; set; } = false;
|
|
[BsonRef("subroomsaves")]
|
|
public SubRoomSave? CurrentSave { get; set; } = null;
|
|
public bool SupportsJoinInProgress { get; set; } = true;
|
|
public bool UseLevelBasedMatchmaking { get; set; } = false;
|
|
public bool UseAgeBasedMatchmaking { get; set; } = true;
|
|
public bool UseRecRoyaleMatchmaking { get; set; } = false;
|
|
|
|
[BsonIgnore]
|
|
public Dictionary<string, object> ToDictionary(bool includeCurrentSave = false, bool includeMatchmaking = false)
|
|
{
|
|
Dictionary<string, object>? CurrentSavedic = null;
|
|
if (CurrentSave != null && includeCurrentSave)
|
|
{
|
|
CurrentSavedic = CurrentSave.ToDictionary();
|
|
}
|
|
RoomAccessibility Accessibility = RoomAccessibility.Unlisted;
|
|
if (CanMatchmakeInto)
|
|
{
|
|
Accessibility = RoomAccessibility.Public;
|
|
}
|
|
|
|
#pragma warning disable CS8601 // Possible null reference assignment.
|
|
Dictionary<string, object> data= new()
|
|
{
|
|
["RoomId"] = Room.Id,
|
|
["SubRoomId"] = Id,
|
|
["Accessibility"] = (int)Accessibility,
|
|
["CurrentSave"] = CurrentSavedic,
|
|
["IsSandbox"] = IsSandbox,
|
|
["MaxPlayers"] = MaxPlayers,
|
|
["Name"] = Name,
|
|
["UnitySceneId"] = LocationId
|
|
};
|
|
if (includeMatchmaking)
|
|
{
|
|
data["CanMatchmakeInto"] = CanMatchmakeInto;
|
|
data["SupportsJoinInProgress"] = SupportsJoinInProgress;
|
|
data["UseLevelBasedMatchmaking"] = UseLevelBasedMatchmaking;
|
|
data["UseAgeBasedMatchmaking"] = UseAgeBasedMatchmaking;
|
|
data["UseRecRoyaleMatchmaking"] = UseRecRoyaleMatchmaking;
|
|
}
|
|
return data;
|
|
#pragma warning restore CS8601
|
|
}
|
|
}
|
|
}
|