public static void UpdateColor(IConnectedPlayer connectedPlayer, ILobbyPlayerDataModel playerDataModel, GameServerPlayerTableCell __instance) { Image background = __instance.GetField <Image>("_localPlayerBackgroundImage"); if (playerDataModel.beatmapLevel != null) { background.enabled = true; PreviewBeatmapManager.GetPopulatedPreview(playerDataModel.beatmapLevel.levelID).ContinueWith(r => { PreviewBeatmapStub preview = r.Result; float transparency = connectedPlayer.isMe ? 0.4f : 0.1f; Color color = connectedPlayer.HasState("bmlocal") ? green : connectedPlayer.HasState("bmcloud") ? yellow : red; color.a = transparency; HMMainThreadDispatcher.instance.Enqueue(() => { background.color = color; }); }); } else { background.color = normal; } }
public override void HandleMenuRpcManagerSelectedBeatmap(string userId, BeatmapIdentifierNetSerializable beatmapId) { if (beatmapId != null) { string?hash = Utilities.Utils.LevelIdToHash(beatmapId.levelID); if (hash != null) { Plugin.Log?.Debug($"'{userId}' selected song '{hash}'."); BeatmapCharacteristicSO characteristic = _beatmapCharacteristicCollection.GetBeatmapCharacteristicBySerializedName(beatmapId.beatmapCharacteristicSerializedName); PreviewBeatmapManager.GetPopulatedPreview(beatmapId.levelID).ContinueWith(r => { PreviewBeatmapStub preview = r.Result; Plugin.Log?.Info($"user: {userId} | hostuser: {base.hostUserId}"); Plugin.Log?.Info($"local: {preview.isDownloaded} | cloud: {preview.isDownloadable}"); if (userId == base.hostUserId) { _sessionManager.SetLocalPlayerState("bmlocal", preview.isDownloaded); _sessionManager.SetLocalPlayerState("bmcloud", preview.isDownloadable); } HMMainThreadDispatcher.instance.Enqueue(() => { base.SetPlayerBeatmapLevel(userId, preview, beatmapId.difficulty, characteristic); }); }); return; } } base.HandleMenuRpcManagerSelectedBeatmap(userId, beatmapId); }
public new void SetLocalPlayerBeatmapLevel(string levelId, BeatmapDifficulty beatmapDifficulty, BeatmapCharacteristicSO characteristic) { string?hash = Utilities.Utils.LevelIdToHash(levelId); if (hash != null) { Plugin.Log?.Debug($"Local user selected song '{hash}'."); PreviewBeatmapManager.GetPopulatedPreview(levelId).ContinueWith(r => { PreviewBeatmapStub preview = r.Result; Plugin.Log?.Info($"localuser: {base.localUserId} | hostuser: {base.hostUserId}"); Plugin.Log?.Info($"local: {preview.isDownloaded} | cloud: {preview.isDownloadable}"); if (base.localUserId == base.hostUserId) { _sessionManager.SetLocalPlayerState("bmlocal", preview.isDownloaded); _sessionManager.SetLocalPlayerState("bmcloud", preview.isDownloadable); } HMMainThreadDispatcher.instance.Enqueue(() => { SendPreviewBeatmapPacket(preview, characteristic.serializedName, beatmapDifficulty); _menuRpcManager.SelectBeatmap(new BeatmapIdentifierNetSerializable(levelId, characteristic.serializedName, beatmapDifficulty)); base.SetPlayerBeatmapLevel(base.localUserId, preview, beatmapDifficulty, characteristic); }); }); return; } base.SetLocalPlayerBeatmapLevel(levelId, beatmapDifficulty, characteristic); }
public void HandlePreviewBeatmapPacket(PreviewBeatmapPacket packet, ExtendedPlayer player) { if (Utilities.Utils.LevelIdToHash(packet.levelId) != null) { PreviewBeatmapStub preview = PreviewBeatmapManager.GetPreview(packet); if (!preview.isDownloaded) { BeatmapCharacteristicSO?characteristic = _beatmapCharacteristicCollection.GetBeatmapCharacteristicBySerializedName(packet.characteristic); HMMainThreadDispatcher.instance.Enqueue(() => { base.SetPlayerBeatmapLevel(player.userId, preview, packet.difficulty, characteristic); }); } } }