-
Notifications
You must be signed in to change notification settings - Fork 32
/
PartExtensions.cs
32 lines (30 loc) · 1.14 KB
/
PartExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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();
}
}
}