From dbbfad95f0c0250988a1e2b0c7c8e028e32a132b Mon Sep 17 00:00:00 2001 From: Gauge Date: Fri, 29 Nov 2024 15:27:26 -0800 Subject: [PATCH] added an ignore option --- ThermalDynamics/Data/CubeBlocks.xml | 275 ++++++++---------- .../Thermodynamics/Blocks/CoolantPump.cs | 2 +- .../Definitions/ThermalCellDefinition.cs | 13 +- .../Data/Scripts/Thermodynamics/Settings.cs | 2 +- .../Scripts/Thermodynamics/ThermalCell.cs | 7 +- .../Scripts/Thermodynamics/ThermalGrid.cs | 10 +- 6 files changed, 156 insertions(+), 153 deletions(-) diff --git a/ThermalDynamics/Data/CubeBlocks.xml b/ThermalDynamics/Data/CubeBlocks.xml index 29b1ded..ed9a5a6 100644 --- a/ThermalDynamics/Data/CubeBlocks.xml +++ b/ThermalDynamics/Data/CubeBlocks.xml @@ -9,13 +9,14 @@ + - + - + @@ -26,7 +27,7 @@ - + Reactor @@ -34,8 +35,9 @@ - - + + + @@ -45,7 +47,7 @@ - + @@ -54,12 +56,13 @@ - - + + + - + @@ -72,12 +75,13 @@ - - + + + - + @@ -90,12 +94,13 @@ - - + + + - + @@ -107,12 +112,13 @@ - - + + + - + @@ -124,12 +130,13 @@ - - + + + - + @@ -141,12 +148,13 @@ - - + + + - + @@ -158,12 +166,13 @@ - - + + + - + @@ -175,83 +184,73 @@ - - + + + - + + + - Conveyor + Thrust DefaultThermodynamics - - + + + - - + + - - - Conveyor - SmallShipConveyorHub - - - - - - - - - - - - - + - Conveyor - SmallBlockConveyorConverter + Thrust + LargeBlockLargeHydrogenThrustIndustrial - - + + + - - + + - + - ConveyorConnector - DefaultThermodynamics + Thrust + LargeBlockSmallHydrogenThrustIndustrial - - + + + - - + + @@ -260,74 +259,57 @@ - ConveyorConnector - ConveyorTubeCurvedMedium + Thrust + LargeBlockLargeHydrogenThrust - - + + + - - + + - - Thrust - DefaultThermodynamics + LargeBlockSmallHydrogenThrust - - + + + - - + + - + Thrust - LargeBlockLargeHydrogenThrustIndustrial - - - - - - - - - - - - - - - - - Thrust - LargeBlockSmallHydrogenThrustIndustrial + SmallBlockLargeHydrogenThrustIndustrial - - + + + - - + + @@ -337,15 +319,16 @@ Thrust - LargeBlockLargeHydrogenThrust + SmallBlockSmallHydrogenThrustIndustrial - - + + + - - + + @@ -355,53 +338,57 @@ Thrust - LargeBlockSmallHydrogenThrust + SmallBlockLargeHydrogenThrust - - + + + - - + + - - Thrust - SmallBlockLargeHydrogenThrustIndustrial + SmallBlockSmallHydrogenThrust - - + + + - - + + - + + + + - Thrust - SmallBlockSmallHydrogenThrustIndustrial + InteriorLight + SmallLight - - + + + - + @@ -410,16 +397,17 @@ - Thrust - SmallBlockLargeHydrogenThrust + CameraBlock + LargeCameraBlock - - + + + - + @@ -428,37 +416,32 @@ - Thrust - SmallBlockSmallHydrogenThrust + CubeBlock + LargeBlockArmorCorner2Tip - - + + + - - - - - - + - InteriorLight - DefaultThermodynamics + CubeBlock + LargeBlockArmorHalfSlopeCorner - - + + + - - diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Blocks/CoolantPump.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Blocks/CoolantPump.cs index 30c7247..c8b69d5 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Blocks/CoolantPump.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Blocks/CoolantPump.cs @@ -59,7 +59,7 @@ public override void Init(MyObjectBuilder_EntityBase objectBuilder) float mass = 200f; // c = Temp / (watt * meter) - float specificHeat = 1000f; + float specificHeat = 100f; C = 1 / (specificHeat * mass * Block.CubeGrid.GridSize); thermalMassInv = 1f / (specificHeat * mass); diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Definitions/ThermalCellDefinition.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Definitions/ThermalCellDefinition.cs index 1631919..bb1e1ea 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Definitions/ThermalCellDefinition.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Definitions/ThermalCellDefinition.cs @@ -13,6 +13,7 @@ namespace Thermodynamics public class ThermalCellDefinition { private static readonly MyStringId GroupId = MyStringId.GetOrCompute("ThermalBlockProperties"); + private static readonly MyStringId IgnoreId = MyStringId.GetOrCompute("Ignore"); private static readonly MyStringId ConductivityId = MyStringId.GetOrCompute("Conductivity"); private static readonly MyStringId SpecificHeatId = MyStringId.GetOrCompute("SpecificHeat"); private static readonly MyStringId EmissivityId = MyStringId.GetOrCompute("Emissivity"); @@ -22,12 +23,17 @@ public class ThermalCellDefinition private static readonly MyStringId CriticalTemperatureScalerId = MyStringId.GetOrCompute("CriticalTemperatureScaler"); private static readonly MyDefinitionId DefaultCubeBlockDefinitionId = new MyDefinitionId(typeof(MyObjectBuilder_EnvironmentDefinition), Settings.DefaultSubtypeId); + /// + /// The block type should be ignored + /// + [ProtoMember(1)] + public bool Ignore; /// /// Conductivity equation: watt / ( meter * Temp) /// For examples see https://www.engineeringtoolbox.com/thermal-conductivity-metals-d_858.html /// - [ProtoMember(1)] + [ProtoMember(5)] public float Conductivity; /// @@ -78,8 +84,11 @@ public static ThermalCellDefinition GetDefinition(MyDefinitionId defId) } } - double dvalue; + bool isTrue; + if (lookup.TryGetBool(defId, GroupId, IgnoreId, out isTrue)) + def.Ignore = isTrue; + double dvalue; if (lookup.TryGetDouble(defId, GroupId, ConductivityId, out dvalue)) def.Conductivity = (float)dvalue; diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs index 4e70e12..2b49f2e 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs @@ -77,7 +77,7 @@ public static Settings GetDefaults() EnableSolarHeat = false, EnableDamage = true, Frequency = 1, - SimulationSpeed = 10, + SimulationSpeed = 1, SolarEnergy = 1000f, EnvironmentalRaycastDistance = 5000f, VaccumeRadiationStrength = 0.05f, diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs index a4295df..2f36f23 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs @@ -53,18 +53,21 @@ public class ThermalCell private int[] ExposedSurfacesByDirection = new int[6]; //public List ExposedSurfaceDirections = new List(); - public ThermalCell(ThermalGrid g, IMySlimBlock b) + public ThermalCell(ThermalGrid g, IMySlimBlock b, ThermalCellDefinition def) { Grid = g; Block = b; Id = b.Position.Flatten(); - Definition = ThermalCellDefinition.GetDefinition(Block.BlockDefinition.Id); + Definition = def; //TODO: the listeners need to handle changes at the end //of the update cycle instead of whenever. SetupListeners(); Mass = Block.Mass; + + MyLog.Default.Info($"[{Settings.Name}] {Block.BlockDefinition.Id} -- mass: {Mass}"); +; Area = Block.CubeGrid.GridSize * Block.CubeGrid.GridSize; C = 1 / (Definition.SpecificHeat * Mass * Block.CubeGrid.GridSize); ThermalMassInv = 1f / (Definition.SpecificHeat * Mass); diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs index 382a8bb..f691a35 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs @@ -215,13 +215,17 @@ private void BlockAdded(IMySlimBlock b) return; } + ThermalCellDefinition def = ThermalCellDefinition.GetDefinition(b.BlockDefinition.Id); + if (def.Ignore) return; + AddBlockMapping(ref b); - ThermalCell cell = new ThermalCell(this, b); + ThermalCell cell = new ThermalCell(this, b, def); cell.AddAllNeighbors(); int index = Thermals.Allocate(); PositionToIndex.Add(cell.Id, index); Thermals.ItemArray[index] = cell; + } private void BlockRemoved(IMySlimBlock b) @@ -236,6 +240,10 @@ private void BlockRemoved(IMySlimBlock b) //MyLog.Default.Info($"[{Settings.Name}] [{Grid.EntityId}] Removed ({b.Position.Flatten()}) {b.Position}"); + // dont process ignored blocks + ThermalCellDefinition def = ThermalCellDefinition.GetDefinition(b.BlockDefinition.Id); + if (def.Ignore) return; + RemoveBlockMapping(ref b); int flat = b.Position.Flatten();