-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathCore.cs
More file actions
53 lines (47 loc) · 1.79 KB
/
Core.cs
File metadata and controls
53 lines (47 loc) · 1.79 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
45
46
47
48
49
50
51
52
53
using kOS.Safe.Encapsulation;
using kOS.Safe.Encapsulation.Suffixes;
using kOS.Safe.Persistence;
using kOS.Safe.Utilities;
using kOS.Module;
using kOS.Suffixed;
using kOS.Suffixed.Part;
using kOS.Suffixed.PartModuleField;
using kOS.Utilities;
using System.Linq;
using kOS.Communication;
namespace kOS
{
[kOS.Safe.Utilities.KOSNomenclature("Core")]
public class Core : kOSProcessorFields
{
public static VersionInfo VersionInfo;
static Core()
{
var ver = typeof(Core).Assembly.GetName().Version;
VersionInfo = new VersionInfo(ver);
}
public Core(kOSProcessor processor, SharedObjects shared):base(processor, shared)
{
InitializeSuffixes();
}
private void InitializeSuffixes()
{
AddSuffix("VERSION", new Suffix<VersionInfo>(() => VersionInfo));
AddSuffix("VESSEL", new Suffix<VesselTarget>(() => VesselTarget.CreateOrGetExisting(shared.KSPPart.vessel, shared)));
AddSuffix("ELEMENT", new Suffix<ElementValue>(GetEelement));
AddSuffix("CURRENTVOLUME", new Suffix<Volume>(GetCurrentVolume, "The currently selected volume"));
AddSuffix("MESSAGES", new NoArgsSuffix<MessageQueueStructure>(() => new MessageQueueStructure(processor.Messages, shared),
"This processor's message queue"));
}
private ElementValue GetEelement()
{
var elList = shared.KSPPart.vessel.PartList("elements", shared);
var part = VesselTarget.CreateOrGetExisting(shared)[shared.KSPPart];
return elList.Cast<ElementValue>().FirstOrDefault(el => el.Parts.Contains(part));
}
private Volume GetCurrentVolume()
{
return shared.VolumeMgr.CurrentVolume;
}
}
}