project update

This commit is contained in:
h z
2024-06-30 01:52:44 +08:00
parent 117835b503
commit 59d257c06a
67 changed files with 2268 additions and 92 deletions

View 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;
}
}