Upgrade structure of code base
This commit is contained in:
41
Modules/TerminalModules/EngineModule.cs
Normal file
41
Modules/TerminalModules/EngineModule.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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 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(EnigmosConstant.DataPortTypes.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!.Double.DoubleCut() * bottom.CombustRate);
|
||||
EnigmosControl.Instance.Energy = consumption * bottom.Energy;
|
||||
bottom.Amount -= consumption;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user