Decompiled source of MUL T Scrap Jump v0.2.0

BepInEx/plugins/MULTScrapJump/MULTScrapJump.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2.Projectile;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MULTScrapJump;

public struct Launch
{
	public float X;

	public float Y;

	public float Z;

	public float Damage;

	public float Strength;

	public bool Active => Strength > 0f;
}
public static class BlastMath
{
	public static bool Finite(float x)
	{
		if (!float.IsNaN(x))
		{
			return !float.IsInfinity(x);
		}
		return false;
	}

	public static float ArmorMultiplier(float armor)
	{
		if (!(armor >= 0f))
		{
			return 2f - 100f / (100f - armor);
		}
		return 100f / (100f + armor);
	}

	public static Launch Evaluate(float x, float y, float z, float bodyRadius, float radius, float rawDamage, float armor, float speed, float damageFraction, bool enemy = false)
	{
		if (!Finite(x) || !Finite(y) || !Finite(z) || !Finite(bodyRadius) || !Finite(radius) || !Finite(rawDamage) || !Finite(armor) || !Finite(speed) || !Finite(damageFraction) || radius <= 0f || rawDamage <= 0f || speed <= 0f)
		{
			return default(Launch);
		}
		double num = Math.Sqrt((double)x * (double)x + (double)y * (double)y + (double)z * (double)z);
		float num2 = Math.Max(0f, (float)num - Math.Max(0f, bodyRadius)) / radius;
		float num3 = (enemy ? Math.Max(0f, 1f - num2) : WideFalloff(num2, 0.8f));
		if (num3 <= 0f)
		{
			return default(Launch);
		}
		if (num < 0.001)
		{
			x = 0f;
			y = 1f;
			z = 0f;
			num = 1.0;
		}
		float num4 = (float)((double)(speed * num3) / num);
		return new Launch
		{
			X = x * num4,
			Y = y * num4,
			Z = z * num4,
			Strength = num3,
			Damage = (enemy ? 0f : (rawDamage * Math.Min(0.95f, Math.Max(0.1f, damageFraction)) * WideFalloff(num2, 0.9f) * ArmorMultiplier(armor)))
		};
	}

	public static float WideFalloff(float t, float shoulder)
	{
		if (!Finite(t) || t >= 1f)
		{
			return 0f;
		}
		if (t <= 0.5f)
		{
			return 1f;
		}
		if (t <= 0.85f)
		{
			return 1f - (1f - shoulder) * (t - 0.5f) / 0.35f;
		}
		float num = (t - 0.85f) / 0.15f;
		return shoulder * (1f - num * num * (3f - 2f * num));
	}

	public static float EnemyScale(float mass, float radius, bool medium, bool boss, bool stoneGolem = false)
	{
		if (boss || !Finite(mass) || !Finite(radius) || mass <= 0f || (mass >= 600f && !stoneGolem) || radius >= 3.5f)
		{
			return 0f;
		}
		float num = (float)Math.Min(1.0, Math.Sqrt(100f / mass));
		if (!medium)
		{
			return num;
		}
		return Math.Min(0.35f, num);
	}

	public static bool Debit(float cost, ref float barrier, ref float shield, ref float health)
	{
		if (!Finite(cost) || cost <= 0f)
		{
			return false;
		}
		float num = Math.Min(Math.Max(0f, barrier), cost);
		barrier -= num;
		cost -= num;
		num = Math.Min(Math.Max(0f, shield), cost);
		shield -= num;
		cost -= num;
		if (cost >= health)
		{
			return true;
		}
		health -= cost;
		return false;
	}
}
[BepInPlugin("com.rodanius.multscrapjump", "MUL-T Scrap Jump", "0.2.0")]
public sealed class Plugin : BaseUnityPlugin
{
	private sealed class Once
	{
	}

	public const string Guid = "com.rodanius.multscrapjump";

	public const string Version = "0.2.0";

	private ConfigEntry<float> speed;

	private ConfigEntry<float> fraction;

	private ConfigEntry<float> enemySpeed;

	private ConfigEntry<bool> diagnostics;

	private BodyIndex toolbot = (BodyIndex)(-1);

	private int scrap = -1;

	private BodyIndex stoneGolem = (BodyIndex)(-1);

	private readonly HashSet<BodyIndex> heavyBodies = new HashSet<BodyIndex>();

	private bool ready;

	private Action<HealthComponent, FixedTimeStamp> setLastHit;

	private FieldInfo dangerStopwatch;

	private Action<CharacterBody> refreshDanger;

	private readonly ConditionalWeakTable<ProjectileExplosion, Once> fired = new ConditionalWeakTable<ProjectileExplosion, Once>();

	private void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Expected O, but got Unknown
		speed = ((BaseUnityPlugin)this).Config.Bind<float>("Launch", "ImpulseSpeed", 36f, new ConfigDescription("Maximum added speed in metres/second per rocket. Host setting; does not scale with damage or crit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), Array.Empty<object>()));
		fraction = ((BaseUnityPlugin)this).Config.Bind<float>("Damage", "SelfDamageFraction", 0.6f, new ConfigDescription("Fraction of non-critical projectile blast damage, before distance falloff and armor. Each rocket pays independently.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 0.95f), Array.Empty<object>()));
		enemySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "ImpulseSpeed", 16f, new ConfigDescription("Maximum added speed for light enemies; mass/hull reduce this and bosses/large bodies receive none.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 24f), Array.Empty<object>()));
		ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Migration", "BalanceRevision", 0, "Internal default migration marker. Custom launch speeds other than the old default are preserved.");
		if (val.Value < 2)
		{
			if (Math.Abs(speed.Value - 22f) < 0.001f)
			{
				speed.Value = 36f;
			}
			val.Value = 2;
			((BaseUnityPlugin)this).Config.Save();
		}
		diagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "LogJumps", false, "Log each server-side launch and cost for private playtesting.");
		try
		{
			MethodInfo methodInfo = typeof(HealthComponent).GetProperty("lastHitTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetSetMethod(nonPublic: true);
			if (methodInfo == null)
			{
				throw new MissingMethodException("HealthComponent.lastHitTime setter");
			}
			setLastHit = (Action<HealthComponent, FixedTimeStamp>)Delegate.CreateDelegate(typeof(Action<HealthComponent, FixedTimeStamp>), methodInfo);
			dangerStopwatch = typeof(CharacterBody).GetField("outOfDangerStopwatch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo method = typeof(CharacterBody).GetMethod("UpdateOutOfCombatAndDanger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (dangerStopwatch == null || method == null)
			{
				throw new MissingMemberException("CharacterBody danger timer API");
			}
			refreshDanger = (Action<CharacterBody>)Delegate.CreateDelegate(typeof(Action<CharacterBody>), method);
			ProjectileExplosion.DetonateServer += new hook_DetonateServer(Detonate);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ResolveCatalogs));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MUL-T Scrap Jump 0.2.0 loaded; standalone gameplay mod. Native playtest pending.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Scrap Jump disabled: native API mismatch. " + ex));
		}
	}

	private void OnDestroy()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		ProjectileExplosion.DetonateServer -= new hook_DetonateServer(Detonate);
		RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(ResolveCatalogs));
	}

	private void ResolveCatalogs()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Invalid comparison between Unknown and I4
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Invalid comparison between Unknown and I4
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		toolbot = BodyCatalog.FindBodyIndex("ToolbotBody");
		scrap = ProjectileCatalog.FindProjectileIndex("ToolbotGrenadeLauncherProjectile");
		stoneGolem = BodyCatalog.FindBodyIndex("GolemBody");
		string[] array = new string[5] { "BeetleGuardBody", "LemurianBruiserBody", "ParentBody", "GupBody", "ClayBruiserBody" };
		for (int i = 0; i < array.Length; i++)
		{
			BodyIndex val = BodyCatalog.FindBodyIndex(array[i]);
			if ((int)val != -1)
			{
				heavyBodies.Add(val);
			}
		}
		ready = (int)toolbot != -1 && scrap >= 0;
		if (!ready)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Scrap Jump disabled: native MUL-T/Scrap Launcher catalog entry missing.");
		}
	}

	private static bool Occluded(Vector3 center, Vector3 origin)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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)
		//IL_0020: 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)
		Vector3 val = center - origin;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude > 0.08f)
		{
			return Physics.Raycast(center, -((Vector3)(ref val)).normalized, magnitude - 0.08f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
		}
		return false;
	}

	private void Detonate(orig_DetonateServer orig, ProjectileExplosion explosion)
	{
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Invalid comparison between Unknown and I4
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Invalid comparison between Unknown and I4
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: 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)
		//IL_017d: 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_018b: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody owner = null;
		Launch launch = default(Launch);
		bool flag = false;
		try
		{
			if (NetworkServer.active && ready && Object.op_Implicit((Object)(object)explosion))
			{
				ProjectileController component = ((Component)explosion).GetComponent<ProjectileController>();
				if (Object.op_Implicit((Object)(object)component) && component.catalogIndex == scrap && Object.op_Implicit((Object)(object)component.owner))
				{
					owner = component.owner.GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)owner) && owner.bodyIndex == toolbot && !fired.TryGetValue(explosion, out var _))
					{
						fired.Add(explosion, new Once());
						flag = true;
						HealthComponent healthComponent = owner.healthComponent;
						ProjectileDamage component2 = ((Component)explosion).GetComponent<ProjectileDamage>();
						if (Object.op_Implicit((Object)(object)owner.characterMotor) && Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive && Object.op_Implicit((Object)(object)component2) && !healthComponent.IsImmuneToPhysicsForces() && (owner.bodyFlags & 0x10000) == 0)
						{
							Vector3 val = owner.corePosition - ((Component)explosion).transform.position;
							if (!Occluded(owner.corePosition, ((Component)explosion).transform.position))
							{
								launch = BlastMath.Evaluate(val.x, val.y, val.z, owner.radius, explosion.blastRadius, component2.damage * explosion.blastDamageCoefficient, owner.armor, speed.Value, fraction.Value);
							}
						}
					}
				}
			}
		}
		catch (Exception ex)
		{
			ready = false;
			flag = false;
			launch = default(Launch);
			((BaseUnityPlugin)this).Logger.LogError((object)("Scrap Jump disabled during capture: " + ex));
		}
		AttackerFiltering blastAttackerFiltering = explosion.blastAttackerFiltering;
		bool num = NetworkServer.active && ready && Object.op_Implicit((Object)(object)owner) && owner.bodyIndex == toolbot;
		Action<BlastAttack> action = null;
		Action<BlastAttack, Result> action2 = null;
		if (num)
		{
			if ((int)blastAttackerFiltering == 1)
			{
				explosion.blastAttackerFiltering = (AttackerFiltering)4;
			}
			else if ((int)blastAttackerFiltering == 0 || (int)blastAttackerFiltering == 3)
			{
				explosion.blastAttackerFiltering = (AttackerFiltering)2;
			}
			action = delegate(BlastAttack blast)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				blast.baseForce = 0f;
				blast.bonusForce = Vector3.zero;
			};
			explosion.OnModifyBlastAttack = (Action<BlastAttack>)Delegate.Combine(explosion.OnModifyBlastAttack, action);
			if (flag)
			{
				action2 = delegate(BlastAttack blast, Result hits)
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					try
					{
						PushEnemies(owner, blast, hits);
					}
					catch (Exception ex3)
					{
						((BaseUnityPlugin)this).Logger.LogError((object)("Scrap Jump enemy recoil failed: " + ex3));
					}
				};
				explosion.OnProjectileExplosion = (Action<BlastAttack, Result>)Delegate.Combine(explosion.OnProjectileExplosion, action2);
			}
		}
		try
		{
			orig.Invoke(explosion);
		}
		finally
		{
			if (Object.op_Implicit((Object)(object)explosion))
			{
				explosion.blastAttackerFiltering = blastAttackerFiltering;
				if (action != null)
				{
					explosion.OnModifyBlastAttack = (Action<BlastAttack>)Delegate.Remove(explosion.OnModifyBlastAttack, action);
				}
				if (action2 != null)
				{
					explosion.OnProjectileExplosion = (Action<BlastAttack, Result>)Delegate.Remove(explosion.OnProjectileExplosion, action2);
				}
			}
		}
		if (!launch.Active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)owner.healthComponent) || !owner.healthComponent.alive)
		{
			return;
		}
		try
		{
			ApplyImpulse(owner.healthComponent, launch, enemy: false);
			PayBlastCost(owner.healthComponent, launch.Damage);
			if (diagnostics.Value)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Scrap jump owner={((NetworkBehaviour)owner).netId} impulse=({launch.X:F2},{launch.Y:F2},{launch.Z:F2}) armor={owner.armor:F1} cost={launch.Damage:F2}");
			}
		}
		catch (Exception ex2)
		{
			ready = false;
			((BaseUnityPlugin)this).Logger.LogError((object)("Scrap Jump disabled during launch: " + ex2));
		}
	}

	private static void ApplyImpulse(HealthComponent hc, Launch launch, bool enemy)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		PhysForceInfo val = PhysForceInfo.Create();
		val.force = new Vector3(launch.X, launch.Y, launch.Z);
		((PhysForceInfo)(ref val)).massIsOne = true;
		((PhysForceInfo)(ref val)).ignoreGroundStick = true;
		((PhysForceInfo)(ref val)).disableAirControlUntilCollision = false;
		((PhysForceInfo)(ref val)).resetVelocity = false;
		((PhysForceInfo)(ref val)).doNotExceed = false;
		((PhysForceInfo)(ref val)).respectKnockupImmune = enemy;
		hc.TakeDamageForce(val);
	}

	private void PushEnemies(CharacterBody owner, BlastAttack blast, Result result)
	{
		//IL_001c: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Invalid comparison between Unknown and I4
		//IL_00e0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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_0158: Invalid comparison between Unknown and I4
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Invalid comparison between Unknown and I4
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: 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)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)owner.teamComponent) || result.hitPoints == null)
		{
			return;
		}
		HashSet<HealthComponent> hashSet = new HashSet<HealthComponent>();
		HitPoint[] hitPoints = result.hitPoints;
		foreach (HitPoint val in hitPoints)
		{
			HealthComponent val2 = (Object.op_Implicit((Object)(object)val.hurtBox) ? val.hurtBox.healthComponent : null);
			if (!Object.op_Implicit((Object)(object)val2) || !val2.alive || !hashSet.Add(val2) || (Object)(object)val2 == (Object)(object)owner.healthComponent)
			{
				continue;
			}
			CharacterBody body = val2.body;
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent) || body.isPlayerControlled || (int)body.teamComponent.teamIndex <= 0 || body.teamComponent.teamIndex == owner.teamComponent.teamIndex || val2.IsImmuneToPhysicsForces() || (body.bodyFlags & 0x10000) != 0)
			{
				continue;
			}
			IPhysMotor component = ((Component)body).GetComponent<IPhysMotor>();
			Rigidbody component2 = ((Component)body).GetComponent<Rigidbody>();
			float num = BlastMath.EnemyScale((component != null) ? component.mass : (Object.op_Implicit((Object)(object)component2) ? component2.mass : 0f), body.radius, (int)body.hullClassification == 1 || body.bodyIndex == stoneGolem, body.isChampion || body.isBoss || heavyBodies.Contains(body.bodyIndex) || (int)body.hullClassification == 2, body.bodyIndex == stoneGolem);
			if (!(num <= 0f) && !Occluded(body.corePosition, blast.position))
			{
				Vector3 val3 = body.corePosition - blast.position;
				float num2 = Math.Min(enemySpeed.Value, speed.Value * 0.45f);
				Launch launch = BlastMath.Evaluate(val3.x, val3.y, val3.z, body.radius, blast.radius, 1f, 0f, num2 * num, 0.6f, enemy: true);
				if (launch.Active)
				{
					ApplyImpulse(val2, launch, enemy: true);
				}
			}
		}
	}

	private void PayBlastCost(HealthComponent hc, float cost)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		if (!hc.godMode && !hc.body.HasBuff(Buffs.HiddenInvincibility) && !hc.body.HasBuff(Buffs.Immune))
		{
			float barrier = hc.barrier;
			float shield = hc.shield;
			float health = hc.health;
			bool num = BlastMath.Debit(cost, ref barrier, ref shield, ref health);
			setLastHit(hc, FixedTimeStamp.now);
			dangerStopwatch.SetValue(hc.body, 0f);
			refreshDanger(hc.body);
			hc.Networkbarrier = barrier;
			hc.Networkshield = shield;
			if (num)
			{
				hc.Suicide((GameObject)null, (GameObject)null, DamageTypeCombo.op_Implicit((DamageType)0));
			}
			else
			{
				hc.Networkhealth = health;
			}
		}
	}
}