blob: 305f9fc2f5b62373beb0829430aa69f0bad728d2 (
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 ProjectileHit : MonoBehaviour
{
public GameObject soundPlayer;
public ProjectileHitSpawn[] objectsToSpawnOnHit;
private bool done;
public float damage = 25f;
public float force;
private void Start()
{
}
private void Update()
{
}
public void Hit(RaycastHit hit)
{
if (done)
{
return;
}
done = true;
Player component = hit.transform.root.GetComponent<Player>();
ProjectileHitSpawn[] array = objectsToSpawnOnHit;
foreach (ProjectileHitSpawn projectileHitSpawn in array)
{
Vector3 point = hit.point;
Quaternion rotation = Quaternion.identity;
if ((bool)component)
{
if (projectileHitSpawn.playerSpawnRotation == ProjectileHitSpawn.SpawnRotation.forward)
{
rotation = Quaternion.LookRotation(base.transform.forward);
}
if (projectileHitSpawn.playerSpawnRotation == ProjectileHitSpawn.SpawnRotation.normal)
{
rotation = Quaternion.LookRotation(hit.normal);
}
}
else
{
if (projectileHitSpawn.groundSpawnRotation == ProjectileHitSpawn.SpawnRotation.forward)
{
rotation = Quaternion.LookRotation(base.transform.forward);
}
if (projectileHitSpawn.groundSpawnRotation == ProjectileHitSpawn.SpawnRotation.normal)
{
rotation = Quaternion.LookRotation(hit.normal);
}
}
GameObject gameObject = Object.Instantiate(projectileHitSpawn.spawnedObject, point, rotation);
}
Damagable component2 = hit.transform.GetComponent<Damagable>();
if ((bool)component2)
{
component2.TakeDamage(damage * base.transform.forward, hit.point);
}
Rigidbody rigidbody = hit.rigidbody;
if ((bool)rigidbody && force != 0f)
{
float num = 1f;
num = Mathf.Clamp(rigidbody.mass / 10f, 0f, 1f);
rigidbody.AddForceAtPosition(base.transform.forward * force * num, hit.point, ForceMode.Impulse);
}
Object.Instantiate(soundPlayer, hit.point, Quaternion.identity).GetComponent<SFXPlayer>().Play(hit);
Object.Destroy(base.gameObject);
}
}
|