using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using UnityEngine;
using ffxocmodels.Scripts;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("45x OC Models")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("45x OC Models")]
[assembly: AssemblyTitle("45x OC Models")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace ffxocmodels
{
public class BodyReplacements
{
public static void InitBodyReplacements()
{
ModelReplacementAPI.RegisterSuitModelReplacement("Eve", typeof(EveModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Eve [Casual Alt]", typeof(EveAltModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Eve [Casual Skirt]", typeof(EveCasualSkirtModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Eve [Cyber]", typeof(EveCyberModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Lilium", typeof(LiliumModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Lilium [Uniform]", typeof(LiliumUniformModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Kiryuu Rumi", typeof(KiryuuRumiModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Kiryuu Rumi [Casual]", typeof(KiryuuRumiCasualModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Kiryuu Rumi [Suit]", typeof(KiryuuRumiSuitModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Kiryuu Rumi [Maid]", typeof(KiryuuRumiMaidModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Kiryuu Rumi [Farmer]", typeof(KiryuuRumiFarmerModel));
ModelReplacementAPI.RegisterSuitModelReplacement("Willow", typeof(WillowModel));
}
public static void AddKKModelScripts(BodyReplacementBase bodyReplacementBase, float blinkOverride = -1f)
{
GameObject gameObject = ((Component)bodyReplacementBase.replacementModel.transform.Find("Body")).gameObject;
LipSync lipSync = gameObject.AddComponent<LipSync>();
lipSync.player = bodyReplacementBase.controller;
lipSync.Init();
Blinking blinking = gameObject.AddComponent<Blinking>();
blinking.player = bodyReplacementBase.controller;
if (blinkOverride != -1f)
{
blinking.closedValue = blinkOverride;
}
blinking.Init();
}
}
public class EveModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.EveBundle.LoadAsset<GameObject>("Eve");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this);
}
}
public class EveAltModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.EveBundle.LoadAsset<GameObject>("Eve [Alt]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this);
}
}
public class EveCasualSkirtModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.EveBundle.LoadAsset<GameObject>("Eve [Casual Skirt]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this);
}
}
public class EveCyberModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.EveBundle.LoadAsset<GameObject>("Eve [Cyber]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this);
}
}
public class LiliumModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.LiliumBundle.LoadAsset<GameObject>("Lilium");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 64.5f);
}
}
public class LiliumUniformModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.LiliumBundle.LoadAsset<GameObject>("Lilium [Uniform]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 64.5f);
}
}
public class KiryuuRumiModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Kiryuu Rumi");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public class KiryuuRumiCasualModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Kiryuu Rumi [Casual]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public class KiryuuRumiSuitModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Kiryuu Rumi [Suit]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public class KiryuuRumiMaidModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Kiryuu Rumi [Maid]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public class KiryuuRumiFarmerModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Kiryuu Rumi [Farmer]");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public class WillowModel : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.KiryuuBundle.LoadAsset<GameObject>("Willow");
}
protected override void AddModelScripts()
{
BodyReplacements.AddKKModelScripts((BodyReplacementBase)(object)this, 75.5f);
}
}
public static class Assets
{
public static AssetBundle? EveBundle;
public static AssetBundle? LiliumBundle;
public static AssetBundle? KiryuuBundle;
private static string GetAssemblyName()
{
return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
}
public static void PopulateAssets()
{
EveBundle = LoadAssetBundle("evebundle");
LiliumBundle = LoadAssetBundle("liliumbundle");
KiryuuBundle = LoadAssetBundle("kiryuubundle");
}
private static AssetBundle LoadAssetBundle(string AssetBundleName)
{
AssetBundle result = null;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + ".AssetBundles." + AssetBundleName))
{
result = AssetBundle.LoadFromStream(stream);
}
return result;
}
}
[BepInPlugin("dev.45x.45xocmodels", "45x OC Models", "2.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FFXOCModels : BaseUnityPlugin
{
public static ManualLogSource PluginLogger = Logger.CreateLogSource("dev.45x.45xocmodels");
private readonly Harmony harmony = new Harmony("dev.45x.45xocmodels");
private void Awake()
{
PluginLogger.LogInfo((object)"Loading Plugin: dev.45x.45xocmodels");
Stopwatch stopwatch = Stopwatch.StartNew();
Assets.PopulateAssets();
BodyReplacements.InitBodyReplacements();
harmony.PatchAll();
stopwatch.Stop();
PluginLogger.LogInfo((object)string.Format("Plugin {0} is loaded! Took {1}ms", "dev.45x.45xocmodels", stopwatch.ElapsedMilliseconds));
}
}
}
namespace ffxocmodels.Scripts
{
public class Blinking : MonoBehaviour
{
public PlayerControllerB player;
public SkinnedMeshRenderer SkinnedMeshRenderer;
public int BlendShapeIndex = -1;
public float closedValue = 50.1f;
public float openValue = 0f;
public int minDelay = 3;
public int maxDelay = 10;
public void Init()
{
if ((Object)(object)SkinnedMeshRenderer == (Object)null)
{
((Component)this).TryGetComponent<SkinnedMeshRenderer>(ref SkinnedMeshRenderer);
BlendShapeIndex = SkinnedMeshRenderer.sharedMesh.GetBlendShapeIndex("KK Eyes_default_cl");
}
if ((Object)(object)SkinnedMeshRenderer != (Object)null && BlendShapeIndex != -1)
{
Task.Factory.StartNew(delegate
{
Blink(1);
});
}
}
private void Blink(int delay)
{
Thread.Sleep(delay * 1000);
if (player.isPlayerDead)
{
SkinnedMeshRenderer.SetBlendShapeWeight(BlendShapeIndex, closedValue);
Blink(1);
}
else
{
CloseEyes();
OpenEyes();
Blink(Random.Range(minDelay, maxDelay));
}
}
private void CloseEyes()
{
for (float num = 0f; num < closedValue; num += 1f)
{
SkinnedMeshRenderer.SetBlendShapeWeight(BlendShapeIndex, num);
Thread.Sleep(3);
}
}
private void OpenEyes()
{
for (float num = closedValue; num > openValue; num -= 1f)
{
SkinnedMeshRenderer.SetBlendShapeWeight(BlendShapeIndex, num);
Thread.Sleep(3);
}
}
}
public class LipSync : MonoBehaviour
{
public SkinnedMeshRenderer SkinnedMeshRenderer;
public int BlendShapeIndex = -1;
public PlayerControllerB player;
public float closedValue = 0f;
public float openValue = 100f;
protected VoicePlayerState voice;
private void Start()
{
}
private void Update()
{
if (!((Object)(object)StartOfRound.Instance.voiceChatModule == (Object)null) && voice != null && !((Object)(object)SkinnedMeshRenderer == (Object)null) && BlendShapeIndex != -1)
{
float num = closedValue;
if (voice.IsSpeaking && !player.isPlayerDead)
{
num = Mathf.Clamp(voice.Amplitude * 1000f, closedValue, openValue);
}
SkinnedMeshRenderer.SetBlendShapeWeight(BlendShapeIndex, num);
}
}
public void Init()
{
StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
voice = player.voicePlayerState;
if (voice == null && (Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController)
{
voice = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName);
}
if ((Object)(object)SkinnedMeshRenderer == (Object)null)
{
((Component)this).TryGetComponent<SkinnedMeshRenderer>(ref SkinnedMeshRenderer);
BlendShapeIndex = SkinnedMeshRenderer.sharedMesh.GetBlendShapeIndex("KK Mouth_default_op");
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}