Exemple #1
0
    /**
     * Returns true if a heat source is under the block
     */

    private bool IsHeated()
    {
        if (!this.requiresHeat)
        {
            return(true);
        }

        World    world         = GameManager.Instance.World;
        Vector3i tileEntityPos = this.ToWorldPos();
        Vector3i posUnderTE    = CoordinateHelper.GetCoordinateBelow(tileEntityPos);

        // If TE is on very bottom of world this will prevent out of boundary shenanigans.
        if (tileEntityPos == posUnderTE)
        {
            return(false);
        }

        Dictionary <Vector3i, TileEntity> tileEntitiesUnderneath = CoordinateHelper.GetTileEntitiesInCoordinates(world, new List <Vector3i>()
        {
            posUnderTE
        }, TileEntityType.Workstation);

        if (tileEntitiesUnderneath.Count == 0)
        {
            return(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(true);
                        }
                    }
                }
            }
        }
        return(false);
    }
Exemple #2
0
    /**
     * Calculates the lookup coordinates.
     */

    public void CalculateLookupCoordinates()
    {
        this.poweredBlockCoords = new List <Vector3i>();
        this.heatedBlockCoords  = new List <Vector3i>();
        this.nearbyBlockCoords  = new List <Vector3i>();

        World    world         = GameManager.Instance.World;
        Vector3i tileEntityPos = this.ToWorldPos();

        this.poweredBlockCoords = CoordinateHelper.GetCoOrdinatesAround(tileEntityPos, true, 1, 1, 1);
        this.heatedBlockCoords.Add(CoordinateHelper.GetCoordinateBelow(tileEntityPos));
        this.nearbyBlockCoords = CoordinateHelper.GetCoOrdinatesAround(tileEntityPos, this.nearbyBlockRange);
    }