mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using RadicadeServer.RecNet.Enums.Players;
|
||||
using RadicadeServer.RecNet.Enums.Rooms;
|
||||
using RadicadeServer.RecNet.Rooms;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RadicadeServer.DB;
|
||||
|
||||
namespace RadicadeServer.RecNet.Accounts
|
||||
{
|
||||
public class Presence
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public long playerId { get; set; }
|
||||
public bool isOnline { get; set; }
|
||||
public DeviceClass deviceClass { get; set; }
|
||||
public StatusVisibility statusVisibility { get; set; }
|
||||
public VRMovementModes vRMovementMode { get; set; }
|
||||
public JoinStatus errorCode { get; set; }
|
||||
public RoomInstance? roomInstance { get; set; }
|
||||
public string appVersion { get; set; } = DBConfig.GameVersion;
|
||||
|
||||
public Presence ForViewer(long? viewerId)
|
||||
{
|
||||
if (viewerId != playerId && (!isOnline || statusVisibility == StatusVisibility.Offline))
|
||||
{
|
||||
isOnline = false;
|
||||
roomInstance = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public static async Task<Presence> CreateAsync(RecDBContext db, RealPresence presence, RoomInstance? instance)
|
||||
{
|
||||
var version = await db.Players.Where(player => player.AccountId == presence.playerId)
|
||||
.Select(player => player.AppVersion).FirstOrDefaultAsync();
|
||||
return new Presence(presence, instance)
|
||||
{
|
||||
appVersion = string.IsNullOrWhiteSpace(version) ? DBConfig.GameVersion : version
|
||||
};
|
||||
}
|
||||
|
||||
public Presence(RealPresence presence, RoomInstance? instance)
|
||||
{
|
||||
this.playerId = presence.playerId;
|
||||
this.deviceClass = presence.deviceClass;
|
||||
this.isOnline = presence.isOnline;
|
||||
this.statusVisibility = presence.statusVisibility;
|
||||
|
||||
if (instance != null)
|
||||
{
|
||||
instance.eventId ??= 0;
|
||||
instance.clubId ??= 0;
|
||||
instance.roomCode ??= string.Empty;
|
||||
instance.location ??= string.Empty;
|
||||
}
|
||||
|
||||
this.roomInstance = instance;
|
||||
this.vRMovementMode = presence.vRMovementMode;
|
||||
this.errorCode = presence.errorCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user