Internals rewritten. PHoton config can now be fetched from the server, and if it fails, fallback to the local configuration.
This commit is contained in:
51
Core/Content/CustomRecNet/CustomEmotes/RecNetEmotes.cs
Normal file
51
Core/Content/CustomRecNet/CustomEmotes/RecNetEmotes.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Mapster;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BestHTTP;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Core.Content.CustomRecNet.CustomEmotes;
|
||||
|
||||
public class EmoteConfigDTO
|
||||
{
|
||||
public string UniqueName { get; set; }
|
||||
public string NewText { get; set; }
|
||||
public string RoomChatText { get; set; }
|
||||
public string FacialExpression { get; set; }
|
||||
public bool ForceEmoteBubble { get; set; }
|
||||
public bool OnlyBroadcastToTeam { get; set; }
|
||||
}
|
||||
|
||||
public class CustomEmotes : MonoBehaviour
|
||||
{
|
||||
|
||||
public void Start()
|
||||
{
|
||||
RecNetInteractions.postLocalAccountActions.Add(DownloadCustomEmotes);
|
||||
}
|
||||
|
||||
void Patch(HTTPResponse _res, List<EmoteConfigDTO> emotes)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogInfo("Setting new emotes");
|
||||
|
||||
var internalEmotes = RecRoom.AGUI.Expresso.ContextualEmotesSettings.ConfigAsset.Emotes.ToList();
|
||||
foreach (var emote in emotes)
|
||||
{
|
||||
var internalEmote = internalEmotes.Find(match => match.emoteUniqueName == emote.UniqueName);
|
||||
if (internalEmote != null)
|
||||
{
|
||||
emote.Adapt(internalEmote);
|
||||
}
|
||||
}
|
||||
|
||||
Util.ConditionalDebug($"{emotes.Count} new emote configurations");
|
||||
}
|
||||
|
||||
void DownloadCustomEmotes()
|
||||
{
|
||||
RecNetInteractions.SendRequest<List<EmoteConfigDTO>>(HTTPMethods.Get, RecNet.Service.API, "/api/undead/v1/emotes", Patch);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user