blob: 83c247af926c751812e9c6a9219242bfb08671d5 (
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
81
82
83
84
85
|
using UnityEngine;
public class CollisionChecker : MonoBehaviour
{
private Transform head;
private Transform hip;
private StandingDataHandler data;
public bool active = true;
public float sinceGrounded;
private PickupHandler pickupHandler;
private HasControl hasControl;
public float allowedSteepnesAngle = 60f;
private void Start()
{
pickupHandler = base.transform.root.GetComponent<PickupHandler>();
hasControl = base.transform.root.GetComponent<HasControl>();
data = GetComponentInParent<StandingDataHandler>();
Head componentInChildren = base.transform.root.GetComponentInChildren<Head>();
if ((bool)componentInChildren)
{
head = componentInChildren.transform;
}
Hip componentInChildren2 = base.transform.root.GetComponentInChildren<Hip>();
if ((bool)componentInChildren2)
{
hip = componentInChildren2.transform;
}
}
private void Update()
{
sinceGrounded += Time.deltaTime;
}
private void OnCollisionStay(Collision collision)
{
Collide(collision);
}
private void OnCollisionEnter(Collision collision)
{
Collide(collision);
}
private void Collide(Collision collision)
{
if (collision.transform.root == base.transform.root)
{
return;
}
if ((bool)collision.rigidbody)
{
Pickup component = collision.gameObject.GetComponent<Pickup>();
if ((bool)component && !component.GetComponent<HoldableObject>().isHeld && hasControl.hasControl)
{
pickupHandler.PickUp(component);
}
if (collision.rigidbody.mass < 100f || collision.rigidbody.velocity.magnitude > 1f)
{
return;
}
}
if (active && Vector3.Angle(Vector3.up, collision.contacts[0].normal) < allowedSteepnesAngle)
{
if ((bool)data)
{
data.TouchGround(Mathf.Abs(hip.position.y - collision.contacts[0].point.y), collision.contacts[0].normal);
}
sinceGrounded = 0f;
}
}
public void SwitchActive(bool setActive)
{
active = setActive;
}
}
|