public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length == 0) { shell.WriteError("Not enough arguments."); return; } var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var mixture = new GasMixture(Atmospherics.CellVolume) { Temperature = Atmospherics.T20C }; mixture.AdjustMoles(Gas.Oxygen, Atmospherics.OxygenMolesStandard); mixture.AdjustMoles(Gas.Nitrogen, Atmospherics.NitrogenMolesStandard); foreach (var gid in args) { // I like offering detailed error messages, that's why I don't use one of the extension methods. if (!int.TryParse(gid, out var i) || i <= 0) { shell.WriteError($"Invalid grid ID \"{gid}\"."); continue; } if (!mapManager.TryGetGrid(new GridId(i), out var grid)) { shell.WriteError($"Grid \"{i}\" doesn't exist."); continue; } if (!entityManager.TryGetEntity(grid.GridEntityId, out var entity)) { shell.WriteError($"Grid entity for grid \"{i}\" doesn't exist."); continue; } var gridAtmosphere = new GridAtmosphereComponent() { Owner = entity }; // Inject dependencies manually or a NRE will eat your face. IoCManager.InjectDependencies(gridAtmosphere); entityManager.ComponentManager.AddComponent(entity, gridAtmosphere, true); gridAtmosphere.RepopulateTiles(); foreach (var tile in gridAtmosphere) { tile.Air = (GasMixture)mixture.Clone(); tile.Air.Volume = gridAtmosphere.GetVolumeForCells(1); tile.Invalidate(); } } }
private void NeighborConductWithSource(TileAtmosphere other) { if (BlocksAir) { if (!other.BlocksAir) { other.TemperatureShareOpenToSolid(this); } else { other.TemperatureShareMutualSolid(this, ThermalConductivity); } TemperatureExpose(null, _temperature, _gridAtmosphereComponent.GetVolumeForCells(1)); return; } if (!other.BlocksAir) { other.Air.TemperatureShare(Air, Atmospherics.WindowHeatTransferCoefficient); } else { TemperatureShareOpenToSolid(other); } _gridAtmosphereComponent.AddActiveTile(this); }