-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplashedSituationFix.cs
More file actions
44 lines (39 loc) · 1.4 KB
/
Copy pathSplashedSituationFix.cs
File metadata and controls
44 lines (39 loc) · 1.4 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace TinkerTech
{
[KSPAddon(KSPAddon.Startup.Flight, true)]
class SplashedSituationFix : MonoBehaviour
{
void Start()
{
GameEvents.onVesselSituationChange.Add(new EventData<GameEvents.HostedFromToAction<Vessel, Vessel.Situations>>.OnEvent(OnVesselSituationChanged));
DontDestroyOnLoad(this);
}
void OnDestroy()
{
GameEvents.onVesselSituationChange.Remove(OnVesselSituationChanged);
}
private void OnVesselSituationChanged(GameEvents.HostedFromToAction<Vessel, Vessel.Situations> data)
{
//fix landed to splashed on fluids
if (data.to == Vessel.Situations.LANDED)
{
//if a part with water contact exists, force splashed situation
foreach (Part part in data.host.Parts)
{
if (part.WaterContact)
{
Debug.Log("found part with water contact in LANDED situation, changing situation to SPLASHED");
data.host.situation = Vessel.Situations.SPLASHED;
data.host.Splashed = true;
return;
}
}
}//endif
}//end onsituation
}//end behaviour
}