using System;
using System.Collections;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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("Rosay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlasmaGunAPI")]
[assembly: AssemblyTitle("PlasmaGunAPI")]
[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;
}
}
}
public class ItemPlasmaGun : MonoBehaviour
{
public enum State
{
Idle,
OutOfEnergy,
Buildup,
Shooting,
Reloading
}
[Header("Plasma Gun Settings")]
public bool hasOneShot = true;
public float shootTime = 1f;
public bool hasBuildUp;
public float buildUpTime = 1f;
public int numberOfBullets = 1;
[Header("Gun Physics")]
[Range(0f, 65f)]
public float gunRandomSpread;
public float gunRange = 50f;
public float distanceKeep = 0.8f;
public float gunRecoilForce = 1f;
public float cameraShakeMultiplier = 1f;
public float torqueMultiplier = 1f;
public float grabStrengthMultiplier = 1f;
public float shootCooldown = 1f;
[Header("Plasma Energy")]
[Range(0f, 100f)]
public float misfirePercentageChange = 50f;
[Header("Gun Components")]
public Transform gunMuzzle;
public GameObject bulletPrefab;
public GameObject muzzleFlashPrefab;
public Transform gunTrigger;
public float grabVerticalOffset = -0.2f;
public float aimVerticalOffset = -5f;
public float investigateRadius = 20f;
[Header("Particle Effects")]
public ParticleSystem muzzleFlashParticles;
public ParticleSystem chargingParticles;
public ParticleSystem energyTrailParticles;
[Header("Audio")]
public Sound soundShoot;
public Sound soundShootGlobal;
public Sound soundNoEnergyClick;
public Sound soundHit;
public Sound soundCharging;
public Sound soundEnergyDepleted;
[Header("Unity Events")]
public UnityEvent onStateIdleStart;
public UnityEvent onStateIdleUpdate;
public UnityEvent onStateIdleFixedUpdate;
[Space(20f)]
public UnityEvent onStateOutOfEnergyStart;
public UnityEvent onStateOutOfEnergyUpdate;
public UnityEvent onStateOutOfEnergyFixedUpdate;
[Space(20f)]
public UnityEvent onStateBuildupStart;
public UnityEvent onStateBuildupUpdate;
public UnityEvent onStateBuildupFixedUpdate;
[Space(20f)]
public UnityEvent onStateShootingStart;
public UnityEvent onStateShootingUpdate;
public UnityEvent onStateShootingFixedUpdate;
[Space(20f)]
public UnityEvent onStateReloadingStart;
public UnityEvent onStateReloadingUpdate;
public UnityEvent onStateReloadingFixedUpdate;
private PhysGrabObject physGrabObject;
private ItemToggle itemToggle;
private PlasmaEnergySystem plasmaEnergySystem;
private PhotonView photonView;
private PhysGrabObjectImpactDetector impactDetector;
private ItemEquippable itemEquippable;
private RoomVolumeCheck roomVolumeCheck;
private bool prevToggleState;
private AnimationCurve triggerAnimationCurve;
private float triggerAnimationEval;
private bool triggerAnimationActive;
private float investigateCooldown;
internal float stateTimer;
internal float stateTimeMax;
internal State stateCurrent;
private State statePrev;
private bool stateStart;
private bool hasIdleUpdate = true;
private bool hasIdleFixedUpdate = true;
private bool hasOutOfEnergyUpdate = true;
private bool hasOutOfEnergyFixedUpdate = true;
private bool hasBuildupUpdate = true;
private bool hasBuildupFixedUpdate = true;
private bool hasShootingUpdate = true;
private bool hasShootingFixedUpdate = true;
private bool hasReloadingUpdate = true;
private bool hasReloadingFixedUpdate = true;
internal HurtCollider hurtCollider;
private void Start()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
roomVolumeCheck = ((Component)this).GetComponent<RoomVolumeCheck>();
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
plasmaEnergySystem = ((Component)this).GetComponent<PlasmaEnergySystem>();
photonView = ((Component)this).GetComponent<PhotonView>();
impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
if ((Object)(object)plasmaEnergySystem == (Object)null)
{
Debug.LogError((object)"ItemPlasmaGun: PlasmaEnergySystem component is required!");
((Behaviour)this).enabled = false;
}
else
{
plasmaEnergySystem.OnEnergyDepleted.AddListener(new UnityAction(OnEnergyDepleted));
triggerAnimationCurve = AssetManager.instance.animationCurveClickInOut;
OptimizeEventCalls();
}
}
private void OptimizeEventCalls()
{
hasIdleUpdate = onStateIdleUpdate != null;
hasIdleFixedUpdate = onStateIdleFixedUpdate != null;
hasOutOfEnergyUpdate = onStateOutOfEnergyUpdate != null;
hasOutOfEnergyFixedUpdate = onStateOutOfEnergyFixedUpdate != null;
hasBuildupUpdate = onStateBuildupUpdate != null;
hasBuildupFixedUpdate = onStateBuildupFixedUpdate != null;
hasShootingUpdate = onStateShootingUpdate != null;
hasShootingFixedUpdate = onStateShootingFixedUpdate != null;
hasReloadingUpdate = onStateReloadingUpdate != null;
hasReloadingFixedUpdate = onStateReloadingFixedUpdate != null;
}
private void FixedUpdate()
{
StateMachine(_fixedUpdate: true);
}
private void Update()
{
StateMachine(_fixedUpdate: false);
HandleGrabbing();
HandleTriggerAnimation();
UpdateMaster();
}
private void HandleGrabbing()
{
if (physGrabObject.grabbed && physGrabObject.grabbedLocal)
{
PhysGrabber.instance.OverrideGrabDistance(distanceKeep);
}
}
private void HandleTriggerAnimation()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if (triggerAnimationActive)
{
float num = 45f;
triggerAnimationEval += Time.deltaTime * 4f;
gunTrigger.localRotation = Quaternion.Euler(num * triggerAnimationCurve.Evaluate(triggerAnimationEval), 0f, 0f);
if (triggerAnimationEval >= 1f)
{
gunTrigger.localRotation = Quaternion.Euler(0f, 0f, 0f);
triggerAnimationActive = false;
triggerAnimationEval = 1f;
}
}
}
private void UpdateMaster()
{
//IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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)
if (!SemiFunc.IsMasterClientOrSingleplayer() || physGrabObject.playerGrabbing.Count <= 0)
{
return;
}
Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f);
Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
Quaternion identity = Quaternion.identity;
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = true;
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
if (flag4)
{
if (item.playerAvatar.isCrouching)
{
flag2 = true;
}
if (item.playerAvatar.isCrawling)
{
flag3 = true;
}
flag4 = false;
}
if (item.isRotating)
{
flag = true;
}
}
if (!flag)
{
physGrabObject.TurnXYZ(val, val2, identity);
}
float num = grabVerticalOffset;
if (flag2)
{
num += 0.5f;
}
if (flag3)
{
num -= 0.5f;
}
physGrabObject.OverrideGrabVerticalPosition(num);
if (!flag && physGrabObject.grabbed)
{
physGrabObject.OverrideTorqueStrength(12f, 0.1f);
physGrabObject.OverrideAngularDrag(20f, 0.1f);
}
if (flag)
{
physGrabObject.OverrideTorqueStrength(2f, 0.1f);
physGrabObject.OverrideAngularDrag(20f, 0.1f);
}
}
public void Misfire()
{
if (!roomVolumeCheck.inTruck && !physGrabObject.grabbed && !physGrabObject.hasNeverBeenGrabbed && SemiFunc.IsMasterClientOrSingleplayer() && (float)Random.Range(0, 100) < misfirePercentageChange)
{
Shoot();
}
}
public void Shoot()
{
//IL_0061: 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)
if (!plasmaEnergySystem.HasEnoughEnergy || !plasmaEnergySystem.TryConsumeEnergy())
{
return;
}
if (hasOneShot)
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("ShootRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
ShootRPC();
}
StateSet(State.Reloading);
}
else if (hasBuildUp)
{
StateSet(State.Buildup);
}
else
{
StateSet(State.Shooting);
}
}
private void MuzzleFlash()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)muzzleFlashPrefab != (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(muzzleFlashPrefab, gunMuzzle.position, gunMuzzle.rotation, gunMuzzle);
PlasmaMuzzleFlash component = val.GetComponent<PlasmaMuzzleFlash>();
if ((Object)(object)component != (Object)null)
{
component.ActivateAllEffects();
}
else
{
ItemGunMuzzleFlash component2 = val.GetComponent<ItemGunMuzzleFlash>();
if ((Object)(object)component2 != (Object)null)
{
component2.ActivateAllEffects();
}
}
}
if ((Object)(object)muzzleFlashParticles != (Object)null)
{
muzzleFlashParticles.Play();
}
}
private void StartTriggerAnimation()
{
triggerAnimationActive = true;
triggerAnimationEval = 0f;
}
private void OnEnergyDepleted()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (soundEnergyDepleted != null)
{
soundEnergyDepleted.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
[PunRPC]
public void ShootRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0089: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.MasterOnlyRPC(_info))
{
return;
}
float num = 3f * cameraShakeMultiplier;
float num2 = 16f * cameraShakeMultiplier;
SemiFunc.CameraShakeImpactDistance(gunMuzzle.position, 5f * cameraShakeMultiplier, 0.1f, num, num2);
SemiFunc.CameraShakeDistance(gunMuzzle.position, 0.1f * cameraShakeMultiplier, 0.1f * cameraShakeMultiplier, num, num2);
soundShoot.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
soundShootGlobal.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
MuzzleFlash();
StartTriggerAnimation();
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
if (investigateRadius > 0f)
{
EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
}
physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * gunRecoilForce, gunMuzzle.position, (ForceMode)1);
RaycastHit val4 = default(RaycastHit);
for (int i = 0; i < numberOfBullets; i++)
{
Vector3 endPosition = gunMuzzle.position;
bool hit = false;
bool flag = false;
Vector3 val = gunMuzzle.forward;
if (gunRandomSpread > 0f)
{
float num3 = Random.Range(0f, gunRandomSpread / 2f);
float num4 = Random.Range(0f, 360f);
Vector3 val2 = Vector3.Cross(val, Random.onUnitSphere);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Quaternion val3 = Quaternion.AngleAxis(num3, normalized);
val2 = Quaternion.AngleAxis(num4, val) * val3 * val;
val = ((Vector3)(ref val2)).normalized;
}
if (Physics.Raycast(gunMuzzle.position, val, ref val4, gunRange, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "Enemy" })))
{
endPosition = ((RaycastHit)(ref val4)).point;
hit = true;
}
else
{
flag = true;
}
if (flag)
{
endPosition = gunMuzzle.position + gunMuzzle.forward * gunRange;
hit = true;
}
ShootBullet(endPosition, hit);
}
}
private void ShootBullet(Vector3 _endPosition, bool _hit)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("ShootBulletRPC", (RpcTarget)0, new object[2] { _endPosition, _hit });
}
else
{
ShootBulletRPC(_endPosition, _hit);
}
}
}
[PunRPC]
public void ShootBulletRPC(Vector3 _endPosition, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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)
if (!SemiFunc.MasterOnlyRPC(_info))
{
return;
}
if (physGrabObject.playerGrabbing.Count > 1)
{
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
item.OverrideGrabRelease();
}
}
if ((Object)(object)bulletPrefab != (Object)null)
{
PlasmaProjectile component = Object.Instantiate<GameObject>(bulletPrefab, gunMuzzle.position, gunMuzzle.rotation).GetComponent<PlasmaProjectile>();
component.SetProjectileData(gunMuzzle.position, _endPosition, _hit);
hurtCollider = ((Component)component).GetComponentInChildren<HurtCollider>();
component.ActivateAll();
}
soundHit.Play(_endPosition, 1f, 1f, 1f, 1f);
if ((Object)(object)energyTrailParticles != (Object)null)
{
energyTrailParticles.Play();
}
}
private void StateSet(State _state)
{
//IL_004f: 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)
if (_state == stateCurrent)
{
return;
}
if (SemiFunc.IsMultiplayer())
{
if (SemiFunc.IsMasterClient())
{
photonView.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (int)_state });
}
}
else
{
StateSetRPC((int)_state);
}
}
private void ShootLogic()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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)
if (SemiFunc.IsMasterClientOrSingleplayer() && itemToggle.toggleState != prevToggleState)
{
if (!plasmaEnergySystem.HasEnoughEnergy)
{
soundNoEnergyClick.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
StartTriggerAnimation();
SemiFunc.CameraShakeImpact(1f, 0.1f);
physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * 1f, gunMuzzle.position, (ForceMode)1);
}
else
{
Shoot();
}
prevToggleState = itemToggle.toggleState;
}
}
[PunRPC]
private void StateSetRPC(int state, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
stateStart = true;
statePrev = stateCurrent;
stateCurrent = (State)state;
}
}
private void StateMachine(bool _fixedUpdate)
{
switch (stateCurrent)
{
case State.Idle:
StateIdle(_fixedUpdate);
break;
case State.OutOfEnergy:
StateOutOfEnergy(_fixedUpdate);
break;
case State.Buildup:
StateBuildup(_fixedUpdate);
break;
case State.Shooting:
StateShooting(_fixedUpdate);
break;
case State.Reloading:
StateReloading(_fixedUpdate);
break;
}
}
private void StateIdle(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
UnityEvent obj = onStateIdleStart;
if (obj != null)
{
obj.Invoke();
}
stateStart = false;
prevToggleState = itemToggle.toggleState;
}
if (!_fixedUpdate)
{
ShootLogic();
if (hasIdleUpdate)
{
onStateIdleUpdate.Invoke();
}
}
if (_fixedUpdate && hasIdleFixedUpdate)
{
onStateIdleFixedUpdate.Invoke();
}
}
private void StateOutOfEnergy(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
UnityEvent obj = onStateOutOfEnergyStart;
if (obj != null)
{
obj.Invoke();
}
stateStart = false;
prevToggleState = itemToggle.toggleState;
}
if (!_fixedUpdate)
{
if (plasmaEnergySystem.HasEnoughEnergy)
{
StateSet(State.Idle);
return;
}
ShootLogic();
if (hasOutOfEnergyUpdate)
{
onStateOutOfEnergyUpdate.Invoke();
}
}
if (_fixedUpdate && hasOutOfEnergyFixedUpdate)
{
onStateOutOfEnergyFixedUpdate.Invoke();
}
}
private void StateBuildup(bool _fixedUpdate)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if (stateStart && !_fixedUpdate)
{
UnityEvent obj = onStateBuildupStart;
if (obj != null)
{
obj.Invoke();
}
stateTimer = 0f;
stateTimeMax = buildUpTime;
stateStart = false;
if ((Object)(object)chargingParticles != (Object)null)
{
chargingParticles.Play();
}
if (soundCharging != null)
{
soundCharging.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
if (!_fixedUpdate)
{
if (hasBuildupUpdate)
{
onStateBuildupUpdate.Invoke();
}
stateTimer += Time.deltaTime;
if (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped)
{
StateSet(State.Idle);
}
if (stateTimer >= stateTimeMax && plasmaEnergySystem.HasEnoughEnergy)
{
StateSet(State.Shooting);
}
}
if (_fixedUpdate && hasBuildupFixedUpdate)
{
onStateBuildupFixedUpdate.Invoke();
}
}
private void StateShooting(bool _fixedUpdate)
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
if (stateStart && !_fixedUpdate)
{
stateStart = false;
UnityEvent obj = onStateShootingStart;
if (obj != null)
{
obj.Invoke();
}
if (!hasOneShot)
{
stateTimeMax = shootTime;
stateTimer = 0f;
investigateCooldown = 0f;
}
else
{
stateTimer = 0.001f;
}
}
if (!_fixedUpdate)
{
if (investigateRadius > 0f)
{
if (investigateCooldown <= 0f)
{
EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
investigateCooldown = 0.5f;
}
else
{
investigateCooldown -= Time.deltaTime;
}
}
stateTimer += Time.deltaTime;
if (stateTimer >= stateTimeMax || (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped))
{
StateSet(State.Reloading);
}
if (hasShootingUpdate)
{
onStateShootingUpdate.Invoke();
}
}
if (_fixedUpdate && hasShootingFixedUpdate)
{
onStateShootingFixedUpdate.Invoke();
}
}
private void StateReloading(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
UnityEvent obj = onStateReloadingStart;
if (obj != null)
{
obj.Invoke();
}
stateTimeMax = shootCooldown;
stateTimer = 0f;
}
if (!_fixedUpdate)
{
stateTimer += Time.deltaTime;
if (stateTimer >= stateTimeMax)
{
if (plasmaEnergySystem.HasEnoughEnergy)
{
StateSet(State.Idle);
}
else
{
StateSet(State.OutOfEnergy);
}
}
if (hasReloadingUpdate)
{
onStateReloadingUpdate.Invoke();
}
}
if (_fixedUpdate && hasReloadingFixedUpdate)
{
onStateReloadingFixedUpdate.Invoke();
}
}
public float GetCurrentEnergyPercentage()
{
return plasmaEnergySystem.CurrentEnergyPercentage;
}
public bool HasEnoughEnergy()
{
return plasmaEnergySystem.HasEnoughEnergy;
}
public bool IsRegenerating()
{
return plasmaEnergySystem.IsRegenerating;
}
}
[Serializable]
public class PlasmaEnergySystem : MonoBehaviour
{
[Header("Plasma Energy Settings")]
[Range(0f, 100f)]
public float maxEnergy = 100f;
[Range(0.1f, 50f)]
public float energyDrainPerShot = 10f;
[Range(0.1f, 20f)]
public float energyRegenRate = 5f;
[Range(0f, 5f)]
public float regenDelay = 1f;
[Header("Critical Energy System")]
[Range(0f, 25f)]
public float criticalEnergyThreshold = 10f;
[Range(0f, 10f)]
public float criticalRegenDelay = 3f;
public Sound criticalEnergySound;
[Header("Current State")]
[SerializeField]
private float currentEnergy = 100f;
[SerializeField]
private bool isRegenerating = false;
[SerializeField]
private bool isInCriticalState = false;
private float lastShotTime = 0f;
private PhotonView photonView;
private bool hasPlayedCriticalSound = false;
[Header("Events")]
public UnityEvent<float> OnEnergyChanged;
public UnityEvent OnEnergyDepleted;
public UnityEvent OnRegenerationStarted;
public UnityEvent OnRegenerationStopped;
public UnityEvent<bool> OnRegenerationStateChanged;
public float CurrentEnergy => currentEnergy;
public float CurrentEnergyPercentage => currentEnergy / maxEnergy * 100f;
public bool HasEnoughEnergy => currentEnergy >= energyDrainPerShot && !isInCriticalState;
public bool IsRegenerating => isRegenerating;
public bool IsFullyCharged => currentEnergy >= maxEnergy;
public bool IsInCriticalState => isInCriticalState;
private void Awake()
{
photonView = ((Component)this).GetComponent<PhotonView>();
currentEnergy = maxEnergy;
}
private void Start()
{
OnEnergyChanged?.Invoke(CurrentEnergyPercentage);
}
private void Update()
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
HandleEnergyRegeneration();
}
}
private void HandleEnergyRegeneration()
{
HandleCriticalEnergyState();
float num = (isInCriticalState ? (regenDelay + criticalRegenDelay) : regenDelay);
bool flag = currentEnergy < maxEnergy && Time.time >= lastShotTime + num;
if (flag && !isRegenerating)
{
StartRegeneration();
}
else if (!flag && isRegenerating)
{
StopRegeneration();
}
if (!isRegenerating)
{
return;
}
float num2 = currentEnergy;
currentEnergy = Mathf.Min(currentEnergy + energyRegenRate * Time.deltaTime, maxEnergy);
if (currentEnergy != num2)
{
SyncEnergyLevel(currentEnergy);
}
if (currentEnergy >= maxEnergy)
{
StopRegeneration();
if (isInCriticalState)
{
ExitCriticalState();
}
}
}
private void HandleCriticalEnergyState()
{
float currentEnergyPercentage = CurrentEnergyPercentage;
if (!isInCriticalState && currentEnergyPercentage <= criticalEnergyThreshold)
{
EnterCriticalState();
}
else if (isInCriticalState && currentEnergyPercentage >= 100f)
{
ExitCriticalState();
}
}
private void EnterCriticalState()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
isInCriticalState = true;
if (!hasPlayedCriticalSound && criticalEnergySound != null)
{
criticalEnergySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
hasPlayedCriticalSound = true;
}
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("SetCriticalStateRPC", (RpcTarget)0, new object[1] { true });
}
}
private void ExitCriticalState()
{
isInCriticalState = false;
hasPlayedCriticalSound = false;
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("SetCriticalStateRPC", (RpcTarget)0, new object[1] { false });
}
}
public bool TryConsumeEnergy()
{
if (!HasEnoughEnergy)
{
UnityEvent onEnergyDepleted = OnEnergyDepleted;
if (onEnergyDepleted != null)
{
onEnergyDepleted.Invoke();
}
return false;
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
ConsumeEnergy(energyDrainPerShot);
}
return true;
}
public bool TryConsumeEnergy(float amount)
{
if (currentEnergy < amount)
{
UnityEvent onEnergyDepleted = OnEnergyDepleted;
if (onEnergyDepleted != null)
{
onEnergyDepleted.Invoke();
}
return false;
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
ConsumeEnergy(amount);
}
return true;
}
private void ConsumeEnergy(float amount)
{
currentEnergy = Mathf.Max(currentEnergy - amount, 0f);
lastShotTime = Time.time;
if (isRegenerating)
{
StopRegeneration();
}
SyncEnergyLevel(currentEnergy);
}
private void StartRegeneration()
{
isRegenerating = true;
UnityEvent onRegenerationStarted = OnRegenerationStarted;
if (onRegenerationStarted != null)
{
onRegenerationStarted.Invoke();
}
OnRegenerationStateChanged?.Invoke(true);
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("SetRegenerationStateRPC", (RpcTarget)0, new object[1] { true });
}
}
private void StopRegeneration()
{
isRegenerating = false;
UnityEvent onRegenerationStopped = OnRegenerationStopped;
if (onRegenerationStopped != null)
{
onRegenerationStopped.Invoke();
}
OnRegenerationStateChanged?.Invoke(false);
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("SetRegenerationStateRPC", (RpcTarget)0, new object[1] { false });
}
}
private void SyncEnergyLevel(float energy)
{
OnEnergyChanged?.Invoke(energy / maxEnergy * 100f);
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("SetEnergyLevelRPC", (RpcTarget)0, new object[1] { energy });
}
}
[PunRPC]
private void SetEnergyLevelRPC(float energy)
{
currentEnergy = energy;
OnEnergyChanged?.Invoke(energy / maxEnergy * 100f);
}
[PunRPC]
private void SetRegenerationStateRPC(bool regenerating)
{
isRegenerating = regenerating;
OnRegenerationStateChanged?.Invoke(regenerating);
if (regenerating)
{
UnityEvent onRegenerationStarted = OnRegenerationStarted;
if (onRegenerationStarted != null)
{
onRegenerationStarted.Invoke();
}
}
else
{
UnityEvent onRegenerationStopped = OnRegenerationStopped;
if (onRegenerationStopped != null)
{
onRegenerationStopped.Invoke();
}
}
}
[PunRPC]
private void SetCriticalStateRPC(bool critical)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
isInCriticalState = critical;
if (critical && !hasPlayedCriticalSound && criticalEnergySound != null)
{
criticalEnergySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
hasPlayedCriticalSound = true;
}
else if (!critical)
{
hasPlayedCriticalSound = false;
}
}
public void SetMaxEnergy(float newMaxEnergy)
{
maxEnergy = newMaxEnergy;
currentEnergy = Mathf.Min(currentEnergy, maxEnergy);
OnEnergyChanged?.Invoke(CurrentEnergyPercentage);
}
public void SetEnergyDrainPerShot(float newDrain)
{
energyDrainPerShot = newDrain;
}
public void SetRegenRate(float newRate)
{
energyRegenRate = newRate;
}
public void SetRegenDelay(float newDelay)
{
regenDelay = newDelay;
}
public void RestoreEnergy(float amount)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
currentEnergy = Mathf.Min(currentEnergy + amount, maxEnergy);
SyncEnergyLevel(currentEnergy);
}
}
public void SetEnergyLevel(float energy)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
currentEnergy = Mathf.Clamp(energy, 0f, maxEnergy);
SyncEnergyLevel(currentEnergy);
}
}
[ContextMenu("Drain 25% Energy")]
private void DebugDrainEnergy()
{
TryConsumeEnergy(maxEnergy * 0.25f);
}
[ContextMenu("Restore Full Energy")]
private void DebugRestoreEnergy()
{
SetEnergyLevel(maxEnergy);
}
}
public class PlasmaMuzzleFlash : MonoBehaviour
{
[CompilerGenerated]
private sealed class <MuzzleFlashDestroy>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlasmaMuzzleFlash <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MuzzleFlashDestroy>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(<>4__this.initialDelay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
break;
case 2:
<>1__state = -1;
break;
}
if (<>4__this.AreParticlesPlaying() || <>4__this.AreLightsActive())
{
<>2__current = null;
<>1__state = 2;
return true;
}
Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
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();
}
}
[Header("Particle Systems")]
[Tooltip("Assign as many particle systems as you want for the muzzle flash")]
public ParticleSystem[] muzzleParticles;
[Header("Lights")]
[Tooltip("Assign as many lights as you want for the muzzle flash")]
public Light[] muzzleLights;
[Header("Settings")]
[Tooltip("How long to wait before starting the destruction check")]
public float initialDelay = 0.1f;
[Tooltip("Speed at which lights fade out")]
public float lightFadeSpeed = 10f;
[Tooltip("Minimum light intensity before disabling")]
public float minLightIntensity = 0.01f;
private List<float> originalLightIntensities = new List<float>();
private bool effectsActivated = false;
public void ActivateAllEffects()
{
((Component)this).gameObject.SetActive(true);
effectsActivated = true;
originalLightIntensities.Clear();
if (muzzleParticles != null)
{
ParticleSystem[] array = muzzleParticles;
foreach (ParticleSystem val in array)
{
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(true);
val.Play();
}
}
}
if (muzzleLights != null)
{
Light[] array2 = muzzleLights;
foreach (Light val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
originalLightIntensities.Add(val2.intensity);
((Behaviour)val2).enabled = true;
}
}
}
((MonoBehaviour)this).StartCoroutine(MuzzleFlashDestroy());
}
[IteratorStateMachine(typeof(<MuzzleFlashDestroy>d__8))]
private IEnumerator MuzzleFlashDestroy()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MuzzleFlashDestroy>d__8(0)
{
<>4__this = this
};
}
private bool AreParticlesPlaying()
{
if (muzzleParticles == null)
{
return false;
}
ParticleSystem[] array = muzzleParticles;
foreach (ParticleSystem val in array)
{
if ((Object)(object)val != (Object)null && val.isPlaying)
{
return true;
}
}
return false;
}
private bool AreLightsActive()
{
if (muzzleLights == null)
{
return false;
}
Light[] array = muzzleLights;
foreach (Light val in array)
{
if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
{
return true;
}
}
return false;
}
private void Update()
{
if (!effectsActivated || muzzleLights == null)
{
return;
}
for (int i = 0; i < muzzleLights.Length; i++)
{
Light val = muzzleLights[i];
if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
{
val.intensity = Mathf.Lerp(val.intensity, 0f, Time.deltaTime * lightFadeSpeed);
if (val.intensity < minLightIntensity)
{
((Behaviour)val).enabled = false;
}
}
}
}
public void StopAllEffects()
{
if (muzzleParticles != null)
{
ParticleSystem[] array = muzzleParticles;
foreach (ParticleSystem val in array)
{
if ((Object)(object)val != (Object)null)
{
val.Stop();
}
}
}
if (muzzleLights == null)
{
return;
}
Light[] array2 = muzzleLights;
foreach (Light val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
((Behaviour)val2).enabled = false;
}
}
}
public void ResetLightIntensities()
{
if (muzzleLights == null || originalLightIntensities.Count != muzzleLights.Length)
{
return;
}
for (int i = 0; i < muzzleLights.Length; i++)
{
if ((Object)(object)muzzleLights[i] != (Object)null && i < originalLightIntensities.Count)
{
muzzleLights[i].intensity = originalLightIntensities[i];
}
}
}
[ContextMenu("Test Muzzle Flash")]
private void TestMuzzleFlash()
{
ActivateAllEffects();
}
private void OnDestroy()
{
originalLightIntensities.Clear();
}
}
public class PlasmaProjectile : MonoBehaviour
{
[CompilerGenerated]
private sealed class <ProjectileDestroy>d__54 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlasmaProjectile <>4__this;
private float <timer>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ProjectileDestroy>d__54(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<timer>5__1 = 0f;
goto IL_0066;
case 1:
<>1__state = -1;
goto IL_0066;
case 2:
{
<>1__state = -1;
<>4__this.StopProjectileParticles();
if (<>4__this.useTrailRenderer && (Object)(object)<>4__this.plasmaTrailRenderer != (Object)null)
{
((Renderer)<>4__this.plasmaTrailRenderer).enabled = false;
}
Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
return false;
}
IL_0066:
if (<timer>5__1 < <>4__this.maxLifetime && <>4__this.isMoving)
{
<timer>5__1 += Time.deltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
if (<>4__this.isMoving)
{
<>4__this.isMoving = false;
<>4__this.StopProjectileParticles();
}
<>2__current = (object)new WaitForSeconds(<>4__this.projectileLingerTime);
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ProjectileMovement>d__52 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlasmaProjectile <>4__this;
private float <moveDistance>5__1;
private Vector3 <newPosition>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ProjectileMovement>d__52(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.currentDistance = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<>4__this.isMoving && <>4__this.currentDistance < <>4__this.totalDistance)
{
<moveDistance>5__1 = <>4__this.projectileSpeed * Time.deltaTime;
<>4__this.currentDistance += <moveDistance>5__1;
<newPosition>5__2 = <>4__this.startPosition + <>4__this.direction * <>4__this.currentDistance;
((Component)<>4__this).transform.position = <newPosition>5__2;
if (!(<>4__this.currentDistance >= <>4__this.totalDistance))
{
<>2__current = null;
<>1__state = 1;
return true;
}
((Component)<>4__this).transform.position = <>4__this.hitPosition;
<>4__this.hasReachedTarget = true;
<>4__this.isMoving = false;
<>4__this.TriggerImpact();
}
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();
}
}
[Header("Projectile Settings")]
public float projectileSpeed = 30f;
public float maxLifetime = 3f;
[Header("Plasma Particle Effects")]
private Transform hitEffectTransform;
private ParticleSystem particleImpactSparks;
private ParticleSystem particleImpactSmoke;
private ParticleSystem particleImpactEnergy;
private ParticleSystem particleImpactGlow;
private Light hitLight;
private Light projectileLight;
[Header("Projectile Particles")]
public ParticleSystem plasmaCore;
public ParticleSystem plasmaTrail;
public ParticleSystem plasmaGlow;
public ParticleSystem plasmaEnergy;
[Header("Trail Renderer Option")]
public bool useTrailRenderer = false;
public TrailRenderer plasmaTrailRenderer;
[Header("Scaling Options")]
public bool enableScaling = true;
[Space(5f)]
public bool useInitialScale = true;
public Vector3 initialScaleMultiplier = new Vector3(0.5f, 0.5f, 0.5f);
[Space(5f)]
public bool scaleOverDistance = true;
public AnimationCurve scaleOverDistanceCurve = AnimationCurve.Linear(0f, 1f, 1f, 0.5f);
[Space(5f)]
public bool scaleOverTime = false;
public AnimationCurve scaleOverTimeCurve = AnimationCurve.Linear(0f, 1f, 1f, 0.8f);
[Space(5f)]
public bool scaleOnImpact = true;
public AnimationCurve impactScaleCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, 1f),
new Keyframe(0.3f, 0f)
});
public float impactScaleDuration = 0.3f;
[Space(5f)]
public Vector3 minScale = new Vector3(0.1f, 0.1f, 0.1f);
public Vector3 maxScale = new Vector3(2f, 2f, 2f);
[Header("Damage Settings")]
public bool hasHurtCollider = true;
public HurtCollider hurtCollider;
public float hurtColliderTimer = 0.25f;
[Header("Impact Effects")]
public GameObject hitEffectPrefab;
public float hitEffectDestroyTime = 3f;
public GameObject hitGameObject;
public float hitGameObjectDestroyTime = 2f;
public bool hasExtraParticles;
public GameObject extraParticles;
[Header("Projectile Cleanup")]
public float projectileLingerTime = 0.1f;
internal bool projectileHit;
internal Vector3 hitPosition;
internal Vector3 startPosition;
internal Vector3 direction;
private float currentDistance;
private float totalDistance;
private bool isMoving = true;
private bool hasReachedTarget = false;
private Vector3 originalScale;
private float projectileLifetime = 0f;
private bool isImpactScaling = false;
private float impactScaleTimer = 0f;
public void ActivateAll()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.SetActive(true);
originalScale = ((Component)this).transform.localScale;
hitEffectTransform = ((Component)this).transform.Find("Hit Effect");
if ((Object)(object)hitEffectTransform != (Object)null)
{
Transform obj = hitEffectTransform.Find("Particle Impact Sparks");
particleImpactSparks = ((obj != null) ? ((Component)obj).GetComponent<ParticleSystem>() : null);
Transform obj2 = hitEffectTransform.Find("Particle Impact Smoke");
particleImpactSmoke = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null);
Transform obj3 = hitEffectTransform.Find("Particle Impact Energy");
particleImpactEnergy = ((obj3 != null) ? ((Component)obj3).GetComponent<ParticleSystem>() : null);
Transform obj4 = hitEffectTransform.Find("Particle Impact Glow");
particleImpactGlow = ((obj4 != null) ? ((Component)obj4).GetComponent<ParticleSystem>() : null);
Transform obj5 = hitEffectTransform.Find("Hit Light");
hitLight = ((obj5 != null) ? ((Component)obj5).GetComponent<Light>() : null);
}
projectileLight = ((Component)this).GetComponentInChildren<Light>();
if (useTrailRenderer && (Object)(object)plasmaTrailRenderer == (Object)null)
{
plasmaTrailRenderer = ((Component)this).GetComponentInChildren<TrailRenderer>();
}
startPosition = ((Component)this).transform.position;
Vector3 val = hitPosition - startPosition;
direction = ((Vector3)(ref val)).normalized;
totalDistance = Vector3.Distance(startPosition, hitPosition);
if (direction != Vector3.zero)
{
((Component)this).transform.rotation = Quaternion.LookRotation(direction);
}
if (enableScaling && useInitialScale)
{
originalScale = Vector3.Scale(originalScale, initialScaleMultiplier);
((Component)this).transform.localScale = originalScale;
}
StartProjectileParticles();
if (useTrailRenderer && (Object)(object)plasmaTrailRenderer != (Object)null)
{
((Renderer)plasmaTrailRenderer).enabled = true;
}
if ((Object)(object)projectileLight != (Object)null)
{
((Behaviour)projectileLight).enabled = true;
}
((MonoBehaviour)this).StartCoroutine(ProjectileMovement());
((MonoBehaviour)this).StartCoroutine(ProjectileDestroy());
}
private void StartProjectileParticles()
{
if ((Object)(object)plasmaCore != (Object)null)
{
((Component)plasmaCore).gameObject.SetActive(true);
plasmaCore.Play();
}
if ((Object)(object)plasmaTrail != (Object)null)
{
((Component)plasmaTrail).gameObject.SetActive(true);
plasmaTrail.Play();
}
if ((Object)(object)plasmaGlow != (Object)null)
{
((Component)plasmaGlow).gameObject.SetActive(true);
plasmaGlow.Play();
}
if ((Object)(object)plasmaEnergy != (Object)null)
{
((Component)plasmaEnergy).gameObject.SetActive(true);
plasmaEnergy.Play();
}
}
private void StopProjectileParticles()
{
if ((Object)(object)plasmaCore != (Object)null)
{
plasmaCore.Stop();
}
if ((Object)(object)plasmaTrail != (Object)null)
{
plasmaTrail.Stop();
}
if ((Object)(object)plasmaGlow != (Object)null)
{
plasmaGlow.Stop();
}
if ((Object)(object)plasmaEnergy != (Object)null)
{
plasmaEnergy.Stop();
}
if ((Object)(object)projectileLight != (Object)null)
{
((Behaviour)projectileLight).enabled = false;
}
}
[IteratorStateMachine(typeof(<ProjectileMovement>d__52))]
private IEnumerator ProjectileMovement()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ProjectileMovement>d__52(0)
{
<>4__this = this
};
}
private void TriggerImpact()
{
//IL_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
StopProjectileParticles();
if (enableScaling && scaleOnImpact)
{
isImpactScaling = true;
impactScaleTimer = 0f;
}
if (!projectileHit)
{
return;
}
if ((Object)(object)hitEffectPrefab != (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(hitEffectPrefab, hitPosition, Quaternion.LookRotation(-direction));
val.SetActive(true);
ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>();
ParticleSystem[] array = componentsInChildren;
foreach (ParticleSystem val2 in array)
{
((Component)val2).gameObject.SetActive(true);
val2.Play();
}
Light[] componentsInChildren2 = val.GetComponentsInChildren<Light>();
Light[] array2 = componentsInChildren2;
foreach (Light val3 in array2)
{
((Behaviour)val3).enabled = true;
}
Object.Destroy((Object)(object)val, hitEffectDestroyTime);
}
if ((Object)(object)hitEffectTransform != (Object)null)
{
((Component)hitEffectTransform).gameObject.SetActive(true);
hitEffectTransform.position = hitPosition;
hitEffectTransform.rotation = Quaternion.LookRotation(-direction);
if ((Object)(object)particleImpactSparks != (Object)null)
{
((Component)particleImpactSparks).gameObject.SetActive(true);
particleImpactSparks.Play();
}
if ((Object)(object)particleImpactSmoke != (Object)null)
{
((Component)particleImpactSmoke).gameObject.SetActive(true);
particleImpactSmoke.Play();
}
if ((Object)(object)particleImpactEnergy != (Object)null)
{
((Component)particleImpactEnergy).gameObject.SetActive(true);
particleImpactEnergy.Play();
}
if ((Object)(object)particleImpactGlow != (Object)null)
{
((Component)particleImpactGlow).gameObject.SetActive(true);
particleImpactGlow.Play();
}
if ((Object)(object)hitLight != (Object)null)
{
((Behaviour)hitLight).enabled = true;
}
}
GameObject val4 = null;
if (hasHurtCollider && (Object)(object)hurtCollider != (Object)null)
{
val4 = ((Component)hurtCollider).gameObject;
}
else if ((Object)(object)hitGameObject != (Object)null)
{
val4 = hitGameObject;
}
if ((Object)(object)val4 != (Object)null)
{
val4.SetActive(true);
val4.transform.position = hitPosition;
val4.transform.rotation = Quaternion.LookRotation(-direction);
}
if (hasExtraParticles && (Object)(object)extraParticles != (Object)null)
{
extraParticles.SetActive(true);
extraParticles.transform.position = hitPosition;
extraParticles.transform.rotation = Quaternion.LookRotation(-direction);
}
}
[IteratorStateMachine(typeof(<ProjectileDestroy>d__54))]
private IEnumerator ProjectileDestroy()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ProjectileDestroy>d__54(0)
{
<>4__this = this
};
}
private bool AreParticlesPlaying()
{
bool result = false;
if ((Object)(object)plasmaCore != (Object)null && plasmaCore.isPlaying)
{
result = true;
}
if ((Object)(object)plasmaTrail != (Object)null && plasmaTrail.isPlaying)
{
result = true;
}
if ((Object)(object)plasmaGlow != (Object)null && plasmaGlow.isPlaying)
{
result = true;
}
if ((Object)(object)plasmaEnergy != (Object)null && plasmaEnergy.isPlaying)
{
result = true;
}
if ((Object)(object)particleImpactSparks != (Object)null && particleImpactSparks.isPlaying)
{
result = true;
}
if ((Object)(object)particleImpactSmoke != (Object)null && particleImpactSmoke.isPlaying)
{
result = true;
}
if ((Object)(object)particleImpactEnergy != (Object)null && particleImpactEnergy.isPlaying)
{
result = true;
}
if ((Object)(object)particleImpactGlow != (Object)null && particleImpactGlow.isPlaying)
{
result = true;
}
return result;
}
private bool IsLightActive()
{
bool result = false;
if ((Object)(object)projectileLight != (Object)null && ((Behaviour)projectileLight).enabled)
{
result = true;
}
if ((Object)(object)hitLight != (Object)null && ((Behaviour)hitLight).enabled)
{
result = true;
}
return result;
}
private bool IsHurtColliderActive()
{
return hasHurtCollider && (Object)(object)hurtCollider != (Object)null && ((Component)hurtCollider).gameObject.activeSelf;
}
private bool IsHitGameObjectActive()
{
return !hasHurtCollider && (Object)(object)hitGameObject != (Object)null && hitGameObject.activeSelf;
}
private void UpdateEffects()
{
if (projectileHit && hasHurtCollider && (Object)(object)hurtCollider != (Object)null)
{
if (hurtColliderTimer > 0f)
{
hurtColliderTimer -= Time.deltaTime;
if (!((Component)hurtCollider).gameObject.activeSelf)
{
}
}
else
{
((Component)hurtCollider).gameObject.SetActive(false);
}
}
if (projectileHit && !hasHurtCollider && (Object)(object)hitGameObject != (Object)null)
{
hitGameObjectDestroyTime -= Time.deltaTime;
if (hitGameObjectDestroyTime <= 0f)
{
hitGameObject.SetActive(false);
}
}
if ((Object)(object)hitLight != (Object)null && ((Behaviour)hitLight).enabled)
{
hitLight.intensity = Mathf.Lerp(hitLight.intensity, 0f, Time.deltaTime * 10f);
if (hitLight.intensity < 0.01f)
{
((Behaviour)hitLight).enabled = false;
}
}
if ((Object)(object)projectileLight != (Object)null && ((Behaviour)projectileLight).enabled && !isMoving)
{
projectileLight.intensity = Mathf.Lerp(projectileLight.intensity, 0f, Time.deltaTime * 15f);
if (projectileLight.intensity < 0.01f)
{
((Behaviour)projectileLight).enabled = false;
}
}
}
private void Update()
{
projectileLifetime += Time.deltaTime;
if (enableScaling)
{
UpdateScaling();
}
if (hasReachedTarget || !isMoving)
{
UpdateEffects();
}
}
private void UpdateScaling()
{
//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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: 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)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = originalScale;
if (isImpactScaling)
{
impactScaleTimer += Time.deltaTime;
float num = Mathf.Clamp01(impactScaleTimer / impactScaleDuration);
float num2 = impactScaleCurve.Evaluate(num);
val = Vector3.Scale(originalScale, Vector3.one * num2);
if (num >= 1f)
{
isImpactScaling = false;
}
}
else
{
if (scaleOverDistance && totalDistance > 0f)
{
float num3 = Mathf.Clamp01(currentDistance / totalDistance);
float num4 = scaleOverDistanceCurve.Evaluate(num3);
val = Vector3.Scale(val, Vector3.one * num4);
}
if (scaleOverTime)
{
float num5 = Mathf.Clamp01(projectileLifetime / maxLifetime);
float num6 = scaleOverTimeCurve.Evaluate(num5);
val = Vector3.Scale(val, Vector3.one * num6);
}
}
val.x = Mathf.Clamp(val.x, minScale.x, maxScale.x);
val.y = Mathf.Clamp(val.y, minScale.y, maxScale.y);
val.z = Mathf.Clamp(val.z, minScale.z, maxScale.z);
((Component)this).transform.localScale = val;
}
public void SetProjectileData(Vector3 startPos, Vector3 endPos, bool hit)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
startPosition = startPos;
hitPosition = endPos;
projectileHit = hit;
((Component)this).transform.position = startPos;
}
}
public class PlasmaVisualLogic : MonoBehaviour
{
[Header("Plasma System Reference")]
[Tooltip("Assign the specific PlasmaEnergySystem this UI should display")]
public PlasmaEnergySystem plasmaEnergySystem;
[Header("UI Components")]
public TextMeshProUGUI energyText;
public TextMeshPro energyText3D;
public Image energyBar;
public GameObject energyContainer;
[Header("Visual Settings")]
public bool usePercentage = true;
public bool showDecimalPlaces = true;
public int decimalPlaces = 1;
public bool showEnergyBar = true;
[Header("Colors")]
public Color normalColor = Color.white;
public Color regeneratingColor = Color.green;
public Color lowEnergyColor = Color.red;
public Color depletedColor = Color.red;
[Header("Animation Settings")]
public bool animateText = true;
public float textAnimationSpeed = 2f;
public bool pulseWhenRegenerating = true;
public float pulseSpeed = 3f;
public float pulseIntensity = 0.3f;
[Header("Low Energy Warning")]
[Range(0f, 50f)]
public float lowEnergyThreshold = 25f;
public bool blinkWhenLow = true;
public float blinkSpeed = 2f;
[Header("Critical Energy Warning")]
public Color criticalColor = Color.red;
public bool flashWhenCritical = true;
public float criticalFlashSpeed = 5f;
public float criticalFlashIntensity = 0.8f;
public bool showCriticalWarning = true;
public string criticalWarningText = "CRITICAL";
public float criticalWarningDuration = 2f;
public bool scalePulseWhenCritical = true;
public float criticalScalePulse = 1.3f;
[Header("World Space Settings")]
public bool faceCamera = true;
public bool scaleWithDistance = true;
public float baseScale = 1f;
public float maxScale = 3f;
public float scaleDistance = 10f;
private PlasmaEnergySystem energySystem;
private Camera mainCamera;
private float currentDisplayedEnergy;
private float targetEnergy;
private bool isRegenerating;
private float animationTimer;
private Color baseColor;
private Vector3 originalScale;
private bool isBlinking;
private float blinkTimer;
private bool isPulsing;
private float pulseTimer;
private bool isInCriticalState;
private bool isCriticalFlashing;
private float criticalFlashTimer;
private bool isCriticalScaling;
private float criticalScaleTimer;
private string originalEnergyText;
private float criticalWarningTimer;
private bool showingCriticalWarning;
private void Awake()
{
//IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_00a9: Expected O, but got Unknown
mainCamera = Camera.main;
energySystem = plasmaEnergySystem;
if ((Object)(object)energySystem == (Object)null)
{
Debug.LogError((object)"PlasmaVisualLogic: No PlasmaEnergySystem assigned! Please assign one in the inspector.");
return;
}
originalScale = ((Component)this).transform.localScale;
baseColor = GetCurrentTextColor();
energySystem.OnEnergyChanged.AddListener((UnityAction<float>)OnEnergyChanged);
energySystem.OnRegenerationStateChanged.AddListener((UnityAction<bool>)OnRegenerationStateChanged);
energySystem.OnEnergyDepleted.AddListener(new UnityAction(OnEnergyDepleted));
}
private void Start()
{
currentDisplayedEnergy = energySystem.CurrentEnergyPercentage;
targetEnergy = currentDisplayedEnergy;
UpdateEnergyDisplay();
if ((Object)(object)energyContainer != (Object)null)
{
energyContainer.SetActive(true);
}
}
private void Update()
{
HandleWorldSpaceSettings();
HandleTextAnimation();
HandleVisualEffects();
}
private void HandleWorldSpaceSettings()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
if (faceCamera && !((Object)(object)mainCamera == (Object)null))
{
((Component)this).transform.LookAt(((Component)mainCamera).transform);
((Component)this).transform.Rotate(0f, 180f, 0f);
if (scaleWithDistance)
{
float num = Vector3.Distance(((Component)this).transform.position, ((Component)mainCamera).transform.position);
float num2 = Mathf.Lerp(baseScale, maxScale, num / scaleDistance);
num2 = Mathf.Clamp(num2, baseScale, maxScale);
((Component)this).transform.localScale = originalScale * num2;
}
}
}
private void HandleTextAnimation()
{
if (animateText)
{
if (Mathf.Abs(currentDisplayedEnergy - targetEnergy) > 0.1f)
{
currentDisplayedEnergy = Mathf.Lerp(currentDisplayedEnergy, targetEnergy, textAnimationSpeed * Time.deltaTime);
UpdateEnergyDisplay();
}
else if (currentDisplayedEnergy != targetEnergy)
{
currentDisplayedEnergy = targetEnergy;
UpdateEnergyDisplay();
}
}
}
private void HandleVisualEffects()
{
//IL_0050: 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_0062: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
HandleCriticalEnergyState();
if (isInCriticalState && showingCriticalWarning)
{
criticalWarningTimer += Time.deltaTime;
if (criticalWarningTimer >= criticalWarningDuration)
{
showingCriticalWarning = false;
}
}
Color textColor = normalColor;
if (isInCriticalState)
{
textColor = criticalColor;
if (flashWhenCritical)
{
HandleCriticalFlashEffect();
}
if (scalePulseWhenCritical)
{
HandleCriticalScaleEffect();
}
}
else if (isRegenerating)
{
textColor = regeneratingColor;
if (pulseWhenRegenerating)
{
HandlePulseEffect();
}
}
else if (currentDisplayedEnergy <= 0f)
{
textColor = depletedColor;
}
else if (currentDisplayedEnergy <= lowEnergyThreshold)
{
textColor = lowEnergyColor;
if (blinkWhenLow)
{
HandleBlinkEffect();
}
}
if (!isPulsing && !isBlinking && !isCriticalFlashing)
{
SetTextColor(textColor);
}
}
private void HandlePulseEffect()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (isPulsing)
{
pulseTimer += Time.deltaTime * pulseSpeed;
float num = (Mathf.Sin(pulseTimer) + 1f) * 0.5f;
Color textColor = Color.Lerp(regeneratingColor, regeneratingColor * (1f + pulseIntensity), num);
SetTextColor(textColor);
}
}
private void HandleBlinkEffect()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
if (isBlinking)
{
blinkTimer += Time.deltaTime * blinkSpeed;
Color textColor = ((Mathf.Sin(blinkTimer) > 0f) ? lowEnergyColor : Color.clear);
SetTextColor(textColor);
}
}
private void HandleCriticalEnergyState()
{
if ((Object)(object)energySystem == (Object)null)
{
return;
}
bool flag = energySystem.IsInCriticalState;
if (flag != isInCriticalState)
{
isInCriticalState = flag;
if (isInCriticalState)
{
EnterCriticalState();
}
else
{
ExitCriticalState();
}
}
}
private void EnterCriticalState()
{
isCriticalFlashing = flashWhenCritical;
isCriticalScaling = scalePulseWhenCritical;
criticalFlashTimer = 0f;
criticalScaleTimer = 0f;
criticalWarningTimer = 0f;
showingCriticalWarning = showCriticalWarning;
if (showCriticalWarning)
{
originalEnergyText = FormatEnergyText(currentDisplayedEnergy);
}
}
private void ExitCriticalState()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
isCriticalFlashing = false;
isCriticalScaling = false;
if (scalePulseWhenCritical)
{
((Component)this).transform.localScale = originalScale;
}
}
private void HandleCriticalFlashEffect()
{
//IL_0042: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
if (isCriticalFlashing)
{
criticalFlashTimer += Time.deltaTime * criticalFlashSpeed;
float num = (Mathf.Sin(criticalFlashTimer) + 1f) * 0.5f;
Color val = criticalColor * (1f + criticalFlashIntensity);
Color textColor = Color.Lerp(criticalColor, val, num);
SetTextColor(textColor);
}
}
private void HandleCriticalScaleEffect()
{
//IL_005a: 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)
if (isCriticalScaling)
{
criticalScaleTimer += Time.deltaTime * criticalFlashSpeed;
float num = (Mathf.Sin(criticalScaleTimer) + 1f) * 0.5f;
float num2 = Mathf.Lerp(1f, criticalScalePulse, num);
((Component)this).transform.localScale = originalScale * num2;
}
}
private void OnEnergyChanged(float energyPercentage)
{
targetEnergy = energyPercentage;
if (!animateText)
{
currentDisplayedEnergy = targetEnergy;
UpdateEnergyDisplay();
}
}
private void OnRegenerationStateChanged(bool regenerating)
{
isRegenerating = regenerating;
isPulsing = regenerating && pulseWhenRegenerating;
if (isPulsing)
{
pulseTimer = 0f;
}
}
private void OnEnergyDepleted()
{
if (!((Object)(object)energyContainer != (Object)null))
{
}
}
private void UpdateEnergyDisplay()
{
string text = ((!isInCriticalState || !showingCriticalWarning) ? FormatEnergyText(currentDisplayedEnergy) : criticalWarningText);
if ((Object)(object)energyText != (Object)null)
{
((TMP_Text)energyText).text = text;
}
if ((Object)(object)energyText3D != (Object)null)
{
((TMP_Text)energyText3D).text = text;
}
if ((Object)(object)energyBar != (Object)null && showEnergyBar)
{
energyBar.fillAmount = currentDisplayedEnergy / 100f;
}
bool flag = currentDisplayedEnergy <= lowEnergyThreshold && currentDisplayedEnergy > 0f && !isRegenerating && !isInCriticalState && blinkWhenLow;
if (flag != isBlinking)
{
isBlinking = flag;
blinkTimer = 0f;
}
}
private string FormatEnergyText(float energy)
{
if (usePercentage)
{
if (showDecimalPlaces)
{
return energy.ToString($"F{decimalPlaces}") + "%";
}
return Mathf.RoundToInt(energy) + "%";
}
float num = energy / 100f * energySystem.maxEnergy;
if (showDecimalPlaces)
{
return num.ToString($"F{decimalPlaces}");
}
return Mathf.RoundToInt(num).ToString();
}
private Color GetCurrentTextColor()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_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_0047: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)energyText != (Object)null)
{
return ((Graphic)energyText).color;
}
if ((Object)(object)energyText3D != (Object)null)
{
return ((Graphic)energyText3D).color;
}
return Color.white;
}
private void SetTextColor(Color color)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)energyText != (Object)null)
{
((Graphic)energyText).color = color;
}
if ((Object)(object)energyText3D != (Object)null)
{
((Graphic)energyText3D).color = color;
}
if ((Object)(object)energyBar != (Object)null)
{
((Graphic)energyBar).color = color;
}
}
public void Show()
{
if ((Object)(object)energyContainer != (Object)null)
{
energyContainer.SetActive(true);
}
}
public void Hide()
{
if ((Object)(object)energyContainer != (Object)null)
{
energyContainer.SetActive(false);
}
}
public void SetVisibility(bool visible)
{
if (visible)
{
Show();
}
else
{
Hide();
}
}
public void OverrideShowTime(float time)
{
Show();
if (time > 0f)
{
((MonoBehaviour)this).Invoke("Hide", time);
}
}
private void OnDestroy()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
if ((Object)(object)energySystem != (Object)null)
{
energySystem.OnEnergyChanged.RemoveListener((UnityAction<float>)OnEnergyChanged);
energySystem.OnRegenerationStateChanged.RemoveListener((UnityAction<bool>)OnRegenerationStateChanged);
energySystem.OnEnergyDepleted.RemoveListener(new UnityAction(OnEnergyDepleted));
}
}
[ContextMenu("Test Low Energy")]
private void TestLowEnergy()
{
OnEnergyChanged(15f);
}
[ContextMenu("Test Critical Energy")]
private void TestCriticalEnergy()
{
isInCriticalState = true;
EnterCriticalState();
OnEnergyChanged(5f);
}
[ContextMenu("Test Regeneration")]
private void TestRegeneration()
{
OnRegenerationStateChanged(regenerating: true);
}
[ContextMenu("Test Normal")]
private void TestNormal()
{
OnEnergyChanged(75f);
OnRegenerationStateChanged(regenerating: false);
isInCriticalState = false;
ExitCriticalState();
}
}
namespace PlasmaGunAPI
{
[BepInPlugin("Rosay.PlasmaGunAPI", "PlasmaGunAPI", "1.0")]
public class PlasmaGunAPI : BaseUnityPlugin
{
internal static PlasmaGunAPI 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()
{
}
}
}