-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleAnimatedAnchoredDecoupler.cs
More file actions
37 lines (30 loc) · 1015 Bytes
/
Copy pathModuleAnimatedAnchoredDecoupler.cs
File metadata and controls
37 lines (30 loc) · 1015 Bytes
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
33
34
35
36
37
using System.Linq;
using AnimatedDecoupler;
using KspHelper.Actions;
using KspHelper.Events;
namespace AnimatedDecouplers
{
public class ModuleAnimatedAnchoredDecoupler : ModuleAnchoredDecoupler
{
//animation name from model
[KSPField]
public string AnimationName;
private DecoupleAnimator _animator;
public override void OnStart(StartState state)
{
base.OnStart(state);
if ((state & StartState.Flying) != StartState.Flying) return;
_animator = gameObject.AddComponent<DecoupleAnimator>();
_animator.Initialize(this.OnDecouple, AnimationName, s => part.FindModelAnimators(AnimationName).FirstOrDefault());
this.ReplaceEvent("Decouple", _animator.Execute);
this.ReplaceAction("DecoupleAction", _animator.Execute);
}
public override void OnActive()
{
if (staged)
{
_animator.Execute();
}
}
}
}