<commit_before>﻿using System.Collections.Generic;
using UnityEngine;
using Core.Editor.Attributes;


/// <summary>
/// Component which causes ONLY parent to rotate based on Directional orientation
/// It's mostly useful when you need colider to rotate with Directional (like Wall Protrusions)
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(Directional))]
public class DirectionalRotatesParent : MonoBehaviour
{
	[Tooltip("Direction that the children of the root of this prefab are facing in.")]
	[SerializeField, PrefabModeOnly]
	private OrientationEnum prefabChildrenOrientation = OrientationEnum.Down;

	[SerializeField, PrefabModeOnly]
	private bool forceChildrenOpposite;

	public OrientationEnum MappedOrientation
	{
		get { return prefabChildrenOrientation; }
	}

	private void Awake()
	{
		var directional = GetComponent<Directional>();
		directional.OnDirectionChange.AddListener(OnDirectionChanged);
	}

	private void OnDirectionChanged(Orientation newDir)
	{
		//rotate our sprite renderers based on the deviation from
		//the prefab sprite orientation
		var offset = Orientation.FromEnum(prefabChildrenOrientation).OffsetTo(newDir);
		transform.rotation = offset.Quaternion;

		if (forceChildrenOpposite)
		{
			foreach (Transform child in transform)
			{
				child.rotation = Quaternion.Euler(newDir.Vector);
			}
		}
	}

	//changes the rendered sprite in editor based on the value set in Directional
#if UNITY_EDITOR
	private void Update()
	{
		if (Application.isEditor && !Application.isPlaying)
		{
			var dir = GetComponent<Directional>().InitialOrientation;
			var offset = Orientation.FromEnum(prefabChildrenOrientation).OffsetTo(dir);

			transform.rotation = offset.Quaternion;

			if (forceChildrenOpposite)
			{
				foreach (Transform child in transform)
				{
					child.rotation = Quaternion.Euler(dir.Vector);
				}
			}
		}
	}
<commit_msg>Fixes pipe construction overriding the rotation to south. (#7438)<commit_after>﻿using System.Collections.Generic;
using UnityEngine;
using Core.Editor.Attributes;


/// <summary>
/// Component which causes ONLY parent to rotate based on Directional orientation
/// It's mostly useful when you need colider to rotate with Directional (like Wall Protrusions)
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(Directional))]
public class DirectionalRotatesParent : MonoBehaviour
{
	[Tooltip("Direction that the children of the root of this prefab are facing in.")]
	[SerializeField, PrefabModeOnly]
	private OrientationEnum prefabChildrenOrientation = OrientationEnum.Down;

	[SerializeField, PrefabModeOnly]
	private bool forceChildrenOpposite;

	public OrientationEnum MappedOrientation
	{
		get { return prefabChildrenOrientation; }
	}

	private void Awake()
	{
		var directional = GetComponent<Directional>();
		directional.OnDirectionChange.AddListener(OnDirectionChanged);
	}

	private void OnDirectionChanged(Orientation newDir)
	{
		//rotate our sprite renderers based on the deviation from
		//the prefab sprite orientation
		var offset = Orientation.FromEnum(prefabChildrenOrientation).OffsetTo(newDir);

		if (forceChildrenOpposite)
		{
			foreach (Transform child in transform)
			{
				child.localRotation = offset.Quaternion;
			}
		}
	}

	//changes the rendered sprite in editor based on the value set in Directional
#if UNITY_EDITOR
	private void Update()
	{
		if (Application.isEditor && !Application.isPlaying)
		{
			var dir = GetComponent<Directional>().InitialOrientation;
			var offset = Orientation.FromEnum(prefabChildrenOrientation).OffsetTo(dir);

			transform.rotation = offset.Quaternion;

			if (forceChildrenOpposite)
			{
				foreach (Transform child in transform)
				{
					child.rotation = Quaternion.Euler(dir.Vector);
				}
			}
		}
	}

{'fraction_non_alphanumeric': 0.08597285067873303, 'fraction_numerical': 0.001064679265371307, 'mean_word_length': 4.728658536585366, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5046434', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1041, 'n_words': 296}