using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Shield_Mod;
using ULTRAKILL.Cheats;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;
[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-CSharp")]
[assembly: AssemblyCompany("Shield_Mod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+13f8975ede088c85c7cf961d4c09fbb914a90905")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("Shield_Mod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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 ShieldProjectile : MonoBehaviour
{
private float timer = 0.08f;
private List<EnemyType> lightEnemies = new List<EnemyType>();
private float speed = 75f;
private float drillT = 0f;
private bool attached = false;
public int drillHits;
private int drillHitsLeft;
private float drillCooldown;
private bool drilling;
private bool punched;
public AudioSource drillSound;
private AudioSource currentDrillSound;
private AudioSource source;
private EnemyIdentifier target;
[HideInInspector]
public GameObject sourceWeapon;
[Header("Return To Player")]
public int maxBounces = 7;
public float maxLifetime = 5f;
public float returnBaseSpeed = 75f;
public float speedGrowthRate = 1.5f;
public float catchDistance = 1.25f;
public ShieldWeapon weapon;
private int bounceCount = 0;
private float lifeTimer = 0f;
private bool returningToPlayer = false;
private float returnTimer = 0f;
private Vector3 lastPosition;
private bool caught = false;
private List<EnemyIdentifier> hitEnemies = new List<EnemyIdentifier>();
private void Awake()
{
//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)
lightEnemies.Add((EnemyType)1);
lightEnemies.Add((EnemyType)3);
lightEnemies.Add((EnemyType)14);
lightEnemies.Add((EnemyType)15);
lightEnemies.Add((EnemyType)13);
lightEnemies.Add((EnemyType)6);
drillHitsLeft = drillHits;
lastPosition = ((Component)this).transform.position;
source = ((Component)this).GetComponent<AudioSource>();
}
private void Update()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: 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)
if (attached)
{
if (drilling)
{
((Component)this).transform.Rotate(Vector3.forward, 14400f * Time.deltaTime);
}
}
else
{
if (caught)
{
return;
}
if (timer > 0f)
{
timer -= Time.deltaTime;
}
if (!returningToPlayer)
{
lifeTimer += Time.deltaTime;
if (bounceCount >= maxBounces || lifeTimer >= maxLifetime)
{
BeginReturnToPlayer();
}
}
lastPosition = ((Component)this).transform.position;
if (returningToPlayer)
{
UpdateReturnToPlayer();
}
else
{
Transform transform = ((Component)this).transform;
transform.position += ((Component)this).transform.forward * speed * Time.deltaTime;
}
if (MonoSingleton<InputManager>.Instance.InputSource.Fire2.WasPerformedThisFrame && MonoSingleton<GunControl>.Instance.activated && ((Component)weapon).gameObject.activeInHierarchy)
{
BeginReturnToPlayer();
}
CheckCatchAlongPath(lastPosition, ((Component)this).transform.position);
}
}
private void BeginReturnToPlayer()
{
returningToPlayer = true;
returnTimer = 0f;
speed = returnBaseSpeed;
}
private void UpdateReturnToPlayer()
{
//IL_0050: 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_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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
NewMovement instance = MonoSingleton<NewMovement>.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
returnTimer += Time.deltaTime;
speed = returnBaseSpeed * Mathf.Exp(speedGrowthRate * returnTimer);
Vector3 val = ((Component)instance).transform.position - ((Component)this).transform.position;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude <= catchDistance)
{
CatchPlayer();
return;
}
((Component)this).transform.forward = val / magnitude;
float num = speed * Time.deltaTime;
if (num >= magnitude)
{
((Component)this).transform.position = ((Component)instance).transform.position;
CatchPlayer();
}
else
{
Transform transform = ((Component)this).transform;
transform.position += ((Component)this).transform.forward * num;
}
}
private void CheckCatchAlongPath(Vector3 from, Vector3 to)
{
//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_0047: 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_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_0066: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (caught || !returningToPlayer)
{
return;
}
NewMovement instance = MonoSingleton<NewMovement>.Instance;
if (!((Object)(object)instance == (Object)null))
{
Vector3 position = ((Component)instance).transform.position;
Vector3 val = to - from;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
float num = ((sqrMagnitude > 0.0001f) ? Mathf.Clamp01(Vector3.Dot(position - from, val) / sqrMagnitude) : 0f);
Vector3 val2 = from + val * num;
if (Vector3.Distance(val2, position) <= catchDistance)
{
CatchPlayer();
}
}
}
private void CatchPlayer()
{
if (!caught)
{
caught = true;
returningToPlayer = false;
weapon.noShield = false;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
private void FixedUpdate()
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
if (attached && drilling && Object.op_Implicit((Object)(object)target))
{
if (drillCooldown != 0f)
{
drillCooldown = Mathf.MoveTowards(drillCooldown, 0f, Time.deltaTime);
return;
}
drillCooldown = 0.08f;
target.hitter = "drill";
target.DeliverDamage(((Component)target).gameObject, Vector3.zero, ((Component)this).transform.position, 0.0325f, false, 0f, sourceWeapon, false, false);
if (Object.op_Implicit((Object)(object)currentDrillSound))
{
AudioSourceExtensions.SetPitch(currentDrillSound, 1.5f - (float)drillHitsLeft / (float)drillHits / 2f);
}
drillHitsLeft--;
if (drillHitsLeft <= 0 && !PauseTimedBombs.Paused)
{
Object.Instantiate<GameObject>(AssetsManager.BreakParticleMetalSaw, ((Component)this).transform.position, Quaternion.identity);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
else if (drilling && (Object)(object)target == (Object)null)
{
drilling = false;
}
}
private void OnTriggerEnter(Collider other)
{
//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_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: 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_0218: 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_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
if (attached || LayerMaskDefaults.IsMatchingLayer(((Component)other).gameObject.layer, (LMD)8))
{
return;
}
EnemyIdentifier eid = default(EnemyIdentifier);
EnemyIdentifierIdentifier val = default(EnemyIdentifierIdentifier);
if (!((Component)other).gameObject.TryGetComponent<EnemyIdentifier>(ref eid) && ((Component)other).gameObject.TryGetComponent<EnemyIdentifierIdentifier>(ref val))
{
eid = val.eid;
}
Vector3 val4;
if ((Object)(object)eid != (Object)null)
{
if (hitEnemies.Contains(eid))
{
return;
}
hitEnemies.Add(eid);
eid.hitter = ((bounceCount == 0) ? "shieldnobounce" : "shieldproj");
eid.DeliverDamage(((Component)other).gameObject, Vector3.zero, ((Component)other).transform.position, 4f, true, 0f, sourceWeapon, false, false);
if (!lightEnemies.Contains(eid.enemyType))
{
if (!eid.dead)
{
attached = true;
((Component)this).transform.parent = ((Component)other).transform;
target = eid;
drilling = true;
currentDrillSound = Object.Instantiate<AudioSource>(drillSound, ((Component)this).transform.position, ((Component)this).transform.rotation);
((Component)currentDrillSound).transform.SetParent(((Component)this).transform, true);
}
return;
}
eid.DeliverDamage(((Component)other).gameObject, Vector3.zero, ((Component)other).transform.position, 50f, true, 0f, (GameObject)null, false, false);
List<EnemyIdentifier> currentEnemies = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies();
currentEnemies.RemoveAll((EnemyIdentifier x) => (Object)(object)x == (Object)null || x.dead || hitEnemies.Contains(x));
EnemyIdentifier val2 = null;
float num = float.MaxValue;
foreach (EnemyIdentifier item in currentEnemies)
{
Transform val3 = (((Object)(object)item.weakPoint != (Object)null) ? item.weakPoint.transform : ((Component)item).transform);
val4 = val3.position - ((Component)this).transform.position;
float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
val2 = item;
}
}
if ((Object)(object)val2 != (Object)null)
{
Transform val5 = (((Object)(object)val2.weakPoint != (Object)null) ? val2.weakPoint.transform : ((Component)val2).transform);
Transform transform = ((Component)this).transform;
val4 = val5.position - ((Component)this).transform.position;
transform.forward = ((Vector3)(ref val4)).normalized;
}
}
else if (LayerMaskDefaults.IsMatchingLayer(((Component)other).gameObject.layer, (LMD)1) && !(timer > 0f) && !returningToPlayer)
{
source.Play();
Vector3 val6 = other.ClosestPoint(((Component)this).transform.position);
val4 = ((Component)this).transform.position - val6;
Vector3 normalized = ((Vector3)(ref val4)).normalized;
((Component)this).transform.forward = Vector3.Reflect(((Component)this).transform.forward, normalized);
RicochetAimAssist(((Component)this).gameObject, aimAtHead: true);
bounceCount++;
if (!returningToPlayer && (bounceCount >= maxBounces || lifeTimer >= maxLifetime))
{
BeginReturnToPlayer();
}
}
}
private void OnDestroy()
{
CatchPlayer();
}
private void OnDisable()
{
CatchPlayer();
}
public void Punched()
{
//IL_0058: 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_006d: Unknown result type (might be due to invalid IL or missing references)
if (attached)
{
punched = true;
drilling = false;
if (Object.op_Implicit((Object)(object)target))
{
target.hitter = "drillpunch";
target.DeliverDamage(((Component)target).gameObject, ((Component)this).transform.forward * 150f, ((Component)this).transform.position, 4f + (float)drillHitsLeft * 0.0325f, true, 0f, (GameObject)null, false, false);
}
if (Object.op_Implicit((Object)(object)currentDrillSound))
{
Object.Destroy((Object)(object)currentDrillSound);
}
drillHitsLeft = drillHits;
attached = false;
((Component)this).transform.parent = null;
timer = 0.08f;
returningToPlayer = false;
bounceCount = 0;
lifeTimer = 0f;
caught = false;
speed = 75f;
}
}
private void RicochetAimAssist(GameObject beam, bool aimAtHead = false)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: 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_010f: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: 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)
RaycastHit[] array = Physics.SphereCastAll(beam.transform.position, 5f, beam.transform.forward, float.PositiveInfinity, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)0)));
if (array == null || array.Length == 0)
{
return;
}
Vector3 val = beam.transform.forward * 1000f;
float num = float.PositiveInfinity;
GameObject val2 = null;
bool flag = false;
Coin val3 = default(Coin);
PhysicsCastResult val4 = default(PhysicsCastResult);
PortalTraversalV2[] array2 = default(PortalTraversalV2[]);
Vector3 val5 = default(Vector3);
EnemyIdentifierIdentifier val6 = default(EnemyIdentifierIdentifier);
for (int i = 0; i < array.Length; i++)
{
bool flag2 = MonoSingleton<CoinTracker>.Instance.revolverCoinsList.Count > 0 && ((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<Coin>(ref val3) && (!val3.shot || val3.shotByEnemy);
if ((!flag || flag2) && (((RaycastHit)(ref array[i])).distance <= num || (!flag && flag2)) && (((RaycastHit)(ref array[i])).distance >= 0.1f || flag2) && !PortalPhysicsV2.Raycast(beam.transform.position, ((RaycastHit)(ref array[i])).point - beam.transform.position, ((RaycastHit)(ref array[i])).distance, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1)), ref val4, ref array2, ref val5, (QueryTriggerInteraction)0) && (flag2 || (((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<EnemyIdentifierIdentifier>(ref val6) && Object.op_Implicit((Object)(object)val6.eid) && !val6.eid.dead)))
{
if (flag2)
{
flag = true;
}
val = (flag2 ? ((RaycastHit)(ref array[i])).transform.position : ((RaycastHit)(ref array[i])).point);
num = ((RaycastHit)(ref array[i])).distance;
val2 = ((Component)((RaycastHit)(ref array[i])).transform).gameObject;
}
}
if (Object.op_Implicit((Object)(object)val2))
{
EnemyIdentifierIdentifier val7 = default(EnemyIdentifierIdentifier);
if (aimAtHead && !flag && val2.TryGetComponent<EnemyIdentifierIdentifier>(ref val7) && Object.op_Implicit((Object)(object)val7.eid) && Object.op_Implicit((Object)(object)val7.eid.weakPoint) && !PortalPhysicsV2.Raycast(beam.transform.position, val7.eid.weakPoint.transform.position - beam.transform.position, Vector3.Distance(val7.eid.weakPoint.transform.position, beam.transform.position), LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1)), (QueryTriggerInteraction)0))
{
val = val7.eid.weakPoint.transform.position;
}
beam.transform.LookAt(val);
}
}
}
[HarmonyPatch(typeof(Punch), "PunchSuccess")]
public class PunchPatch
{
public static void Postfix(Punch __instance, Vector3 point, Transform target)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
((Component)__instance).transform.parent.LookAt(point);
ParryHelper val = default(ParryHelper);
if (((Component)target).TryGetComponent<ParryHelper>(ref val))
{
target = val.target;
}
if (!((Component)target).gameObject.CompareTag("Enemy") && !((Component)target).gameObject.CompareTag("Armor") && !((Component)target).gameObject.CompareTag("Head") && !((Component)target).gameObject.CompareTag("Body") && !((Component)target).gameObject.CompareTag("Limb") && !((Component)target).gameObject.CompareTag("EndLimb"))
{
return;
}
EnemyIdentifier val2 = null;
EnemyIdentifierIdentifier val3 = default(EnemyIdentifierIdentifier);
if (((Component)target).TryGetComponent<EnemyIdentifierIdentifier>(ref val3))
{
val2 = val3.eid;
}
if (Object.op_Implicit((Object)(object)val2))
{
ShieldProjectile componentInChildren = ((Component)val2).GetComponentInChildren<ShieldProjectile>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
__instance.anim.Play("Hook", 0, 0.065f);
MonoSingleton<TimeController>.Instance.ParryFlash();
((Component)componentInChildren).transform.forward = ((Component)__instance.cc).transform.forward;
((Component)componentInChildren).transform.position = __instance.cc.GetDefaultPos();
componentInChildren.Punched();
}
}
}
}
public class ShieldWeapon : MonoBehaviour
{
public int variation = 2;
private InputManager inman;
private Animator anim;
private AudioSource source;
private GunControl gc;
private bool attackAgain = true;
private GameObject sourceWeapon;
private List<EnemyType> lightEnemies = new List<EnemyType>();
private bool isCharging;
private float chargeT;
private float chargeForce = 85f;
private float fire1Cooldown = 0.25f;
private float fire2Cooldown = 0.6f;
private float fire1Timer;
private float fire2Timer;
public bool noShield = false;
[Header("Green Variant")]
public ShieldProjectile ShieldProj;
[Header("Red Variant")]
public SpriteRenderer Twirl;
public AudioSource TwirlSound;
private float twirling = 0f;
private bool fullyCharged = false;
private void Awake()
{
sourceWeapon = ((Component)((Component)this).transform.parent).gameObject;
AssetsManager.GetAssets();
inman = MonoSingleton<InputManager>.Instance;
anim = ((Component)this).GetComponent<Animator>();
gc = MonoSingleton<GunControl>.Instance;
source = ((Component)this).GetComponent<AudioSource>();
lightEnemies.Add((EnemyType)1);
lightEnemies.Add((EnemyType)3);
lightEnemies.Add((EnemyType)14);
lightEnemies.Add((EnemyType)15);
lightEnemies.Add((EnemyType)13);
lightEnemies.Add((EnemyType)6);
}
private void Update()
{
anim.SetBool("NoShield", noShield);
if (gc.activated && !noShield)
{
if (fire1Timer > 0f)
{
fire1Timer -= Time.deltaTime;
}
if (fire2Timer > 0f)
{
fire2Timer -= Time.deltaTime;
}
anim.SetBool("Twirling", variation == 2 && inman.InputSource.Fire2.IsPressed);
HandleInput();
if (isCharging)
{
HandleCharge();
}
}
}
private void OnDisable()
{
isCharging = false;
attackAgain = true;
chargeT = 0f;
fire1Timer = 0f;
fire2Timer = 0f;
}
private void FixedUpdate()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if (variation == 2 && inman.InputSource.Fire2.IsPressed)
{
MonoSingleton<NewMovement>.Instance.rb.AddForce(((Component)MonoSingleton<CameraController>.Instance).transform.up * 1200f * twirling * Time.deltaTime, (ForceMode)5);
}
}
public void ThrowShield()
{
//IL_0011: 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)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
Vector3 defaultPos = MonoSingleton<CameraController>.Instance.GetDefaultPos();
ShieldProjectile shieldProjectile = Object.Instantiate<ShieldProjectile>(ShieldProj, defaultPos, Quaternion.identity);
((Component)shieldProjectile).transform.forward = transform.forward;
shieldProjectile.weapon = this;
shieldProjectile.sourceWeapon = sourceWeapon;
}
private void HandleCharge()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: 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)
float num = 100f;
attackAgain = true;
Vector3 defaultPos = MonoSingleton<CameraController>.Instance.GetDefaultPos();
Vector3 forward = ((Component)MonoSingleton<CameraController>.Instance).transform.forward;
Collider[] array = Physics.OverlapSphere(defaultPos, 2.5f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)3)));
List<EnemyIdentifier> list = new List<EnemyIdentifier>();
Collider[] array2 = array;
EnemyIdentifier eid = default(EnemyIdentifier);
EnemyIdentifierIdentifier val2 = default(EnemyIdentifierIdentifier);
foreach (Collider val in array2)
{
if (!((Component)val).gameObject.TryGetComponent<EnemyIdentifier>(ref eid) && ((Component)val).gameObject.TryGetComponent<EnemyIdentifierIdentifier>(ref val2))
{
eid = val2.eid;
}
if ((Object)(object)eid != (Object)null && !list.Contains(eid))
{
list.Add(eid);
eid.hitter = "shieldcharge";
eid.DeliverDamage(((Component)val).gameObject, forward * num, ((Component)val).transform.position, 7.5f, true, 0f, sourceWeapon, false, false);
if ((Object)(object)eid != (Object)null && !lightEnemies.Contains(eid.enemyType))
{
isCharging = false;
MonoSingleton<CameraController>.Instance.CameraShake(2f);
source.Play();
MonoSingleton<NewMovement>.Instance.Launch(-forward, num / 2f, true);
}
}
}
if (chargeT > 0f)
{
chargeT -= Time.deltaTime;
}
else if (MonoSingleton<NewMovement>.Instance.gc.onGround)
{
isCharging = false;
}
}
private void HandleInput()
{
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
if (inman.InputSource.Fire1.WasPerformedThisFrame && attackAgain && fire1Timer <= 0f && !isCharging && (variation != 2 || !inman.InputSource.Fire2.IsPressed))
{
attackAgain = false;
fire1Timer = fire1Cooldown;
anim.SetTrigger("Fire1");
}
if (variation == 2)
{
if (inman.InputSource.Fire2.WasCanceledThisFrame && twirling >= 2.99f)
{
GameObject val = Object.Instantiate<GameObject>(AssetsManager.Lightning, MonoSingleton<CameraController>.Instance.GetDefaultPos(), MonoSingleton<CameraController>.Instance.rotation);
val.transform.forward = ((Component)MonoSingleton<CameraController>.Instance).transform.forward;
}
if (inman.InputSource.Fire2.IsPressed && attackAgain)
{
if (!TwirlSound.isPlaying)
{
anim.SetTrigger("StartTwirl");
TwirlSound.Play();
}
twirling += Time.deltaTime;
twirling = Mathf.Clamp(twirling, 0f, 3f);
anim.SetFloat("TwirlSpeed", twirling);
Twirl.color = new Color(1f, 1f, 1f, Mathf.Lerp(0f, 1f, twirling / 3f));
TwirlSound.pitch = twirling;
if (twirling >= 2.99f && !fullyCharged)
{
fullyCharged = true;
GameObject val2 = Object.Instantiate<GameObject>(AssetsManager.flash, MonoSingleton<CameraController>.Instance.GetDefaultPos(), MonoSingleton<CameraController>.Instance.rotation);
val2.transform.forward = ((Component)MonoSingleton<CameraController>.Instance).transform.forward;
}
}
else
{
Twirl.color = new Color(1f, 1f, 1f, 0f);
twirling = 0f;
TwirlSound.Stop();
fullyCharged = false;
}
}
else
{
if (!inman.InputSource.Fire2.WasPerformedThisFrame || !attackAgain || !(fire2Timer <= 0f))
{
return;
}
switch (variation)
{
case 0:
if (!isCharging)
{
fire2Timer = fire2Cooldown;
Charge();
}
break;
case 1:
anim.SetTrigger("Fire2Throw");
noShield = true;
break;
}
}
}
private void Charge()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
MonoSingleton<NewMovement>.Instance.Launch(((Component)MonoSingleton<CameraController>.Instance).transform.forward, chargeForce, true);
chargeT = 0.25f;
isCharging = true;
source.PlayOneShot(AssetsManager.Woosh);
}
public void DealDamage()
{
//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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
float num = 50f;
attackAgain = true;
Vector3 defaultPos = MonoSingleton<CameraController>.Instance.GetDefaultPos();
Vector3 forward = ((Component)MonoSingleton<CameraController>.Instance).transform.forward;
RaycastHit[] array = Physics.SphereCastAll(defaultPos, 2.5f, forward, 2f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)0)));
List<EnemyIdentifier> list = new List<EnemyIdentifier>();
RaycastHit[] array2 = array;
EnemyIdentifier eid = default(EnemyIdentifier);
EnemyIdentifierIdentifier val2 = default(EnemyIdentifierIdentifier);
for (int i = 0; i < array2.Length; i++)
{
RaycastHit val = array2[i];
flag = true;
Collider collider = ((RaycastHit)(ref val)).collider;
if (!((Component)collider).gameObject.TryGetComponent<EnemyIdentifier>(ref eid) && ((Component)collider).gameObject.TryGetComponent<EnemyIdentifierIdentifier>(ref val2))
{
eid = val2.eid;
}
if ((Object)(object)eid != (Object)null && !list.Contains(eid))
{
list.Add(eid);
eid.hitter = "shield";
eid.DeliverDamage(((Component)collider).gameObject, forward * num, ((RaycastHit)(ref val)).point, 2.5f, true, 0f, sourceWeapon, false, false);
}
}
source.PlayOneShot(flag ? AssetsManager.PunchHeavy : AssetsManager.Woosh);
}
}
namespace Shield_Mod
{
public class AssetsManager
{
public static AudioClip Woosh;
public static AudioClip PunchHeavy;
public static GameObject BreakParticleMetalSaw;
public static GameObject Lightning;
public static GameObject flash;
private static bool loaded;
public static void GetAssets()
{
if (!loaded)
{
Woosh = GetAddress<AudioClip>("Assets/Sounds/Weapons/PunchSwooshHeavy.wav");
PunchHeavy = GetAddress<AudioClip>("Assets/Sounds/Weapons/punch_heavy.wav");
BreakParticleMetalSaw = GetAddress<GameObject>("Assets/Particles/Breaks/BreakParticleMetalSaw.prefab");
flash = GetAddress<GameObject>("Assets/Particles/Flashes/V2FlashUnparriable.prefab");
Lightning = GetAddress<GameObject>("Assets/Prefabs/Attacks and Projectiles/Hitscan Beams/Lighting Beam Reflected.prefab");
loaded = true;
}
}
public static T GetAddress<T>(string path)
{
//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)
return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
}
}
public static class BundleLoader
{
public static bool alrLoaded;
public static string EpicScene => Path.Combine(Application.temporaryCachePath, "ShieldMod");
public static void Load()
{
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
if (alrLoaded)
{
return;
}
if (Directory.Exists(EpicScene))
{
try
{
Directory.Delete(EpicScene, recursive: true);
}
catch (IOException ex)
{
string path = Path.Combine(EpicScene, "catalog.json");
if (File.Exists(path))
{
Plugin.Logger.LogWarning((object)("[BundleLoader] Could not delete temp dir (files locked?), reusing existing extraction. Error: " + ex.Message));
goto IL_0137;
}
TryDeleteContents(EpicScene);
}
}
Directory.CreateDirectory(EpicScene);
Assembly assembly = typeof(Plugin).Assembly;
string[] manifestResourceNames = assembly.GetManifestResourceNames();
foreach (string text in manifestResourceNames)
{
string path2 = (text.StartsWith("Shield_Mod.Assets.") ? text.Substring("Shield_Mod.Assets.".Length) : text);
string path3 = Path.Combine(EpicScene, path2);
using Stream stream = assembly.GetManifestResourceStream(text);
using FileStream destination = File.Create(path3);
stream.CopyTo(destination);
}
goto IL_0137;
IL_0137:
Func<IResourceLocation, string> previousTransform = Addressables.ResourceManager.InternalIdTransformFunc;
Addressables.ResourceManager.InternalIdTransformFunc = delegate(IResourceLocation location)
{
string internalId = location.InternalId;
return internalId.Contains("ShieldMod.Bundleloader.Shield") ? internalId.Replace("ShieldMod.Bundleloader.Shield", EpicScene) : ((previousTransform != null) ? previousTransform(location) : internalId);
};
Addressables.LoadContentCatalogAsync(Path.Combine(EpicScene, "catalog.json"), true, (string)null).WaitForCompletion();
alrLoaded = true;
}
private static void TryDeleteContents(string dir)
{
string[] files = Directory.GetFiles(dir, "*", SearchOption.AllDirectories);
foreach (string path in files)
{
try
{
File.Delete(path);
}
catch
{
}
}
string[] directories = Directory.GetDirectories(dir);
foreach (string path2 in directories)
{
try
{
Directory.Delete(path2, recursive: false);
}
catch
{
}
}
}
public static GameObject LoadObject(string name)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
string text = "Assets/Modding/ShieldMod/";
return Addressables.LoadAssetAsync<GameObject>((object)(text + name)).WaitForCompletion();
}
}
[BepInPlugin("com.banana.shield", "My first plugin", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private GameObject ShieldPrefab;
private GameObject ShieldPrefabGreen;
private GameObject ShieldPrefabRed;
private GameObject ShieldWeapon;
private GameObject ShieldWeaponGreen;
private GameObject ShieldWeaponRed;
private Harmony Harmony = new Harmony("My first plugin");
internal static ManualLogSource Logger { get; private set; }
public static Plugin Instance { get; set; }
private void Awake()
{
Harmony.PatchAll();
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin com.banana.shield is loaded!");
((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
Instance = this;
}
private void Update()
{
if (BundleLoader.alrLoaded && (Object)(object)ShieldPrefab == (Object)null)
{
ShieldPrefab = BundleLoader.LoadObject("Shield.prefab");
ShieldPrefabGreen = BundleLoader.LoadObject("ShieldGreen Variant.prefab");
ShieldPrefabRed = BundleLoader.LoadObject("ShieldRed Variant.prefab");
}
if (!((Object)(object)ShieldPrefab == (Object)null) && !((Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null))
{
if ((Object)(object)ShieldWeapon == (Object)null)
{
ShieldWeapon = MakeGun(5, ShieldPrefab);
}
if ((Object)(object)ShieldWeaponGreen == (Object)null)
{
ShieldWeaponGreen = MakeGun(5, ShieldPrefabGreen);
}
if ((Object)(object)ShieldWeaponRed == (Object)null)
{
ShieldWeaponRed = MakeGun(5, ShieldPrefabRed);
}
}
}
public static GameObject MakeGun(int var, GameObject original)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)MonoSingleton<GunControl>.Instance == (Object)null || (Object)(object)MonoSingleton<StyleHUD>.Instance == (Object)null)
{
return null;
}
if (!((Behaviour)MonoSingleton<GunControl>.Instance).enabled || !((Behaviour)MonoSingleton<StyleHUD>.Instance).enabled)
{
return null;
}
GameObject val = Object.Instantiate<GameObject>(original);
Collider val2 = default(Collider);
if (val.TryGetComponent<Collider>(ref val2))
{
Object.Destroy((Object)(object)val2);
}
if ((Object)(object)val == (Object)null)
{
return null;
}
Vector3 position = val.transform.position;
Quaternion rotation = val.transform.rotation;
val.transform.parent = ((Component)MonoSingleton<GunControl>.Instance).transform;
val.transform.localPosition = position;
val.transform.localRotation = rotation;
MonoSingleton<GunControl>.Instance.slots[var].Add(val);
MonoSingleton<GunControl>.Instance.allWeapons.Add(val);
MonoSingleton<GunControl>.Instance.slotDict.Add(val, var);
MonoSingleton<StyleHUD>.Instance.weaponFreshness.Add(val, 10f);
val.SetActive(false);
MonoSingleton<GunControl>.Instance.noWeapons = false;
MonoSingleton<GunControl>.Instance.YesWeapon();
for (int i = 0; i < ((Component)MonoSingleton<GunControl>.Instance).transform.childCount; i++)
{
((Component)((Component)MonoSingleton<GunControl>.Instance).transform.GetChild(i)).gameObject.SetActive(false);
}
return val;
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if (SceneHelper.CurrentScene == "Main Menu")
{
BundleLoader.Load();
}
}
}
[HarmonyPatch(typeof(StyleCalculator), "HitCalculator")]
public class CustomStyle
{
public static void Prefix(StyleCalculator __instance, string hitter, string enemyType, string hitLimb, bool dead, EnemyIdentifier eid = null, GameObject sourceWeapon = null)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
if (((Object)(object)eid != (Object)null && eid.blessed) || (int)MonoSingleton<PlayerTracker>.Instance.playerType == 1)
{
return;
}
if (hitter == "shieldcharge")
{
__instance.AddPoints(15, "", eid, sourceWeapon);
if (dead)
{
__instance.AddPoints(75, "BATTERING RAM", eid, sourceWeapon);
}
}
if (hitter == "shield")
{
__instance.AddPoints(45, "", eid, sourceWeapon);
if (dead)
{
__instance.AddPoints(85, "CLANG", eid, sourceWeapon);
}
}
if (hitter == "shieldproj")
{
__instance.AddPoints(5, "", eid, sourceWeapon);
if (dead)
{
__instance.AddPoints(55, "REBOUND", eid, sourceWeapon);
}
}
if (hitter == "shieldnobounce")
{
__instance.AddPoints(48, "", eid, sourceWeapon);
if (dead)
{
__instance.AddPoints(90, "BULLSEYE", eid, sourceWeapon);
}
}
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.banana.shield";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}