Exemplo n.º 1
0
    /**
     * Checks whether nearby blocks are needed.
     */

    public bool HasNearbyBlocks()
    {
        if (!this.CanTick())
        {
            return(this.hasNearbyBlocks);
        }

        if (!this.requiresNearbyBlocks)
        {
            return(this.hasNearbyBlocks = true);
        }

        World world = GameManager.Instance.World;

        bool namesFound = true;
        bool tagsFound  = true;

        if (this.nearbyBlockNames.Count > 0)
        {
            namesFound = CoordinateHelper.EnoughBlocksInCoordinatesThatAre(world, this.nearbyBlockCoords, this.nearbyBlockNames, this.nearbyBlocksNeeded);
        }

        if (this.nearbyBlockTags.Count > 0)
        {
            tagsFound = CoordinateHelper.EnoughBlocksInCoordinatesThatHaveTags(world, this.nearbyBlockCoords, this.nearbyBlockTags, this.nearbyBlocksNeeded, this.nearbyBlockRequireAllTags);
        }

        return(this.hasNearbyBlocks = (tagsFound & namesFound));
    }
Exemplo n.º 2
0
    /**
     * Checks whether nearby blocks are needed.
     */

    public bool HasNearbyBlocks()
    {
        if (!this.CanTick())
        {
            return(this.hasNearbyBlocks);
        }

        if (!this.requiresNearbyBlocks)
        {
            return(this.hasNearbyBlocks = true);
        }

        World world = GameManager.Instance.World;

        bool namesFound = false;
        bool tagsFound  = false;

        if (this.nearbyBlockNames.Count > 0)
        {
            if (nearbyBlockNames.Count == 1)
            {
                if (this.nearbyBlockNames[0] == "")
                {
                    namesFound = true;
                    Log.Out("Name was empty.");
                }
            }
            if (!namesFound)
            {
                namesFound = CoordinateHelper.EnoughBlocksInCoordinatesThatAre(world, this.nearbyBlockCoords, this.nearbyBlockNames, this.nearbyBlocksNeeded);
                Log.Out("Names: " + namesFound.ToString());
            }
        }
        else
        {
            namesFound = true;
        }

        if (this.nearbyBlockTags.Count > 0)
        {
            if (nearbyBlockTags.Count == 1)
            {
                if (this.nearbyBlockTags[0] == "")
                {
                    tagsFound = true;
                    Log.Out("Tag was empty");
                }
            }
            if (!tagsFound)
            {
                tagsFound = CoordinateHelper.EnoughBlocksInCoordinatesThatHaveTags(world, this.nearbyBlockCoords, this.nearbyBlockTags, this.nearbyBlocksNeeded, this.nearbyBlockRequireAllTags);
                Log.Out("Tags: " + tagsFound.ToString());
            }
        }
        else
        {
            tagsFound = true;
        }

        Log.Out("Tags and name found? " + (tagsFound & namesFound).ToString());
        return(this.hasNearbyBlocks = (tagsFound & namesFound));
    }