project update
This commit is contained in:
53
Modules/Other/EngineControllingModule.cs
Normal file
53
Modules/Other/EngineControllingModule.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Inventories.ItemSlots.ItemSlots;
|
||||
using Skeleton.Algebra.Extensions;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.Other;
|
||||
public partial class EngineControllingModule : BaseModule
|
||||
{
|
||||
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<BasePort> Ports => new[] { Throttle };
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Throttle = GetPort<DataInPort>("Throttle");
|
||||
Throttle.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
FuelTank = GetNode<IChemicalItemSlot>("FuelTank");
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public double Combust(RootModule root)
|
||||
{
|
||||
if (FuelTank.Item == null)
|
||||
return 0d;
|
||||
if (FuelTank.Item.Amount <= 0)
|
||||
return 0d;
|
||||
double fuelAmount = Mathf.Min(
|
||||
FuelTank.Item.BottomAmount,
|
||||
Throttle.GetData(root).Real.DoubleCut() * MaxPumpSpeed * (1 - FuelTank.Item.BottomViscosity)
|
||||
);
|
||||
if (fuelAmount == 0)
|
||||
{
|
||||
//TODO Drain fuel from pipeline
|
||||
}
|
||||
|
||||
double res =
|
||||
fuelAmount * FuelTank.Item.ContentMaterial.LayerOrder.Last.Value.Energy * EnergyConversionEfficiency;
|
||||
FuelTank.Item.ConsumeFromBottom(fuelAmount);
|
||||
if (FuelTank.Item.Amount.IsEqualApprox(0d))
|
||||
{
|
||||
//TODO Try get fuel
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user