Apply skin to the vote avatar in multiplayer
This commit is contained in:
parent
a145e22fce
commit
4371b20c87
1 changed files with 38 additions and 0 deletions
38
Patches/VoteAvatarPatches.cs
Normal file
38
Patches/VoteAvatarPatches.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue