Beispiel #1
0
        public void UpdateFSM()
        {
            if (!hasAnimation)
            {
                return;
            }

            switch (visorState)
            {
            case KerbalEVA.VisorStates.Raising:
                if (visorAnimation[module.visorAnimationName].normalizedTime >= 1.0f)
                {
                    visorAnimation.Stop(module.visorAnimationName);
                    visorState = KerbalEVA.VisorStates.Raised;
                }
                break;

            case KerbalEVA.VisorStates.Lowering:
                if (visorAnimation[module.visorAnimationName].normalizedTime <= 0.0f)
                {
                    visorAnimation.Stop(module.visorAnimationName);
                    visorState = KerbalEVA.VisorStates.Lowered;
                }
                break;
            }
        }
Beispiel #2
0
        private void LowerVisor()
        {
            if (!hasAnimation)
            {
                return;
            }

            visorAnimation[module.visorAnimationName].speed          = -1f;
            visorAnimation[module.visorAnimationName].normalizedTime = 1.0f;
            visorAnimation[module.visorAnimationName].enabled        = true;
            visorAnimation.Play(module.visorAnimationName);
            visorState = KerbalEVA.VisorStates.Lowering;
        }
Beispiel #3
0
        public void Start()
        {
            if (!string.IsNullOrEmpty(module.visorAnimationName))
            {
                List <Animation> animators = transform.GetComponentsInChildren <Animation>().ToList();
                foreach (Animation animation in animators)
                {
                    AnimationClip animationClip = animation.GetClip(module.visorAnimationName);

                    if (animationClip == null)
                    {
                        continue;
                    }

                    visorAnimation = animation;
                    break;
                }

                if (visorAnimation == null)
                {
                    Debug.LogWarning($"[{DISPLAYNAME}] Could not find visor animation '{visorAnimation}' on first pass");
                    visorAnimation = kerbal.part.FindModelAnimator(module.visorAnimationName);
                }

                if (visorAnimation == null)
                {
                    Debug.LogWarning($"[{DISPLAYNAME}] Could not find visor animation '{visorAnimation}' on second pass");
                    hasAnimation = false;
                }
                else
                {
                    hasAnimation = true;
                    visorState   = kerbal.VisorState;
                    StartFSM();
                }
            }
            else
            {
                hasAnimation = false;
            }

            LightComponent lightComponent = gameObject.AddComponent <LightComponent>();

            lightComponent.kerbal   = this.kerbal;
            lightComponent.lights   = lights;
            lightComponent.isHelmet = true;

            GameEvents.OnVisorLowering.Add(OnVisorLowering);
            GameEvents.OnVisorRaising.Add(OnVisorRaised);
            GameEvents.OnHelmetChanged.Add(OnHelmetChanged);
        }