/
SimModuleDecouple.cs
34 lines (26 loc) · 1.02 KB
/
SimModuleDecouple.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
/*
* Copyright Lamont Granquist, Sebastien Gaggini and the MechJeb contributors
* SPDX-License-Identifier: LicenseRef-PD-hp OR Unlicense OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT OR LGPL-2.1+
*/
#nullable enable
using MechJebLib.Utils;
namespace MechJebLib.FuelFlowSimulation.PartModules
{
public class SimModuleDecouple : SimPartModule
{
private static readonly ObjectPool<SimModuleDecouple> _pool = new ObjectPool<SimModuleDecouple>(New, Clear);
public bool IsDecoupled;
public bool IsOmniDecoupler;
public bool Staged;
public SimPart? AttachedPart;
public override void Dispose() => _pool.Release(this);
public static SimModuleDecouple Borrow(SimPart part)
{
SimModuleDecouple decoupler = _pool.Borrow();
decoupler.Part = part;
return decoupler;
}
private static SimModuleDecouple New() => new SimModuleDecouple();
private static void Clear(SimModuleDecouple m) => m.AttachedPart = null;
}
}