blob: 2555c98eb4dc80dcca0280af749d9ce155cda76b (
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 Thruster : MonoBehaviour
{
public float force;
public float drag;
public float pow = 1f;
public float physicsObjectM = 1f;
private FollowLocalPos follow;
private Rigidbody2D rig;
private Vector2 startForward;
private NetworkPhysicsObject pushed;
private Player player;
private bool checkedForPlayer;
private void Start()
{
force *= Mathf.Pow(base.transform.localScale.x, pow);
drag *= Mathf.Pow(base.transform.localScale.x, pow);
follow = GetComponent<FollowLocalPos>();
if ((bool)follow.target)
{
pushed = follow.target.gameObject.GetComponent<NetworkPhysicsObject>();
}
float num = 1f;
if (!follow.targetPlayer)
{
num = 0.2f;
}
else if ((bool)pushed)
{
num = 0.5f;
}
ParticleSystem.MainModule main = GetComponentInChildren<ParticleSystem>().main;
main.duration *= num;
GetComponent<DelayEvent>().time *= num;
GetComponent<RemoveAfterSeconds>().seconds *= num;
startForward = base.transform.forward;
}
private void FixedUpdate()
{
if (!follow)
{
return;
}
if ((bool)follow.target)
{
if ((bool)player)
{
if ((bool)player)
{
player.data.healthHandler.TakeForce(startForward * force, ForceMode2D.Force);
}
else
{
rig.AddForce(startForward * force, ForceMode2D.Force);
}
}
else if (!checkedForPlayer)
{
player = follow.target.transform.root.GetComponent<Player>();
checkedForPlayer = true;
if (!player && !pushed)
{
base.enabled = false;
}
}
}
if ((bool)pushed && pushed.photonView.IsMine)
{
pushed.RPCA_SendForce(base.transform.forward * force * physicsObjectM, pushed.transform.InverseTransformPoint(base.transform.position));
}
}
}
|