From 4d6aa08314da5aa375795c1c00c53c0555638c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=C3=AF=7E?= Date: Sat, 12 Mar 2022 22:27:15 +0100 Subject: [PATCH] Add AacFlState.PlayableEnables(...), PlayableDisables, and PlayableSets: - Add AacFlState.PlayableEnables(...) with 0-duration default overload. This function is exposed with the assumption that Playable Layer Control would often be used with a all-or-nothing weight. - Add AacFlState.PlayableDisables(...) with 0-duration default overload. - Add AacFlState.PlayableSets(...) to control everything about the behaviour. --- Framework/Editor/V0/AacFlStates.cs | 20 ++++++++++++++++++++ README.md | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/Framework/Editor/V0/AacFlStates.cs b/Framework/Editor/V0/AacFlStates.cs index 68a2703..ac0303a 100644 --- a/Framework/Editor/V0/AacFlStates.cs +++ b/Framework/Editor/V0/AacFlStates.cs @@ -508,6 +508,26 @@ namespace AnimatorAsCode.V0 return this; } + public AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds = 0f) + { + return PlayableSets(blendable, blendDurationSeconds, 1.0f); + } + + public AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds = 0f) + { + return PlayableSets(blendable, blendDurationSeconds, 0.0f); + } + + public AacFlState PlayableSets(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds, float weight) + { + var playable = State.AddStateMachineBehaviour(); + playable.layer = blendable; + playable.goalWeight = weight; + playable.blendDuration = blendDurationSeconds; + + return this; + } + public AacFlState MotionTime(AacFlFloatParameter floatParam) { State.timeParameterActive = true; diff --git a/README.md b/README.md index 2d51552..c58da27 100644 --- a/README.md +++ b/README.md @@ -701,6 +701,11 @@ foreach (var cancelWhenNotAllowed in new[] {auto, reverse, manual, custom, done} - `AacFlState TrackingSets(TrackingElement element, VRC_AnimatorTrackingControl.TrackingType trackingType)` /// Use an Animator Tracking Control to set the element to be the value of `trackingType`. Create an Animator Tracking Control state behaviour if it does not exist. - `AacFlState LocomotionEnabled()` /// Enable locomotion. Create an Animator Locomotion Control if it does not exist. - `AacFlState LocomotionDisabled()` /// Disable locomotion. Create an Animator Locomotion Control if it does not exist. +- `public AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 1, enabling it immediately. Create an Playable Layer Control no matter what. +- `public AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 0, disabling it immediately. Create an Playable Layer Control no matter what. +- `public AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 1, blending it over a duration, enabling it. Create an Playable Layer Control no matter what. +- `public AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 0, blending it over a duration, disabling it. Create an Playable Layer Control no matter what. +- `public AacFlState PlayableSets(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds, float weight)` /// Use a Playable Layer Control to set the playable layer weight to a specified value, blending it over a duration. Create an Playable Layer Control no matter what. # Clip (AacFlClip)