miuu-custom-cosmetic-loader/Patches/VoteAvatarPatches.cs

38 lines
932 B
C#

using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace CustomCosmeticLoader.Patches
{
/*
* Since the Setup method already uses the hijacked skin pulled from the marble, we just need to apply the custom
* texture after the fact
*/
[HarmonyPatch(typeof(VoteAvatar), nameof(VoteAvatar.Setup))]
internal class VoteAvatarSetupPatch
{
static void Postfix(VoteAvatar __instance, MarbleController marble)
{
if (!Config.enabled)
return;
Texture2D skin = null;
if (marble.isMyClientMarble())
{
skin = Config.skins[Config.currentSkin];
}
else
{
if (Config.otherPlayers.ContainsKey(marble.nickname))
skin = Config.skins[Config.otherPlayers[marble.nickname]];
}
if (skin != null)
Shared.ApplyCustomTexture(__instance.widget.cosmeticDisplay.gameObject, skin);
}
}
}