/** * Returns true if a heat source is under the block */ public bool IsHeated() { if (!this.CanTick()) { return(this.hasHeat); } if (!this.requiresHeat) { return(this.hasHeat = true); } World world = GameManager.Instance.World; // If TE is on very bottom of world this will prevent out of boundary shenanigans. if (this.ToWorldPos() == this.heatedBlockCoords[0]) { return(this.hasHeat = false); } Dictionary <Vector3i, TileEntity> tileEntitiesUnderneath = CoordinateHelper.GetTileEntitiesInCoordinatesWithType(world, this.heatedBlockCoords, TileEntityType.Workstation); if (tileEntitiesUnderneath.Count == 0) { return(this.hasHeat = false); } foreach (KeyValuePair <Vector3i, TileEntity> entry in tileEntitiesUnderneath) { TileEntityWorkstation otherTileEntity = entry.Value as TileEntityWorkstation; Vector3i otherTileEntityPos = entry.Key; foreach (string heatSource in this.heatSources) { if (!CoordinateHelper.BlockAtCoordinateIs(world, otherTileEntityPos, heatSource)) { continue; } // Checks that there is fuel being used for the workstation as well as if it's burning. foreach (ItemStack itemStack in otherTileEntity.Fuel) { if (itemStack != null & !itemStack.Equals(ItemStack.Empty.Clone())) { if (otherTileEntity.IsActive(world)) { return(this.hasHeat = true); } } } } } return(this.hasHeat = false); }
/** * Checks if block is powered. It is required to be next to a TileEntityPowered type of block in any cardinal direction. */ public bool IsPowered() { if (!this.CanTick()) { return(this.hasPower); } if (!this.requiresPower) { return(this.hasPower = true); } if (this.poweredBlockCoords.Count == 0) { return(this.hasPower = false); } World world = GameManager.Instance.World; Dictionary <Vector3i, TileEntity> tileEntitiesNearby = CoordinateHelper.GetTileEntitiesInCoordinatesWithType(world, this.poweredBlockCoords, TileEntityType.Powered); if (tileEntitiesNearby.Count == 0) { return(this.hasPower = false); } foreach (KeyValuePair <Vector3i, TileEntity> entry in tileEntitiesNearby) { TileEntityPowered otherTileEntity = entry.Value as TileEntityPowered; Vector3i otherTileEntityPos = entry.Key; foreach (string powerSource in this.powerSources) { string name = CoordinateHelper.GetBlockNameAtCoordinate(world, otherTileEntityPos); if (!CoordinateHelper.BlockAtCoordinateIs(world, otherTileEntityPos, powerSource)) { continue; } if (otherTileEntity.IsPowered) { return(this.hasPower = true); } } } return(this.hasPower = false); }