summaryrefslogtreecommitdiff
path: root/FootHandler.cs
blob: 7343e2161c2bb5f315b1948ec502c354fc9a3a99 (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
using UnityEngine;

public class FootHandler : MonoBehaviour
{
	private AnimationHandler animHandler;

	private Collider collider;

	public PhysicMaterial slippery;

	private PhysicMaterial footMaterial;

	private Transform torso;

	private MovementDataHandler moveData;

	private Rigidbody rig;

	private RotationHandler rot;

	private Vector3 rotationDif;

	private AnimationObject anim;

	private StepHandler handler;

	private void Start()
	{
		animHandler = base.transform.root.GetComponent<AnimationHandler>();
		moveData = base.transform.root.GetComponent<MovementDataHandler>();
		collider = GetComponentInChildren<Collider>();
		rig = GetComponent<Rigidbody>();
		footMaterial = collider.material;
		torso = base.transform.root.GetComponentInChildren<Torso>().transform;
		rot = base.transform.root.GetComponent<RotationHandler>();
		handler = base.transform.root.GetComponent<StepHandler>();
		anim = GetComponentInChildren<AnimationObject>();
	}

	private void Update()
	{
		float num = Mathf.Abs(torso.position.x - base.transform.position.x) + Mathf.Abs(torso.position.z - base.transform.position.z);
		if (rot.hipCorrectionAmount > 30f || ((bool)anim && anim.isLeft != handler.isLeft))
		{
			SetFoot(active: false);
		}
		else if (animHandler.animationState == 0)
		{
			if (num > 0.1f || rotationDif.magnitude > 15f)
			{
				SetFoot(active: false);
			}
			else
			{
				SetFoot(active: true);
			}
		}
		else
		{
			SetFoot(active: true);
		}
	}

	private void FixedUpdate()
	{
	}

	private void SetFoot(bool active)
	{
		if (active)
		{
			collider.material = footMaterial;
		}
	}
}