-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDamages.cs
60 lines (51 loc) · 2.01 KB
/
Damages.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
using System;
using UnityEngine;
using KSP.IO;
/******************************************************************************
* Copyright (c) 2013, Justin Bengtson
*
* Part Failure for Kerbal Space Program
*
* This code is licensed under Creative Commons CC BY-NC-SA 3.0
* Attribution-NonCommercial-ShareAlike 3.0 Unported
*
* License text available here:
* http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
******************************************************************************/
namespace RegexKSP {
public interface IConfigSave {
void saveConfigNode(ConfigNode config);
}
public class DamageTestModule : PartModule, IConfigSave {
[KSPField(isPersistant = true, guiActive = true, guiName = "Damage", guiUnits = "", guiFormat = "G")]
public string displayDamage = "";
[KSPField(isPersistant = true, guiActive = false]
public double lastPollTime = 0.0;
public override void OnAwake() {
ScreenMessages.PostScreenMessage(this.part.partInfo.title + " has been damaged!", 5.0f, ScreenMessageStyle.UPPER_CENTER);
this.isEnabled = true;
displayDamage = "Testing";
}
public override void OnFixedUpdate() {
double timeNow = Planetarium.GetUniversalTime();
double timeDiff = timeNow - lastPollTime;
lastPollTime = timeNow;
}
[KSPEvent(guiName = "Repair Test Damage", externalToEVAOnly = true, guiActiveUnfocused = true, unfocusedRange = 2.0f)]
public void Repair() {
var vessel = FlightGlobals.ActiveVessel;
if(!vessel.isEVA) { return; }
this.part.RemoveModule(this);
PartDamage.markGUIDirty(this.part);
}
public void saveConfigNode(ConfigNode config) {
ConfigNode retval = new ConfigNode("MODULE");
retval.AddValue("name", "DamageTestModule");
retval.AddValue("displayDamage", displayDamage);
retval.AddValue("lastPollTime", lastPollTime);
retval.AddValue("vesselId", );
retval.AddValue("partId", );
config.AddNode(node);
}
}
}