Ejemplo n.º 1
0
    public static bool CheckBlueprint(Tile[,] Map, BaseBlueprint blueprint, SimpleCords location, int rotationToUse = 0)
    {
        int mapWidth  = Map.GetLength(0);
        int mapHeight = Map.GetLength(1);

        if (location.x + blueprint.NegWidth < 0)
        {
            return(false);
        }
        if (location.y + blueprint.NegHeight < 0)
        {
            return(false);
        }
        if (location.x + blueprint.PosWidth > mapWidth)
        {
            return(false);
        }
        if (location.y + blueprint.PosHeight > mapHeight)
        {
            return(false);
        }
        bool exist = true;

        List <MaterialOffset> offsets = blueprint.MaterialRequirements.RotateBy90Deg(rotationToUse);

        foreach (var item in offsets)
        {
            // skip over logic
            if (!exist)
            {
                continue;
            }
            // do we even have to check if there the materials match?
            if (Map.SaveGet(item.Offset.x + location.x, item.Offset.y + location.z).occupation != TileOccupation.Material)
            {
                exist = false;
            }
            else
            {
                if (Map.SaveGet(item.Offset.x + location.x, item.Offset.y + location.z).Material.Name != item.MaterialName)
                {
                    exist = false;
                }
            }
        }
        return(exist);
    }