Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using KSP;
- namespace AnimatedDocking
- {
- public class ModuleAnimatedDocking : PartModule
- {
- [KSPField]
- public string animationName = "";
- private ModuleAnimateGeneric module;
- public override void OnStart(StartState state)
- {
- base.OnStart(state);
- foreach (ModuleAnimateGeneric m in base.part.FindModulesImplementing<ModuleAnimateGeneric>())
- {
- if (m.animationName == this.animationName)
- {
- this.module = m;
- break;
- }
- }
- if (this.module == null) return;
- GameEvents.onPartCouple.Add(this.onPartCouple);
- GameEvents.onPartUndock.Add(this.onPartUndock);
- }
- private void onPartCouple(GameEvents.FromToAction<Part, Part> action)
- {
- if (action.to == base.part)
- {
- module.Toggle();
- }
- }
- private void onPartUndock(Part part)
- {
- if (part = base.part)
- {
- this.module.Toggle();
- }
- }
- private void OnDestroy()
- {
- GameEvents.onPartCouple.Add(this.onPartCouple);
- GameEvents.onPartUndock.Remove(this.onPartUndock);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement