using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Missions.BrotherEncounter;
using HG;
using On.EntityStates.Missions.BrotherEncounter;
using On.RoR2;
using On.RoR2.SurvivorMannequins;
using RoR2;
using RoR2.Audio;
using RoR2.SurvivorMannequins;
using UnityEngine;
using UnityEngine.Networking;
[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: AssemblyCompany("BaseVoiceoverLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+caa45317c2aae59b105224191b40df3f9b83d777")]
[assembly: AssemblyProduct("BaseVoiceoverLib")]
[assembly: AssemblyTitle("BaseVoiceoverLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace R2API.Utils
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ManualNetworkRegistrationAttribute : Attribute
{
}
}
namespace BaseVoiceoverLib
{
public class BaseVoiceoverComponent : MonoBehaviour
{
private static class Hooks
{
public static void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
{
int successfulPurchaseCount = self.successfulPurchaseCount;
orig.Invoke(self, activator);
if (!NetworkServer.active || !Object.op_Implicit((Object)(object)activator))
{
return;
}
BaseVoiceoverComponent component = ((Component)activator).GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
if (self.successfulPurchaseCount == successfulPurchaseCount)
{
component.PlayShrineOfChanceFailServer();
}
else
{
component.PlayShrineOfChanceSuccessServer();
}
}
}
public static void CharacterMotor_Jump(orig_Jump orig, CharacterMotor self, float horizontalMultiplier, float verticalMultiplier, bool vault)
{
orig.Invoke(self, horizontalMultiplier, verticalMultiplier, vault);
if (Object.op_Implicit((Object)(object)self))
{
BaseVoiceoverComponent component = ((Component)self).GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.PlayJump();
}
}
}
public static void ChargingState_OnEnter(orig_OnEnter orig, BaseState self)
{
orig.Invoke(self);
foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
{
if (!Object.op_Implicit((Object)(object)readOnlyInstances))
{
continue;
}
GameObject bodyObject = readOnlyInstances.GetBodyObject();
if (Object.op_Implicit((Object)(object)bodyObject))
{
BaseVoiceoverComponent component = bodyObject.GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.PlayTeleporterStart();
}
}
}
}
public static void ChargedState_OnEnter(orig_OnEnter orig, BaseState self)
{
orig.Invoke(self);
foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
{
if (!Object.op_Implicit((Object)(object)readOnlyInstances))
{
continue;
}
GameObject bodyObject = readOnlyInstances.GetBodyObject();
if (Object.op_Implicit((Object)(object)bodyObject))
{
BaseVoiceoverComponent component = bodyObject.GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.PlayTeleporterFinish();
}
}
}
}
public static void EncounterFinished_OnEnter(orig_OnEnter orig, EncounterFinished self)
{
orig.Invoke(self);
foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
{
if (!Object.op_Implicit((Object)(object)readOnlyInstances))
{
continue;
}
GameObject bodyObject = readOnlyInstances.GetBodyObject();
if (Object.op_Implicit((Object)(object)bodyObject))
{
BaseVoiceoverComponent component = bodyObject.GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.PlayVictory();
}
}
}
}
public static void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
orig.Invoke(self, damageInfo);
if (damageInfo.rejected)
{
BaseVoiceoverComponent component = ((Component)self).GetComponent<BaseVoiceoverComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.PlayDamageBlockedServer();
}
}
}
}
public static ItemIndex scepterIndex;
protected bool playedSpawnVoiceline = false;
protected float voiceCooldown = 0f;
protected float spawnVoicelineDelay = 0f;
protected CharacterBody body;
protected Inventory inventory;
protected SkillLocator skillLocator;
protected HealthComponent healthComponent;
protected NetworkStateMachine networker;
private bool playedDeathSound = false;
private float prevHP = 0f;
private int prevLevel = 0;
private bool addedInventoryHook = false;
private static bool initializedHooks;
public static void Init()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
if (!initializedHooks)
{
initializedHooks = true;
CharacterMotor.Jump += new hook_Jump(Hooks.CharacterMotor_Jump);
ChargingState.OnEnter += new hook_OnEnter(Hooks.ChargingState_OnEnter);
ChargedState.OnEnter += new hook_OnEnter(Hooks.ChargedState_OnEnter);
HealthComponent.TakeDamage += new hook_TakeDamage(Hooks.HealthComponent_TakeDamage);
EncounterFinished.OnEnter += new hook_OnEnter(Hooks.EncounterFinished_OnEnter);
ShrineChanceBehavior.AddShrineStack += new hook_AddShrineStack(Hooks.ShrineChanceBehavior_AddShrineStack);
}
}
public bool TryPlayNetworkSound(string soundName, float cooldown, bool forcePlay)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
NetworkSoundEventIndex networkSoundIndex = NetworkSoundEventCatalog.FindNetworkSoundEventIndex(soundName);
return TryPlayNetworkSound(networkSoundIndex, cooldown, forcePlay);
}
public bool TryPlayNetworkSound(NetworkSoundEventDef nse, float cooldown, bool forcePlay)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return TryPlayNetworkSound(nse.index, cooldown, forcePlay);
}
public bool TryPlayNetworkSound(NetworkSoundEventIndex networkSoundIndex, float cooldown, bool forcePlay)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
bool result = false;
if (ComponentEnableVoicelines() && (CanPlayVoiceline() || forcePlay))
{
if (NetworkServer.active)
{
EntitySoundManager.EmitSoundServer(networkSoundIndex, ((Component)this).gameObject);
}
else
{
EffectManager.SimpleSoundEffect(networkSoundIndex, ((Component)this).gameObject.transform.position, true);
}
result = true;
SetVoiceCooldown(cooldown);
}
return result;
}
public bool TryPlaySound(string soundName, float cooldown, bool forcePlay)
{
bool result = false;
if (ComponentEnableVoicelines() && (CanPlayVoiceline() || forcePlay))
{
Util.PlaySound(soundName, ((Component)this).gameObject);
result = true;
SetVoiceCooldown(cooldown);
}
return result;
}
public bool isAuthority()
{
return Object.op_Implicit((Object)(object)networker) && ((NetworkBehaviour)networker).hasAuthority;
}
protected virtual void Awake()
{
body = ((Component)this).GetComponent<CharacterBody>();
skillLocator = ((Component)this).GetComponent<SkillLocator>();
healthComponent = ((Component)this).GetComponent<HealthComponent>();
networker = ((Component)this).GetComponent<NetworkStateMachine>();
if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)skillLocator))
{
body.onSkillActivatedAuthority += Body_onSkillActivatedAuthority;
}
SetSpawnVoicelineDelay();
}
protected virtual void SetSpawnVoicelineDelay()
{
spawnVoicelineDelay = 3f;
if (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.stageClearCount == 0)
{
spawnVoicelineDelay = 6.5f;
}
voiceCooldown = spawnVoicelineDelay;
}
protected virtual void Start()
{
if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inventory))
{
inventory = body.inventory;
inventory.onItemAddedClient += Inventory_onItemAddedClient;
addedInventoryHook = true;
}
}
protected virtual void OnDestroy()
{
if (addedInventoryHook && Object.op_Implicit((Object)(object)inventory))
{
inventory.onItemAddedClient -= Inventory_onItemAddedClient;
}
}
protected virtual void Inventory_onItemAddedClient(ItemIndex itemIndex)
{
}
protected virtual void Body_onSkillActivatedAuthority(GenericSkill skill)
{
if ((Object)(object)skill == (Object)(object)skillLocator.primary)
{
PlayPrimaryAuthority(skillLocator.primary);
}
else if ((Object)(object)skill == (Object)(object)skillLocator.secondary)
{
PlaySecondaryAuthority(skillLocator.secondary);
}
else if ((Object)(object)skill == (Object)(object)skillLocator.utility)
{
PlayUtilityAuthority(skillLocator.utility);
}
else if ((Object)(object)skill == (Object)(object)skillLocator.special)
{
PlaySpecialAuthority(skillLocator.special);
}
}
protected virtual void FixedUpdate()
{
if (voiceCooldown > 0f)
{
voiceCooldown -= Time.fixedDeltaTime;
if (voiceCooldown < 0f)
{
voiceCooldown = 0f;
}
}
if (!playedSpawnVoiceline)
{
if (spawnVoicelineDelay > 0f)
{
spawnVoicelineDelay -= Time.fixedDeltaTime;
}
if (spawnVoicelineDelay <= 0f)
{
playedSpawnVoiceline = true;
PlaySpawn();
}
}
FixedUpdateHealth();
FixedUpdateBody();
}
protected virtual void Update()
{
if (isAuthority())
{
CheckInputs();
}
}
protected virtual void CheckInputs()
{
}
protected virtual void FixedUpdateHealth()
{
if (!Object.op_Implicit((Object)(object)healthComponent))
{
return;
}
if (!healthComponent.alive && !playedDeathSound)
{
playedDeathSound = true;
PlayDeath();
}
float health = healthComponent.health;
if (healthComponent.combinedHealthFraction <= 0.25f)
{
PlayLowHealth();
return;
}
if (health < prevHP)
{
PlayHurt((prevHP - health) / healthComponent.fullHealth);
}
prevHP = health;
}
protected virtual void FixedUpdateBody()
{
if (Object.op_Implicit((Object)(object)body))
{
int num = Mathf.FloorToInt(body.level);
if (num > prevLevel && prevLevel != 0)
{
PlayLevelUp();
}
prevLevel = num;
}
}
public bool CanPlayVoiceline()
{
return voiceCooldown <= 0f && (!Object.op_Implicit((Object)(object)healthComponent) || healthComponent.alive);
}
public void SetVoiceCooldown(float newCooldown)
{
if (voiceCooldown < newCooldown)
{
voiceCooldown = newCooldown;
}
}
public virtual bool ComponentEnableVoicelines()
{
return true;
}
public virtual void PlaySpawn()
{
}
public virtual void PlayPrimaryAuthority(GenericSkill skill)
{
}
public virtual void PlaySecondaryAuthority(GenericSkill skill)
{
}
public virtual void PlayUtilityAuthority(GenericSkill skill)
{
}
public virtual void PlaySpecialAuthority(GenericSkill skill)
{
}
public virtual void PlayDamageBlockedServer()
{
}
public virtual void PlayShrineOfChanceSuccessServer()
{
}
public virtual void PlayShrineOfChanceFailServer()
{
}
public virtual void PlayHurt(float percentHPLost)
{
}
public virtual void PlayJump()
{
}
public virtual void PlayDeath()
{
}
public virtual void PlayTeleporterStart()
{
}
public virtual void PlayTeleporterFinish()
{
}
public virtual void PlayVictory()
{
}
public virtual void PlayLowHealth()
{
}
public virtual void PlayLevelUp()
{
}
public virtual void PlayLobby()
{
}
}
[BepInPlugin("com.Moffein.BaseVoiceoverLib", "BaseVoiceoverLib", "1.1.5")]
public class BaseVoiceoverLibPlugin : BaseUnityPlugin
{
public void Awake()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
BaseVoiceoverComponent.Init();
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
CharacterBody.Start += new hook_Start(AttachVoiceoverComponent);
SurvivorMannequinSlotController.RebuildMannequinInstance += new hook_RebuildMannequinInstance(LobbyVoicelines);
}
private void LobbyVoicelines(orig_RebuildMannequinInstance orig, SurvivorMannequinSlotController self)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!Object.op_Implicit((Object)(object)self) || !Object.op_Implicit((Object)(object)self.currentSurvivorDef) || !Object.op_Implicit((Object)(object)self.networkUser))
{
return;
}
foreach (VoiceoverInfo voiceover in VoiceoverInfo.voiceoverList)
{
if (self.currentSurvivorDef.survivorIndex == SurvivorCatalog.GetSurvivorIndexFromBodyIndex(voiceover.bodyIndex))
{
if (self.loadoutDirty && Object.op_Implicit((Object)(object)self.networkUser))
{
self.networkUser.networkLoadout.CopyLoadout(self.currentLoadout);
}
BodyIndex bodyIndexFromSurvivorIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(self.currentSurvivorDef.survivorIndex);
int skinIndex = (int)self.currentLoadout.bodyLoadoutManager.GetSkinIndex(bodyIndexFromSurvivorIndex);
SkinDef safe = ArrayUtils.GetSafe<SkinDef>(BodyCatalog.GetBodySkins(bodyIndexFromSurvivorIndex), skinIndex);
if (voiceover.validSkins.Contains(safe))
{
voiceover.selectActions?.Invoke(((Component)self.mannequinInstanceTransform).gameObject);
break;
}
}
}
}
private void OnLoad()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
BaseVoiceoverComponent.scepterIndex = ItemCatalog.FindItemIndex("ITEM_ANCIENT_SCEPTER");
VoiceoverInfo.ValidateVoiceoverList();
}
private void AttachVoiceoverComponent(orig_Start orig, CharacterBody self)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!Object.op_Implicit((Object)(object)self))
{
return;
}
foreach (VoiceoverInfo voiceover in VoiceoverInfo.voiceoverList)
{
if (self.bodyIndex == voiceover.bodyIndex && voiceover.validSkins.Contains(SkinCatalog.GetBodySkinDef(self.bodyIndex, (int)self.skinIndex)))
{
BaseVoiceoverComponent component = ((Component)self).GetComponent<BaseVoiceoverComponent>();
if (!Object.op_Implicit((Object)(object)component))
{
((Component)self).gameObject.AddComponent(voiceover.type);
}
break;
}
}
}
}
public class Utils
{
public static bool GetKeyPressed(ConfigEntry<KeyboardShortcut> entry)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = entry.Value;
foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
{
if (!Input.GetKey(modifier))
{
return false;
}
}
value = entry.Value;
return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey);
}
}
public class VoiceoverInfo
{
public delegate void LobbySelectActions(GameObject mannequinObject);
public static List<VoiceoverInfo> voiceoverList = new List<VoiceoverInfo>();
public LobbySelectActions selectActions;
public Type type;
public List<SkinDef> validSkins;
public BodyIndex bodyIndex = (BodyIndex)(-1);
public string bodyName;
public static void ValidateVoiceoverList()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
foreach (VoiceoverInfo voiceover in voiceoverList)
{
voiceover.bodyIndex = BodyCatalog.FindBodyIndex(voiceover.bodyName);
}
}
public VoiceoverInfo(Type type, SkinDef skinDef, string bodyName)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if (typeof(BaseVoiceoverComponent).IsAssignableFrom(type))
{
this.type = type;
}
else
{
Debug.LogError((object)"Created VoiceoverInfo with a type that isn't assignable from BaseVoiceoverComponent.");
}
validSkins = new List<SkinDef>();
validSkins.Add(skinDef);
bodyIndex = BodyCatalog.FindBodyIndex(bodyName);
this.bodyName = bodyName;
voiceoverList.Add(this);
}
public VoiceoverInfo(Type type, List<SkinDef> validSkinsList, string bodyName)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (typeof(BaseVoiceoverComponent).IsAssignableFrom(type))
{
this.type = type;
}
else
{
Debug.LogError((object)"Created VoiceoverInfo with a type that isn't assignable from BaseVoiceoverComponent.");
}
validSkins = validSkinsList;
bodyIndex = BodyCatalog.FindBodyIndex(bodyName);
this.bodyName = bodyName;
voiceoverList.Add(this);
}
}
}