-
Notifications
You must be signed in to change notification settings - Fork 11
/
FlamingJoints.cs
70 lines (57 loc) · 1.72 KB
/
FlamingJoints.cs
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
using System;
using UnityEngine;
using System.Collections.Generic;
namespace DestructionEffects
{
[KSPAddon(KSPAddon.Startup.Flight, false)]
public class FlamingJoints : MonoBehaviour
{
public static List<GameObject> flameObjects = new List<GameObject>();
public void Start()
{
GameEvents.onPartJointBreak.Add(onPartJointBreak);
}
public void onPartJointBreak(PartJoint partJoint)
{
if(partJoint.Target!=null && partJoint.Target.PhysicsSignificance != 1)
{
Part part = partJoint.Target;
bool attachFlames = false;
if(part.partInfo.title.Contains("Wing")
|| part.partInfo.title.Contains("Fuselage")
|| part.FindModuleImplementing<ModuleEngines>()
|| part.FindModuleImplementing<ModuleEnginesFX>()
)
{
attachFlames = true;
}
else
{
foreach(PartResource resource in part.Resources)
{
if(resource.resourceName.Contains("Fuel") || resource.resourceName.Contains("Ox"))
{
attachFlames = true;
}
}
}
if(attachFlames)
{
GameObject flameObject2 = (GameObject) GameObject.Instantiate(GameDatabase.Instance.GetModel("DestructionEffects/Models/FlameEffect/model"), partJoint.transform.position, Quaternion.identity);
flameObject2.SetActive(true);
flameObject2.transform.parent = partJoint.Target.transform;
flameObject2.AddComponent<FlamingJointScript>();
foreach(var pe in flameObject2.GetComponentsInChildren<KSPParticleEmitter>())
{
if(pe.useWorldSpace)
{
DEGaplessParticleEmitter gpe = pe.gameObject.AddComponent<DEGaplessParticleEmitter>();
gpe.part = partJoint.Target;
gpe.emit = true;
}
}
}
}
}
}
}