summaryrefslogtreecommitdiff
path: root/GameCode/RayHitBash.cs
blob: e56603e2450781478823b3e574616dde132e4cc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using UnityEngine;

public class RayHitBash : RayHitEffect
{
	public float triggerChancePerTenDamage = 0.1f;

	public float baseTriggerChance = 0.2f;

	[Space(15f)]
	public float stunMultiplier = 1f;

	public float stunTimePerTenDamage = 0.1f;

	public float baseStunTime = 1f;

	public bool cannotPermaStun;

	[Space(15f)]
	public float stunTimeThreshold = 0.2f;

	public float stunTimeExponent = 1f;

	public float multiplierPerTenMeterTravelled;

	private MoveTransform move;

	private float multiplier = 1f;

	private void Start()
	{
		move = GetComponentInParent<MoveTransform>();
		multiplier = base.transform.localScale.x;
	}

	public override HasToReturn DoHitEffect(HitInfo hit)
	{
		if (!hit.transform)
		{
			return HasToReturn.canContinue;
		}
		StunHandler component = hit.transform.GetComponent<StunHandler>();
		if ((bool)component)
		{
			ProjectileHit componentInParent = GetComponentInParent<ProjectileHit>();
			float num = 25f;
			if ((bool)componentInParent)
			{
				num = componentInParent.damage;
			}
			float num2 = triggerChancePerTenDamage * num * 0.1f;
			num2 += baseTriggerChance;
			if (Random.value < num2)
			{
				float num3 = baseStunTime + stunTimePerTenDamage * num * 0.1f;
				SetMultiplier();
				num3 *= stunMultiplier;
				num3 = Mathf.Pow(num3, stunTimeExponent);
				num3 *= multiplier;
				if (cannotPermaStun)
				{
					num3 = Mathf.Clamp(num3, 0f, GetComponentInParent<SpawnedAttack>().spawner.data.weaponHandler.gun.attackSpeed * GetComponentInParent<SpawnedAttack>().spawner.data.stats.attackSpeedMultiplier + 0.3f);
				}
				if (num3 > stunTimeThreshold)
				{
					component.AddStun(num3);
				}
			}
		}
		return HasToReturn.canContinue;
	}

	private void SetMultiplier()
	{
		float distanceTravelled = move.distanceTravelled;
		if (multiplierPerTenMeterTravelled != 0f)
		{
			stunMultiplier = distanceTravelled * multiplierPerTenMeterTravelled * 0.1f;
		}
	}
}