Add remaining project files

This commit is contained in:
Marco Baldwin
2026-07-23 18:21:43 -07:00
parent c12d8ac35d
commit 6e15e89a9d
453 changed files with 64265 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class Account
{
[BsonId]
public long Id { get; set; }
public required string Username { get; set; } = string.Empty;
public string PasswordHash { get; set; } = string.Empty;
public List<string> Roles { get; set; } = [];
public string DisplayName { get; set; } = string.Empty;
public string ImageName { get; set; } = "DefaultProfileImage";
public DateOnly? Birthday { get; set; } = null;
public string Bio { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public ulong? DiscordId { get; set; } = null;
public PronounsType Pronouns { get; set; } = PronounsType.None;
public IdentityFlagsType IdentityFlags { get; set; } = IdentityFlagsType.None;
public Dictionary<long, DateTime> VisitedRooms { get; set; } = [];
public bool IsRecentHistoryVisible { get; set; } = true;
[BsonIgnore]
public bool? IsJunior
{
get
{
if (!Birthday.HasValue) return null;
var today = DateOnly.FromDateTime(DateTime.UtcNow);
return Birthday.Value.AddYears(13) > today;
}
}
[BsonIgnore]
private readonly Dictionary<string, bool> _roleCache = new(StringComparer.OrdinalIgnoreCase);
[BsonIgnore]
private DateTime _cacheExpiration = DateTime.MinValue;
[BsonIgnore]
private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(5);
[BsonIgnore]
public async Task<bool> HasRoleAsync(DiscordBotService discord, string role)
{
if (Roles.Any(r => r.Equals(role, StringComparison.OrdinalIgnoreCase)))
return true;
if (!DiscordId.HasValue)
return false;
if (DateTime.UtcNow > _cacheExpiration)
{
_roleCache.Clear();
_cacheExpiration = DateTime.UtcNow.Add(CacheDuration);
}
if (_roleCache.TryGetValue(role, out bool hasRole))
{
return hasRole;
}
bool externalHasRole = await discord.HasRole(DiscordId.Value, role);
_roleCache[role] = externalHasRole;
return externalHasRole;
}
#pragma warning disable CS8601 // Possible null reference assignment.
[BsonIgnore]
public Dictionary<string, object> ToDictionaryMe()
{
return new Dictionary<string, object>
{
["accountId"] = Id,
["availableUsernameChanges"] = 0,
["birthday"] = Birthday?.ToString("o"),
["username"] = Username,
["displayName"] = DisplayName ?? Username,
["profileImage"] = ImageName,
["isJunior"] = IsJunior,
["platforms"] = 1,//steam,
["personalPronouns"] = (int)Pronouns,
["identityFlags"] = (int)IdentityFlags,
["createdAt"] = CreatedAt.ToString("o")
};
}
[BsonIgnore]
public Dictionary<string, object> ToDictionary()
{
return new Dictionary<string, object>
{
["accountId"] = Id,
["username"] = Username,
["displayName"] = DisplayName ?? Username,
["profileImage"] = ImageName,
["isJunior"] = IsJunior,
["platforms"] = 1,//steam,
["personalPronouns"] = (int)Pronouns,
["identityFlags"] = (int)IdentityFlags,
["createdAt"] = CreatedAt.ToString("o")
};
}
#pragma warning restore CS8601
}
}
+20
View File
@@ -0,0 +1,20 @@
using LiteDB;
namespace DeluxeBackend.Models
{
public class AccountAvatar
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Account { get; set; }
public string OutfitSelections { get; set; } = "";
public string OutfitSelectionsV2 { get; set; } = "";
public string FaceFeatures { get; set; } = "";
public string SkinColor { get; set; } = "";
public string HairColor { get; set; } = "";
}
}
+51
View File
@@ -0,0 +1,51 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class AccountPresence
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Account { get; set; }
public PlayerType PlayerType { get; set; } = PlayerType.UNINITIALIZED;
public StatusVisibilityType StatusVisibility { get; set; } = StatusVisibilityType.Public;
public PlatformType LastPlatform { get; set; } = PlatformType.All;
//public something LastDeviceClass { get; set; }
public VrMovementModeType VrMovementMode { get; set; } = VrMovementModeType.TELEPORT;
public DateTime LastOnline { get; set; } = DateTime.UtcNow;
public bool IsOnline { get; set; } = false;
public string? AppVersion { get; set; } = null;
[BsonRef("roominstances")]
public RoomInstance? Instance { get; set; } = null;
[BsonIgnore]
public Dictionary<string, object> ToDictionary()
{
Dictionary<string, object?>? RoomInstance = null;
if (Instance != null)
{
RoomInstance = Instance.ToDictionary();
}
#pragma warning disable CS8601 // Possible null reference assignment.
return new Dictionary<string, object>()
{
["serverTime"] = DateTime.UtcNow.Ticks,
["playerId"] = Account!.Id,
["statusVisibility"] = (int)StatusVisibility,
["platform"] = (int)PlatformType.Steam,//(int)LastPlatform,
["deviceClass"] = 0,
["roomInstance"] = RoomInstance,
["vrMovementMode"] = (int)VrMovementMode,
["lastOnline"] = LastOnline,
["isOnline"] = IsOnline,
["appVersion"] = AppVersion
};
#pragma warning restore CS8601
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using LiteDB;
namespace DeluxeBackend.Models
{
public class AccountSetting
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Account { get; set; }
public required string Key { get; set; }
public required string Value { get; set; }
}
}
+68
View File
@@ -0,0 +1,68 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class ActionLinkExtraData
{
public ulong? DiscordUserId { get; set; } = null;
public long? RoomId { get; set; } = null;
}
public class ActionLink
{
[BsonId]
public long Id { get; set; }
public PlatformType? Platform { get; set; } = null;
public required string Code { get; set; }
public required long CreatorPlayerId { get; set; }
public required string Description { get; set; }
public required ActionLinkType Type { get; set; }
public ActionLinkExtraData? ExtraData { get; set; } = null;
public required DateTime ExpiresAt { get; set; }
public int MaxUses { get; set; } = 100;
public int Uses { get; set; } = 0;
[BsonIgnore]
public bool IsValid
{
get
{
var now = DateTime.UtcNow;
bool timeValid = ExpiresAt.Kind == DateTimeKind.Utc
? ExpiresAt > now
: ExpiresAt.ToUniversalTime() > now;
return timeValid && Uses < MaxUses;
}
}
[BsonIgnore]
public Dictionary<string, object> ToDictionary()
{
Dictionary<string, object> dataMeow = new()
{
["Type"] = (int)Type
};
if (Type == ActionLinkType.DiscordLink)
{
dataMeow["Type"] = (int)ActionLinkType.Room;
ExtraData!.RoomId = 2;
}
if (Platform != null)
{
dataMeow["Platform"] = (int)Platform;
}
if (ExtraData != null)
{
dataMeow["ExtraJson"] = System.Text.Json.JsonSerializer.Serialize(ExtraData);
}
Dictionary<string, object> data = new()
{
["creatorPlayerId"] = CreatorPlayerId,
["data"] = System.Text.Json.JsonSerializer.Serialize(dataMeow),
["isValid"] = IsValid
};
return data;
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using LiteDB;
namespace DeluxeBackend.Models
{
public class AvatarSaved
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Account { get; set; }
public required int Slot { get; set; }
public required string PreviewImageName { get; set; }
public string Name { get; set; } = "";
public string OutfitSelections { get; set; } = "";
public string OutfitSelectionsV2 { get; set; } = "";
public string FaceFeatures { get; set; } = "";
public string SkinColor { get; set; } = "";
public string HairColor { get; set; } = "";
}
}
+19
View File
@@ -0,0 +1,19 @@
using LiteDB;
using System.Numerics;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class Cachedlogin
{
[BsonId]
public long Id { get; set; }
public required PlatformType Platform { get; set; }
public required string PlatformId { get; set; }
public required DateTime LastLoginAt { get; set; }
public bool RequirePassword { get; set; } = false;
[BsonRef("accounts")]
public required Account Account { get; set; }
}
}
+52
View File
@@ -0,0 +1,52 @@
using LiteDB;
using Newtonsoft.Json.Linq;
using System.Drawing;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class CustomAvatarItem
{
[BsonId]
public Guid Id { get; set; }
[BsonRef("accounts")]
public required Account Creator { get; set; }
public required string Name { get; set; }
public string Description { get; set; } = string.Empty;
public required int Price { get; set; }
public bool IsFeatured { get; set; } = false;
public int? BaseAvatarItemId { get; set; }
public required Color BaseAvatarItemColor { get; set; }
public required string DesignFilename { get; set; }
public required string ThumbnailImageFilename { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime ModifiedAt { get; set; } = DateTime.UtcNow;
public RoomAccessibility Accessibility { get; set; } = RoomAccessibility.Public;//i love how i just use RoomAccessibility for any accessibility
public required PreviewOrientationType PreviewOrientation { get; set; }
[BsonIgnore]
public Dictionary<string, object> ToDictionary()
{
Dictionary<string, object> data= new()
{
["CustomAvatarItemId"] = Id.ToString(),
["CreatorAccountId"] = Creator.Id,
["Name"] = Name,
["Description"] = Description ?? "",
["Price"] = Price,
["Accessibility"] = (int)Accessibility,
["IsFeatured"] = IsFeatured,
["BaseAvatarItemColor"] = $"{ColorTranslator.ToHtml(BaseAvatarItemColor)}",
["DesignFilename"] = DesignFilename,
["ThumbnailImageFilename"] = ThumbnailImageFilename,
["CreatedAt"] = CreatedAt.ToString("O"),
["ModifiedAt"] = ModifiedAt.ToString("O"),
};
if (BaseAvatarItemId.HasValue)
{
data["BaseAvatarItemId"] = BaseAvatarItemId.Value;
}
return data;
}
}
}
+102
View File
@@ -0,0 +1,102 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class Invention
{
[BsonId]
public long Id { get; set; }
public required Guid ReplicationId { get; set; }
[BsonRef("accounts")]
public required Account Creator { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public required string ImageName { get; set; }
public List<InventionVersion> Versions { get; set; } = [];
public required int CurrentVersionNumber { get; set; }
public required RoomAccessibility Accessibility { get; set; }
public DateTime ModifiedAt { get; set; } = DateTime.UtcNow;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? FirstPublishedAt { get; set; }
[BsonRef("rooms")]
public required Room Room { get; set; }
public List<long> DownloadIds { get; set; } = [];
public List<long> CheeredIds { get; set; } = [];
public InventionPermission CreatorPermission { get; set; } = InventionPermission.Unassigned;
public InventionPermission GeneralPermission { get; set; } = InventionPermission.Unassigned;
public bool AllowTrial { get; set; } = false;
public int? Price { get; set; }
[BsonIgnore]
public Dictionary<string, object?> ToDictionary()
{
#pragma warning disable CS8601 // Possible null reference assignment.
Dictionary<string, object?> data = new()
{
["InventionId"] = Id,
["ReplicationId"] = ReplicationId.ToString(),
["CreatorPlayerId"] = Creator.Id,
["Name"] = Name,
["Description"] = Description,
["ImageName"] = ImageName,
["CurrentVersionNumber"] = CurrentVersionNumber,
["Accessibility"] = Accessibility,
["ModifiedAt"] = ModifiedAt.ToString("O"),
["CreatedAt"] = CreatedAt.ToString("O"),
["CreationRoomId"] = Room.Id,
["NumPlayersHaveUsedInRoom"] = -1,
["NumDownloads"] = DownloadIds.Count,
["CheerCount"] = CheeredIds.Count,
["CreatorPermission"] = CreatorPermission,
["GeneralPermission"] = GeneralPermission,
["IsAGInvention"] = false,
["IsCertifiedInvention"] = false,
["AllowTrial"] = AllowTrial
};
if (FirstPublishedAt.HasValue)
{
data["FirstPublishedAt"] = FirstPublishedAt.Value.ToString("O");
}
if (Price.HasValue)
{
data["Price"] = Price.Value;
}
return data;
#pragma warning restore CS8601
}
}
public class InventionVersion
{
public required int Id { get; set; }
public required Guid ReplicationId { get; set; }
public required int InstantiationCost { get; set; }
public required int LightsCost { get; set; }
public required int ChipsCost { get; set; }
public required int CloudVariablesCost { get; set; }
public required string BlobName { get; set; }
[BsonIgnore]
public Dictionary<string, object?> ToDictionary(long inventionId)
{
#pragma warning disable CS8601 // Possible null reference assignment.
Dictionary<string, object?> data = new()
{
["InventionId"] = inventionId,
["ReplicationId"] = ReplicationId.ToString(),
["VersionNumber"] = Id,
["InstantiationCost"] = InstantiationCost,
["LightsCost"] = LightsCost,
["ChipsCost"] = ChipsCost,
["CloudVariablesCost"] = CloudVariablesCost,
["BlobName"] = BlobName
};
return data;
#pragma warning restore CS8601
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using LiteDB;
using System.Globalization;
using System.Numerics;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class Message
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Player { get; set; }
[BsonRef("accounts")]
public required Account FromPlayer { get; set; }
public DateTime SentTime { get; set; } = DateTime.UtcNow;
public required MessageType Type { get; set; }
public string Data { get; set; } = string.Empty;
public Dictionary<string, object> ToDictionary()
{
string daya = string.Empty;
if (Data != null)
{
daya = Data;
}
var data = new Dictionary<string, object>
{
["Id"] = Id,
["FromPlayerId"] = FromPlayer.Id,
["SentTime"] = SentTime.ToString("o", CultureInfo.InvariantCulture),
["Type"] = (int)Type,
["Data"] = daya
};
return data;
}
}
}
+51
View File
@@ -0,0 +1,51 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class PlayerEvent
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Creator { get; set; }
[BsonRef("rooms")]
public required Room Room { get; set; }
[BsonRef("subrooms")]
public required SubRoom SubRoom { get; set; }
public required string Name { get; set; }
public string Description { get; set; } = string.Empty;
public string? ImageName { get; set; } = string.Empty;
public required DateTime StartTime { get; set; }
public required DateTime EndTime { get; set; }
public required RoomAccessibility Accessibility { get; set; }
public bool IsMultiInstance { get; set; } = false;
public bool SupportMultiInstanceRoomChat { get; set; } = false;
public BroadcastPerms DefaultBroadcastPermissions { get; set; } = BroadcastPerms.None;
public BroadcastPerms CanRequestBroadcastPermissions { get; set; } = BroadcastPerms.None;
public long? BroadcastingRoomInstanceId { get; set; } = null;
[BsonIgnore]
public Dictionary<string, object?> ToDictionary()
{
return new Dictionary<string, object?>()
{
["PlayerEventId"] = Id,
["CreatorPlayerId"] = Creator.Id,
["RoomId"] = Room.Id,
["SubRoomId"] = SubRoom.Id,
["Name"] = Name,
["Description"] = Description ?? "",
["ImageName"] = ImageName ?? "",
["StartTime"] = StartTime.ToUniversalTime().ToString("O"),
["EndTime"] = EndTime.ToUniversalTime().ToString("O"),
["AttendeeCount"] = -1,
["Accessibility"] = (int)Accessibility,
["IsMultiInstance"] = IsMultiInstance,
["SupportMultiInstanceRoomChat"] = SupportMultiInstanceRoomChat,
["DefaultBroadcastPermissions"] = (int)DefaultBroadcastPermissions,
["CanRequestBroadcastPermissions"] = (int)CanRequestBroadcastPermissions,
["BroadcastingRoomInstanceId"] = BroadcastingRoomInstanceId
};
}
}
}
+30
View File
@@ -0,0 +1,30 @@
using LiteDB;
namespace DeluxeBackend.Models
{
public class PlayerInvite
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Account { get; set; }
[BsonRef("accounts")]
public required Account InvitedBy { get; set; }
public required long InstanceId { get; set; }
public required DateTime ExpiresAt { get; set; }
[BsonIgnore]
public bool IsValid
{
get
{
var now = DateTime.UtcNow;
bool timeValid = ExpiresAt.Kind == DateTimeKind.Utc
? ExpiresAt > now
: ExpiresAt.ToUniversalTime() > now;
return timeValid;
}
}
}
}
+18
View File
@@ -0,0 +1,18 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class RefreshToken
{
[BsonId]
public long Id { get; set; }
public required string Token { get; set; }
public required DateTime Expires { get; set; }
public bool IsRevoked { get; set; } = false;
[BsonRef("accounts")]
public required Account Account { get; set; }
}
}
+37
View File
@@ -0,0 +1,37 @@
using LiteDB;
using System.Numerics;
using DeluxeBackend.Models;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class Relationship
{
[BsonId]
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Player { get; set; }
[BsonRef("accounts")]
public required Account TargetPlayer { get; set; }
public RelationshipType RelationshipType { get; set; } = RelationshipType.None;
public MuteState Muted { get; set; } = MuteState.None;
public IgnoreState Ignored { get; set; } = IgnoreState.None;
public int Favorited { get; set; } = 0;
public Dictionary<string, object> ToDictionary()
{
return new Dictionary<string, object>
{
["PlayerID"] = TargetPlayer.Id,
["RelationshipType"] = (int)RelationshipType,
["Muted"] = (int)Muted,
["Ignored"] = (int)Ignored,
["Favorited"] = Favorited
};
}
}
}
+73
View File
@@ -0,0 +1,73 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
[Flags]
public enum RoomSupports
{
None = 0,
Screens = 1,
WalkVR = 2,
TeleportVR = 4,
Juniors = 8,
All = Screens | WalkVR | TeleportVR | Juniors
}
public class RoomRole
{
public long AccountId { get; set; }
public RoomRoleType InvitedRole { get; set; } = RoomRoleType.None;
public RoomRoleType Role { get; set; } = RoomRoleType.None;
}
public class RoomStats
{
public List<long> VisitorIds { get; set; } = [];
public List<long> CheeredIds { get; set; } = [];
public List<long> FavoritedIds { get; set; } = [];
public long VisitCount { get; set; } = 0;
}
public class Room
{
[BsonId]
public long Id { get; set; }
public RoomAccessibility Accessibility { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public bool CloningAllowed { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
[BsonRef("accounts")]
public Account Creator { get; set; } = null!;
public string? CustomWarning { get; set; } = string.Empty;
public RoomWarningMask WarningMask { get; set; } = RoomWarningMask.None;
public string DataBlob { get; set; } = string.Empty;
public bool DisableMicAutoMute { get; set; } = false;
public bool DisableRoomComments { get; set; } = false;
public bool EncryptVoiceChat { get; set; } = false;
public string ImageName { get; set; } = "DefaultRoomImage.jpg";
public bool IsDorm { get; set; } = false;
public bool IsRRO { get; set; } = false;
public int MinLevel { get; set; } = 0;
public RoomSupports SupportedPlayerTypes { get; set; } = RoomSupports.All;
public List<RoomRole> Roles { get; set; } = [];
public int? PersistenceVersion { get; set; }
public RoomStats Stats { get; set; } = new RoomStats();
[BsonIgnore]
public bool HasRole(long id, RoomRoleType requiredRole)
{
if (Creator != null && Creator.Id == id)
{
return true;
}
var playerRoleEntry = Roles.FirstOrDefault(r => r.AccountId == id);
RoomRoleType playerRole = playerRoleEntry?.Role ?? RoomRoleType.None;
return (int)playerRole >= (int)requiredRole;
}
}
}
+80
View File
@@ -0,0 +1,80 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class RoomInstance
{
[BsonId]
public long Id { get; set; }
public required string PhotonRegion { get; set; } = "eu";
public required string PhotonRoom { get; set; }
public RoomInstanceType InstanceType { get; set; } = RoomInstanceType.Private;
[BsonRef("subrooms")]
public required SubRoom SubRoom { get; set; }
public long EventId { get; set; } = -1;
public string Name { get; set; } = string.Empty;
public bool Private { get; set; } = true;
public bool GameInProgress { get; set; } = false;
public MatchmakingPolicyType MatchmakingPolicy { get; set; } = MatchmakingPolicyType.Default;
public DateTime CreatedAt { get; set; } = DateTime.MinValue;
[BsonIgnore]
public Dictionary<string, object?> ToDictionary()
{
#pragma warning disable CS8601 // Possible null reference assignment.
Dictionary<string, object?> data = new()
{
["roomInstanceId"] = Id,
["roomId"] = SubRoom.Room.Id,
["subRoomId"] = SubRoom.Id,
["location"] = SubRoom.LocationId,
["roomInstanceType"] = (int)InstanceType,
["maxCapacity"] = SubRoom.MaxPlayers,
["isFull"] = false,
["isPrivate"] = Private,
["isInProgress"] = GameInProgress,
//["voiceServerId"] = "test-voice-5",
//["voiceAuthId"] = "",
["matchmakingPolicy"] = (int)MatchmakingPolicy
};
if (EventId != -1)
{
data["eventId"] = EventId;
}
string roomName = string.IsNullOrWhiteSpace(SubRoom.Room.Name)
? $"UnknownRoom-{SubRoom.Room.Id}"
: SubRoom.Room.Name;
string name = $"^{roomName}";
if (InstanceType == RoomInstanceType.Dormroom)
{
if (SubRoom.Room.Creator != null) {
if (string.IsNullOrEmpty(SubRoom.Room.Creator.Username))
{
name = $"Can't find room creator username :(";
}
else
{
name = $"@{SubRoom.Room.Creator.Username}'s Dorm";
}
}
else
{
name = $"Can't find room creator :(";
}
}
data["name"] = name;
return data;
#pragma warning restore CS8601
}
}
}
+50
View File
@@ -0,0 +1,50 @@
using LiteDB;
using System.Numerics;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class SavedImage
{
public long Id { get; set; }
[BsonRef("accounts")]
public required Account Player { get; set; }
public List<ulong> PlayerIds { get; set; } = new List<ulong>();
public string ImageName { get; set; } = string.Empty;
public long? RoomId { get; set; } = null;
public SavedImageType SavedImageType { get; set; } = SavedImageType.None;
public SavedImageAccessibility Accessibility { get; set; } = SavedImageAccessibility.Private;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public Dictionary<string, object> ToDictionary()
{
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>
{
["SavedImageId"] = Id,
["SavedImageType"] = (int)SavedImageType,
["Accessibility"] = (int)Accessibility,
["AccessibilityLocked"] = false,
["ImageName"] = ImageName,
["Description"] = "",
["PlayerId"] = Player.Id,
["TaggedPlayerIds"] = PlayerIds,
["CreatedAt"] = CreatedAt.ToString("O"),
["CheerCount"] = 0,
["CommentCount"] = 0
};
if (RoomId.HasValue)
{
keyValuePairs["RoomId"] = RoomId.Value;
}
return keyValuePairs;
}
}
}
+63
View File
@@ -0,0 +1,63 @@
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
}
}
}
+49
View File
@@ -0,0 +1,49 @@
using LiteDB;
using System.Xml.Linq;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class SubRoomSave
{
[BsonId]
public long Id { get; set; }
public required long SubRoomId { get; set; }
public required string DataBlob { get; set; }
public long? SavedByAccountId { get; set; } = null;
public PlatformType? SavedOnPlatform { get; set; } = null;
public DeviceClassType? SavedOnDeviceClass { get; set; } = null;
public string? Description { get; set; } = null;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public string? UnityAssetId { get; set; } = null;
public int PersistenceVersion { get; set; } = 0;
//UnityAssetId
[BsonIgnore]
public Dictionary<string, object> ToDictionary()
{
#pragma warning disable CS8601 // Possible null reference assignment.
Dictionary<string, object> data = new()
{
["SubRoomDataSaveId"] = Id,
["SubRoomId"] = SubRoomId,
["DataBlob"] = DataBlob,
["OMVersion"] = 0,
["PersistenceVersion"] = PersistenceVersion,
["SavedByAccountId"] = SavedByAccountId,
["SavedOnPlatform"] = SavedOnPlatform,
["SavedOnDeviceClass"] = SavedOnDeviceClass,
["Description"] = Description,
["CreatedAt"] = CreatedAt.ToString("O"),
["UnityAssetId"] = UnityAssetId
};
return data;
#pragma warning restore CS8601
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using LiteDB;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Models
{
public class UnityAsset
{
public required AssetBundleType Target { get; set; }
public required AssetBundleVersion Version { get; set; }
public required string Filename { get; set; }
}
public class UnityAssets
{
[BsonId]
public Guid Id { get; set; }
public List<UnityAsset> Assets { get; set; } = [];
}
}