Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Part extension methods to PartModules namespace
- Loading branch information
Showing
3 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Kethane.PartModules | ||
{ | ||
internal static class PartExtensions | ||
{ | ||
public static List<PartResource> GetConnectedResources(this Part part, String resourceName) | ||
{ | ||
var resourceDef = PartResourceLibrary.Instance.GetDefinition(resourceName); | ||
var resources = new List<PartResource>(); | ||
part.GetConnectedResources(resourceDef.id, resourceDef.resourceFlowMode, resources); | ||
return resources; | ||
} | ||
|
||
public static AnimationState[] SetUpAnimation(this Part part, string animationName) | ||
{ | ||
var states = new List<AnimationState>(); | ||
foreach (var animation in part.FindModelAnimators(animationName)) | ||
{ | ||
var animationState = animation[animationName]; | ||
animationState.speed = 0; | ||
animationState.enabled = true; | ||
animationState.wrapMode = WrapMode.ClampForever; | ||
animation.Blend(animationName); | ||
states.Add(animationState); | ||
} | ||
return states.ToArray(); | ||
} | ||
} | ||
} |