Skip to content

Commit

Permalink
Merge pull request #12 from kyubuns/feat_この際だから昔の記述は消してしまう
Browse files Browse the repository at this point in the history
feat: この際だから昔の記述は消してしまう
  • Loading branch information
kyubuns authored Jan 6, 2021
2 parents 3869168 + cbab6de commit 0327473
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 165 deletions.
24 changes: 2 additions & 22 deletions Assets/AnimeTask/Scripts/Anime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,12 @@ public static class Anime
{
public static IScheduler DefaultScheduler { get; set; } = new TimeScheduler();

public static UniTask Play<T>(IAnimator<T> animator, ITranslator<T> translator, CancellationToken cancellationToken = default)
{
return Play(animator, translator, DefaultScheduler, cancellationToken);
}

public static UniTask Play<T>(IAnimator<T> animator, IProgress<T> progress, CancellationToken cancellationToken = default)
{
return Play(animator, TranslateTo.Progress(progress), cancellationToken);
}

public static async UniTask Play<T>(IAnimator<T> animator, ITranslator<T> translator, IScheduler scheduler, CancellationToken cancellationToken = default)
public static async UniTask Play<T>(IAnimator<T> animator, ITranslator<T> translator, IScheduler scheduler = default, CancellationToken cancellationToken = default)
{
await PlayInternal(animator, translator, scheduler, cancellationToken);
}

public static UniTask Play<T>(IAnimator<T> animator, IProgress<T> progress, IScheduler scheduler, CancellationToken cancellationToken = default)
{
return Play(animator, TranslateTo.Progress(progress), scheduler, cancellationToken);
}

public static UniTask PlayTo<T>(IAnimatorWithStartValue<T> animator, IValueTranslator<T> translator, CancellationToken cancellationToken = default)
{
return PlayTo(animator, translator, DefaultScheduler, cancellationToken);
}

public static async UniTask PlayTo<T>(IAnimatorWithStartValue<T> animatorWithStartValue, IValueTranslator<T> translator, IScheduler scheduler, CancellationToken cancellationToken = default)
public static async UniTask PlayTo<T>(IAnimatorWithStartValue<T> animatorWithStartValue, IValueTranslator<T> translator, IScheduler scheduler = default, CancellationToken cancellationToken = default)
{
var animator = animatorWithStartValue.Start(translator.Current);
await PlayInternal(animator, translator, scheduler, cancellationToken);
Expand Down
3 changes: 1 addition & 2 deletions Assets/AnimeTask/Scripts/Translator/ActionTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace AnimeTask
{
public static partial class TranslateTo
{
public static ActionTranslator<T> Action<T>(Action<T> action) => new ActionTranslator<T>(action);
public static UniTask ToAction<T>(this IAnimator<T> animator, Action<T> action, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, Action(action), scheduler, cancellationToken);
public static UniTask ToAction<T>(this IAnimator<T> animator, Action<T> action, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new ActionTranslator<T>(action), scheduler, cancellationToken);
}

public class ActionTranslator<T> : ITranslator<T>
Expand Down
34 changes: 14 additions & 20 deletions Assets/AnimeTask/Scripts/Translator/MaterialTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@ namespace AnimeTask
{
public static partial class TranslateTo
{
public static MaterialPropertyColorTranslator MaterialPropertyColor(Renderer renderer, int nameID) => new MaterialPropertyColorTranslator(renderer, nameID);
public static MaterialPropertyColorTranslator MaterialPropertyColor(Renderer renderer, string name) => new MaterialPropertyColorTranslator(renderer, name);
public static UniTask ToMaterialPropertyColor(this IAnimator<Color> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyColor(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimator<Color> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyColor(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimatorWithStartValue<Color> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyColor(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimatorWithStartValue<Color> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyColor(renderer, name), scheduler, cancellationToken);

public static MaterialPropertyFloatTranslator MaterialPropertyFloat(Renderer renderer, int nameID) => new MaterialPropertyFloatTranslator(renderer, nameID);
public static MaterialPropertyFloatTranslator MaterialPropertyFloat(Renderer renderer, string name) => new MaterialPropertyFloatTranslator(renderer, name);
public static UniTask ToMaterialPropertyFloat(this IAnimator<float> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyFloat(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimator<float> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyFloat(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimatorWithStartValue<float> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyFloat(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimatorWithStartValue<float> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyFloat(renderer, name), scheduler, cancellationToken);

public static MaterialPropertyIntTranslator MaterialPropertyInt(Renderer renderer, int nameID) => new MaterialPropertyIntTranslator(renderer, nameID);
public static MaterialPropertyIntTranslator MaterialPropertyInt(Renderer renderer, string name) => new MaterialPropertyIntTranslator(renderer, name);
public static UniTask ToMaterialPropertyInt(this IAnimator<int> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyInt(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimator<int> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, MaterialPropertyInt(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimatorWithStartValue<int> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyInt(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimatorWithStartValue<int> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, MaterialPropertyInt(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimator<Color> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyColorTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimator<Color> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyColorTranslator(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimatorWithStartValue<Color> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyColorTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyColor(this IAnimatorWithStartValue<Color> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyColorTranslator(renderer, name), scheduler, cancellationToken);

public static UniTask ToMaterialPropertyFloat(this IAnimator<float> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyFloatTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimator<float> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyFloatTranslator(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimatorWithStartValue<float> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyFloatTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyFloat(this IAnimatorWithStartValue<float> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyFloatTranslator(renderer, name), scheduler, cancellationToken);

public static UniTask ToMaterialPropertyInt(this IAnimator<int> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyIntTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimator<int> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new MaterialPropertyIntTranslator(renderer, name), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimatorWithStartValue<int> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyIntTranslator(renderer, nameID), scheduler, cancellationToken);
public static UniTask ToMaterialPropertyInt(this IAnimatorWithStartValue<int> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.PlayTo(animator, new MaterialPropertyIntTranslator(renderer, name), scheduler, cancellationToken);
}

public class MaterialPropertyColorTranslator : IValueTranslator<Color>
Expand Down
3 changes: 1 addition & 2 deletions Assets/AnimeTask/Scripts/Translator/ProgressTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace AnimeTask
{
public static partial class TranslateTo
{
public static ProgressTranslator<T> Progress<T>(IProgress<T> progress) => new ProgressTranslator<T>(progress);
public static UniTask ToProgress<T>(this IAnimator<T> animator, IProgress<T> progress, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, Progress(progress), scheduler, cancellationToken);
public static UniTask ToProgress<T>(this IAnimator<T> animator, IProgress<T> progress, CancellationToken cancellationToken = default, IScheduler scheduler = default) => Anime.Play(animator, new ProgressTranslator<T>(progress), scheduler, cancellationToken);
}

public class ProgressTranslator<T> : ITranslator<T>
Expand Down
Loading

0 comments on commit 0327473

Please sign in to comment.