<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using UnityEngine.Serialization;
using WebSocketSharp;

/// <summary>
///     ID card properties
/// </summary>
public class IDCard : NetworkBehaviour, IServerInventoryMove, IServerSpawn
{

	[Tooltip("Sprite to use when the card is a normal card")]
	[SerializeField]
	private Sprite standardSprite = null;

	[Tooltip("Sprite to use when the card is a captain's card")]
	[SerializeField]
	private Sprite captainSprite = null;

	[Tooltip("Sprite to use when the card is a command-tier card")]
	[SerializeField]
	private Sprite commandSprite = null;

	[Tooltip("This is used to place ID cards via map editor and then setting their initial access type")]
	[FormerlySerializedAs("ManuallyAddedAccess")]
	[SerializeField]
	private List<Access> manuallyAddedAccess = new List<Access>();

	[Tooltip("For cards added via map editor and set their initial IDCardType here. This will only work" +
	         "if there are entries in ManuallyAddedAccess list")]
	[FormerlySerializedAs("ManuallyAssignCardType")]
	[SerializeField]
	private IDCardType manuallyAssignCardType = IDCardType.standard;

	[Tooltip("If true, will initialize itself with the correct access list, name, job, etc...based on the" +
	         " first player whose inventory it is added to. Used for initial loadout.")]
	[SerializeField]
	private bool autoInitOnPickup = false;
	private bool initialized;


	public JobType JobType => jobType;
	public Occupation Occupation => OccupationList.Instance.Get(JobType);
	public string RegisteredName => registeredName;


	[SyncVar(hook = nameof(SyncIDCardType))]
	private IDCardType idCardType;

	[SyncVar(hook = nameof(SyncJobType))]
	private JobType jobType;

	[SyncVar(hook = nameof(SyncName))]
	private string registeredName;


	//The actual list of access allowed set via the server and synced to all clients
	private SyncListInt accessSyncList = new SyncListInt();

	//To switch the card sprites when the type changes
	private SpriteRenderer spriteRenderer;
	private Pickupable pickupable;

	private ItemAttributesV2 itemAttributes;

	private void Awake()
	{
		spriteRenderer = GetComponentInChildren<SpriteRenderer>();
		pickupable = GetComponent<Pickupable>();
		itemAttributes = GetComponent<ItemAttributesV2>();
	}

	public void OnSpawnServer(SpawnInfo info)
	{
		//This will add the access from ManuallyAddedAccess list
		if (manuallyAddedAccess.Count > 0)
		{
			ServerAddAccess(manuallyAddedAccess);
			SyncIDCardType(idCardType, manuallyAssignCardType);
		}
		initialized = false;
	}

	public void OnInventoryMoveServer(InventoryMove info)
	{
		if (!initialized && autoInitOnPickup)
		{
			//auto init if being added to a player's inventory
			if (info.ToPlayer != null)
			{<commit_msg>Players can now show their ID cards to other people around them by interacting with them.<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using UnityEngine.Serialization;
using WebSocketSharp;

/// <summary>
///     ID card properties
/// </summary>
public class IDCard : NetworkBehaviour, IServerInventoryMove, IServerSpawn, IInteractable<HandActivate>
{

	[Tooltip("Sprite to use when the card is a normal card")]
	[SerializeField]
	private Sprite standardSprite = null;

	[Tooltip("Sprite to use when the card is a captain's card")]
	[SerializeField]
	private Sprite captainSprite = null;

	[Tooltip("Sprite to use when the card is a command-tier card")]
	[SerializeField]
	private Sprite commandSprite = null;

	[Tooltip("This is used to place ID cards via map editor and then setting their initial access type")]
	[FormerlySerializedAs("ManuallyAddedAccess")]
	[SerializeField]
	private List<Access> manuallyAddedAccess = new List<Access>();

	[Tooltip("For cards added via map editor and set their initial IDCardType here. This will only work" +
	         "if there are entries in ManuallyAddedAccess list")]
	[FormerlySerializedAs("ManuallyAssignCardType")]
	[SerializeField]
	private IDCardType manuallyAssignCardType = IDCardType.standard;

	[Tooltip("If true, will initialize itself with the correct access list, name, job, etc...based on the" +
	         " first player whose inventory it is added to. Used for initial loadout.")]
	[SerializeField]
	private bool autoInitOnPickup = false;
	private bool initialized;


	public JobType JobType => jobType;
	public Occupation Occupation => OccupationList.Instance.Get(JobType);
	public string RegisteredName => registeredName;


	[SyncVar(hook = nameof(SyncIDCardType))]
	private IDCardType idCardType;

	[SyncVar(hook = nameof(SyncJobType))]
	private JobType jobType;

	[SyncVar(hook = nameof(SyncName))]
	private string registeredName;


	//The actual list of access allowed set via the server and synced to all clients
	private SyncListInt accessSyncList = new SyncListInt();

	//To switch the card sprites when the type changes
	private SpriteRenderer spriteRenderer;
	private Pickupable pickupable;

	private ItemAttributesV2 itemAttributes;

	private void Awake()
	{
		spriteRenderer = GetComponentInChildren<SpriteRenderer>();
		pickupable = GetComponent<Pickupable>();
		itemAttributes = GetComponent<ItemAttributesV2>();
	}

	public void OnSpawnServer(SpawnInfo info)
	{
		//This will add the access from ManuallyAddedAccess list
		if (manuallyAddedAccess.Count > 0)
		{
			ServerAddAccess(manuallyAddedAccess);
			SyncIDCardType(idCardType, manuallyAssignCardType);
		}
		initialized = false;
	}
	public void ServerPerformInteraction(HandActivate interaction)
	{
		Chat.AddActionMsgToChat(interaction.Performer,
			$"You show the {itemAttributes.ArticleName}",
			$"{interaction.Performer.ExpensiveName()} shows you: {itemAttributes.ArticleName}");
	}
	public void OnInventoryMoveServer(InventoryMove info)
	{
		if (!initialized && autoInitOnPickup)
		{
			//auto init if being added to a player's inventory
			if (info.ToPlayer != null)
			{
{'fraction_non_alphanumeric': 0.08558108558108558, 'fraction_numerical': 0.000999000999000999, 'mean_word_length': 5.148413510747186, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 26, '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': '5440027', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1721, 'n_words': 571}