42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Enigmos.Ports.DataPorts;
|
|
using Nocturnis.Enigmos.Ports;
|
|
using Nocturnis.GlobalManagement.Constants;
|
|
using Nocturnis.GlobalManagement.Controls;
|
|
using Nocturnis.Inventories.ItemSlots.ItemSlots;
|
|
using Skeleton.Utils.Helpers;
|
|
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
|
|
|
namespace Enigmos.Modules.TerminalModules;
|
|
public abstract partial class EngineModule : TerminalModule
|
|
{
|
|
protected override bool Draggable => false;
|
|
public DataInPort? Throttle { get; set; }
|
|
public IChemicalItemSlot? FuelTank { get; set; }
|
|
private double MaxPumpSpeed => 2d;
|
|
private double EnergyConversionEfficiency => 0.5d;
|
|
public override IEnumerable<IBasePort> Ports => new[] { Throttle! };
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
Throttle!.SetDataType(DataTypeConstant.BaseDataTypes.Real);
|
|
FuelTank = GetNode<IChemicalItemSlot>("FuelTank");
|
|
PostInit();
|
|
}
|
|
|
|
public override void Drain()
|
|
{
|
|
base.Drain();
|
|
if (FuelTank!.Item!.ContentMaterial.Layers.Count == 0)
|
|
{
|
|
EnigmosControl.Instance.Energy = 0;
|
|
return;
|
|
}
|
|
HomogeneousMixture bottom = FuelTank.Item.ContentMaterial.LayerOrder.Last.Value;
|
|
double consumption = Math.Min(bottom.Amount, Throttle!.GetData.Get!.Real.DoubleCut() * bottom.CombustRate);
|
|
EnigmosControl.Instance.Energy = consumption * bottom.Energy;
|
|
bottom.Amount -= consumption;
|
|
}
|
|
|
|
}
|