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.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("NotezyTeam")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("Discharge")]
[assembly: AssemblyTitle("Discharge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.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 Discharge
{
[BepInPlugin("NoteBoxz.Discharge", "Discharge", "0.1.1")]
public class Discharge : BaseUnityPlugin
{
public const string ModGUID = "NoteBoxz.Discharge";
public const string ModVersion = "0.1.1";
public const string ModName = "Discharge";
public static List<AudioClip> DischargeSounds = new List<AudioClip>();
public static GameObject IndicatorPrefab = null;
internal static Discharge Instance { get; private set; } = null;
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal static AssetBundle? AssetBundle { get; private set; } = null;
public static ConfigEntry<KeyCode> DischargeKey { get; private set; } = null;
public static ConfigEntry<float> MinOverchargeToDischarge { get; private set; } = null;
public static ConfigEntry<float> DamageMultiplier { get; private set; } = null;
public static ConfigEntry<bool> ShowIndicator { get; private set; } = null;
public static ConfigEntry<string> OverrideIndicatorText { get; private set; } = null;
public static ConfigEntry<float> OverrideIndicatorTextSize { get; private set; } = null;
public static ConfigEntry<bool> DebugMode { get; private set; } = null;
private void Awake()
{
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
LoadAssetBundle();
BindConfigs();
AssetBundle? assetBundle = AssetBundle;
DischargeSounds = new List<AudioClip>((IEnumerable<AudioClip>)(((object)((assetBundle != null) ? assetBundle.LoadAllAssets<AudioClip>() : null)) ?? ((object)new AudioClip[0])));
List<string> order = new List<string> { "ZapSmall", "ZapMedium", "ZapLarge", "ZapMax" };
DischargeSounds.Sort(delegate(AudioClip a, AudioClip b)
{
int num = order.IndexOf(((Object)a).name);
int value = order.IndexOf(((Object)b).name);
return num.CompareTo(value);
});
Logger.LogInfo((object)$"Loaded {DischargeSounds.Count} discharge sounds from asset bundle.");
AssetBundle? assetBundle2 = AssetBundle;
IndicatorPrefab = ((assetBundle2 != null) ? assetBundle2.LoadAsset<GameObject>("Assets/DischargeAssets/DischargeIndicator.prefab") : null) ?? null;
DischargeIndicator dischargeIndicator = IndicatorPrefab.AddComponent<DischargeIndicator>();
((SemiUI)dischargeIndicator).showPosition = new Vector2(0f, -50f);
((SemiUI)dischargeIndicator).hidePosition = new Vector2(0f, -70f);
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
private void Start()
{
PhysGrabber[] array = Resources.FindObjectsOfTypeAll<PhysGrabber>();
Logger.LogInfo((object)$"Found {array.Length} PhysGrabber instances in resources");
PhysGrabber[] array2 = array;
foreach (PhysGrabber val in array2)
{
if ((Object)(object)((Component)val).gameObject.GetComponent<PhysGrabberDischarger>() == (Object)null)
{
((Component)val).gameObject.AddComponent<PhysGrabberDischarger>();
Logger.LogDebug((object)("Added PhysGrabberDischarger to " + ((Object)val).name));
}
}
PlayerAvatarOverchargeVisuals[] array3 = Resources.FindObjectsOfTypeAll<PlayerAvatarOverchargeVisuals>();
Logger.LogInfo((object)$"Found {array3.Length} PlayerAvatarOverchargeVisuals instances in resources");
PlayerAvatarOverchargeVisuals[] array4 = array3;
foreach (PlayerAvatarOverchargeVisuals val2 in array4)
{
if ((Object)(object)((Component)val2).gameObject.GetComponent<DischargeVisuals>() == (Object)null)
{
((Component)val2).gameObject.AddComponent<DischargeVisuals>();
Logger.LogDebug((object)("Added DischargeVisuals to " + ((Object)val2).name));
}
}
}
private void LoadAssetBundle()
{
string path = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty;
string text = Path.Combine(path, "dischargeassets");
AssetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)AssetBundle == (Object)null)
{
Logger.LogError((object)"Failed to load AssetBundle!");
}
else
{
Logger.LogInfo((object)"Successfully loaded AssetBundle");
}
}
private void BindConfigs()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
DischargeKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Discharge Key", (KeyCode)120, "Key to discharge held object");
MinOverchargeToDischarge = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Minimum Overcharge", 0.25f, new ConfigDescription("(HOST ONLY) Minimum overcharge required to discharge", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
DamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Damage Multiplier", 5f, "(HOST ONLY) Damage multiplier for discharge damage");
ShowIndicator = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Indicator", true, "Show the discharge indicator on the HUD");
OverrideIndicatorText = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Override Indicator Text", "", "Override the text shown in the discharge indicator. You must put {button} to show the key to press (Example: PRESS [{button}]) Leave blank for default text.");
OverrideIndicatorTextSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Override Indicator Text Size", -1f, "Override the font size of the discharge indicator text. Default is 24.");
DamageMultiplier.SettingChanged += delegate
{
ServerConfig.OnServerConfigChanged();
};
MinOverchargeToDischarge.SettingChanged += delegate
{
ServerConfig.OnServerConfigChanged();
};
ServerConfig.Initialize();
DebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugMode", false, "Adds text to the screen with debug info");
}
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()
{
}
}
public static class DischargeFunc
{
public static DischargeStrength GetDischargeStrength(float overchargeFloat)
{
if (overchargeFloat < 0.25f)
{
return DischargeStrength.Weak;
}
if (overchargeFloat < 0.5f)
{
return DischargeStrength.Medium;
}
if (overchargeFloat < 0.75f)
{
return DischargeStrength.Strong;
}
return DischargeStrength.Max;
}
public static float ClampFloatIncrumental(float value, int increments)
{
if (increments <= 0)
{
return value;
}
float num = 1f / (float)increments;
return Mathf.Round(value / num) * num;
}
}
public class DischargeIndicator : SemiUI
{
public TMP_Text indicatorText = null;
public bool ShownThisFrame = false;
[Header("Fade Settings")]
public float fadedAlpha = 0.3f;
public float visibleAlpha = 1f;
private bool shouldBeVisible = false;
public static DischargeIndicator Instance { get; private set; }
public override void Start()
{
((SemiUI)this).Start();
Instance = this;
indicatorText = ((Component)this).GetComponentInChildren<TMP_Text>();
}
public override void Update()
{
//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)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: 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)
((SemiUI)this).Update();
if (!Discharge.ShowIndicator.Value)
{
shouldBeVisible = false;
ShownThisFrame = false;
UpdateFade();
return;
}
indicatorText.fontSize = 24f;
TMP_Text obj = indicatorText;
KeyCode value = Discharge.DischargeKey.Value;
obj.text = "PRESS [" + ((object)(KeyCode)(ref value)).ToString().ToUpper() + "]";
if (!string.IsNullOrWhiteSpace(Discharge.OverrideIndicatorText.Value))
{
TMP_Text obj2 = indicatorText;
string value2 = Discharge.OverrideIndicatorText.Value;
value = Discharge.DischargeKey.Value;
obj2.text = value2.Replace("{button}", ((object)(KeyCode)(ref value)).ToString().ToUpper());
}
if (Discharge.OverrideIndicatorTextSize.Value > 0f)
{
indicatorText.fontSize = Discharge.OverrideIndicatorTextSize.Value;
}
if ((Object)(object)PhysGrabberDischarger.Instance != (Object)null)
{
if (PhysGrabberDischarger.Instance.CanDischarge())
{
shouldBeVisible = true;
if (!ShownThisFrame)
{
ShownThisFrame = true;
((Graphic)indicatorText).color = new Color(((Graphic)indicatorText).color.r, ((Graphic)indicatorText).color.g, ((Graphic)indicatorText).color.b, 0f);
}
}
else
{
shouldBeVisible = false;
ShownThisFrame = false;
}
}
else
{
shouldBeVisible = false;
ShownThisFrame = false;
}
UpdateFade();
}
private void UpdateFade()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_0077: Unknown result type (might be due to invalid IL or missing references)
float y = ((Component)this).transform.position.y;
float y2 = base.hidePosition.y;
float y3 = base.showPosition.y;
float num = Mathf.InverseLerp(y2, y3 - 0.1f, y);
float num2 = Mathf.Lerp(fadedAlpha, visibleAlpha, num);
Color color = ((Graphic)indicatorText).color;
((Graphic)indicatorText).color = new Color(color.r, color.g, color.b, num2);
if (shouldBeVisible)
{
((SemiUI)this).Show();
}
else
{
((SemiUI)this).Hide();
}
}
}
public enum DischargeStrength
{
Weak,
Medium,
Strong,
Max
}
public class DischargeVisuals : MonoBehaviour
{
private PlayerAvatar playerAvatar = null;
private PlayerAvatarOverchargeVisuals overchargeVisuals = null;
private PhysGrabber grabber = null;
private PhysGrabBeam beam = null;
private bool DidModifyLightsAndParticles = false;
private float originalLightRange = 0f;
internal static Dictionary<PlayerAvatar, DischargeVisuals> dischargeVisuals = new Dictionary<PlayerAvatar, DischargeVisuals>();
internal float ThisT = 0f;
internal static float LocalT = 0f;
public void Start()
{
playerAvatar = ((Component)((Component)this).transform.parent).gameObject.GetComponentInChildren<PlayerAvatar>();
overchargeVisuals = ((Component)this).GetComponent<PlayerAvatarOverchargeVisuals>();
grabber = ((Component)((Component)this).transform.parent).gameObject.GetComponentInChildren<PhysGrabber>();
beam = ((Component)((Component)this).transform.parent).gameObject.GetComponentInChildren<PhysGrabBeam>();
originalLightRange = ((Component)this).GetComponentInChildren<Light>().range;
if (!dischargeVisuals.ContainsKey(playerAvatar))
{
dischargeVisuals[playerAvatar] = this;
}
}
public void LateUpdate()
{
if (playerAvatar.isLocal)
{
LocalT = ThisT;
}
}
public void ApplyLightsAndParticles()
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
if (ThisT <= 0.01f)
{
if (DidModifyLightsAndParticles)
{
Discharge.Logger.LogDebug((object)$"Reset overcharge light range {overchargeVisuals.overchargeLight.range} -> {originalLightRange}");
overchargeVisuals.overchargeLight.range = originalLightRange;
DidModifyLightsAndParticles = false;
}
}
else
{
DidModifyLightsAndParticles = true;
Light overchargeLight = overchargeVisuals.overchargeLight;
overchargeLight.intensity += ThisT * 9f;
overchargeVisuals.overchargeLight.range = ThisT * 9f;
ParticleSystem overchargeParticles = overchargeVisuals.overchargeParticles;
overchargeParticles.emissionRate += ThisT * 9f;
Transform transform = ((Component)overchargeVisuals.overchargeParticles).transform;
transform.localScale += ThisT * Vector3.one * 9f;
}
}
public void ApplyLineWidth()
{
if (!(ThisT <= 0.01f))
{
LineRenderer lineRendererOverCharge = beam.lineRendererOverCharge;
lineRendererOverCharge.widthMultiplier += ThisT * 9f;
}
}
public void ApplyOverchargeOverride()
{
if (!(ThisT <= 0.01f))
{
if (grabber.physGrabBeamOverChargeTimer > 0f)
{
grabber.physGrabBeamOverCharge = (byte)Mathf.Lerp(grabber.physGrabBeamOverChargeFloat * 200f, 200f, ThisT);
}
else if (grabber.physGrabBeamOverChargeFloat > 0f)
{
grabber.physGrabBeamOverCharge = (byte)Mathf.Lerp(grabber.physGrabBeamOverChargeFloat * 200f, 200f, ThisT);
}
}
}
public void OnDestroy()
{
if (dischargeVisuals.ContainsKey(playerAvatar))
{
dischargeVisuals.Remove(playerAvatar);
}
}
}
public class PhysGrabberDischarger : MonoBehaviour, IPunObservable
{
[CompilerGenerated]
private sealed class <dischargeRoutine>d__18 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float ClampedStartT;
public PhysGrabberDischarger <>4__this;
private float <T>5__1;
private float <duration>5__2;
private float <t>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <dischargeRoutine>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<T>5__1 = 0f;
<duration>5__2 = 1f;
break;
case 1:
<>1__state = -1;
break;
}
if (<T>5__1 < <duration>5__2)
{
<T>5__1 += Time.deltaTime;
<t>5__3 = <T>5__1 / <duration>5__2;
<>4__this.dischargeVisuals.ThisT = Mathf.Clamp01(ClampedStartT - Mathf.Clamp01(<t>5__3));
<>2__current = null;
<>1__state = 1;
return true;
}
<>4__this.dischargeCoroutine = null;
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 PhotonView photonView = null;
public PlayerAvatar playerAvatar = null;
public PhysGrabber grabber = null;
public DischargeVisuals dischargeVisuals = null;
public Sound soundDischarge;
private Coroutine? dischargeCoroutine;
public static PhysGrabberDischarger Instance { get; private set; }
private bool isLocal => GameManager.instance.gameMode == 0 || (Object)(object)photonView == (Object)null || photonView.IsMine;
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
Discharge.Logger.LogInfo((object)"PhysGrabberDischarger OnPhotonSerializeView");
}
public void Start()
{
grabber = ((Component)this).GetComponent<PhysGrabber>();
playerAvatar = ((Component)this).GetComponent<PlayerAvatar>();
photonView = ((Component)this).GetComponent<PhotonView>();
dischargeVisuals = ((Component)((Component)this).transform.parent).gameObject.GetComponentInChildren<DischargeVisuals>();
if ((Object)(object)grabber == (Object)null)
{
Discharge.Logger.LogError((object)"PhysGrabberDischarger could not find PhysGrabber component!");
}
if (!SemiFunc.IsMultiplayer() || isLocal)
{
Instance = this;
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
ServerConfig.SyncAllServerConfigs();
}
}
public void Update()
{
DischargeInputLogic();
}
public bool CanDischarge()
{
return grabber.grabbed && grabber.physGrabBeamOverChargeFloat >= ServerConfig.MinOverchargeToDischarge && (Object)(object)grabber.grabbedPhysGrabObject != (Object)null && (Object)(object)grabber.grabbedPhysGrabObject.enemyRigidbody != (Object)null;
}
public void DischargeInputLogic()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (isLocal && Input.GetKeyDown(Discharge.DischargeKey.Value) && CanDischarge())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("DischargeRpc", (RpcTarget)0, new object[1] { grabber.physGrabBeamOverChargeFloat });
}
else
{
DischargeRpc(grabber.physGrabBeamOverChargeFloat);
}
}
}
[PunRPC]
public void DischargeRpc(float dischargeAmmount = 0f)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
DischargeStrength dischargeStrength = DischargeFunc.GetDischargeStrength(dischargeAmmount);
AudioClip val = Discharge.DischargeSounds[(int)dischargeStrength];
soundDischarge.Sounds = (AudioClip[])(object)new AudioClip[1] { val };
soundDischarge.Play(((Component)playerAvatar).transform.position, 1f, 1f, 1f, 1f);
int num = 0;
if ((Object)(object)grabber.grabbedPhysGrabObject.enemyRigidbody != (Object)null)
{
float num2 = (float)dischargeStrength * ServerConfig.DamageMultiplier;
float num3 = (float)grabber.grabbedPhysGrabObject.enemyRigidbody.enemyParent.difficulty / 3f;
float num4 = Mathf.Lerp(0.5f, 2f, num3);
num = Mathf.RoundToInt(num2 * num4);
Vector3 val2 = ((Component)this).transform.position - ((Component)grabber.grabbedPhysGrabObject.enemyRigidbody).transform.position;
grabber.grabbedPhysGrabObject.enemyRigidbody.enemy.Health.Hurt(num, val2);
}
if (dischargeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(dischargeCoroutine);
dischargeCoroutine = null;
}
dischargeCoroutine = ((MonoBehaviour)this).StartCoroutine(dischargeRoutine(DischargeFunc.ClampFloatIncrumental(dischargeAmmount, 4)));
if (isLocal)
{
GameDirector.instance.CameraImpact.Shake((float)dischargeStrength * 2f, 0.35f);
if ((Object)(object)DischargeIndicator.Instance != (Object)null)
{
((SemiUI)DischargeIndicator.Instance).SemiUITextFlashColor(Color.white, 0.1f);
((SemiUI)DischargeIndicator.Instance).SemiUISpringShakeY(0.5f, 0.2f, 0.1f);
((SemiUI)DischargeIndicator.Instance).SemiUISpringShakeX(0.5f, 0.2f, 0.1f);
((SemiUI)DischargeIndicator.Instance).SemiUISpringScale(0.5f, 0.2f, 0.1f);
}
}
grabber.OverchargeResetValues();
if (SemiFunc.IsMultiplayer())
{
Discharge.Logger.LogInfo((object)($"{photonView.Controller.NickName} (ID: {photonView.Controller.ActorNumber}) Discharged with strength" + $" {dischargeStrength} (ammount: {dischargeAmmount}) (should have delt {num} damage)"));
}
else
{
Discharge.Logger.LogInfo((object)$"Singleplayer Discharged with strength {dischargeStrength} (ammount: {dischargeAmmount}) (dealt {num} damage)");
}
}
[IteratorStateMachine(typeof(<dischargeRoutine>d__18))]
private IEnumerator dischargeRoutine(float ClampedStartT = 1f)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <dischargeRoutine>d__18(0)
{
<>4__this = this,
ClampedStartT = ClampedStartT
};
}
[PunRPC]
public void SyncServerConfigsRpc(float damageMultiplier, float minOverchargeToDischarge, PhotonMessageInfo info)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMultiplayer() && !info.Sender.IsMasterClient)
{
Discharge.Logger.LogWarning((object)"SyncServerConfigsRpc can only be called by the host/server.");
return;
}
ServerConfig.UpdateCachedValues(damageMultiplier, minOverchargeToDischarge);
Discharge.Logger.LogDebug((object)$"Synced server configs from host - DamageMultiplier: {ServerConfig.DamageMultiplier}, MinOverchargeToDischarge: {ServerConfig.MinOverchargeToDischarge}");
}
public void OnGUI()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
GUIStyle boldStyle;
Color outlineColor;
int outlineThickness;
if (Discharge.DebugMode.Value && grabber.grabbed && isLocal)
{
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1
};
val.normal.textColor = Color.white;
boldStyle = val;
outlineColor = Color.black;
outlineThickness = 1;
DrawOutlinedLabel(new Rect(10f, 110f, 300f, 20f), $"Press {Discharge.DischargeKey.Value} to discharge");
DrawOutlinedLabel(new Rect(10f, 130f, 300f, 20f), $"Overcharge: {grabber.physGrabBeamOverChargeFloat:0.00}");
DrawOutlinedLabel(new Rect(10f, 150f, 300f, 20f), $"Discharge Strength: {DischargeFunc.GetDischargeStrength(grabber.physGrabBeamOverChargeFloat)}");
DrawOutlinedLabel(new Rect(10f, 170f, 300f, 20f), $"OverchargeVis: {grabber.physGrabBeamOverCharge}");
DrawOutlinedLabel(new Rect(10f, 190f, 300f, 20f), $"OverchargeAtt: {grabber.physGrabBeamOverChargeAmount}");
DrawOutlinedLabel(new Rect(10f, 210f, 300f, 20f), $"ThisT: {DischargeVisuals.LocalT}");
DrawOutlinedLabel(new Rect(10f, 230f, 300f, 20f), $"DamageMultiplier: {ServerConfig.DamageMultiplier}");
DrawOutlinedLabel(new Rect(10f, 250f, 300f, 20f), $"MinOverchargeToDischarge: {ServerConfig.MinOverchargeToDischarge}");
}
void DrawOutlinedLabel(Rect position, string text)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
boldStyle.normal.textColor = outlineColor;
for (int i = -outlineThickness; i <= outlineThickness; i++)
{
for (int j = -outlineThickness; j <= outlineThickness; j++)
{
if (i != 0 || j != 0)
{
GUI.Label(new Rect(((Rect)(ref position)).x + (float)i, ((Rect)(ref position)).y + (float)j, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, boldStyle);
}
}
}
boldStyle.normal.textColor = Color.white;
GUI.Label(position, text, boldStyle);
}
}
public PhysGrabberDischarger()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Sound val = new Sound();
val.Sounds = (AudioClip[])(object)new AudioClip[0];
val.Type = (AudioType)1;
val.PitchRandom = 0.1f;
soundDischarge = val;
dischargeCoroutine = null;
((MonoBehaviour)this)..ctor();
}
}
public static class ServerConfig
{
private static bool _initialized = false;
public static float DamageMultiplier { get; private set; } = 5f;
public static float MinOverchargeToDischarge { get; private set; } = 0.25f;
public static void Initialize()
{
if (!_initialized)
{
UpdateLocalValues();
_initialized = true;
}
}
private static void UpdateLocalValues()
{
DamageMultiplier = Discharge.DamageMultiplier.Value;
MinOverchargeToDischarge = Discharge.MinOverchargeToDischarge.Value;
}
public static void OnServerConfigChanged()
{
SyncAllServerConfigs();
}
public static void SyncAllServerConfigs()
{
if ((Object)(object)PhysGrabberDischarger.Instance != (Object)null && SemiFunc.IsMasterClientOrSingleplayer())
{
UpdateLocalValues();
if (SemiFunc.IsMultiplayer())
{
PhysGrabberDischarger.Instance.photonView.RPC("SyncServerConfigsRpc", (RpcTarget)0, new object[2] { DamageMultiplier, MinOverchargeToDischarge });
}
}
}
public static void UpdateCachedValues(float damageMultiplier, float minOverchargeToDischarge)
{
DamageMultiplier = damageMultiplier;
MinOverchargeToDischarge = minOverchargeToDischarge;
}
}
}
namespace Discharge.Patches
{
[HarmonyPatch(typeof(OverchargeRoundBarUI))]
internal static class OverchargeRoundBarUIPatch
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(OverchargeRoundBarUI __instance)
{
if ((Object)(object)DischargeIndicator.Instance == (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(Discharge.IndicatorPrefab, ((Component)__instance).transform.parent);
((Object)val).name = "DischargeIndicator";
Discharge.Logger.LogInfo((object)"DischargeIndicator instantiated and parented to OverchargeRoundBarUI");
}
else
{
Discharge.Logger.LogInfo((object)"DischargeIndicator instance already exists");
}
}
}
[HarmonyPatch(typeof(PhysGrabBeam))]
internal static class PhysGrabBeamPatch
{
[HarmonyPostfix]
[HarmonyPatch("DrawCurve")]
private static void Update_Postfix(PhysGrabBeam __instance)
{
if (DischargeVisuals.dischargeVisuals.ContainsKey(__instance.playerAvatar))
{
DischargeVisuals.dischargeVisuals[__instance.playerAvatar].ApplyLineWidth();
}
}
}
[HarmonyPatch(typeof(PhysGrabber))]
internal static class PhysGrabberPatch
{
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Update_Postfix(PhysGrabber __instance)
{
if (DischargeVisuals.dischargeVisuals.ContainsKey(__instance.playerAvatar))
{
DischargeVisuals.dischargeVisuals[__instance.playerAvatar].ApplyOverchargeOverride();
}
}
}
[HarmonyPatch(typeof(PlayerAvatarOverchargeVisuals))]
internal static class PlayerAvatarOverchargeVisualsPatch
{
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Update_Postfix(PlayerAvatarOverchargeVisuals __instance)
{
if (DischargeVisuals.dischargeVisuals.ContainsKey(__instance.playerAvatar))
{
DischargeVisuals.dischargeVisuals[__instance.playerAvatar].ApplyLightsAndParticles();
}
}
}
[HarmonyPatch(typeof(PlayerController))]
internal static class PlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
}
}
}