<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Lighting
{
	public class LightTile : MonoBehaviour
	{

		public SpriteRenderer thisSprite{ get; set; }

		private LightingTileManager tileManager;
		private bool transmitting = false;

		void Start()
		{
			thisSprite = GetComponentInChildren<SpriteRenderer>();
			tileManager = GetComponentInParent<LightingTileManager>();
		}

		//If this tile touches a light source then absorb the light and send to surrounds
		public void InjectLight(float brightness, int range)
		{
			if (!transmitting) {
				transmitting = true;
				float alpha = Mathf.Abs((100f - brightness) / 100f);
				if (range >= 0f) {
					
					var tempColor = thisSprite.color;
					tempColor.a = alpha;
					thisSprite.color = tempColor;
					StartCoroutine(PassTheLight(brightness, range));
				} else {
					transmitting = false;
				}
			}
		}

		//Pass the brightness of the light to neighbor tiles
		IEnumerator PassTheLight(float brightness, int range)
		{
			range--;
			Vector2 curPos = transform.position;
			//Check up first
			Vector2 checkPos = new Vector2(curPos.x, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check down 
			checkPos = new Vector2(curPos.x, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check left 
			checkPos = new Vector2(curPos.x - 1f, curPos.y);
			CheckNeighbor(checkPos, brightness, range);
			//Check right
			checkPos = new Vector2(curPos.x + 1f, curPos.y);
			CheckNeighbor(checkPos, brightness, range);
			//Check Up Right corner
			checkPos = new Vector2(curPos.x + 1f, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Up Left corner
			checkPos = new Vector2(curPos.x - 1f, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Bottom Left corner
			checkPos = new Vector2(curPos.x - 1f, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Bottom Right corner
			checkPos = new Vector2(curPos.x + 1f, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			yield return new WaitForEndOfFrame();
			transmitting = false;

		}<commit_msg>Fix: Altered coroutine for dispersion to stop tile being adjusted twice<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Lighting
{
	public class LightTile : MonoBehaviour
	{

		public SpriteRenderer thisSprite{ get; set; }

		private LightingTileManager tileManager;
		private bool transmitting = false;

		void Start()
		{
			thisSprite = GetComponentInChildren<SpriteRenderer>();
			tileManager = GetComponentInParent<LightingTileManager>();
		}

		//If this tile touches a light source then absorb the light and send to surrounds
		public void InjectLight(float brightness, int range)
		{
			if (!transmitting) {
				transmitting = true;
				float alpha = Mathf.Abs((100f - brightness) / 100f);
				if (range >= 0f) {
					
					var tempColor = thisSprite.color;
					tempColor.a = alpha;
					thisSprite.color = tempColor;
					StartCoroutine(PassTheLight(brightness, range));
				} else {
					transmitting = false;
				}
			}
		}

		//Pass the brightness of the light to neighbor tiles
		IEnumerator PassTheLight(float brightness, int range)
		{
			range--;
			Vector2 curPos = transform.position;
			//Check up first
			Vector2 checkPos = new Vector2(curPos.x, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check down 
			checkPos = new Vector2(curPos.x, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check left 
			checkPos = new Vector2(curPos.x - 1f, curPos.y);
			CheckNeighbor(checkPos, brightness, range);
			//Check right
			checkPos = new Vector2(curPos.x + 1f, curPos.y);
			CheckNeighbor(checkPos, brightness, range);
			//Check Up Right corner
			checkPos = new Vector2(curPos.x + 1f, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Up Left corner
			checkPos = new Vector2(curPos.x - 1f, curPos.y + 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Bottom Left corner
			checkPos = new Vector2(curPos.x - 1f, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			//Check Bottom Right corner
			checkPos = new Vector2(curPos.x + 1f, curPos.y - 1f);
			CheckNeighbor(checkPos, brightness, range);
			yield return new WaitForSeconds(0.1f);
			transmitting = false;

		}
{'fraction_non_alphanumeric': 0.1028778608656243, 'fraction_numerical': 0.013596193065941536, 'mean_word_length': 3.5225409836065573, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6942421', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1380, 'n_words': 396}