using System;
using System.Collections;
using System.Collections.Generic;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[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: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Eggs")]
[assembly: AssemblyTitle("Eggs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Omni.WalkieTalkie
{
[BepInPlugin("omni.repo.walkietalkie", "Omni Walkie-Talkie", "1.2.0")]
public class WalkieTalkiePlugin : BaseUnityPlugin
{
[HarmonyPatch]
internal static class Patch_AttachController
{
[HarmonyPatch(typeof(PlayerVoiceChat), "Awake")]
[HarmonyPostfix]
private static void Postfix(PlayerVoiceChat __instance)
{
WalkieController walkieController = default(WalkieController);
if (!((Component)__instance).gameObject.TryGetComponent<WalkieController>(ref walkieController))
{
((Component)__instance).gameObject.AddComponent<WalkieController>();
}
}
}
[HarmonyPatch(typeof(PlayerAvatarRightArm), "Update")]
internal static class Patch_RightArmPose
{
private static bool Prefix(PlayerAvatarRightArm __instance)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
try
{
if (WalkieController.PlayersTalking.Contains(__instance.playerAvatar.photonView.ViewID))
{
__instance.SetPose(WalkieController.WalkiePose);
__instance.HeadAnimate(false);
__instance.AnimatePose();
return false;
}
}
catch
{
}
return true;
}
}
public class WalkieController : MonoBehaviourPun
{
[CompilerGenerated]
private sealed class <StopTalkingAfter>d__37 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float delay;
public WalkieController <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StopTalkingAfter>d__37(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this._canToggle = false;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((MonoBehaviourPun)<>4__this).photonView.RPC("RPC_SetVoiceRangeAndFilters", (RpcTarget)0, new object[2] { 25, false });
if ((Object)(object)<>4__this._talkieLocal != (Object)null)
{
<>4__this._talkieLocal.SetActive(false);
}
<>4__this._canToggle = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static readonly HashSet<int> PlayersTalking = new HashSet<int>();
public static readonly Vector3 WalkiePose = new Vector3(0f, -30f, 0f);
private const string BundleBase = "walky";
private const string PrefabName = "Talky";
private const string SfxOnName = "OnSound";
private const string SfxOffName = "OffSound";
private const string SfxIdleName = "IdleOnSound";
private static readonly Vector3 TalkiePos = new Vector3(-0.1f, -0.05f, 0.3f);
private static readonly Quaternion TalkieRotation = Quaternion.Euler(350f, 179f, 45f);
private static readonly Vector3 RemoteTalkiePos = new Vector3(-0.15f, -0.25f, 0.65f);
private static readonly Quaternion RemoteTalkieRotation = Quaternion.Euler(15f, 215f, 345f);
private bool _bootstrapped;
private PlayerAvatar _localAvatar;
private float _maxBattery;
private float _battery;
private bool _recharge;
private float _rechargeRatePerSec;
private bool _enemiesHear;
private KeyCode _pushKey = (KeyCode)118;
private WalkieBatteryUI _batteryUi;
private Transform _localParent;
private GameObject _talkieLocal;
private GameObject _talkieRemote;
private AudioSource _sfxOn;
private AudioSource _sfxOff;
private AudioSource _sfxIdle;
private bool _usingRadio;
private bool _canToggle = true;
private void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene s, LoadSceneMode m)
{
if (IsInGame())
{
return;
}
_bootstrapped = false;
if (IsMasterOrSingle())
{
MaxBattery = CFG_MaxBattery.Value;
Recharge = CFG_Recharge.Value;
RechargeRatePerSec = CFG_RechargeRatePerSec.Value;
EnemiesHear = CFG_EnemiesHear.Value;
((MonoBehaviourPun)this).photonView.RPC("RPC_SyncSettings", (RpcTarget)0, new object[4] { MaxBattery, Recharge, EnemiesHear, RechargeRatePerSec });
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)string.Format("[{0}] Sync settings → max={1}, recharge={2}, enemiesHear={3}, rechargeRate={4:0.##}", "Omni Walkie-Talkie", MaxBattery, Recharge, EnemiesHear, RechargeRatePerSec));
}
}
}
private void Start()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
TryResolveKey(CFG_TalkKey.Value);
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)$"[Walkie] Push-to-talk = {_pushKey}");
}
}
private void Update()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
if (!((MonoBehaviourPun)this).photonView.IsMine)
{
return;
}
bool flag = IsInGame();
if (flag && !_bootstrapped)
{
_bootstrapped = true;
Bootstrap();
}
if (!flag || (Object)(object)_localAvatar == (Object)null || _localAvatar.spectating)
{
if (_usingRadio)
{
ForceStopTalking();
}
if ((Object)(object)_batteryUi != (Object)null && ((Component)_batteryUi).gameObject.activeSelf)
{
((Component)_batteryUi).gameObject.SetActive(false);
}
return;
}
if ((Object)(object)_batteryUi != (Object)null && !((Component)_batteryUi).gameObject.activeSelf)
{
((Component)_batteryUi).gameObject.SetActive(true);
}
if (Input.GetKey(_pushKey))
{
BeginTalking();
}
else if (Input.GetKeyUp(_pushKey))
{
EndTalking();
}
TickBattery();
UpdateSfxVisibility();
}
private void Bootstrap()
{
_maxBattery = MaxBattery;
_battery = Mathf.Max(0f, _maxBattery);
_recharge = Recharge;
_rechargeRatePerSec = RechargeRatePerSec;
_enemiesHear = EnemiesHear;
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
foreach (PlayerAvatar val in array)
{
if (val.photonView.IsMine)
{
_localAvatar = val;
break;
}
}
if ((Object)(object)_localAvatar == (Object)null)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogWarning((object)"[Walkie] No local PlayerAvatar yet.");
}
return;
}
_localParent = FindGrabberTarget(((Component)_localAvatar).transform);
if ((Object)(object)_localParent == (Object)null)
{
Transform parent = ((Component)_localAvatar).transform.parent;
_localParent = ((parent != null) ? parent.Find("Local Camera") : null);
if ((Object)(object)_localParent == (Object)null)
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogWarning((object)"[Walkie] Neither [RIG]/Grabber Target nor Local Camera found — skipping local talkie mesh.");
}
}
}
TryCreateBatteryUi();
TryCreateLocalTalkie();
((MonoBehaviourPun)this).photonView.RPC("RPC_CreateRemoteTalkieOnRightArm", (RpcTarget)4, new object[1] { _localAvatar.photonView.ViewID });
((MonoBehaviourPun)this).photonView.RPC("RPC_SetLocalAvatarViewId", (RpcTarget)0, new object[1] { _localAvatar.photonView.ViewID });
}
private void BeginTalking()
{
if (!_usingRadio && _canToggle && !(_battery <= 1f))
{
_usingRadio = true;
SetVoiceTransmit(enable: true);
if ((Object)(object)_talkieLocal != (Object)null && !_talkieLocal.activeSelf)
{
_talkieLocal.SetActive(true);
}
((MonoBehaviourPun)this).photonView.RPC("RPC_SetVoiceRangeAndFilters", (RpcTarget)0, new object[2] { 100, true });
((MonoBehaviourPun)this).photonView.RPC("RPC_SetTalkingFlag", (RpcTarget)0, new object[2]
{
_localAvatar.photonView.ViewID,
true
});
((MonoBehaviourPun)this).photonView.RPC("RPC_ShowRemoteTalkie", (RpcTarget)1, new object[1] { true });
}
}
private void EndTalking()
{
if (_usingRadio)
{
_usingRadio = false;
SetVoiceTransmit(enable: false);
((MonoBehaviourPun)this).photonView.RPC("RPC_ShowRemoteTalkie", (RpcTarget)1, new object[1] { false });
((MonoBehaviourPun)this).photonView.RPC("RPC_SetTalkingFlag", (RpcTarget)0, new object[2]
{
_localAvatar.photonView.ViewID,
false
});
((MonoBehaviour)this).StartCoroutine(StopTalkingAfter(0.4f));
}
}
private void ForceStopTalking()
{
_usingRadio = false;
SetVoiceTransmit(enable: false);
((MonoBehaviourPun)this).photonView.RPC("RPC_ShowRemoteTalkie", (RpcTarget)1, new object[1] { false });
((MonoBehaviourPun)this).photonView.RPC("RPC_SetVoiceRangeAndFilters", (RpcTarget)0, new object[2] { 25, false });
((MonoBehaviourPun)this).photonView.RPC("RPC_SetTalkingFlag", (RpcTarget)0, new object[2]
{
_localAvatar.photonView.ViewID,
false
});
if ((Object)(object)_talkieLocal != (Object)null)
{
_talkieLocal.SetActive(false);
}
}
[IteratorStateMachine(typeof(<StopTalkingAfter>d__37))]
private IEnumerator StopTalkingAfter(float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StopTalkingAfter>d__37(0)
{
<>4__this = this,
delay = delay
};
}
private void SetVoiceTransmit(bool enable)
{
try
{
Component val = ((Component)this).GetComponent(Type.GetType("Photon.Voice.PUN.PhotonVoiceView, PhotonVoice.PUN")) ?? ((Component)this).GetComponent(Type.GetType("Photon.Voice.Unity.PhotonVoiceView, PhotonVoice.Unity"));
if (!((Object)(object)val == (Object)null))
{
object obj = ((object)val).GetType().GetProperty("RecorderInUse")?.GetValue(val, null);
obj?.GetType().GetProperty("TransmitEnabled")?.SetValue(obj, enable, null);
}
}
catch
{
}
}
private void TickBattery()
{
if (_usingRadio)
{
_battery -= Time.deltaTime * 3f;
if (_battery <= 0f)
{
_battery = 0f;
EndTalking();
}
}
else if (_recharge)
{
_battery += Time.deltaTime * _rechargeRatePerSec;
if (_battery > _maxBattery)
{
_battery = _maxBattery;
}
}
if ((Object)(object)_batteryUi != (Object)null)
{
_batteryUi.Set(_battery, _maxBattery);
}
}
private void TryCreateBatteryUi()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Energy");
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogWarning((object)"[Walkie] 'Energy' UI not found; skipping battery HUD.");
}
return;
}
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
((Object)val2).name = "WalkieEnergy";
Transform transform = val2.transform;
transform.localPosition += new Vector3(0f, -33f, 0f);
EnergyUI component = val2.GetComponent<EnergyUI>();
if (Object.op_Implicit((Object)(object)component))
{
Object.DestroyImmediate((Object)(object)component);
}
TextMeshProUGUI[] componentsInChildren = val2.GetComponentsInChildren<TextMeshProUGUI>(true);
foreach (TextMeshProUGUI val3 in componentsInChildren)
{
((Graphic)val3).color = new Color(0.88f, 0.69f, 1f, 1f);
}
Image componentInChildren = val2.GetComponentInChildren<Image>(true);
if (Object.op_Implicit((Object)(object)componentInChildren))
{
((Behaviour)componentInChildren).enabled = false;
}
_batteryUi = val2.AddComponent<WalkieBatteryUI>();
_batteryUi.Set(_maxBattery, _maxBattery);
}
private void TryCreateLocalTalkie()
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = AssetLoader.GetPrefab("Talky", "walky");
if ((Object)(object)prefab == (Object)null)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogError((object)"[Walkie] Prefab not found in bundle. Place bundle next to DLL. (bundle='walky', prefab='Talky')");
}
}
else if (!((Object)(object)_localParent == (Object)null))
{
_talkieLocal = Object.Instantiate<GameObject>(prefab, _localParent);
bool flag = string.Equals(((Object)_localParent).name, "Grabber Target", StringComparison.OrdinalIgnoreCase) || ((Object)_localParent).name.IndexOf("Grabber", StringComparison.OrdinalIgnoreCase) >= 0;
float num = Mathf.Abs(CFG_RollDegrees.Value);
Quaternion localRotation = Quaternion.AngleAxis(num, Vector3.forward);
if (flag)
{
_talkieLocal.transform.localPosition = Vector3.zero;
_talkieLocal.transform.localRotation = localRotation;
}
else
{
_talkieLocal.transform.localPosition = TalkiePos;
_talkieLocal.transform.localRotation = TalkieRotation;
}
SetWorldScale(_talkieLocal.transform, CFG_WorldScale.Value);
_talkieLocal.SetActive(false);
_sfxOn = FindChildAudio(_talkieLocal, "OnSound");
_sfxOff = FindChildAudio(_talkieLocal, "OffSound");
_sfxIdle = FindChildAudio(_talkieLocal, "IdleOnSound");
SetGoActive((Component)(object)_sfxOn, active: false);
SetGoActive((Component)(object)_sfxOff, active: false);
SetGoActive((Component)(object)_sfxIdle, active: false);
}
}
[PunRPC]
private void RPC_CreateRemoteTalkieOnRightArm(int ownerAvatarViewId)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
PlayerAvatar val = null;
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
foreach (PlayerAvatar val2 in array)
{
if ((Object)(object)val2.photonView != (Object)null && val2.photonView.ViewID == ownerAvatarViewId)
{
val = val2;
break;
}
}
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogWarning((object)$"[Walkie] Remote avatar (ViewID={ownerAvatarViewId}) not found; remote prop skipped.");
}
return;
}
GameObject prefab = AssetLoader.GetPrefab("Talky", "walky");
if ((Object)(object)prefab == (Object)null)
{
return;
}
Transform val3 = FindGrabberTarget(((Component)val).transform);
float num = Mathf.Abs(CFG_RollDegrees.Value);
Quaternion localRotation = Quaternion.AngleAxis(num, Vector3.forward);
if ((Object)(object)val3 != (Object)null)
{
_talkieRemote = Object.Instantiate<GameObject>(prefab, val3);
_talkieRemote.transform.localPosition = Vector3.zero;
_talkieRemote.transform.localRotation = localRotation;
}
else
{
Transform parent = ((Component)val).transform.parent;
PlayerAvatarRightArm val4 = ((parent != null) ? ((Component)parent).GetComponentInChildren<PlayerAvatarRightArm>() : null);
if ((Object)(object)val4 == (Object)null)
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogWarning((object)"[Walkie] PlayerAvatarRightArm not found; remote prop skipped.");
}
return;
}
_talkieRemote = Object.Instantiate<GameObject>(prefab, val4.rightArmTransform);
_talkieRemote.transform.localPosition = RemoteTalkiePos;
_talkieRemote.transform.localRotation = RemoteTalkieRotation;
}
SetWorldScale(_talkieRemote.transform, CFG_WorldScale.Value);
_talkieRemote.SetActive(false);
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogInfo((object)"[Walkie] Remote talkie created.");
}
}
[PunRPC]
private void RPC_ShowRemoteTalkie(bool show)
{
if ((Object)(object)_talkieRemote != (Object)null)
{
_talkieRemote.SetActive(show);
}
}
private void UpdateSfxVisibility()
{
float num = GetGameVolumeScalar() * 0.3f;
if (Object.op_Implicit((Object)(object)_sfxOn))
{
_sfxOn.volume = num * 0.5f;
}
if (Object.op_Implicit((Object)(object)_sfxOff))
{
_sfxOff.volume = num * 0.5f;
}
if (Object.op_Implicit((Object)(object)_sfxIdle))
{
_sfxIdle.volume = num;
}
if (_usingRadio)
{
SetGoActive((Component)(object)_sfxOn, active: true);
SetGoActive((Component)(object)_sfxOff, active: false);
SetGoActive((Component)(object)_sfxIdle, active: true);
}
else
{
SetGoActive((Component)(object)_sfxOn, active: false);
SetGoActive((Component)(object)_sfxOff, active: true);
SetGoActive((Component)(object)_sfxIdle, active: false);
}
}
private float GetGameVolumeScalar()
{
float num = 1f;
float num2 = 1f;
try
{
Type typeFromHandle = typeof(Setting);
int num3 = TryGetEnumIndex(typeFromHandle, new string[4] { "MasterVolume", "Master_Volume", "MasterSound", "Master" }, 1);
int num4 = TryGetEnumIndex(typeFromHandle, new string[6] { "SFXVolume", "SfxVolume", "SoundFXVolume", "EffectsVolume", "SoundEffects", "Effects" }, 13);
num = 0.01f * Convert.ToSingle(DataDirector.instance.SettingValueFetch((Setting)num3));
num2 = 0.01f * Convert.ToSingle(DataDirector.instance.SettingValueFetch((Setting)num4));
}
catch
{
}
return Mathf.Clamp01(num * num2);
}
private static int TryGetEnumIndex(Type enumType, IEnumerable<string> names, int fallback)
{
foreach (string name in names)
{
try
{
if (Enum.IsDefined(enumType, name))
{
return Convert.ToInt32(Enum.Parse(enumType, name));
}
}
catch
{
}
}
return fallback;
}
[PunRPC]
private void RPC_SetVoiceRangeAndFilters(int maxDistance, bool talking)
{
AudioSource component = ((Component)this).GetComponent<AudioSource>();
AudioLowPassLogic component2 = ((Component)this).GetComponent<AudioLowPassLogic>();
if ((Object)(object)component2 != (Object)null)
{
component2.LogicActive = !talking;
if (Object.op_Implicit((Object)(object)component2.AudioLowpassFilter))
{
component2.AudioLowpassFilter.cutoffFrequency = (talking ? component2.LowPassMax : 0f);
}
}
AudioHighPassFilter val = ((Component)this).GetComponent<AudioHighPassFilter>() ?? ((Component)this).gameObject.AddComponent<AudioHighPassFilter>();
val.cutoffFrequency = (talking ? 1000 : 10);
if (Object.op_Implicit((Object)(object)component))
{
component.maxDistance = maxDistance;
}
}
[PunRPC]
private void RPC_SetTalkingFlag(int viewId, bool isTalking)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
if (isTalking)
{
PlayersTalking.Add(viewId);
if (((MonoBehaviourPun)this).photonView.IsMine || !_enemiesHear)
{
return;
}
WalkieController[] array = Object.FindObjectsOfType<WalkieController>();
foreach (WalkieController walkieController in array)
{
if (((MonoBehaviourPun)walkieController).photonView.IsMine && (Object)(object)walkieController._localAvatar != (Object)null)
{
try
{
EnemyDirector.instance.SetInvestigate(((Component)walkieController._localAvatar).transform.position + Vector3.up * 0.2f, 5f, false);
break;
}
catch
{
break;
}
}
}
}
else
{
PlayersTalking.Remove(viewId);
}
}
[PunRPC]
private void RPC_SyncSettings(int maxBattery, bool recharge, bool enemiesHear, float rechargeRatePerSec)
{
MaxBattery = maxBattery;
Recharge = recharge;
EnemiesHear = enemiesHear;
RechargeRatePerSec = rechargeRatePerSec;
_maxBattery = maxBattery;
_recharge = recharge;
_enemiesHear = enemiesHear;
_rechargeRatePerSec = rechargeRatePerSec;
if (_battery > _maxBattery)
{
_battery = _maxBattery;
}
if (Object.op_Implicit((Object)(object)_batteryUi))
{
_batteryUi.Set(_battery, _maxBattery);
}
}
[PunRPC]
private void RPC_SetLocalAvatarViewId(int viewId)
{
}
private static bool IsMasterOrSingle()
{
try
{
return SemiFunc.IsMasterClientOrSingleplayer();
}
catch
{
return PhotonNetwork.IsMasterClient || !PhotonNetwork.InRoom;
}
}
private static bool IsInGame()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
try
{
return (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState == 2 && SemiFunc.RunIsLevel();
}
catch
{
return Object.FindObjectsOfType<PlayerAvatar>().Length != 0;
}
}
private void TryResolveKey(string cfg)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (Enum.TryParse<KeyCode>(cfg, ignoreCase: true, out KeyCode result))
{
_pushKey = result;
}
else
{
_pushKey = (KeyCode)118;
}
}
private static AudioSource FindChildAudio(GameObject root, string childName)
{
if (!Object.op_Implicit((Object)(object)root))
{
return null;
}
Transform val = root.transform.Find(childName);
return ((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<AudioSource>() : null;
}
private static void SetGoActive(Component c, bool active)
{
if (!((Object)(object)c == (Object)null))
{
c.gameObject.SetActive(active);
}
}
private static void SetWorldScale(Transform t, float worldScale)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)t == (Object)null))
{
float num = Mathf.Clamp(worldScale, 0.001f, 5f);
Transform parent = t.parent;
float num2 = (Object.op_Implicit((Object)(object)parent) ? parent.lossyScale.x : 1f);
if (Mathf.Approximately(num2, 0f))
{
num2 = 1f;
}
float num3 = (Object.op_Implicit((Object)(object)parent) ? parent.lossyScale.y : 1f);
if (Mathf.Approximately(num3, 0f))
{
num3 = 1f;
}
float num4 = (Object.op_Implicit((Object)(object)parent) ? parent.lossyScale.z : 1f);
if (Mathf.Approximately(num4, 0f))
{
num4 = 1f;
}
t.localScale = new Vector3(num / num2, num / num3, num / num4);
}
}
private static Transform FindGrabberTarget(Transform avatarRoot)
{
if ((Object)(object)avatarRoot == (Object)null)
{
return null;
}
Transform val = avatarRoot.Find("[RIG]");
Transform val2 = ((val != null) ? val.Find("Grabber Target") : null);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
return FindDeepChildByName(avatarRoot, "Grabber Target");
}
private static Transform FindDeepChildByName(Transform parent, string name)
{
if ((Object)(object)parent == (Object)null)
{
return null;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (string.Equals(((Object)child).name, name, StringComparison.OrdinalIgnoreCase))
{
return child;
}
Transform val = FindDeepChildByName(child, name);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
}
public class WalkieBatteryUI : MonoBehaviour
{
private TextMeshProUGUI _cur;
private TextMeshProUGUI _max;
private void Awake()
{
_cur = ((Component)this).GetComponent<TextMeshProUGUI>();
Transform obj = ((Component)this).transform.Find("EnergyMax");
_max = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
}
public void Set(float value, float max)
{
if (Object.op_Implicit((Object)(object)_cur))
{
((TMP_Text)_cur).text = Mathf.Ceil(value).ToString();
}
if (Object.op_Implicit((Object)(object)_max))
{
((TMP_Text)_max).text = "<b>/</b>" + Mathf.Ceil(max);
}
}
}
internal static class AssetLoader
{
private static AssetBundle _bundle;
private static string _loadedFor;
public static GameObject GetPrefab(string prefabName, string bundleBase)
{
if ((Object)(object)_bundle == (Object)null || _loadedFor != bundleBase)
{
TryLoadBundle(bundleBase);
}
if ((Object)(object)_bundle == (Object)null)
{
return null;
}
GameObject val = _bundle.LoadAsset<GameObject>(prefabName);
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogError((object)("[Walkie] Prefab '" + prefabName + "' not found in bundle '" + bundleBase + "'."));
}
}
return val;
}
private static void TryLoadBundle(string baseName)
{
Unload();
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string[] array = new string[4]
{
Path.Combine(directoryName, baseName),
Path.Combine(directoryName, baseName + ".assetbundle"),
Path.Combine(directoryName, baseName + ".unity3d"),
Path.Combine(directoryName, baseName + ".bundle")
};
string[] array2 = array;
foreach (string text in array2)
{
if (!File.Exists(text))
{
continue;
}
try
{
_bundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)_bundle != (Object)null)
{
_loadedFor = baseName;
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)("[Walkie] Loaded AssetBundle: " + Path.GetFileName(text)));
}
return;
}
}
catch (Exception arg)
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogWarning((object)$"[Walkie] Failed to load bundle '{text}': {arg}");
}
}
}
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogError((object)("[Walkie] Could not find bundle '" + baseName + "' beside the DLL."));
}
}
public static void Unload()
{
if ((Object)(object)_bundle != (Object)null)
{
try
{
_bundle.Unload(false);
}
catch
{
}
}
_bundle = null;
_loadedFor = null;
}
}
public const string PluginGuid = "omni.repo.walkietalkie";
public const string PluginName = "Omni Walkie-Talkie";
public const string PluginVersion = "1.2.0";
internal static ManualLogSource Log;
internal static ConfigEntry<string> CFG_TalkKey;
internal static ConfigEntry<int> CFG_MaxBattery;
internal static ConfigEntry<bool> CFG_Recharge;
internal static ConfigEntry<float> CFG_RechargeRatePerSec;
internal static ConfigEntry<bool> CFG_EnemiesHear;
internal static ConfigEntry<float> CFG_WorldScale;
internal static ConfigEntry<float> CFG_RollDegrees;
internal static int MaxBattery = 40;
internal static bool Recharge = true;
internal static float RechargeRatePerSec = 1f;
internal static bool EnemiesHear = true;
private Harmony _harmony;
private void Awake()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
CFG_TalkKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "PushToTalkKey", "V", "Key to hold for radio talk. Example: V, F, Mouse4, LeftShift");
CFG_MaxBattery = ((BaseUnityPlugin)this).Config.Bind<int>("Battery (host only)", "MaxBattery", 50, new ConfigDescription("Walkie battery capacity.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 200), Array.Empty<object>()));
CFG_Recharge = ((BaseUnityPlugin)this).Config.Bind<bool>("Battery (host only)", "RechargeDuringLevel", true, "Recharge slowly when not transmitting.");
CFG_RechargeRatePerSec = ((BaseUnityPlugin)this).Config.Bind<float>("Battery (host only)", "RechargeRatePerSec", 1f, new ConfigDescription("Units recovered per second when not transmitting (if RechargeDuringLevel=true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
CFG_EnemiesHear = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies (host only)", "EnemiesHearRadio", true, "If true, enemy AI will get an investigate ping when a player transmits.");
CFG_WorldScale = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "WorldScale", 0.05f, new ConfigDescription("World size of the radio model (meters). Compensates for parent scaling.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.005f, 1f), Array.Empty<object>()));
CFG_RollDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "RollDegrees", 0f, new ConfigDescription("Roll (Z) degrees: local +roll, remote -roll. Set 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 45f), Array.Empty<object>()));
MaxBattery = CFG_MaxBattery.Value;
Recharge = CFG_Recharge.Value;
RechargeRatePerSec = CFG_RechargeRatePerSec.Value;
EnemiesHear = CFG_EnemiesHear.Value;
_harmony = new Harmony("omni.repo.walkietalkie");
_harmony.PatchAll(typeof(Patch_AttachController));
_harmony.PatchAll(typeof(Patch_RightArmPose));
Log.LogInfo((object)"[Omni Walkie-Talkie] Loaded.");
}
private void OnDestroy()
{
try
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch
{
}
}
}
}
namespace Eggs
{
[BepInPlugin("Omniscye.Eggs", "Eggs", "1.0")]
public class Eggs : BaseUnityPlugin
{
internal static Eggs Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}