<commit_before>
using System.Collections;
using UnityEngine;

/// <summary>
/// Message informing a client they are now observing / not observing
/// a particular InteractableStorage (and/or any children of it) and can show/hide the popup in the UI.
/// </summary>
public class ObserveInteractableStorageMessage : ServerMessage
{
	public uint Storage;
	public bool Observed;

	public override void Process()
	{
		LoadNetworkObject(Storage);

		var storageObject = NetworkObject;
		if (storageObject == null)
		{
			Logger.LogWarningFormat("Client could not find observed storage with id {0}", Category.Inventory, Storage);
			return;
		}

		var itemStorage = storageObject.GetComponent<ItemStorage>();
		if (Observed)
		{
			UIManager.StorageHandler.OpenStorageUI(itemStorage);
		}
		else
		{
			if (UIManager.StorageHandler.CurrentOpenStorage == itemStorage)
			{
				UIManager.StorageHandler.CloseStorageUI();
			}
			//hide any children they might be viewing as well
			foreach (var slot in itemStorage.GetItemSlotTree())
			{
				if (slot.ItemObject == UIManager.StorageHandler.CurrentOpenStorage?.gameObject)
				{
					UIManager.StorageHandler.CloseStorageUI();
				}
			}
		}

	}

	/// <summary>
	/// Informs the recipient that they can now show/hide the UI popup for observing a particular
	/// storage or any children.
	/// </summary>
	/// <param name="recipient"></param>
	/// <param name="storage"></param>
	/// <param name="observed">true indicates they should show the popup, false indicates it should be hidden</param><commit_msg>Fixes the rustle sound being played multiple times when dropping empty backpacks, making a annoyingly loud sound.<commit_after>
using System.Collections;
using UnityEngine;

/// <summary>
/// Message informing a client they are now observing / not observing
/// a particular InteractableStorage (and/or any children of it) and can show/hide the popup in the UI.
/// </summary>
public class ObserveInteractableStorageMessage : ServerMessage
{
	public uint Storage;
	public bool Observed;

	public override void Process()
	{
		LoadNetworkObject(Storage);

		var storageObject = NetworkObject;
		if (storageObject == null)
		{
			Logger.LogWarningFormat("Client could not find observed storage with id {0}", Category.Inventory, Storage);
			return;
		}

		var itemStorage = storageObject.GetComponent<ItemStorage>();
		if (Observed)
		{
			UIManager.StorageHandler.OpenStorageUI(itemStorage);
		}
		else
		{
			if (UIManager.StorageHandler.CurrentOpenStorage == itemStorage)
			{
				UIManager.StorageHandler.CloseStorageUI();
			}
			//hide any children they might be viewing as well
			foreach (var slot in itemStorage.GetItemSlotTree())
			{
				if (slot.ItemObject && slot.ItemObject == UIManager.StorageHandler.CurrentOpenStorage?.gameObject)
				{
					UIManager.StorageHandler.CloseStorageUI();
				}
			}
		}

	}

	/// <summary>
	/// Informs the recipient that they can now show/hide the UI popup for observing a particular
	/// storage or any children.
	/// </summary>
	/// <param name="recipient"></param>
	/// <param name="storage"></param>
	/// <param name="observed">true indicates they should show the popup, false indicates it should be hidden</param>
{'fraction_non_alphanumeric': 0.10695353913314624, 'fraction_numerical': 0.0006236357966947302, 'mean_word_length': 3.82406015037594, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4943448', 'n_tokens_mistral': 996, 'n_tokens_neox': 891, 'n_words': 284}