using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
[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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LegendaryShuriken
{
[BepInPlugin("ZeroTails.LegendaryShuriken", "Legendary Shuriken", "1.0.1")]
public class LegendaryShuriken : BaseUnityPlugin
{
public class ValuableDefinition
{
public string Name { get; }
public int SpawnCount { get; }
public float SpawnChance { get; set; }
public bool AntiGravity { get; }
public bool EnableFixedRotation { get; }
public float FixedRotationX { get; }
public float FixedRotationY { get; }
public float FixedRotationZ { get; }
public ValuableDefinition(string name, int spawnCount, float spawnChance, bool antiGravity = false, bool enableFixedRotation = false, float fixedRotationX = 0f, float fixedRotationY = 0f, float fixedRotationZ = 0f)
{
Name = name;
SpawnCount = spawnCount;
SpawnChance = spawnChance;
AntiGravity = antiGravity;
EnableFixedRotation = enableFixedRotation;
FixedRotationX = fixedRotationX;
FixedRotationY = fixedRotationY;
FixedRotationZ = fixedRotationZ;
}
}
public class ItemDefinition : ValuableDefinition
{
public ItemDefinition(string name, int spawnCount, float spawnChance, bool antiGravity = false, bool enableFixedRotation = false, float fixedRotationX = 0f, float fixedRotationY = 0f, float fixedRotationZ = 0f)
: base(name, spawnCount, spawnChance, antiGravity, enableFixedRotation, fixedRotationX, fixedRotationY, fixedRotationZ)
{
}
}
public class AntiGravityBehavior : MonoBehaviour
{
[CompilerGenerated]
private sealed class <BounceCooldown>d__42 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AntiGravityBehavior <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BounceCooldown>d__42(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this._isBounceCooldown = true;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._isBounceCooldown = false;
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();
}
}
[CompilerGenerated]
private sealed class <NonEnemyBounceCooldown>d__43 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AntiGravityBehavior <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <NonEnemyBounceCooldown>d__43(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this._isNonEnemyBounceCooldown = true;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._isNonEnemyBounceCooldown = false;
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();
}
}
[CompilerGenerated]
private sealed class <PeriodicEnemySearch>d__34 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AntiGravityBehavior <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PeriodicEnemySearch>d__34(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!<>4__this._isInInventory && (Object)(object)<>4__this._photonView != (Object)null && <>4__this._photonView.IsMine)
{
<>4__this._targetQueue.Clear();
<>4__this._targetQueue = new Queue<GameObject>(from enemy in GameObject.FindGameObjectsWithTag("Enemy")
where (Object)(object)enemy != (Object)null && Vector3.Distance(((Component)<>4__this).transform.position, enemy.transform.position) <= <>4__this.searchRadius
select enemy);
<>4__this._currentTarget = ((<>4__this._targetQueue.Count > 0) ? <>4__this._targetQueue.Dequeue() : null);
<>4__this._isAttacking = (Object)(object)<>4__this._currentTarget != (Object)null;
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
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 <PeriodicSpin>d__35 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AntiGravityBehavior <>4__this;
private float <spinSpeed>5__1;
private Vector3 <torque>5__2;
private string <spinningAxis>5__3;
private string <>s__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PeriodicSpin>d__35(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<spinningAxis>5__3 = null;
<>s__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (<>4__this._isAttacking)
{
if ((Object)(object)<>4__this._rigidbody != (Object)null && (Object)(object)_instance != (Object)null)
{
<spinSpeed>5__1 = <>4__this.rotationSpeed;
<spinningAxis>5__3 = _instance._spinningAxis?.Value?.ToUpperInvariant() ?? "Y";
string text = <spinningAxis>5__3;
<>s__4 = text;
switch (<>s__4)
{
case "X":
<torque>5__2 = new Vector3(<spinSpeed>5__1, 0f, 0f);
break;
case "Y":
<torque>5__2 = new Vector3(0f, <spinSpeed>5__1, 0f);
break;
case "Z":
<torque>5__2 = new Vector3(0f, 0f, <spinSpeed>5__1);
break;
default:
<torque>5__2 = new Vector3(0f, <spinSpeed>5__1, 0f);
break;
}
<>s__4 = null;
<>4__this._rigidbody.AddTorque(<torque>5__2, (ForceMode)0);
<spinningAxis>5__3 = null;
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ResumeAttackingAfterBounce>d__44 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AntiGravityBehavior <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ResumeAttackingAfterBounce>d__44(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)<>4__this._rigidbody != (Object)null)
{
<>4__this._rigidbody.useGravity = true;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)<>4__this._rigidbody != (Object)null)
{
<>4__this._rigidbody.useGravity = false;
}
<>4__this._isAttacking = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private const byte SlashingRotationEventCode = 1;
public float rotationSpeed = 100f;
public float searchRadius = 7f;
public float attackSpeed = 15f;
private const byte BounceEventCode = 101;
public float enemyBounceBackDistance = 1f;
private bool _isBounceCooldown = false;
public float nonEnemyBounceBackDistance = 1f;
private bool _isNonEnemyBounceCooldown = false;
public LayerMask obstacleLayer;
private Rigidbody? _rigidbody;
private GameObject? _currentTarget;
private Queue<GameObject> _targetQueue = new Queue<GameObject>();
private bool _isAttacking = false;
private bool _wasAttacking = false;
private bool _isInInventory = false;
private bool _isSpinning = false;
private bool _isTransitioning = false;
private PhotonView? _photonView;
private ItemBattery? _itemBattery;
private bool _wasBatteryDepleted = false;
private PhysGrabObject? _physGrabObject;
public bool IsAttacking => _isAttacking;
private void Awake()
{
_rigidbody = ((Component)this).GetComponent<Rigidbody>();
if ((Object)(object)_rigidbody == (Object)null)
{
((Behaviour)this).enabled = false;
return;
}
_rigidbody.useGravity = true;
_rigidbody.drag = 0f;
_rigidbody.angularDrag = 0f;
_rigidbody.collisionDetectionMode = (CollisionDetectionMode)2;
_photonView = ((Component)this).GetComponent<PhotonView>();
_itemBattery = ((Component)this).GetComponent<ItemBattery>();
_physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
}
private void Update()
{
//IL_009f: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_itemBattery == (Object)null)
{
return;
}
if (_wasBatteryDepleted && _itemBattery.batteryLife > 0f)
{
_wasBatteryDepleted = false;
ResumeAttacking();
}
else
{
if (!(_itemBattery.batteryLife <= 0f))
{
return;
}
if (!_wasBatteryDepleted)
{
_wasBatteryDepleted = true;
StopAttacking();
if ((Object)(object)_rigidbody != (Object)null)
{
Rigidbody? rigidbody = _rigidbody;
rigidbody.constraints = (RigidbodyConstraints)(rigidbody.constraints & -17);
Rigidbody? rigidbody2 = _rigidbody;
rigidbody2.constraints = (RigidbodyConstraints)(rigidbody2.constraints & -33);
Rigidbody? rigidbody3 = _rigidbody;
rigidbody3.constraints = (RigidbodyConstraints)(rigidbody3.constraints & -65);
}
}
_isAttacking = false;
_wasAttacking = false;
}
}
private void OnEnable()
{
PhotonNetwork.NetworkingClient.EventReceived += OnEventReceived;
}
private void OnDisable()
{
PhotonNetwork.NetworkingClient.EventReceived -= OnEventReceived;
}
private void OnEventReceived(EventData photonEvent)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (photonEvent.Code == 101 && photonEvent.CustomData is object[] array && array.Length > 1)
{
Vector3 bounceDirection = (Vector3)array[0];
float bounceDistance = (float)array[1];
ApplyBounceForceFromEvent(bounceDirection, bounceDistance);
}
}
private void ApplyBounceForceFromEvent(Vector3 bounceDirection, float bounceDistance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_rigidbody == (Object)null))
{
_rigidbody.AddForce(bounceDirection * bounceDistance, (ForceMode)1);
}
}
private void FixedUpdate()
{
//IL_016b: 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_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: 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_0189: 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_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
if (_isInInventory)
{
StopSpinning();
}
else
{
if ((Object)(object)_photonView != (Object)null && !_photonView.IsMine)
{
return;
}
if ((Object)(object)_itemBattery != (Object)null && _itemBattery.batteryLife <= 0f)
{
if ((Object)(object)_rigidbody != (Object)null)
{
_rigidbody.useGravity = true;
}
if (_isSpinning)
{
StopSpinning();
}
return;
}
if (_isAttacking && (Object)(object)_rigidbody != (Object)null && _rigidbody.isKinematic)
{
_rigidbody.isKinematic = false;
}
if ((Object)(object)_rigidbody != (Object)null)
{
_rigidbody.useGravity = !_isAttacking && (Object)(object)_currentTarget == (Object)null;
}
if (_isAttacking)
{
if (!_wasAttacking)
{
SpinAndApplyRotation();
}
if ((Object)(object)_currentTarget != (Object)null && (Object)(object)_rigidbody != (Object)null)
{
Vector3 val = _currentTarget.transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
_rigidbody.AddForce(normalized * attackSpeed, (ForceMode)0);
float num = 15f;
_rigidbody.velocity = Vector3.ClampMagnitude(_rigidbody.velocity, num);
}
AttackTarget();
}
else if (_wasAttacking)
{
StopSpinning();
}
_wasAttacking = _isAttacking;
}
}
private void ResumeAttacking()
{
_isAttacking = true;
if ((Object)(object)_rigidbody != (Object)null)
{
_rigidbody.isKinematic = false;
_rigidbody.useGravity = false;
_rigidbody.drag = 0f;
_rigidbody.angularDrag = 0f;
}
}
private void StopAttacking()
{
if (_isAttacking)
{
_isAttacking = false;
if ((Object)(object)_rigidbody != (Object)null)
{
_rigidbody.isKinematic = false;
_rigidbody.useGravity = true;
_rigidbody.drag = 0f;
_rigidbody.angularDrag = 0f;
}
if (_isSpinning)
{
StopSpinning();
}
}
}
private void Start()
{
((MonoBehaviour)this).StartCoroutine(PeriodicEnemySearch());
}
[IteratorStateMachine(typeof(<PeriodicEnemySearch>d__34))]
private IEnumerator PeriodicEnemySearch()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PeriodicEnemySearch>d__34(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<PeriodicSpin>d__35))]
private IEnumerator PeriodicSpin()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PeriodicSpin>d__35(0)
{
<>4__this = this
};
}
private void SpinAndApplyRotation()
{
//IL_0084: 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_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
if (_isTransitioning)
{
return;
}
_isTransitioning = true;
if (!_isSpinning)
{
_isSpinning = true;
((MonoBehaviour)this).StartCoroutine(PeriodicSpin());
}
if ((Object)(object)_rigidbody != (Object)null && (Object)(object)_instance != (Object)null && _instance._enableFixedShurikenConfig != null)
{
bool value = _instance._enableFixedShurikenConfig.Value;
Rigidbody? rigidbody = _rigidbody;
rigidbody.constraints = (RigidbodyConstraints)(rigidbody.constraints & -17);
Rigidbody? rigidbody2 = _rigidbody;
rigidbody2.constraints = (RigidbodyConstraints)(rigidbody2.constraints & -33);
Rigidbody? rigidbody3 = _rigidbody;
rigidbody3.constraints = (RigidbodyConstraints)(rigidbody3.constraints & -65);
if (value && _isAttacking && (Object)(object)_itemBattery != (Object)null && _itemBattery.batteryLife > 0f)
{
((Component)this).transform.rotation = Quaternion.Euler(0f, 0f, 0f);
Rigidbody? rigidbody4 = _rigidbody;
rigidbody4.constraints = (RigidbodyConstraints)(rigidbody4.constraints | 0x50);
}
}
_isTransitioning = false;
}
private void StopSpinning()
{
//IL_0055: 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_007c: 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_0091: 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)
if (!_isTransitioning)
{
_isTransitioning = true;
_isSpinning = false;
((MonoBehaviour)this).StopCoroutine(PeriodicSpin());
if ((Object)(object)_rigidbody != (Object)null && !_rigidbody.isKinematic)
{
_rigidbody.angularVelocity = Vector3.zero;
Rigidbody? rigidbody = _rigidbody;
rigidbody.constraints = (RigidbodyConstraints)(rigidbody.constraints & -17);
Rigidbody? rigidbody2 = _rigidbody;
rigidbody2.constraints = (RigidbodyConstraints)(rigidbody2.constraints & -33);
Rigidbody? rigidbody3 = _rigidbody;
rigidbody3.constraints = (RigidbodyConstraints)(rigidbody3.constraints & -65);
}
_isTransitioning = false;
}
}
private void AttackTarget()
{
//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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: 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_0161: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_currentTarget == (Object)null || (Object)(object)_rigidbody == (Object)null || !_isAttacking)
{
StopAttacking();
}
else if (!_isBounceCooldown)
{
Vector3 position = _currentTarget.transform.position;
Rigidbody val = default(Rigidbody);
if (_currentTarget.TryGetComponent<Rigidbody>(ref val))
{
position = val.position;
}
Vector3 val2 = position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
float num = Vector3.Distance(((Component)this).transform.position, position);
LegendaryShuriken? instance = _instance;
RaycastHit val3 = default(RaycastHit);
if (instance != null && instance._maxChaseDistance?.Value > 0f && num > _instance._maxChaseDistance.Value)
{
StopAttacking();
_currentTarget = null;
}
else if (Physics.Raycast(((Component)this).transform.position, normalized, ref val3, 1f, LayerMask.op_Implicit(obstacleLayer)))
{
val2 = Vector3.Reflect(normalized, ((RaycastHit)(ref val3)).normal);
Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
}
else
{
ApplyAttackForce(normalized);
}
}
}
private void ApplyAttackForce(Vector3 directionToTarget)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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)
if (!((Object)(object)_rigidbody == (Object)null))
{
_rigidbody.AddForce(directionToTarget * attackSpeed, (ForceMode)0);
float num = 10f;
_rigidbody.velocity = Vector3.ClampMagnitude(_rigidbody.velocity, num);
}
}
private void OnCollisionEnter(Collision collision)
{
if ((Object)(object)_rigidbody == (Object)null)
{
return;
}
if (collision.gameObject.CompareTag("Enemy"))
{
if (enemyBounceBackDistance > 0f)
{
ApplyBounceForce(collision, enemyBounceBackDistance, isEnemy: true);
}
}
else if (_isAttacking && !_isNonEnemyBounceCooldown && nonEnemyBounceBackDistance > 0f)
{
ApplyBounceForce(collision, nonEnemyBounceBackDistance, isEnemy: false);
}
}
private void ApplyBounceForce(Collision collision, float bounceDistance, bool isEnemy)
{
//IL_0041: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_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_0068: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
if (!((Object)(object)_rigidbody == (Object)null))
{
if (_rigidbody.isKinematic)
{
_rigidbody.isKinematic = false;
}
Vector3 normal = ((ContactPoint)(ref collision.contacts[0])).normal;
Vector3 relativeVelocity = collision.relativeVelocity;
Vector3 val = Vector3.Reflect(-((Vector3)(ref relativeVelocity)).normalized, normal);
_rigidbody.AddForce(val * bounceDistance, (ForceMode)1);
if ((Object)(object)_photonView != (Object)null && _photonView.IsMine)
{
object[] array = new object[2] { val, bounceDistance };
PhotonNetwork.RaiseEvent((byte)101, (object)array, new RaiseEventOptions
{
Receivers = (ReceiverGroup)1
}, SendOptions.SendReliable);
}
if (isEnemy)
{
((MonoBehaviour)this).StartCoroutine(BounceCooldown());
}
else
{
((MonoBehaviour)this).StartCoroutine(NonEnemyBounceCooldown());
}
}
}
[IteratorStateMachine(typeof(<BounceCooldown>d__42))]
private IEnumerator BounceCooldown()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BounceCooldown>d__42(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<NonEnemyBounceCooldown>d__43))]
private IEnumerator NonEnemyBounceCooldown()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <NonEnemyBounceCooldown>d__43(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<ResumeAttackingAfterBounce>d__44))]
private IEnumerator ResumeAttackingAfterBounce()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResumeAttackingAfterBounce>d__44(0)
{
<>4__this = this
};
}
}
[CompilerGenerated]
private sealed class <SpawnValuables>d__30 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private GameObject <targetItem>5__1;
private Vector3 <itemPosition>5__2;
private float <currentYOffset>5__3;
private float <currentItemYOffset>5__4;
private Dictionary<string, ValuableDefinition>.ValueCollection.Enumerator <>s__5;
private ValuableDefinition <valuable>5__6;
private int <i>5__7;
private Vector3 <spawnPos>5__8;
private Dictionary<string, ItemDefinition>.ValueCollection.Enumerator <>s__9;
private ItemDefinition <item>5__10;
private bool <skipItem>5__11;
private string <normalizedName>5__12;
private HashSet<string> <saveItems>5__13;
private int <i>5__14;
private Vector3 <spawnPos>5__15;
private GameObject <spawnedObject>5__16;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnValuables>d__30(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<targetItem>5__1 = null;
<>s__5 = default(Dictionary<string, ValuableDefinition>.ValueCollection.Enumerator);
<valuable>5__6 = null;
<>s__9 = default(Dictionary<string, ItemDefinition>.ValueCollection.Enumerator);
<item>5__10 = null;
<normalizedName>5__12 = null;
<saveItems>5__13 = null;
<spawnedObject>5__16 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
//IL_00cc: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: 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_0335: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
_isCoroutineRunning = true;
<targetItem>5__1 = FindTargetItem();
if ((Object)(object)<targetItem>5__1 == (Object)null)
{
_isCoroutineRunning = false;
return false;
}
<itemPosition>5__2 = <targetItem>5__1.transform.position;
<currentYOffset>5__3 = DefaultValuableYOffset;
<>s__5 = DefaultValuables.Values.GetEnumerator();
try
{
while (<>s__5.MoveNext())
{
<valuable>5__6 = <>s__5.Current;
<i>5__7 = 0;
while (<i>5__7 < <valuable>5__6.SpawnCount)
{
if (!(Random.Range(0f, 1f) > <valuable>5__6.SpawnChance))
{
<spawnPos>5__8 = <itemPosition>5__2 + new Vector3(0f, <currentYOffset>5__3, 0f);
SpawnValuableOrItem(<valuable>5__6.Name, <spawnPos>5__8, isItem: false);
<currentYOffset>5__3 += DefaultValuableYOffset;
}
<i>5__7++;
}
<valuable>5__6 = null;
}
}
finally
{
((IDisposable)<>s__5).Dispose();
}
<>s__5 = default(Dictionary<string, ValuableDefinition>.ValueCollection.Enumerator);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<currentItemYOffset>5__4 = DefaultItemYOffset;
<>s__9 = DefaultItems.Values.GetEnumerator();
try
{
while (<>s__9.MoveNext())
{
<item>5__10 = <>s__9.Current;
<skipItem>5__11 = false;
<normalizedName>5__12 = NormalizeItemName(<item>5__10.Name);
LegendaryShuriken? instance = _instance;
if (instance != null && (instance._preventRepeatShuriken?.Value).GetValueOrDefault())
{
ConfigEntry<bool>? useRunBasedTracking = _instance._useRunBasedTracking;
if (useRunBasedTracking != null && useRunBasedTracking.Value && !string.IsNullOrEmpty(_currentRunId) && _purchasedShurikensByRun.TryGetValue(_currentRunId, out <saveItems>5__13))
{
if (<saveItems>5__13.Contains(<normalizedName>5__12))
{
<skipItem>5__11 = true;
}
}
else if (_purchasedShurikenTypes.Contains(<normalizedName>5__12))
{
<skipItem>5__11 = true;
}
<saveItems>5__13 = null;
}
if (<skipItem>5__11)
{
continue;
}
<i>5__14 = 0;
while (<i>5__14 < <item>5__10.SpawnCount)
{
if (!(Random.Range(0f, 1f) > <item>5__10.SpawnChance))
{
<spawnPos>5__15 = <itemPosition>5__2 + new Vector3(0f, <currentItemYOffset>5__4, 0f);
<spawnedObject>5__16 = SpawnValuableOrItem(<item>5__10.Name, <spawnPos>5__15, isItem: true);
if ((Object)(object)<spawnedObject>5__16 != (Object)null)
{
<currentItemYOffset>5__4 += DefaultItemYOffset;
}
<spawnedObject>5__16 = null;
}
<i>5__14++;
}
<normalizedName>5__12 = null;
<item>5__10 = null;
}
}
finally
{
((IDisposable)<>s__9).Dispose();
}
<>s__9 = default(Dictionary<string, ItemDefinition>.ValueCollection.Enumerator);
_isCoroutineRunning = false;
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();
}
}
internal static LegendaryShuriken? _instance;
internal static ManualLogSource? _logger;
private static bool _isCoroutineRunning = false;
private static bool _isPatched = false;
private Coroutine? _spawnCoroutine;
internal static readonly HashSet<string> _purchasedShurikenTypes = new HashSet<string>();
internal ConfigEntry<bool>? _preventRepeatShuriken;
internal ConfigEntry<bool>? _useRunBasedTracking;
internal static Dictionary<string, HashSet<string>> _purchasedShurikensByRun = new Dictionary<string, HashSet<string>>();
private static readonly Queue<string> _saveOrder = new Queue<string>();
internal static string _currentRunId = "";
private static readonly float DefaultValuableYOffset = 0.5f;
private static readonly float DefaultItemYOffset = 0.5f;
private static readonly Dictionary<string, ValuableDefinition> DefaultValuables = new Dictionary<string, ValuableDefinition>();
internal static readonly Dictionary<string, ItemDefinition> DefaultItems = new Dictionary<string, ItemDefinition>();
private ConfigEntry<float>? _maxChaseDistance;
private ConfigEntry<string>? _spinningAxis;
private ConfigEntry<bool>? _enableFixedShurikenConfig;
private Dictionary<string, ConfigEntry<bool>> _fixedShurikenPerItemConfig = new Dictionary<string, ConfigEntry<bool>>();
private Dictionary<string, ConfigEntry<bool>> _freezeXZRotationConfig = new Dictionary<string, ConfigEntry<bool>>();
private Dictionary<string, ConfigEntry<float>> _spinSpeedConfig = new Dictionary<string, ConfigEntry<float>>();
private readonly Dictionary<string, bool> _antiGravityOptions = new Dictionary<string, bool>();
private void Awake()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
if ((Object)(object)_instance != (Object)null)
{
Object.Destroy((Object)(object)this);
return;
}
_instance = this;
_logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("ZeroTails.LegendaryShuriken");
val.PatchAll();
InitializeValuablesConfig();
InitializeItemsConfig();
InitializeAntiGravityConfig();
InitializeFixedShurikenConfig();
_maxChaseDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxChaseDistance", 7f, "After this distance is reached, the item will certainly stop attacking the bound target. Only reducing it will have an effect.");
_spinningAxis = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SpinningAxis", "Y", "The axis to use for spinning (X, Y, or Z). Default is Y.");
_preventRepeatShuriken = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PreventRepeatShuriken", true, "If enabled, once a specific type of shuriken is purchased, it won't spawn again in shops.");
_useRunBasedTracking = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseRunBasedTracking", true, "If enabled, shuriken purchase tracking will be per run/save rather than global.");
if (!_isPatched)
{
val.Patch((MethodBase)AccessTools.Method(typeof(LoadingUI), "LevelAnimationStart", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LegendaryShuriken), "OnLevelStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
_isPatched = true;
}
_purchasedShurikenTypes.Clear();
}
private void InitializeConfig<T>(string category, List<T> definitions, Dictionary<string, T> targetDictionary) where T : ValuableDefinition
{
foreach (T definition in definitions)
{
ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>(category, definition.Name + " Active", true, "Enable or disable spawning of " + definition.Name + ".");
ConfigEntry<int> val2 = ((BaseUnityPlugin)this).Config.Bind<int>(category, definition.Name + " Spawn Count", definition.SpawnCount, "How many " + definition.Name + " to spawn per level.");
ConfigEntry<float> val3 = ((BaseUnityPlugin)this).Config.Bind<float>(category, definition.Name + " Spawn Chance", definition.SpawnChance, "Chance for " + definition.Name + " to spawn (1.0 = 100%, 0.5 = 50%, etc.).");
ConfigEntry<bool> val4 = ((BaseUnityPlugin)this).Config.Bind<bool>(category + " > Rotation", definition.Name + " Enable Fixed Rotation", false, "Enable or disable fixed rotation for " + definition.Name + ".");
ConfigEntry<float> val5 = ((BaseUnityPlugin)this).Config.Bind<float>(category + " > Rotation", definition.Name + " Fixed Rotation X", 0f, "Fixed rotation value for the X-axis of " + definition.Name + " (degrees). Default is 0.");
ConfigEntry<float> val6 = ((BaseUnityPlugin)this).Config.Bind<float>(category + " > Rotation", definition.Name + " Fixed Rotation Y", 0f, "Fixed rotation value for the Y-axis of " + definition.Name + " (degrees). Default is 0.");
ConfigEntry<float> val7 = ((BaseUnityPlugin)this).Config.Bind<float>(category + " > Rotation", definition.Name + " Fixed Rotation Z", 0f, "Fixed rotation value for the Z-axis of " + definition.Name + " (degrees). Default is 0.");
if (val.Value)
{
targetDictionary[definition.Name] = (T)Activator.CreateInstance(typeof(T), definition.Name, val2.Value, val3.Value, definition.AntiGravity, val4.Value, val5.Value, val6.Value, val7.Value);
}
}
}
private void InitializeValuablesConfig()
{
List<ValuableDefinition> list = new List<ValuableDefinition>
{
new ValuableDefinition("Gambler", 1, 0f),
new ValuableDefinition("Valuable Present Big (Chance)", 1, 0f),
new ValuableDefinition("Valuable Dummy Item Smith Note", 1, 0f)
};
foreach (ValuableDefinition item in list)
{
string key = NormalizeItemName(item.Name.Replace(" ", ""));
DefaultValuables[key] = item;
string key2 = NormalizeItemName(item.Name);
DefaultValuables[key2] = item;
}
}
private void InitializeItemsConfig()
{
List<ItemDefinition> list = new List<ItemDefinition>
{
new ItemDefinition("Large Legendary Shuriken", 1, 0.05f, antiGravity: true),
new ItemDefinition("Legendary Shuriken", 1, 1f, antiGravity: true),
new ItemDefinition("Legendary Shuriken Spinner", 1, 0.1f, antiGravity: true),
new ItemDefinition("Legendary Shuriken Star", 1, 0.075f, antiGravity: true)
};
foreach (ItemDefinition item in list)
{
string key = NormalizeItemName(item.Name.Replace(" ", ""));
DefaultItems[key] = item;
string key2 = NormalizeItemName(item.Name);
DefaultItems[key2] = item;
ConfigEntry<float> val = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chances", item.Name + " Spawn Chance", item.SpawnChance, "Chance for " + item.Name + " to spawn (1.0 = 100%, 0.5 = 50%, etc.).");
item.SpawnChance = val.Value;
}
}
private void InitializeAntiGravityConfig()
{
foreach (string key in DefaultValuables.Keys)
{
_antiGravityOptions[key] = false;
}
foreach (ItemDefinition value in DefaultItems.Values)
{
_antiGravityOptions[value.Name] = value.AntiGravity;
}
}
private void InitializeFixedShurikenConfig()
{
_enableFixedShurikenConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixed Shuriken", "Enable Fixed Shuriken", true, "Master toggle for the fixed shuriken rotation system. When disabled, all shurikens will use natural physics rotation.");
}
private static void OnLevelStart()
{
if (!PhotonNetwork.IsMasterClient)
{
return;
}
try
{
_currentRunId = StatsManager.instance?.saveFileCurrent ?? "";
if (!string.IsNullOrEmpty(_currentRunId))
{
if (!_purchasedShurikensByRun.ContainsKey(_currentRunId))
{
_purchasedShurikensByRun[_currentRunId] = new HashSet<string>();
_saveOrder.Enqueue(_currentRunId);
if (_saveOrder.Count > 10)
{
string key = _saveOrder.Dequeue();
_purchasedShurikensByRun.Remove(key);
}
}
}
else
{
_currentRunId = string.Format("run_{0}_{1}", StatsManager.instance?.teamName ?? "unknown", DateTime.Now.Ticks);
_purchasedShurikensByRun[_currentRunId] = new HashSet<string>();
_saveOrder.Enqueue(_currentRunId);
if (_saveOrder.Count > 10)
{
string key2 = _saveOrder.Dequeue();
_purchasedShurikensByRun.Remove(key2);
}
}
}
catch (Exception)
{
if (string.IsNullOrEmpty(_currentRunId))
{
_currentRunId = $"fallback_{DateTime.Now.Ticks}";
_purchasedShurikensByRun[_currentRunId] = new HashSet<string>();
_saveOrder.Enqueue(_currentRunId);
if (_saveOrder.Count > 10)
{
string key3 = _saveOrder.Dequeue();
_purchasedShurikensByRun.Remove(key3);
}
}
}
if (SemiFunc.RunIsShop())
{
ClearPreviousState();
if ((Object)(object)_instance != (Object)null)
{
_instance._spawnCoroutine = ((MonoBehaviour)_instance).StartCoroutine(SpawnValuables());
}
}
}
private static void ClearPreviousState()
{
if (_instance?._spawnCoroutine != null)
{
((MonoBehaviour)_instance).StopCoroutine(_instance._spawnCoroutine);
_instance._spawnCoroutine = null;
}
}
[IteratorStateMachine(typeof(<SpawnValuables>d__30))]
private static IEnumerator SpawnValuables()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnValuables>d__30(0);
}
private static GameObject? FindTargetItem()
{
return ((IEnumerable<GameObject>)GameObject.FindGameObjectsWithTag("Cart")).FirstOrDefault((Func<GameObject, bool>)((GameObject cart) => ((Object)cart).name == "In Cart"));
}
private static GameObject? SpawnValuableOrItem(string name, Vector3 spawnPos, bool isItem)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ValuableObject val3 = default(ValuableObject);
if (isItem)
{
Item val = default(Item);
if (Items.TryGetItemByName(name, ref val))
{
GameObject val2 = Items.SpawnItem(val, spawnPos, Quaternion.identity);
if ((Object)(object)val2 != (Object)null)
{
((Object)val2).name = name;
ApplyProperties(val2, name, isItem: true);
return val2;
}
}
}
else if (Valuables.TryGetValuableByName(name, ref val3))
{
GameObject val4 = Valuables.SpawnValuable(val3, spawnPos, Quaternion.identity);
if ((Object)(object)val4 != (Object)null)
{
((Object)val4).name = name;
ApplyProperties(val4, name, isItem: false);
return val4;
}
}
return null;
}
internal static string NormalizeItemName(string name)
{
return name.Replace(" ", "").ToLowerInvariant();
}
internal static void ApplyProperties(GameObject obj, string name, bool isItem)
{
//IL_00e1: 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)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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_0109: 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_0117: Unknown result type (might be due to invalid IL or missing references)
string text = NormalizeItemName(name);
ValuableDefinition valuableDefinition = (isItem ? DefaultItems.GetValueOrDefault(text) : DefaultValuables.GetValueOrDefault(text));
if (valuableDefinition == null)
{
return;
}
if (valuableDefinition.AntiGravity)
{
AntiGravityBehavior component = obj.GetComponent<AntiGravityBehavior>();
if ((Object)(object)component == (Object)null)
{
component = obj.AddComponent<AntiGravityBehavior>();
}
PhysGrabObjectImpactDetector component2 = obj.GetComponent<PhysGrabObjectImpactDetector>();
if ((Object)(object)component2 != (Object)null)
{
component2.destroyDisable = true;
}
}
HashSet<string> hashSet = new HashSet<string> { "legendaryshuriken", "legendaryshurikenspinner", "legendaryshurikenstar", "largelegendaryshuriken" };
if (hashSet.Contains(text))
{
Rigidbody component3 = obj.GetComponent<Rigidbody>();
if ((Object)(object)component3 != (Object)null)
{
Quaternion val = Quaternion.FromToRotation(obj.transform.up, Vector3.up);
float num = 10f;
component3.AddTorque(new Vector3(val.x, val.y, val.z) * num, (ForceMode)0);
}
}
}
}
[HarmonyPatch(typeof(ItemAttributes), "Start")]
public class ItemAttributes_Start_Patch
{
private static void Postfix(ItemAttributes __instance)
{
LegendaryShuriken.ApplyProperties(((Component)__instance).gameObject, __instance.item.itemName, isItem: true);
}
}
[HarmonyPatch(typeof(ShopManager), "ShoppingListItemAdd")]
public class ShopManager_ShoppingListItemAdd_Patch
{
private static void Postfix(ItemAttributes item)
{
if ((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null)
{
LegendaryShuriken.ApplyProperties(((Component)item).gameObject, item.item.itemAssetName, isItem: true);
}
}
}
[HarmonyPatch(typeof(ItemManager), "ItemsInitialize")]
public class ItemManager_ItemsInitialize_Patch
{
private static void Postfix()
{
foreach (Item purchasedItem in ItemManager.instance.purchasedItems)
{
if (purchasedItem == null)
{
continue;
}
Item val = purchasedItem;
if (!((Object)(object)val.prefab != (Object)null))
{
continue;
}
ItemAttributes component = val.prefab.GetComponent<ItemAttributes>();
if ((Object)(object)component != (Object)null)
{
string key = LegendaryShuriken.NormalizeItemName(component.item.itemName);
if (LegendaryShuriken.DefaultItems.ContainsKey(key))
{
LegendaryShuriken.ApplyProperties(val.prefab, component.item.itemName, isItem: true);
}
}
}
}
}
[HarmonyPatch(typeof(PhysGrabber), "Update")]
public class PhysGrabber_Update_Patch
{
[CompilerGenerated]
private sealed class <RemoveFromRecentTransfers>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public int viewID;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RemoveFromRecentTransfers>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
_recentOwnershipTransfers.Remove(viewID);
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();
}
}
private static readonly Dictionary<int, float> _ownershipCooldowns = new Dictionary<int, float>();
private static readonly HashSet<int> _recentOwnershipTransfers = new HashSet<int>();
private static void Postfix(PhysGrabber __instance)
{
if (!((Object)(object)__instance.grabbedPhysGrabObject != (Object)null))
{
return;
}
PhotonView photonView = __instance.grabbedPhysGrabObject.photonView;
if (!((Object)(object)photonView != (Object)null) || !LegendaryShuriken.DefaultItems.ContainsKey(LegendaryShuriken.NormalizeItemName(((Object)((Component)photonView).gameObject).name)) || (Object)(object)((Component)photonView).gameObject == (Object)null || !((Component)photonView).gameObject.activeInHierarchy || photonView.IsMine || (_ownershipCooldowns.ContainsKey(photonView.ViewID) && !(Time.time > _ownershipCooldowns[photonView.ViewID])) || _recentOwnershipTransfers.Contains(photonView.ViewID))
{
return;
}
try
{
photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
_ownershipCooldowns[photonView.ViewID] = Time.time + 1f;
_recentOwnershipTransfers.Add(photonView.ViewID);
LegendaryShuriken? instance = LegendaryShuriken._instance;
if (instance != null)
{
((MonoBehaviour)instance).StartCoroutine(RemoveFromRecentTransfers(photonView.ViewID));
}
}
catch
{
if (photonView.Owner == null && PhotonNetwork.IsMasterClient)
{
photonView.TransferOwnership(PhotonNetwork.MasterClient);
}
}
}
[IteratorStateMachine(typeof(<RemoveFromRecentTransfers>d__3))]
private static IEnumerator RemoveFromRecentTransfers(int viewID)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RemoveFromRecentTransfers>d__3(0)
{
viewID = viewID
};
}
}
[HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")]
public class LoadingUI_LevelAnimationStart_Patch
{
private static void Postfix()
{
if (PhotonNetwork.IsMasterClient)
{
RechargeAllShurikenBatteries();
}
}
private static void RechargeAllShurikenBatteries()
{
try
{
ItemBattery[] array = Object.FindObjectsOfType<ItemBattery>(true);
int num = 0;
ItemBattery[] array2 = array;
foreach (ItemBattery val in array2)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
try
{
if (!IsShurikenItem(((Component)val).gameObject))
{
continue;
}
val.batteryLife = 100f;
try
{
FieldInfo field = typeof(ItemBattery).GetField("batteryLifeInt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(val, 6);
}
}
catch (Exception)
{
try
{
val.SetBatteryLife(6);
}
catch
{
}
}
num++;
}
catch (Exception)
{
}
}
}
catch (Exception)
{
}
}
private static bool IsShurikenItem(GameObject item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
try
{
string text = LegendaryShuriken.NormalizeItemName(((Object)item).name);
HashSet<string> hashSet = new HashSet<string> { "legendaryshuriken", "legendaryshurikenspinner", "legendaryshurikenstar", "largelegendaryshuriken", "legendary_shuriken", "legendary_shuriken_spinner", "legendary_shuriken_star", "large_legendary_shuriken" };
if (hashSet.Contains(text) || LegendaryShuriken.DefaultItems.ContainsKey(text))
{
return true;
}
ItemAttributes component = item.GetComponent<ItemAttributes>();
if ((Object)(object)component != (Object)null && (Object)(object)component.item != (Object)null)
{
string text2 = LegendaryShuriken.NormalizeItemName(component.item.itemAssetName);
if (hashSet.Contains(text2) || LegendaryShuriken.DefaultItems.ContainsKey(text2))
{
return true;
}
string text3 = LegendaryShuriken.NormalizeItemName(component.item.itemName);
if (hashSet.Contains(text3) || LegendaryShuriken.DefaultItems.ContainsKey(text3))
{
return true;
}
}
foreach (string item2 in hashSet)
{
if (text.Contains(item2))
{
return true;
}
}
if ((Object)(object)item.GetComponent<ItemBattery>() != (Object)null && text.Contains("shuriken"))
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
}
[HarmonyPatch(typeof(ShopManager), "ShopCheck")]
public class ShopManager_ShopCheck_TrackShurikenPatch
{
private static readonly HashSet<int> _trackedItemInstanceIds = new HashSet<int>();
private static void Postfix(ShopManager __instance)
{
if ((Object)(object)LegendaryShuriken._instance == (Object)null || LegendaryShuriken._instance._preventRepeatShuriken == null || !LegendaryShuriken._instance._preventRepeatShuriken.Value)
{
return;
}
try
{
if (__instance.shoppingList == null)
{
return;
}
foreach (ItemAttributes shopping in __instance.shoppingList)
{
if ((Object)(object)shopping == (Object)null || (Object)(object)((Component)shopping).gameObject == (Object)null || !((Object)(object)shopping.roomVolumeCheck != (Object)null) || !shopping.roomVolumeCheck.inExtractionPoint)
{
continue;
}
int instanceID = ((Object)((Component)shopping).gameObject).GetInstanceID();
if (_trackedItemInstanceIds.Contains(instanceID))
{
continue;
}
string name = shopping.item?.itemName ?? ((Object)((Component)shopping).gameObject).name;
string item = LegendaryShuriken.NormalizeItemName(name);
HashSet<string> hashSet = new HashSet<string> { "legendaryshuriken", "legendaryshurikenspinner", "legendaryshurikenstar", "largelegendaryshuriken" };
if (!hashSet.Contains(item))
{
continue;
}
_trackedItemInstanceIds.Add(instanceID);
ConfigEntry<bool>? useRunBasedTracking = LegendaryShuriken._instance._useRunBasedTracking;
if (useRunBasedTracking != null && useRunBasedTracking.Value && !string.IsNullOrEmpty(LegendaryShuriken._currentRunId))
{
if (!LegendaryShuriken._purchasedShurikensByRun.ContainsKey(LegendaryShuriken._currentRunId))
{
LegendaryShuriken._purchasedShurikensByRun[LegendaryShuriken._currentRunId] = new HashSet<string>();
}
LegendaryShuriken._purchasedShurikensByRun[LegendaryShuriken._currentRunId].Add(item);
}
else
{
LegendaryShuriken._purchasedShurikenTypes.Add(item);
}
}
if (!SemiFunc.RunIsShop())
{
_trackedItemInstanceIds.Clear();
}
}
catch (Exception)
{
}
}
}
}