forked from KSP-KOS/KOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartValueFactory.cs
More file actions
23 lines (20 loc) · 942 Bytes
/
PartValueFactory.cs
File metadata and controls
23 lines (20 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using kOS.Safe.Encapsulation;
using System.Collections.Generic;
using System.Linq;
namespace kOS.Suffixed.Part
{
public class PartValueFactory
{
// Any time that we create a list, we have to be very careful about null references
// because ListValue will attempt to assert that the value must
public static ListValue Construct(IEnumerable<global::Part> parts, SharedObjects shared) {
return ListValue.CreateList(parts.Select(part => Construct(part, shared)).Where(p => p != null));
}
public static ListValue ConstructGeneric(IEnumerable<global::Part> parts, SharedObjects shared) {
return new ListValue(parts.Select(part => Construct(part, shared)).Where(p => p != null));
}
public static PartValue Construct(global::Part part, SharedObjects shared) {
return VesselTarget.CreateOrGetExisting(part.vessel, shared)[part];
}
}
}