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


/// <summary>
/// Teleporting Ghosts to other players 
/// </summary>
public class GhostTeleport : MonoBehaviour
{
	//Players
	//Dictionary of UniqueKey(int), data 
	public IDictionary<int, Tuple<string, string, Vector3, GameObject>> MobList = new Dictionary<int, Tuple<string, string, Vector3, GameObject>>();

	public int Count = 0;
	private string NameOfObject;
	private string Status;
	private Vector3 Position;
	private GameObject mobGameObject;
	private PlayerManager playerManager;
	private PlayerSync playerSync;

	//Places
	public IDictionary<int, Tuple<string, Vector3, GameObject>> PlacesDict = new Dictionary<int, Tuple<string, Vector3, GameObject>>();

	public int PlacesCount = 0;
	private string NameOfPlace;
	private Vector3 PlacePosition;
	private GameObject placeGameObject;

	private void Start()
	{
		playerManager = PlayerManager.Instance;
		playerSync = GetComponent<PlayerSync>();
	}

	//Logic for teleporting to players
	//Dictionary of Key(int), object/mob name, status (alive/dead/ghost/none), postion(vector3), GameObject
	private void AddToDict()
	{
		var entry = new Tuple<string, string, Vector3, GameObject>(NameOfObject, Status, Position, mobGameObject);
		MobList.Add(Count, entry);
		Count += 1;
	}

	//Looks through all objects with PlayerScript and then finds their different values(name, status, position). Then calls AddToDict.
	public void FindData()
	{
		MobList.Clear();//Clears Dictionary so everytime button is pressed list is updated.
		Count = 0;
		var PlayerBodies = FindObjectsOfType(typeof(PlayerScript));

		if (PlayerBodies == null | PlayerBodies.Count() == 0)//If list of PlayerScripts is empty dont run rest of code.
		{
		}
		else
		{
			foreach (PlayerScript player in PlayerBodies)
			{
				//Gets Name of Player
				NameOfObject = player.name;

				if(NameOfObject.Length == 0)
				{
					NameOfObject = "Spectator";
				}

				//Gets Status of Player
				if (player.IsGhost)
				{
					Status = "(Ghost)";
				}
				else if(!player.IsGhost & player.playerHealth.IsDead)
				{
					Status = "(Dead)";
				}
				else if (!player.IsGhost)
				{
					Status = "(Alive)";
				}
				else
				{
					Status = "(Cant tell if Dead/Alive or Ghost)";
				}

				//Gets Position of Player
				var tile = player.gameObject.GetComponent<RegisterTile>();
				Position = tile.WorldPositionClient;

				//Gets gameobject
				mobGameObject = player.gameObject;

				AddToDict();// Adds to dictionary
			}
		}		
	}

	//Grabs data needed for teleport.
	public void DataForTeleport(int index)
	{
		var s4 = MobList[index].Item4;//Grabs gameobject from dictionary

		var s3 = s4.GetComponent<RegisterTile>().WorldPositionClient;// Finds current player you want to teleport to coords

		var playerPosition = playerSync.gameObject.GetComponent<RegisterTile>().WorldPositionClient;//Finds current player coords

		if (s3 != playerPosition)//Spam Prevention
		{
			PlayerManager.LocalPlayerScript.playerNetworkActions.CmdGhostPerformTeleport(s3);
		}
	}

	//Logic for Teleport to places:
	public void PlacesAddToDict()
	{
		var entry = new Tuple<string, Vector3, GameObject>(NameOfPlace, PlacePosition, placeGameObject);
		PlacesDict.Add(PlacesCount, entry);
		PlacesCount += 1;
	}

	public void PlacesFindData()
	{
		PlacesDict.Clear();
		PlacesCount = 0;

		var placeGameObjects = FindObjectsOfType(typeof(SpawnPoint));

		if (placeGameObjects == null | placeGameObjects.Count() == 0)//If list of SpawnPoints is empty dont run rest of code.
		{
		}
		else
		{
			foreach (SpawnPoint place in placeGameObjects)
			{
				NameOfPlace = place.name;

				if (NameOfPlace.Length == 0)
				{
					NameOfPlace = "Has No Name";
				}

				PlacePosition = place.transform.position;// Only way to get position of this object.

				placeGameObject = place.gameObject;

				PlacesAddToDict();
			}
		}
	}

	//Gets Places Data for teleport, is updated to latest coord.
	public void PlacesDataForTeleport(int index)
	{
		var gameobject = PlacesDict[index].Item3;
		var vector = gameobject.transform.position;//Gets current coords of object

		var playerPosition = playerSync.gameObject.GetComponent<RegisterTile>().WorldPositionClient;//Finds current player coords

		if (vector != playerPosition)//Spam Prevention
		{
			PlayerManager.LocalPlayerScript.playerNetworkActions.CmdGhostPerformTeleport(vector);
		}
	}<commit_msg>Update GhostTeleport.cs<commit_after>﻿using System.Collections;
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// Teleporting Ghosts to other players 
/// </summary>
public class GhostTeleport : MonoBehaviour
{
	//Players
	//Dictionary of UniqueKey(int), data 
	public IDictionary<int, Tuple<string, string, Vector3, GameObject>> MobList = new Dictionary<int, Tuple<string, string, Vector3, GameObject>>();

	public int Count = 0;
	private string NameOfObject;
	private string Status;
	private Vector3 Position;
	private GameObject mobGameObject;

	//Places
	public IDictionary<int, Tuple<string, Vector3, GameObject>> PlacesDict = new Dictionary<int, Tuple<string, Vector3, GameObject>>();

	public int PlacesCount = 0;
	private string NameOfPlace;
	private Vector3 PlacePosition;
	private GameObject placeGameObject;

	//Logic for teleporting to players
	//Dictionary of Key(int), object/mob name, status (alive/dead/ghost/none), postion(vector3), GameObject
	private void AddToDict()
	{
		var entry = new Tuple<string, string, Vector3, GameObject>(NameOfObject, Status, Position, mobGameObject);
		MobList.Add(Count, entry);
		Count += 1;
	}

	//Looks through all objects with PlayerScript and then finds their different values(name, status, position). Then calls AddToDict.
	public void FindData()
	{
		MobList.Clear();//Clears Dictionary so everytime button is pressed list is updated.
		Count = 0;
		var PlayerBodies = FindObjectsOfType(typeof(PlayerScript));

		if (PlayerBodies == null | PlayerBodies.Count() == 0)//If list of PlayerScripts is empty dont run rest of code.
		{
		}
		else
		{
			foreach (PlayerScript player in PlayerBodies)
			{
				//Gets Name of Player
				NameOfObject = player.name;

				if(NameOfObject.Length == 0)
				{
					NameOfObject = "Spectator";
				}

				//Gets Status of Player
				if (player.IsGhost)
				{
					Status = "(Ghost)";
				}
				else if(!player.IsGhost & player.playerHealth.IsDead)
				{
					Status = "(Dead)";
				}
				else if (!player.IsGhost)
				{
					Status = "(Alive)";
				}
				else
				{
					Status = "(Cant tell if Dead/Alive or Ghost)";
				}

				//Gets Position of Player
				var tile = player.gameObject.GetComponent<RegisterTile>();
				Position = tile.WorldPositionClient;

				//Gets gameobject
				mobGameObject = player.gameObject;

				AddToDict();// Adds to dictionary
			}
		}		
	}

	//Grabs data needed for teleport.
	public void DataForTeleport(int index)
	{
		var s4 = MobList[index].Item4;//Grabs gameobject from dictionary

		var s3 = s4.GetComponent<RegisterTile>().WorldPositionClient;// Finds current player you want to teleport to coords

		var playerPosition = PlayerManager.LocalPlayer.gameObject.GetComponent<RegisterTile>().WorldPositionClient;//Finds current player coords

		if (s3 != playerPosition)//Spam Prevention
		{
			PlayerManager.LocalPlayerScript.playerNetworkActions.CmdGhostPerformTeleport(s3);
		}
	}

	//Logic for Teleport to places:
	public void PlacesAddToDict()
	{
		var entry = new Tuple<string, Vector3, GameObject>(NameOfPlace, PlacePosition, placeGameObject);
		PlacesDict.Add(PlacesCount, entry);
		PlacesCount += 1;
	}

	public void PlacesFindData()
	{
		PlacesDict.Clear();
		PlacesCount = 0;

		var placeGameObjects = FindObjectsOfType(typeof(SpawnPoint));

		if (placeGameObjects == null | placeGameObjects.Count() == 0)//If list of SpawnPoints is empty dont run rest of code.
		{
		}
		else
		{
			foreach (SpawnPoint place in placeGameObjects)
			{
				NameOfPlace = place.name;

				if (NameOfPlace.Length == 0)
				{
					NameOfPlace = "Has No Name";
				}

				PlacePosition = place.transform.position;// Only way to get position of this object.

				placeGameObject = place.gameObject;

				PlacesAddToDict();
			}
		}
	}

	//Gets Places Data for teleport, is updated to latest coord.
	public void PlacesDataForTeleport(int index)
	{
		var gameobject = PlacesDict[index].Item3;
		var vector = gameobject.transform.position;//Gets current coords of object

		var playerPosition = PlayerManager.LocalPlayer.gameObject.GetComponent<RegisterTile>().WorldPositionClient;//Finds current player coords

		if (vector != playerPosition)//Spam Prevention
		{
			PlayerManager.LocalPlayerScript.playerNetworkActions.CmdGhostPerformTeleport(vector);
		}
	}
{'fraction_non_alphanumeric': 0.10358927760109041, 'fraction_numerical': 0.005906406179009541, 'mean_word_length': 3.867330016583748, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, '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': '2489496', 'n_tokens_mistral': 3130, 'n_tokens_neox': 2675, 'n_words': 744}