forked from zombieb/undead-universal-patch-il2cpp
INTERNAL REWRITE! server configs
This commit is contained in:
64
Core/CustomRecNet/CustomEmotes/RecNetEmotes.cs
Normal file
64
Core/CustomRecNet/CustomEmotes/RecNetEmotes.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Mapster;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Core.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 EmoteConfig
|
||||
{
|
||||
public static void Patch(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");
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomEmotes : MonoBehaviour
|
||||
{
|
||||
private static readonly ConcurrentQueue<Action> mainThreadQueue = new ConcurrentQueue<Action>();
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (ServerPatchesConfig.CustomEmotes.Value)
|
||||
RecNetInteractions.postAuthenticationActions.Add(DownloadCustomEmotes);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
while (mainThreadQueue.TryDequeue(out var action))
|
||||
{
|
||||
try { action(); }
|
||||
catch (Exception ex) { UniversalPatchPlugin.Log.LogError(ex); }
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadCustomEmotes()
|
||||
{
|
||||
RecNetInteractions.SendRequest<List<EmoteConfigDTO>>(BestHTTP.HTTPMethods.Get, RecNet.Service.API, "/api/undead/v1/emotes", EmoteConfig.Patch);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user