45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Nocturnis.Enigmos.Modules;
|
|
using Nocturnis.Enigmos.Ports;
|
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
|
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, IEngineModule
|
|
{
|
|
protected override bool Draggable => false;
|
|
public IDataInPort 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();
|
|
this.DataInInit("Throttle", 1);
|
|
Throttle = DataInPorts[0];
|
|
Throttle.SetDataType(DataTypeConstant.BaseDataTypes.Real);
|
|
FuelTank = GetNode<IChemicalItemSlot>("FuelTank");
|
|
PostInit();
|
|
}
|
|
|
|
public override void Drain()
|
|
{
|
|
base.Drain();
|
|
if (FuelTank.Item == null || 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;
|
|
}
|
|
|
|
}
|