<commit_before>﻿using System;
using Microsoft.Xna.Framework;
using Citysim.Map.Tiles;

namespace Citysim.Map
{
    public class World
    {
        public int[,,] tiles; // array of tile IDs on map

        public int width;
        public int height;
        public const int depth = 16;
        
        public bool InBounds(double x, double y)
        {
            return (((x >= 0) && (x < width)) && ((y >= 0) && (y < height)));
        }

        public bool InBounds(Vector2 vector)
        {
            return InBounds(vector.X, vector.Y);
        }

        public bool RemoveTile(Vector3 position)
        {
            tiles[(int)position.X, (int)position.Y, (int)position.Z] = 0;

            return true;
        }

        public bool PlaceTile(int tileID, Vector3 position)
        {
            ITile tile = Citysim.instance.tileRegistry.GetTile(tileID);
            Point size = tile.GetTileSize();
            Vector3 position2 = new Vector3(position.X + size.X - 1, position.Y + size.Y - 1, 1);
            
            for (int width = (int)position.X; width <= position2.X; width++)
            {
                for (int height = (int)position.Y; height <= position2.Y; height++)
                {
                    tiles[width, height, (int)position.Z] = tileID;
                }
            }<commit_msg>Attempting to place tile ID 0 will simply call the RemoveTile method instead.<commit_after>﻿using System;
using Microsoft.Xna.Framework;
using Citysim.Map.Tiles;

namespace Citysim.Map
{
    public class World
    {
        public int[,,] tiles; // array of tile IDs on map

        public int width;
        public int height;
        public const int depth = 16;
        
        public bool InBounds(double x, double y)
        {
            return (((x >= 0) && (x < width)) && ((y >= 0) && (y < height)));
        }

        public bool InBounds(Vector2 vector)
        {
            return InBounds(vector.X, vector.Y);
        }

        public bool RemoveTile(Vector3 position)
        {
            tiles[(int)position.X, (int)position.Y, (int)position.Z] = 0;

            return true;
        }

        public bool PlaceTile(int tileID, Vector3 position)
        {
            if (tileID == 0)
                return RemoveTile(position);

            ITile tile = Citysim.instance.tileRegistry.GetTile(tileID);
            Point size = tile.GetTileSize();
            Vector3 position2 = new Vector3(position.X + size.X - 1, position.Y + size.Y - 1, 1);
            
            for (int width = (int)position.X; width <= position2.X; width++)
            {
                for (int height = (int)position.Y; height <= position2.Y; height++)
                {
                    tiles[width, height, (int)position.Z] = tileID;
                }
            }
{'fraction_non_alphanumeric': 0.1140819964349376, 'fraction_numerical': 0.012121212121212121, 'mean_word_length': 1.6347417840375587, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3351757', 'n_tokens_mistral': 819, 'n_tokens_neox': 780, 'n_words': 223}