<commit_before>﻿using System;
using DG.Tweening;
using Silphid.Extensions;
using Silphid.Sequencit;
using UniRx;
using UnityEngine;
using Sequence = Silphid.Sequencit.Sequence;

namespace Silphid.Showzup
{
    public class CrossfadeTransition : Transition
    {
        public Ease Ease { get; set; } = Ease.InOutCubic;
        public bool FadeOutSource { get; set; } = true;
        public bool FadeInTarget { get; set; } = true;
        public bool SourceAboveTarget { get; set; } = true;
        public bool IsSequential { get; set; } = false;

        public override void Prepare(GameObject sourceContainer, GameObject targetContainer, Direction direction)
        {
            targetContainer.GetComponent<CanvasGroup>().alpha = FadeInTarget ? 0 : 1;

            if (sourceContainer == null)
                return;
            
            if (SourceAboveTarget)
                sourceContainer.transform.SetAsLastSibling();
            else
                sourceContainer.transform.SetAsFirstSibling();
        }

        public override IObservable<Unit> Perform(GameObject sourceContainer, GameObject targetContainer, Direction direction, float duration)
        {
            var sequencer = IsSequential ? (IObservableSequencer) Sequence.Create() : Parallel.Create();
            PerformTransition(sourceContainer, targetContainer, duration, sequencer);
            return sequencer;
        }

        private void PerformTransition(GameObject sourceContainer, GameObject targetContainer, float duration, ISequencer sequencer)
        {
            if (sourceContainer != null && FadeOutSource)
                sourceContainer.GetComponent<CanvasGroup>()
                    .DOFadeOut(duration)
                    .SetEase(Ease)
                    .SetAutoKill()
                    .In(sequencer);<commit_msg>Fixed duration when in Sequential to keep the same transition length with Parallel.<commit_after>﻿using System;
using DG.Tweening;
using Silphid.Extensions;
using Silphid.Sequencit;
using UniRx;
using UnityEngine;
using Sequence = Silphid.Sequencit.Sequence;

namespace Silphid.Showzup
{
    public class CrossfadeTransition : Transition
    {
        public Ease Ease { get; set; } = Ease.InOutCubic;
        public bool FadeOutSource { get; set; } = true;
        public bool FadeInTarget { get; set; } = true;
        public bool SourceAboveTarget { get; set; } = true;
        public bool IsSequential { get; set; } = false;

        public override void Prepare(GameObject sourceContainer, GameObject targetContainer, Direction direction)
        {
            targetContainer.GetComponent<CanvasGroup>().alpha = FadeInTarget ? 0 : 1;

            if (sourceContainer == null)
                return;
            
            if (SourceAboveTarget)
                sourceContainer.transform.SetAsLastSibling();
            else
                sourceContainer.transform.SetAsFirstSibling();
        }

        public override IObservable<Unit> Perform(GameObject sourceContainer, GameObject targetContainer, Direction direction, float duration)
        {
            var sequencer = IsSequential ? (IObservableSequencer) Sequence.Create() : Parallel.Create();
            PerformTransition(sourceContainer, targetContainer, IsSequential ? duration *  0.5f : duration, sequencer);
            return sequencer;
        }

        private void PerformTransition(GameObject sourceContainer, GameObject targetContainer, float duration, ISequencer sequencer)
        {
            if (sourceContainer != null && FadeOutSource)
                sourceContainer.GetComponent<CanvasGroup>()
                    .DOFadeOut(duration)
                    .SetEase(Ease)
                    .SetAutoKill()
                    .In(sequencer);
{'fraction_non_alphanumeric': 0.0773524720893142, 'fraction_numerical': 0.001594896331738437, 'mean_word_length': 2.4333941605839415, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6816234', 'n_tokens_mistral': 979, 'n_tokens_neox': 940, 'n_words': 244}