Skip to content

Commit

Permalink
Add AacAccessorForExtensions:
Browse files Browse the repository at this point in the history
- Add static class AacAccessorForExtensions:
  - Provides methods for use by extension functions, exposing methods departing from normal fluent interface usage.
- Prepare to make methods marked "Not for public use" private starting from V1.2.0.
- Due to their active use in other packages, it is not immediately private.
  • Loading branch information
hai-vr committed Aug 19, 2024
1 parent d7d240a commit 705f25d
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/Aac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,39 @@ public AacFlLayer WithBlendingMode(AnimatorLayerBlendingMode blendingMode)
}
}

/// Provides methods for use by extension functions, exposing methods departing from normal fluent interface usage.
/// These methods are entering a staging phase as of V1.1.0. It is not recommended to use them.
public static class AacAccessorForExtensions
{
/// NOT FOR PUBLIC USE: This method is entering a staging phase as of V1.1.0. It is not recommended to use it.
public static AacConfiguration AccessConfiguration(AacFlBase aacBase)
{
return aacBase.AccessConfiguration();
}

/// NOT FOR PUBLIC USE: This method is entering a staging phase as of V1.1.0. It is not recommended to use it.
public static AacFlLayer AccessCreateLayer(AacFlBase aacBase, AnimatorController animator, string layerName)
{
return aacBase.AccessCreateLayer(animator, layerName);
}
}

public class AacFlBase
{
private readonly AacConfiguration _configuration;

/// NON-PUBLIC: Internal use only so that destructive workflow can access this. Maybe this can be improved
/// NOT FOR PUBLIC USE: Internal use only so that destructive workflow can access this. Maybe this can be improved
[Obsolete("This will be made private/internal in V1.2.0. Use AacAccessorForExtensions.AccessConfiguration(...) instead")]
public AacConfiguration InternalConfiguration()
{
return _configuration;
}

internal AacConfiguration AccessConfiguration()
{
return _configuration;
}

internal AacFlBase(AacConfiguration configuration)
{
_configuration = configuration;
Expand Down Expand Up @@ -550,16 +573,27 @@ public AacFlController NewAnimatorController(string name)
//---- ## Destructive workflow

/// Destructive workflow: Create a main layer for an arbitrary AnimatorController, clearing the previous one of the same system. You are not obligated to have a main layer.
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => DoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));

/// Destructive workflow: Create a supporting layer for an arbitrary AnimatorController, clearing the previous one of the same system and suffix. You can create multiple supporting layers with different suffixes, and you are not obligated to have a main layer to create a supporting layer.
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => DoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));

/// Destructive workflow: Clears the topmost layer of an arbitrary AnimatorController, and returns it.
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, controller.layers[0].name);
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => DoCreateLayer(controller, controller.layers[0].name);

/// NON-PUBLIC: Internal use only so that destructive workflow can access this. Maybe this can be improved
/// NOT FOR PUBLIC USE: Internal use only so that destructive workflow can access this. Maybe this can be improved
[Obsolete("This will be made private/internal in V1.2.0. Use AacAccessorForExtensions.CreateLayer(...) instead")]
public AacFlLayer InternalDoCreateLayer(AnimatorController animator, string layerName)
{
return DoCreateLayer(animator, layerName);
}

internal AacFlLayer AccessCreateLayer(AnimatorController animator, string layerName)
{
return DoCreateLayer(animator, layerName);
}

private AacFlLayer DoCreateLayer(AnimatorController animator, string layerName)
{
var ag = new AacAnimatorGenerator(animator, CreateEmptyClip().Clip, _configuration.DefaultsProvider, _configuration.AnimatorRoot);
var machine = ag.CreateOrClearLayerAtSameIndex(layerName, 1f);
Expand Down

0 comments on commit 705f25d

Please sign in to comment.