private IEnumerator ACCELERATE_enum() { if (is_Grounded && !is_Acceleration_pressed_one_time) { #region ACT forward_speed *= 2f; animator.animation.Play("accelerate"); // -----------------------------------------> animation_for_accelerationBtn.Play(animation_for_accelerationBtn.name); is_Acceleration_pressed_one_time = true; #endregion yield return(new WaitForSeconds(action_duration)); #region DEACT foreach (var item in acceleration_UI) { item.SetActive(false); } forward_speed /= 2f; animator.animation.Stop("accelerate"); // -----------------------------------------> animation_for_accelerationBtn.Stop(animation_for_accelerationBtn.name); is_Acceleration_pressed_one_time = false; #endregion } }
public void Update() { var currentTime = Time.time; foreach (var entry in entries.ToArray()) { if (entry.StartTime <= currentTime) { entries.Remove(entry); if (entry.OnlyIfNotPlaying) { if (animation.IsPlaying(entry.Name)) { continue; } } if (entry.BlendWeight > 0.0f) { animation.Blend(entry.Name, entry.BlendWeight); } else { animation.Play(entry.Name, entry.PlayMode); } animationStartedCallback(entry.Name, animation.GetClip(entry.Name).length); } } }
public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent<DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent<DragManager>(); DragManager.SetPart(part); } anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) s.layer = i++; } animState.normalizedSpeed = 0; if (engaged) { animState.normalizedTime = Drag / 100; spoilerState = ModuleLandingGear.GearStates.DEPLOYED; } else { animState.normalizedTime = 0; spoilerState = ModuleLandingGear.GearStates.RETRACTED; } anim.Play(AnimationName); }
// ============================================================================================================ public void Start() { ani = GetComponent<Animation>(); chara = GetComponent<Chara2_Base>(); // init idle ani if (string.IsNullOrEmpty(idleClip)) idleClip = null; // set to null for faster if() checks if (idleClip != null) { ani[idleClip].speed = idlePlaySpeed; ani[idleClip].wrapMode = WrapMode.Loop; ani.Play(idleClip); } // sorted so that lower speedDetect is checked first movementAnimations.Sort((a, b) => { return a.maxSpeedDetect.CompareTo(b.maxSpeedDetect); }); // init movement anis for (int i = 0; i < movementAnimations.Count; i++) { if (!string.IsNullOrEmpty(movementAnimations[i].clipName)) { ani[movementAnimations[i].clipName].speed = movementAnimations[i].playSpeed; ani[movementAnimations[i].clipName].wrapMode = WrapMode.Loop; } else movementAnimations[i] = null; // set to null for faster if() checks } // init antics _anticsOn = (UniRPGGlobal.Instance.state != UniRPGGlobal.State.InMainMenu); anticsTimer = anticsWaitTimeMin; }
public void PlayAnimation(Animation animation) { if (_animation == null) { _animation = GetComponentInChildren <UnityEngine.Animation>(); } _animation.Play(Enum.GetName(typeof(Animation), animation).ToLower()); }
public AnimationState PlayAnim(AnimGroup group, AnimIndex anim, PlayMode playMode) { var animState = LoadAnim(group, anim); _curAnimGroup = AnimGroup = group; _curAnim = AnimIndex = anim; _anim.Play(animState.name, playMode); return(animState); }
private Task PlayClip(AnimationClip clip) { if (clip == null) { return(Task.CompletedTask); } m_Animation.clip = clip; m_Animation.Play(); return(Task.Delay(TimeSpan.FromSeconds(clip.length))); }
static public int Play(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 4) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 3, out a1); UnityEngine.PlayMode a2; checkEnum(l, 4, out a2); var ret = self.Play(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, "Play__PlayMode", argc, 2, typeof(UnityEngine.PlayMode))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.PlayMode a1; checkEnum(l, 3, out a1); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, "Play__String", argc, 2, typeof(string))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 3, out a1); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); var ret = self.Play(); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
private IEnumerator <IYieldInstruction> PlayAnimations() { mAvatarAnimationComponent.Stop(); while (true) { if (!mAvatarAnimationComponent.isPlaying) { AnimationClip clip = mAnimations[mRand.Next(0, mAnimations.Count - 1)]; mAvatarAnimationComponent.Play(clip.name); } yield return(new YieldUntilNextFrame()); } }
static public int Play(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); var ret = self.Play(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int Play(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.Animation.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); bool o = obj.Play(); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.PlayMode>(L, 2)) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); UnityEngine.PlayMode arg0 = (UnityEngine.PlayMode)ToLua.ToObject(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2)) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.ToString(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 3) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.CheckString(L, 2); UnityEngine.PlayMode arg1 = (UnityEngine.PlayMode)ToLua.CheckObject(L, 3, typeof(UnityEngine.PlayMode)); bool o = obj.Play(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.Play")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static IEnumerator WaitForPlay(this UnityEngine.Animation anim, string clipName = null, bool forward = true, System.Action endAction = null) { float length = anim.Play(clipName, forward); if (length > 0) { yield return(new WaitForSeconds(length)); } if (endAction != null) { endAction(); } }
static public int Play__PlayMode(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.PlayMode a1; checkEnum(l, 2, out a1); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int Play__String(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int Play(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Animation))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); bool o = obj.Play(); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(UnityEngine.PlayMode))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); UnityEngine.PlayMode arg0 = (UnityEngine.PlayMode)ToLua.ToObject(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 3 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string), typeof(UnityEngine.PlayMode))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UnityEngine.PlayMode arg1 = (UnityEngine.PlayMode)ToLua.ToObject(L, 3); bool o = obj.Play(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.tolua_error(L, "invalid arguments to method: UnityEngine.Animation.Play")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int Play(IntPtr l) { try{ int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.Boolean ret = self.Play(); pushValue(l, ret); return(1); } else if (matchType(l, argc, 2, typeof(UnityEngine.PlayMode))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.PlayMode a1; checkEnum(l, 2, out a1); System.Boolean ret = self.Play(a1); pushValue(l, ret); return(1); } else if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.PlayMode a2; checkEnum(l, 3, out a2); System.Boolean ret = self.Play(a1, a2); pushValue(l, ret); return(1); } else if (matchType(l, argc, 2, typeof(string))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean ret = self.Play(a1); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int Play(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); bool o = obj.Play(); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <uint>(L, 2)) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); UnityEngine.PlayMode arg0 = (UnityEngine.PlayMode)LuaDLL.lua_tonumber(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2)) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.ToString(L, 2); bool o = obj.Play(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 3) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.CheckString(L, 2); UnityEngine.PlayMode arg1 = (UnityEngine.PlayMode)LuaDLL.luaL_checknumber(L, 3); bool o = obj.Play(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.Play")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void PlayAnimation(AnimationClip clip) { graphicRaycaster.enabled = false; if (animator.isPlaying) { animator.Stop(); } animator.RemoveClip(animator.clip); animator.clip = clip; animator.AddClip(clip, clip.name); animator.Play(); Debug.Log("Playing " + clip.name, clip); StopAnimationEndAwaiter(); _animationWaitCoroutine = StartCoroutine(WaitForAnimationEnd(clip)); }
public static int Play_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); bool ret = obj.Play(); long ret_ptr = FCLibHelper.fc_get_return_ptr(L); FCLibHelper.fc_set_value_bool(ret_ptr, ret); } catch (Exception e) { Debug.LogException(e); } return(0); }
protected override void Compute() { status = Status.Compute; step = Config.Zero; if (animation.clip == null) { return; } interval = animation.clip.length; animation.Play(); status = Status.Transition; }
static int QPYX_Play_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 1) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); bool QPYX_o_YXQP = QPYX_obj_YXQP.Play(); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <string>(L_YXQP, 2)) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); string QPYX_arg0_YXQP = ToLua.ToString(L_YXQP, 2); bool QPYX_o_YXQP = QPYX_obj_YXQP.Play(QPYX_arg0_YXQP); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <UnityEngine.PlayMode>(L_YXQP, 2)) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); UnityEngine.PlayMode QPYX_arg0_YXQP = (UnityEngine.PlayMode)ToLua.ToObject(L_YXQP, 2); bool QPYX_o_YXQP = QPYX_obj_YXQP.Play(QPYX_arg0_YXQP); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 3) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); UnityEngine.PlayMode QPYX_arg1_YXQP = (UnityEngine.PlayMode)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.PlayMode)); bool QPYX_o_YXQP = QPYX_obj_YXQP.Play(QPYX_arg0_YXQP, QPYX_arg1_YXQP); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Animation.Play")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } this.part.force_activate(); anim = part.FindModelAnimators (animName).FirstOrDefault (); if (anim != null) { anim [animName].layer = 1; if (!IsEnabled) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } }
public static int Play2_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); string arg0 = FCLibHelper.fc_get_string_a(L, 0); UnityEngine.PlayMode arg1 = (UnityEngine.PlayMode)(FCLibHelper.fc_get_int(L, 1)); bool ret = obj.Play(arg0, arg1); long ret_ptr = FCLibHelper.fc_get_return_ptr(L); FCLibHelper.fc_set_value_bool(ret_ptr, ret); } catch (Exception e) { Debug.LogException(e); } return(0); }
public void PlayAnimation(AnimType animType) { var clip = GetClip(animType); var speed = GetSpeed(animType); if (!clip) { return; } if (anim.isPlaying) { anim.Stop(); } SetClipToStart(animType); SetAnimationSpeed(clip, speed); anim.Play(clip.name); }
public static void Sample(this UnityEngine.Animation anim, float time, string clipName = null, bool normalized = false) { AnimationState animState = anim.GetAnimState(clipName); if (animState != null) { anim.Play(animState.name); if (normalized) { animState.normalizedTime = time; } else { animState.time = time; } animState.enabled = true; anim.Sample(); animState.enabled = false; } }
/// <summary> /// 断点续播,clip正在播放时候,调用当前播放方向的倒播,会从当前点倒着播回去 /// </summary> /// <returns>The with breakpoint.</returns> /// <param name="anim">Animation.</param> /// <param name="clipName">Clip name.</param> /// <param name="forward">If set to <c>true</c> forward.</param> public static float PlayWithBreakpoint(this UnityEngine.Animation anim, string clipName = null, bool forward = true) { AnimationState animState = anim.GetAnimState(clipName); if (animState != null) { animState.time = animState.length * (Mathf.Min(1f, animState.normalizedTime)); if (forward) { animState.speed = Mathf.Abs(animState.speed); } else { animState.speed = -Mathf.Abs(animState.speed); } anim.Play(animState.name); return(animState.length); } return(0); }
public override void ShowData(DataProvider data) { base.ShowData(data); EventManager.Instance.AddEventListener <PlayerLoadArchiveEvent>(OnPlayerLoadArchive); if (isShowLogo) { if (anim != null) { anim.playAutomatically = false; } if (logoAnimCtrl != null) { logoAnimCtrl.Show(() => { if (anim != null) { anim.Play(); } }); } } }
public static float Play(this UnityEngine.Animation anim, string clipName = null, bool forward = true) { AnimationState animState = anim.GetAnimState(clipName); if (animState != null) { if (forward) { animState.time = 0; animState.speed = Mathf.Abs(animState.speed); } else { animState.time = animState.length; animState.speed = -Mathf.Abs(animState.speed); } anim.Play(animState.name); return(animState.length); } return(0); }
public override void OnStart(PartModule.StartState state) { Actions["ActivateTransmitterAction"].guiName = Events["ActivateTransmitter"].guiName = String.Format("Activate Transmitter"); Actions["DeactivateTransmitterAction"].guiName = Events["DeactivateTransmitter"].guiName = String.Format("Deactivate Transmitter"); if (state == StartState.Editor) { return; } this.part.force_activate(); anim = part.FindModelAnimators (animName).FirstOrDefault (); if (anim != null) { anim [animName].layer = 1; if (!IsEnabled) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } List<Part> vesselparts = vessel.parts; for (int i = 0; i < vesselparts.Count; ++i) { Part cPart = vesselparts.ElementAt(i); PartModuleList pml = cPart.Modules; for (int j = 0; j < pml.Count; ++j) { var curSolarPan = pml.GetModule(j) as ModuleDeployableSolarPanel; if (curSolarPan != null) { //curSolarPan.powerCurve = PluginHelper.getSatFloatCurve(); } } } }
public static void PlayAnimation(this GameObject go, string name = null, State state = State.Play) { UnityEngine.Animation animation = go.GetComponentInChildren <UnityEngine.Animation>(); if (animation != null) { if (string.IsNullOrEmpty(name)) { name = animation.clip.name; } switch (state) { case State.Play: { if (animation.isPlaying && animation.IsPlaying(name)) { } else { animation.Play(name); } } break; case State.Pause: case State.Stop: { if (animation.isPlaying && animation.IsPlaying(name)) { animation.Stop(); } } break; } } }
public VariableAnimationSet(ConfigNode node, InternalProp thisProp) { part = thisProp.part; if (!node.HasData) { throw new ArgumentException("No data?!"); } comp = RasterPropMonitorComputer.Instantiate(thisProp); string[] tokens = { }; if (node.HasValue("scale")) { tokens = node.GetValue("scale").Split(','); } if (tokens.Length != 2) { throw new ArgumentException("Could not parse 'scale' parameter."); } if (node.HasValue("variableName")) { string variableName; variableName = node.GetValue("variableName").Trim(); scaleEnds[2] = new VariableOrNumber(variableName, this); } else if (node.HasValue("stateMethod")) { Func<bool> stateFunction = (Func<bool>)comp.GetMethod(node.GetValue("stateMethod").Trim(), thisProp, typeof(Func<bool>)); if (stateFunction != null) { scaleEnds[2] = new VariableOrNumber(stateFunction, this); } else { throw new ArgumentException("Unrecognized stateMethod"); } } else { throw new ArgumentException("Missing variable name."); } scaleEnds[0] = new VariableOrNumber(tokens[0], this); scaleEnds[1] = new VariableOrNumber(tokens[1], this); // That takes care of the scale, now what to do about that scale: if (node.HasValue("reverse")) { if (!bool.TryParse(node.GetValue("reverse"), out reverse)) { throw new ArgumentException("So is 'reverse' true or false?"); } } if (node.HasValue("animationName")) { animationName = node.GetValue("animationName"); if (node.HasValue("animationSpeed")) { animationSpeed = float.Parse(node.GetValue("animationSpeed")); if (reverse) { animationSpeed = -animationSpeed; } } else { animationSpeed = 0.0f; } Animation[] anims = node.HasValue("animateExterior") ? thisProp.part.FindModelAnimators(animationName) : thisProp.FindModelAnimators(animationName); if (anims.Length > 0) { onAnim = anims[0]; onAnim.enabled = true; onAnim[animationName].speed = 0; onAnim[animationName].normalizedTime = reverse ? 1f : 0f; looping = node.HasValue("loopingAnimation"); if (looping) { onAnim[animationName].wrapMode = WrapMode.Loop; onAnim.wrapMode = WrapMode.Loop; onAnim[animationName].speed = animationSpeed; mode = Mode.LoopingAnimation; } else { onAnim[animationName].wrapMode = WrapMode.Once; mode = Mode.Animation; } onAnim.Play(); alwaysActive = node.HasValue("animateExterior"); } else { throw new ArgumentException("Animation could not be found."); } if (node.HasValue("stopAnimationName")) { stopAnimationName = node.GetValue("stopAnimationName"); anims = node.HasValue("animateExterior") ? thisProp.part.FindModelAnimators(stopAnimationName) : thisProp.FindModelAnimators(stopAnimationName); if (anims.Length > 0) { offAnim = anims[0]; offAnim.enabled = true; offAnim[stopAnimationName].speed = 0; offAnim[stopAnimationName].normalizedTime = reverse ? 1f : 0f; if (looping) { offAnim[stopAnimationName].wrapMode = WrapMode.Loop; offAnim.wrapMode = WrapMode.Loop; offAnim[stopAnimationName].speed = animationSpeed; mode = Mode.LoopingAnimation; } else { offAnim[stopAnimationName].wrapMode = WrapMode.Once; mode = Mode.Animation; } } } } else if (node.HasValue("activeColor") && node.HasValue("passiveColor") && node.HasValue("coloredObject")) { if (node.HasValue("colorName")) colorName = node.GetValue("colorName"); passiveColor = ConfigNode.ParseColor32(node.GetValue("passiveColor")); activeColor = ConfigNode.ParseColor32(node.GetValue("activeColor")); colorShiftRenderer = thisProp.FindModelComponent<Renderer>(node.GetValue("coloredObject")); colorShiftRenderer.material.SetColor(colorName, reverse ? activeColor : passiveColor); mode = Mode.Color; } else if (node.HasValue("controlledTransform") && node.HasValue("localRotationStart") && node.HasValue("localRotationEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialRotation = controlledTransform.localRotation; if (node.HasValue("longPath")) { longPath = true; vectorStart = ConfigNode.ParseVector3(node.GetValue("localRotationStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localRotationEnd")); } else { rotationStart = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationStart"))); rotationEnd = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationEnd"))); } mode = Mode.Rotation; } else if (node.HasValue("controlledTransform") && node.HasValue("localTranslationStart") && node.HasValue("localTranslationEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialPosition = controlledTransform.localPosition; vectorStart = ConfigNode.ParseVector3(node.GetValue("localTranslationStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localTranslationEnd")); mode = Mode.Translation; } else if (node.HasValue("controlledTransform") && node.HasValue("localScaleStart") && node.HasValue("localScaleEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialScale = controlledTransform.localScale; vectorStart = ConfigNode.ParseVector3(node.GetValue("localScaleStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localScaleEnd")); mode = Mode.Scale; } else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureShiftStart") && node.HasValue("textureShiftEnd")) { affectedMaterial = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()).renderer.material; textureLayer = node.GetValue("textureLayers"); textureShiftStart = ConfigNode.ParseVector2(node.GetValue("textureShiftStart")); textureShiftEnd = ConfigNode.ParseVector2(node.GetValue("textureShiftEnd")); mode = Mode.TextureShift; } else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureScaleStart") && node.HasValue("textureScaleEnd")) { affectedMaterial = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()).renderer.material; textureLayer = node.GetValue("textureLayers"); textureScaleStart = ConfigNode.ParseVector2(node.GetValue("textureScaleStart")); textureScaleEnd = ConfigNode.ParseVector2(node.GetValue("textureScaleEnd")); mode = Mode.TextureScale; } else { throw new ArgumentException("Cannot initiate any of the possible action modes."); } if (node.HasValue("threshold")) { threshold = ConfigNode.ParseVector2(node.GetValue("threshold")); } resourceAmount = 0.0f; if (threshold != Vector2.zero) { thresholdMode = true; float min = Mathf.Min(threshold.x, threshold.y); float max = Mathf.Max(threshold.x, threshold.y); threshold.x = min; threshold.y = max; if (node.HasValue("flashingDelay")) { flashingDelay = double.Parse(node.GetValue("flashingDelay")); } if (node.HasValue("alarmSound")) { alarmSoundVolume = 0.5f; if (node.HasValue("alarmSoundVolume")) alarmSoundVolume = float.Parse(node.GetValue("alarmSoundVolume")); audioOutput = JUtil.SetupIVASound(thisProp, node.GetValue("alarmSound"), alarmSoundVolume, false); if (node.HasValue("alarmMustPlayOnce")) { if (!bool.TryParse(node.GetValue("alarmMustPlayOnce"), out alarmMustPlayOnce)) throw new ArgumentException("So is 'alarmMustPlayOnce' true or false?"); } if (node.HasValue("alarmShutdownButton")) SmarterButton.CreateButton(thisProp, node.GetValue("alarmShutdownButton"), AlarmShutdown); if (node.HasValue("alarmSoundLooping")) { if (!bool.TryParse(node.GetValue("alarmSoundLooping"), out alarmSoundLooping)) throw new ArgumentException("So is 'alarmSoundLooping' true or false?"); audioOutput.audio.loop = alarmSoundLooping; } } if (node.HasValue("resourceAmount")) { resourceAmount = float.Parse(node.GetValue("resourceAmount")); } TurnOff(); } }
private void thawCryopodWindow(int seatIndx, float speed) { setCryopodWindowOpaque(seatIndx); string windowname = ""; if (isPartAnimated) windowname = "Animated-Cryopod-" + (seatIndx + 1) + "-Window"; else windowname = "Cryopod-" + (seatIndx + 1) + "-Window"; _windowAnimation = part.internalModel.FindModelComponent<Animation>(windowname); Animation _extwindowAnimation = null; if (isPodExternal) { _extwindowAnimation = part.FindModelComponent<Animation>(windowname); Utilities.SetInternalDepthMask(part, false, "External_Window_Occluder"); //Set window occluder off } if (_windowAnimation == null) { Utilities.Log_Debug("Why can't I find the window animation?"); } else { _windowAnimation["CryopodWindowOpen"].speed = speed; _windowAnimation.Play("CryopodWindowOpen"); } if (isPodExternal && _extwindowAnimation != null) { _extwindowAnimation["CryopodWindowOpen"].speed = speed; _extwindowAnimation.Play("CryopodWindowOpen"); } }
//only called for animated internal parts private void openCryopod(int seatIndx, float speed) { string podname = "Animated-Cryopod-" + (seatIndx + 1); try { _animation = part.internalModel.FindModelComponent<Animation>(podname); if (_animation != null) { if (cryopodstateclosed[seatIndx]) { _animation["Open"].speed = speed; _animation.Play("Open"); cryopodstateclosed[seatIndx] = false; savecryopodstatepersistent(); } } else Utilities.Log_Debug("animation not found"); } catch (Exception ex) { Debug.Log("Unable to find animation in internal model for this part called " + podname); Debug.Log("Err: " + ex); } }
static public int Play(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); var ret = self.Play(); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, argc, 2, typeof(UnityEngine.PlayMode))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.PlayMode a1; a1 = (UnityEngine.PlayMode)LuaDLL.luaL_checkinteger(l, 2); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, argc, 2, typeof(string))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.Play(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.PlayMode a2; a2 = (UnityEngine.PlayMode)LuaDLL.luaL_checkinteger(l, 3); var ret = self.Play(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function Play to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } generators = vessel.FindPartModulesImplementing<FNGenerator>(); receivers = vessel.FindPartModulesImplementing<MicrowavePowerReceiver>(); panels = vessel.FindPartModulesImplementing<ModuleDeployableSolarPanel>(); if (part.FindModulesImplementing<MicrowavePowerReceiver>().Count == 1) { part_receiver = part.FindModulesImplementing<MicrowavePowerReceiver>().First(); has_receiver = true; } anim = part.FindModelAnimators(animName).FirstOrDefault(); if (anim != null) { anim[animName].layer = 1; if (!IsEnabled) { anim[animName].normalizedTime = 1f; anim[animName].speed = -1f; } else { anim[animName].normalizedTime = 0f; anim[animName].speed = 1f; } anim.Play(); } this.part.force_activate(); }
private void thawCryopodWindow(int seatIndx, float speed) { setCryopodWindowOpaque(seatIndx); string windowname = "Animated-Cryopod-" + (seatIndx + 1).ToString() + "-Window"; _windowAnimation = this.part.internalModel.FindModelComponent<Animation>(windowname); if (_windowAnimation == null) { this.Log_Debug("Why can't I find the window animation?"); } else { _windowAnimation["CryopodWindowOpen"].speed = speed; _windowAnimation.Play("CryopodWindowOpen"); } }
//----------------methods----------------- /** * Called at the start. Initialize animation and state of this module */ public override void OnStart(PartModule.StartState state) { base.OnStart(state); part.CheckTransferDialog(); isInternalPacked = true; //get the deploy animation deployAnim = part.FindModelAnimators(animationName).FirstOrDefault(); //Only initialize when an animation is available if (deployAnim != null) { // Run Only on first launch if (!hasBeenInitialized) { if (part.protoModuleCrew.Count() > crewCapcityRetracted) { nextIsReverse = true; animationTime = 0.999f; deployAnim[animationName].normalizedTime = 1f; } else { nextIsReverse = false; animationTime = 0f; deployAnim[animationName].normalizedTime = 0f; } hasBeenInitialized = true; } if (part.protoModuleCrew.Count() > crewCapcityRetracted) { animationTime = 0.999f; deployAnim[animationName].speed = 1f; } else if (nextIsReverse) { if (animationTime == 0f) { animationTime = 1f; } if (animationTime == 1f) { status = "Deployed"; part.CrewCapacity = crewCapacityDeployed; } else { status = "Deploying.."; part.CrewCapacity = crewCapacityDeployed; } deployAnim[animationName].speed = 1f; } else { if (animationTime == 0f) { status = "Retracted"; } else { status = "Retracting.."; } this.part.CrewCapacity = crewCapcityRetracted; deployAnim[animationName].speed = -1f; } // Set up animation state according to persistent values deployAnim[animationName].layer = layer; deployAnim[animationName].normalizedTime = animationTime; deployAnim.Play(animationName); // Settings for the GUI if (nextIsReverse) { Events["toggleAnimation"].guiName = endEventGUIName; } else { Events["toggleAnimation"].guiName = startEventGUIName; } Events["toggleAnimation"].guiActiveEditor = availableInEditor; Events["toggleAnimation"].guiActiveUnfocused = availableInEVA; Events["toggleAnimation"].guiActive = availableInVessel; Events["toggleAnimation"].unfocusedRange = EVArange; } // When the animation can not be found deactivate it in the GUI else { Events["toggleAnimation"].guiActiveEditor = false; Events["toggleAnimation"].guiActive = false; Events["toggleAnimation"].guiActiveUnfocused = false; Debug.Log("[KPBS] Deploy animation not found: " + animationName); } }
private void PlayLoopAnimation(Animation StartAnimation, string startAnimationName, int speed, bool instant) { if (startAnimationName != "") { // //print(StartAnimation[startAnimationName].time.ToString() + " " + loopPoint.ToString()); if (StartAnimation[startAnimationName].time >= StartAnimation[startAnimationName].length || StartAnimation.isPlaying == false) { StartAnimation[startAnimationName].time = loopPoint; ////print(StartAnimation[startAnimationName].time.ToString() + " " + loopPoint.ToString()); if (instant) StartAnimation[startAnimationName].speed = 999999 * speed; StartAnimation[startAnimationName].speed = speed; StartAnimation[startAnimationName].wrapMode = WrapMode.Default; StartAnimation.Play(startAnimationName); } } }
/** * <summary>Initialises and plays a legacy AnimationClip on an Animation component, starting from a set point.</summary> * <param name = "_animation">The Animation component</param> * <param name = "layer">The layer to play the animation on</param> * <param name = "clip">The AnimatonClip to play</param> * <param name = "blendMode">The animation's AnimationBlendMode</param> * <param name = "wrapMode">The animation's WrapMode</param> * <param name = "fadeTime">The transition time to the new animation</param> * <param name = "mixingBone">The transform to set as the animation's mixing transform</param> * <param name = "normalisedFrame">How far along the timeline the animation should start from (0 to 1)</param> */ public static void PlayAnimClipFrame(Animation _animation, int layer, AnimationClip clip, AnimationBlendMode blendMode, WrapMode wrapMode, float fadeTime, Transform mixingBone, float normalisedFrame) { if (clip != null) { AddAnimClip (_animation, layer, clip, blendMode, wrapMode, mixingBone); _animation [clip.name].normalizedTime = normalisedFrame; _animation [clip.name].speed *= 1f; _animation.Play (clip.name); CleanUnusedClips (_animation); } }
public override void OnStart(PartModule.StartState state) { Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = String.Format("Deploy Radiator"); Actions["RetractRadiatorAction"].guiName = Events["RetractRadiator"].guiName = String.Format("Retract Radiator"); Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator"); if (state == StartState.Editor) { return; } this.part.force_activate(); anim = part.FindModelAnimators (animName).FirstOrDefault (); //orig_emissive_colour = part.renderer.material.GetTexture (emissive_property_name); if (anim != null) { anim [animName].layer = 1; if (!IsEnabled) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } pivot = part.FindModelTransform("suntransform"); original_eulers = pivot.transform.localEulerAngles; if (!isupgraded) { radiatorType = originalName; } else { radiatorType = upgradedName; radiatorTemp = upgradedRadiatorTemp; } radiatorTempStr = radiatorTemp + "K"; }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) return; generators = vessel.FindPartModulesImplementing<FNGenerator>(); receivers = vessel.FindPartModulesImplementing<MicrowavePowerReceiver>(); panels = vessel.FindPartModulesImplementing<ModuleDeployableSolarPanel>(); if (part.FindModulesImplementing<MicrowavePowerReceiver>().Count == 1) { part_receiver = part.FindModulesImplementing<MicrowavePowerReceiver>().First(); has_receiver = true; } anim = part.FindModelAnimators(animName).FirstOrDefault(); if (anim != null) { anim[animName].layer = 1; if (!IsEnabled) { anim[animName].normalizedTime = 1f; anim[animName].speed = -1f; } else { anim[animName].normalizedTime = 0f; anim[animName].speed = 1f; } anim.Play(); } this.part.force_activate(); // Debug.Log("[KSPI] - MicrowavePowerTransmitter - Looking for externalPowerSources"); // foreach (Part vesselpart in vessel.Parts) // { // if (vesselpart.partName == "reactor-25") // { // externalPowerSources.Add(new ExternalPowerSourePartModule() { Name = "reactor-25", Power = 2 }); // Debug.Log("[KSPI] - MicrowavePowerTransmitter - found " + vesselpart.partInfo.title); // } //} }
public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } ConfigNode config = PluginHelper.getPluginSaveFile (); if (config.HasNode ("DATA_PACKET")) { Events ["ReceivePacket"].active = true; } else { Events ["ReceivePacket"].active = false; } part.force_activate(); anim = part.FindModelAnimators (animName1).FirstOrDefault (); anim2 = part.FindModelAnimators (animName2).FirstOrDefault (); if (anim != null && anim2 != null) { anim [animName1].layer = 1; anim2 [animName2].layer = 1; if (IsEnabled) { anim [animName1].normalizedTime = 0f; anim [animName1].speed = -1f; anim2 [animName2].normalizedTime = 0f; anim2 [animName2].speed = -1f; } else { anim [animName1].normalizedTime = 1f; anim [animName1].speed = 1f; anim2 [animName2].normalizedTime = 1f; anim2 [animName2].speed = 1f; } anim.Play (); anim2.Play (); } if (IsEnabled && last_active_time != 0) { float global_rate_multipliers = 1; crew_capacity_ratio = ((float)part.protoModuleCrew.Count) / ((float)part.CrewCapacity); global_rate_multipliers = global_rate_multipliers * crew_capacity_ratio; if (active_mode == 0) { // Science persistence double now = Planetarium.GetUniversalTime (); double time_diff = now - last_active_time; float altitude_multiplier = (float)(vessel.altitude / (vessel.mainBody.Radius)); altitude_multiplier = Math.Max (altitude_multiplier, 1); float stupidity = 0; foreach (ProtoCrewMember proto_crew_member in part.protoModuleCrew) { stupidity += proto_crew_member.stupidity; } stupidity = 1.5f - stupidity / 2.0f; double science_to_add = baseScienceRate * time_diff / 86400 * electrical_power_ratio * stupidity * global_rate_multipliers * PluginHelper.getScienceMultiplier (vessel.mainBody.flightGlobalsIndex,vessel.LandedOrSplashed) / ((float)Math.Sqrt (altitude_multiplier)); part.RequestResource ("Science", -science_to_add); } else if (active_mode == 2) { // Antimatter persistence double now = Planetarium.GetUniversalTime (); double time_diff = now - last_active_time; List<PartResource> partresources = new List<PartResource>(); part.GetConnectedResources(PartResourceLibrary.Instance.GetDefinition("Antimatter").id, partresources); float currentAntimatter_missing = 0; foreach (PartResource partresource in partresources) { currentAntimatter_missing += (float)(partresource.maxAmount-partresource.amount); } float total_electrical_power_provided = electrical_power_ratio * (baseAMFPowerConsumption + basePowerConsumption)*1E6f; float antimatter_mass = total_electrical_power_provided/AlcubierreDrive.warpspeed/AlcubierreDrive.warpspeed*1E6f/20000.0f; float antimatter_peristence_to_add = (float) -Math.Min (currentAntimatter_missing, antimatter_mass * time_diff); part.RequestResource("Antimatter", antimatter_peristence_to_add); } } }
private void ExportMeshAnimation() { AnimationClip[] animationClips = exportParams.AnimationClips; string[] animationClipNames = exportParams.AnimationNames; GameObject instanceObj = Instantiate(fbx) as GameObject; UnityEngine.Animation animation = instanceObj.GetComponentInChildren <UnityEngine.Animation>(); SkinnedMeshRenderer[] skinnedMeshRenders = instanceObj.GetComponentsInChildren <SkinnedMeshRenderer>(); int subMeshLength = skinnedMeshRenders.Length; Mesh[] subMeshArr = new Mesh[subMeshLength]; for (int i = 0; i < subMeshLength; i++) { subMeshArr[i] = skinnedMeshRenders[i].sharedMesh; } float interval = 1.0f / exportParams.FrameRate; if (File.Exists(exportParams.OutputFilePath)) { File.Delete(exportParams.OutputFilePath); } ExportMeshAnimationData meshAnimationData = ScriptableObject.CreateInstance <ExportMeshAnimationData>(); meshAnimationData.GenerateNormal = exportParams.GenerateNormal; meshAnimationData.SubMeshLength = subMeshLength; meshAnimationData.Fps = exportParams.FrameRate; meshAnimationData.SubMeshData = new ExportMeshAnimationData.AnimationSubMeshData[subMeshLength]; for (int i = 0; i < subMeshLength; i++) { meshAnimationData.SubMeshData[i].ClipDatas = new ExportMeshAnimationData.AnimationClipData[animationClips.Length]; meshAnimationData.SubMeshData[i].FrameRate = exportParams.FrameRate; for (int j = 0; j < animationClips.Length; j++) { AnimationClip clip = animationClips[j]; if (clip == null) { return; } animation.AddClip(clip, animationClipNames[j]); animation.clip = clip; AnimationState state = animation[animationClipNames[j]]; state.enabled = true; state.weight = 1; List <float> frameTimes = GetFrameTimes(clip.length, interval); meshAnimationData.SubMeshData[i].ClipDatas[j].FrameDatas = new ExportMeshAnimationData.AnimationFrameData[frameTimes.Count]; meshAnimationData.SubMeshData[i].ClipDatas[j].ClipName = animationClipNames[j]; for (int k = 0; k < frameTimes.Count; k++) { state.time = frameTimes[k]; animation.Play(); animation.Sample(); Matrix4x4 matrix4X4 = skinnedMeshRenders[i].transform.localToWorldMatrix; Mesh backMesh = BakeFrameAfterMatrixTransform(skinnedMeshRenders[i], matrix4X4); meshAnimationData.SubMeshData[i].ClipDatas[j].FrameDatas[k].Vertexs = backMesh.vertices; backMesh.Clear(); DestroyImmediate(backMesh); animation.Stop(); } } meshAnimationData.SubMeshData[i].UVs = subMeshArr[i].uv; meshAnimationData.SubMeshData[i].Triangles = subMeshArr[i].triangles; } AssetDatabase.CreateAsset(meshAnimationData, GetAssetPath(exportParams.OutputFilePath) + fbx.name + ".asset"); AssetDatabase.Refresh(); }
private void PlayStartAnimation(Animation StartAnimation, string startAnimationName, int speed, bool instant) { if (startAnimationName != "") { if (speed < 0) { StartAnimation[startAnimationName].time = StartAnimation[startAnimationName].length; } if (instant) StartAnimation[startAnimationName].speed = 999999 * speed; StartAnimation[startAnimationName].speed = speed; StartAnimation.Play(startAnimationName); } }
public override void OnStart(PartModule.StartState state) { String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_THERMALPOWER }; this.resources_to_supply = resources_to_supply; base.OnStart(state); if (state == StartState.Editor) { return; } if (part.FindModulesImplementing<MicrowavePowerTransmitter>().Count == 1) { part_transmitter = part.FindModulesImplementing<MicrowavePowerTransmitter>().First(); has_transmitter = true; } if (animTName != null) { animT = part.FindModelAnimators(animTName).FirstOrDefault(); if (animT != null) { animT[animTName].layer = 1; animT[animTName].normalizedTime = 0f; animT[animTName].speed = 0.001f; animT.Play(); } } if (animName != null) { anim = part.FindModelAnimators(animName).FirstOrDefault(); if (anim != null) { anim[animName].layer = 1; if (connectedsatsi > 0 || connectedrelaysi > 0) { anim[animName].normalizedTime = 1f; anim[animName].speed = -1f; } else { anim[animName].normalizedTime = 0f; anim[animName].speed = 1f; } anim.Play(); } } vmps = new List<VesselMicrowavePersistence>(); vrps = new List<VesselRelayPersistence>(); foreach (Vessel vess in FlightGlobals.Vessels) { String vesselID = vess.id.ToString(); if (vess.isActiveVessel == false && vess.vesselName.ToLower().IndexOf("debris") == -1) { ConfigNode config = PluginHelper.getPluginSaveFile(); if (config.HasNode("VESSEL_MICROWAVE_POWER_" + vesselID)) { ConfigNode power_node = config.GetNode("VESSEL_MICROWAVE_POWER_" + vesselID); double nuclear_power = 0; double solar_power = 0; if (power_node.HasValue("nuclear_power")) { nuclear_power = double.Parse(power_node.GetValue("nuclear_power")); } if (power_node.HasValue("solar_power")) { solar_power = double.Parse(power_node.GetValue("solar_power")); } if (nuclear_power > 0 || solar_power > 0) { VesselMicrowavePersistence vmp = new VesselMicrowavePersistence(vess); vmp.setSolarPower(solar_power); vmp.setNuclearPower(nuclear_power); vmps.Add(vmp); } } if (config.HasNode("VESSEL_MICROWAVE_RELAY_" + vesselID)) { ConfigNode relay_node = config.GetNode("VESSEL_MICROWAVE_RELAY_" + vesselID); if (relay_node.HasValue("relay")) { bool relay = bool.Parse(relay_node.GetValue("relay")); if (relay) { VesselRelayPersistence vrp = new VesselRelayPersistence(vess); vrp.setActive(relay); vrps.Add(vrp); } } } } } penaltyFreeDistance = Math.Sqrt(1 / ((microwaveAngleTan * microwaveAngleTan) / collectorArea)); this.part.force_activate(); }
public override void OnStart(PartModule.StartState state) { Actions["ActivateReceiverAction"].guiName = Events["ActivateReceiver"].guiName = String.Format("Activate Receiver"); Actions["DisableReceiverAction"].guiName = Events["DisableReceiver"].guiName = String.Format("Disable Receiver"); Actions["ToggleReceiverAction"].guiName = String.Format("Toggle Receiver"); base.OnStart (state); if (state == StartState.Editor) { return; } this.part.force_activate(); anim = part.FindModelAnimators (animName).FirstOrDefault (); if (anim != null) { anim [animName].layer = 1; if (connectedsatsf > 0 || connectedrelaysf > 0) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } if (mycount == -1) { mycount = dishcount; dishcount++; } }
public void Start() { thisTransform = transform; thisAnimation = GetComponent<Animation>(); gameManager = GameManager.instance; thisTransform.position = spawnPosition; thisTransform.eulerAngles = spawnRotation; platformLayer = (1 << LayerMask.NameToLayer("Platform")) | (1 << LayerMask.NameToLayer("PlatformJump")) | (1 << LayerMask.NameToLayer("Floor")); // setup the animation wrap modes thisAnimation[idleAnimationName].wrapMode = WrapMode.Loop; thisAnimation[runAnimationName].wrapMode = WrapMode.Loop; thisAnimation[attackAnimationName].wrapMode = WrapMode.Once; thisAnimation.Play(idleAnimationName); GameManager.instance.OnStartGame += StartGame; }
/// <summary> /// 播放动画片段 /// </summary> /// <param name="anim"></param> /// <param name="name"></param> /// <param name="dir"></param> /// <returns></returns> public static AnimationState PlayAnimation(Animation anim, string name, AnimationOrTween.Direction dir) { var state = anim[name]; if (state) { float speed = Mathf.Abs(state.speed); state.speed = speed * (int)dir; if (dir == AnimationOrTween.Direction.Reverse && state.time == 0f) state.time = state.length; else if (dir == AnimationOrTween.Direction.Forward && state.time == state.length) state.time = 0f; //Debug.Log(string.Format(" speed {0},dir ={1},time = {2},length={3}",state.speed,dir,state.time,state.length)); anim.Play(name); anim.Sample(); } return state; }
//only called for animated internal parts private void closeCryopod(int seatIndx, float speed) { string podname = "Animated-Cryopod-" + (seatIndx + 1); string windowname = "Animated-Cryopod-" + (seatIndx + 1) + "-Window"; Utilities.Log_Debug("playing animation closecryopod " + podname + " " + windowname); try { _animation = part.internalModel.FindModelComponent<Animation>(podname); if (_animation != null) { if (!cryopodstateclosed[seatIndx]) { _animation["Close"].speed = speed; _animation.Play("Close"); cryopodstateclosed[seatIndx] = true; savecryopodstatepersistent(); } } else Utilities.Log_Debug("Cryopod animation not found"); } catch (Exception ex) { Debug.Log("Unable to find animation in internal model for this part called " + podname); Debug.Log("Err: " + ex); } }
public override void OnStart(PartModule.StartState state) { print("[KSP Interstellar] Generator OnStart Begin " + startcount); String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT }; this.resources_to_supply = resources_to_supply; if (state == PartModule.StartState.Docked) { base.OnStart(state); return; } // calculate WasteHeat Capacity var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT); if (wasteheatPowerResource != null) { var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount; wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio; } previousTimeWarp = TimeWarp.fixedDeltaTime - 1.0e-6f; megajouleResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_MEGAJOULES); base.OnStart(state); generatorType = originalName; Fields["maxChargedPower"].guiActive = chargedParticleMode; Fields["maxThermalPower"].guiActive = !chargedParticleMode; if (state == StartState.Editor) { if (this.HasTechsRequiredToUpgrade()) { isupgraded = true; hasrequiredupgrade = true; upgradePartModule(); } part.OnEditorAttach += OnEditorAttach; return; } if (this.HasTechsRequiredToUpgrade()) hasrequiredupgrade = true; this.part.force_activate(); anim = part.FindModelAnimators(animName).FirstOrDefault(); if (anim != null) { anim[animName].layer = 1; if (!IsEnabled) { anim[animName].normalizedTime = 1f; anim[animName].speed = -1f; } else { anim[animName].normalizedTime = 0f; anim[animName].speed = 1f; } anim.Play(); } if (generatorInit == false) { generatorInit = true; IsEnabled = true; } if (isupgraded) upgradePartModule(); FindAttachedThermalSource(); UpdateHeatExchangedThrustDivisor(); print("[KSP Interstellar] Generator OnStart Finished"); }
private void freezeCryopodWindow(int seatIndx, float speed) { if (isPartAnimated || (isPodExternal && DFInstalledMods.IsJSITransparentPodsInstalled && _prevRPMTransparentpodSetting == "ON")) setCryopodWindowTransparent(seatIndx); else speed = float.MaxValue; string windowname = ""; if (isPartAnimated) windowname = "Animated-Cryopod-" + (seatIndx + 1) + "-Window"; else windowname = "Cryopod-" + (seatIndx + 1) + "-Window"; _windowAnimation = part.internalModel.FindModelComponent<Animation>(windowname); Animation _extwindowAnimation = null; if (isPodExternal) { _extwindowAnimation = part.FindModelComponent<Animation>(windowname); //Utilities.SetInternalDepthMask(part, true, "External_Window_Occluder"); //Set window occluder visible (block internals) } if (_windowAnimation == null) { Utilities.Log_Debug("Why can't I find the window animation?"); } else { _windowAnimation["CryopodWindowClose"].speed = speed; _windowAnimation.Play("CryopodWindowClose"); } if (isPodExternal && _extwindowAnimation != null) { _extwindowAnimation["CryopodWindowClose"].speed = speed; _extwindowAnimation.Play("CryopodWindowClose"); } }
public override void OnStart(PartModule.StartState state) { String[] resources_to_supply = {FNResourceManager.FNRESOURCE_MEGAJOULES,FNResourceManager.FNRESOURCE_WASTEHEAT}; this.resources_to_supply = resources_to_supply; base.OnStart (state); generatorType = originalName; if (state == StartState.Editor) { if (hasTechsRequiredToUpgrade()) { isupgraded = true; hasrequiredupgrade = true; upgradePartModule(); } part.OnEditorAttach += OnEditorAttach; return; } if (hasTechsRequiredToUpgrade()) { hasrequiredupgrade = true; } this.part.force_activate(); anim = part.FindModelAnimators (animName).FirstOrDefault (); if (anim != null) { anim [animName].layer = 1; if (!IsEnabled) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } if (generatorInit == false) { generatorInit = true; IsEnabled = true; } if (isupgraded) { upgradePartModule (); } foreach (AttachNode attach_node in part.attachNodes) { if(attach_node.attachedPart != null) { List<FNThermalSource> sources = attach_node.attachedPart.FindModulesImplementing<FNThermalSource> (); if (sources.Count > 0) { myAttachedReactor = sources.First (); if (myAttachedReactor != null) { break; } } } } print("[KSP Interstellar] Configuring Generator"); }
//----------------methods----------------- public override void OnStart(PartModule.StartState state) { base.OnStart(state); //find the animation anim = part.FindModelAnimators(animationName).FirstOrDefault(); //find the dependent module dependent = (PlanetaryModule)this.part.GetComponent("PlanetaryModule"); if (anim != null) //Only Init when an animation is available { if (!hasBeenInitialized) // Run Only on first launch { nextIsReverse = false; animationTime = 0f; anim[animationName].normalizedTime = 0f; hasBeenInitialized = true; } // make sure you stay in your place on launch, and don't start going in the wrong direction if deployed/retracted if (nextIsReverse) { anim[animationName].speed = 1f; if (animationTime == 0f) { animationTime = 1f; } if (animationTime == 1f) { lightStatus = "On"; } else { lightStatus = "Turning on"; } } else { if (animationTime == 0f) { lightStatus = "Off"; } else { lightStatus = "Turning off"; } anim[animationName].speed = -1f; } //set up animation state according to persistent values anim[animationName].layer = layer; anim.Play(animationName); anim[animationName].normalizedTime = animationTime; //Settings for the GUI if (nextIsReverse) { Events["toggleAnimation"].guiName = endEventGUIName; } else { Events["toggleAnimation"].guiName = startEventGUIName; } //check whether the element can be active or not bool bShowGUI = true; if (dependent != null) { bShowGUI = dependent.status.Equals("Deployed"); } Events["toggleAnimation"].guiActiveEditor = availableInEditor; Events["toggleAnimation"].guiActiveUnfocused = availableInEVA && bShowGUI; Events["toggleAnimation"].guiActive = availableInVessel && bShowGUI; Events["toggleAnimation"].unfocusedRange = EVArange; } else //When the animation can not be found deactivate it in the GUI { Events["toggleAnimation"].guiActiveEditor = false; Events["toggleAnimation"].guiActive = false; Events["toggleAnimation"].guiActiveUnfocused = false; Debug.Log("KBILightAnimation: Animation not found: " + animationName); } }
public override void OnStart(PartModule.StartState state) { String[] resources_to_supply = { FNResourceManager.FNRESOURCE_THERMALPOWER, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_CHARGED_PARTICLES }; this.resources_to_supply = resources_to_supply; //name_to_use = originalName; base.OnStart(state); Actions["ActivateReactorAction"].guiName = Events["ActivateReactor"].guiName = String.Format("Activate Reactor"); Actions["DeactivateReactorAction"].guiName = Events["DeactivateReactor"].guiName = String.Format("Deactivate Reactor"); Actions["ToggleReactorAction"].guiName = String.Format("Toggle Reactor"); if (state == StartState.Editor) { if (startDisabled) { Events["ActivateReactorVAB"].guiActiveEditor = true; Events["DeactivateReactorVAB"].guiActiveEditor = false; } if (hasTechsRequiredToUpgrade()) { isupgraded = true; upgradePartModule(); } return; } if (hasTechsRequiredToUpgrade()) { hasrequiredupgrade = true; } if (startDisabled) { last_active_time = (float) (Planetarium.GetUniversalTime() - 4.0 * 86400.0); IsEnabled = false; startDisabled = false; } anim = part.FindModelAnimators (animName).FirstOrDefault (); if (anim != null) { anim [animName].layer = 1; if (!IsEnabled) { anim [animName].normalizedTime = 1f; anim [animName].speed = -1f; } else { anim [animName].normalizedTime = 0f; anim [animName].speed = 1f; } anim.Play (); } if (IsEnabled && last_active_time > 0) { double now = Planetarium.GetUniversalTime(); double time_diff = now - last_active_time; double resource_to_take = consumeReactorResource(resourceRate*time_diff*ongoing_consumption_rate); if (breedtritium) { tritium_rate = (float)(ThermalPower / 1000.0f / GameConstants.tritiumBreedRate); List<PartResource> lithium_resources = new List<PartResource>(); part.GetConnectedResources(PartResourceLibrary.Instance.GetDefinition("Lithium").id, lithium_resources); double lithium_current_amount = 0; foreach (PartResource lithium_resource in lithium_resources) { lithium_current_amount += lithium_resource.amount; } List<PartResource> tritium_resources = new List<PartResource>(); part.GetConnectedResources(PartResourceLibrary.Instance.GetDefinition("Tritium").id, tritium_resources); double tritium_missing_amount = 0; foreach (PartResource tritium_resource in tritium_resources) { tritium_missing_amount += tritium_resource.maxAmount - tritium_resource.amount; } double lithium_to_take = Math.Min(tritium_rate * time_diff * ongoing_consumption_rate, lithium_current_amount); double tritium_to_add = Math.Min(tritium_rate * time_diff * ongoing_consumption_rate, tritium_missing_amount); ORSHelper.fixedRequestResource(part, "Lithium", Math.Min(tritium_to_add, lithium_to_take)); ORSHelper.fixedRequestResource(part, "Tritium", -Math.Min(tritium_to_add, lithium_to_take)); } } this.part.force_activate(); }
void Start() { m_controller = this.GetComponentInChildren<CharacterController>(); m_curState = AnimStates.Idle; m_animComponent = this.gameObject.GetComponentInChildren<Animation>(); m_isDead = false; m_isSitting = false; for (int i = 0; i < (int)AnimationType.DEFAULT; i++) { m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString()); } m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name); m_animComponent.wrapMode = WrapMode.Loop; m_attackType = AnimAttackType.None; m_turnDir = TurningType.None; }
public void GoMooCowGo() { _cowAnimation.Rewind(); _cowAnimation.Play(); }
private void PlayStartAnimation(Animation StartAnimation, string startAnimationName, int speed, bool instant) { if (startAnimationName != "") { if (speed < 0) { StartAnimation[startAnimationName].time = StartAnimation[startAnimationName].length; if (loopPoint != 0) StartAnimation[startAnimationName].time = loopPoint; } if (instant) StartAnimation[startAnimationName].speed = 999999 * speed; StartAnimation[startAnimationName].wrapMode = WrapMode.Default; StartAnimation[startAnimationName].speed = speed; StartAnimation.Play(startAnimationName); } }
public VariableAnimationSet(ConfigNode node, InternalProp thisProp, RasterPropMonitorComputer rpmComp, JSIVariableAnimator parent) { varAnim = parent; onChangeDelegate = (Action<float>)Delegate.CreateDelegate(typeof(Action<float>), this, "OnChange"); part = thisProp.part; if (!node.HasData) { throw new ArgumentException("No data?!"); } string[] tokens = { }; if (node.HasValue("scale")) { tokens = node.GetValue("scale").Split(','); } if (tokens.Length != 2) { throw new ArgumentException("Could not parse 'scale' parameter."); } string variableName = string.Empty; if (node.HasValue("variableName")) { variableName = node.GetValue("variableName").Trim(); } else if (node.HasValue("stateMethod")) { string stateMethod = node.GetValue("stateMethod").Trim(); // Verify the state method actually exists Func<bool> stateFunction = (Func<bool>)rpmComp.GetMethod(stateMethod, thisProp, typeof(Func<bool>)); if (stateFunction != null) { variableName = "PLUGIN_" + stateMethod; } else { throw new ArgumentException("Unrecognized stateMethod"); } } else { throw new ArgumentException("Missing variable name."); } if (node.HasValue("modulo")) { variable = new VariableOrNumberRange(rpmComp, variableName, tokens[0], tokens[1], node.GetValue("modulo")); usesModulo = true; } else { variable = new VariableOrNumberRange(rpmComp, variableName, tokens[0], tokens[1]); usesModulo = false; } // That takes care of the scale, now what to do about that scale: if (node.HasValue("reverse")) { if (!bool.TryParse(node.GetValue("reverse"), out reverse)) { throw new ArgumentException("So is 'reverse' true or false?"); } } if (node.HasValue("animationName")) { animationName = node.GetValue("animationName"); if (node.HasValue("animationSpeed")) { animationSpeed = float.Parse(node.GetValue("animationSpeed")); if (reverse) { animationSpeed = -animationSpeed; } } else { animationSpeed = 0.0f; } Animation[] anims = node.HasValue("animateExterior") ? thisProp.part.FindModelAnimators(animationName) : thisProp.FindModelAnimators(animationName); if (anims.Length > 0) { onAnim = anims[0]; onAnim.enabled = true; onAnim[animationName].speed = 0; onAnim[animationName].normalizedTime = reverse ? 1f : 0f; looping = node.HasValue("loopingAnimation"); if (looping) { onAnim[animationName].wrapMode = WrapMode.Loop; onAnim.wrapMode = WrapMode.Loop; onAnim[animationName].speed = animationSpeed; mode = Mode.LoopingAnimation; } else { onAnim[animationName].wrapMode = WrapMode.Once; mode = Mode.Animation; } onAnim.Play(); alwaysActive = node.HasValue("animateExterior"); } else { throw new ArgumentException("Animation could not be found."); } if (node.HasValue("stopAnimationName")) { stopAnimationName = node.GetValue("stopAnimationName"); anims = node.HasValue("animateExterior") ? thisProp.part.FindModelAnimators(stopAnimationName) : thisProp.FindModelAnimators(stopAnimationName); if (anims.Length > 0) { offAnim = anims[0]; offAnim.enabled = true; offAnim[stopAnimationName].speed = 0; offAnim[stopAnimationName].normalizedTime = reverse ? 1f : 0f; if (looping) { offAnim[stopAnimationName].wrapMode = WrapMode.Loop; offAnim.wrapMode = WrapMode.Loop; offAnim[stopAnimationName].speed = animationSpeed; mode = Mode.LoopingAnimation; } else { offAnim[stopAnimationName].wrapMode = WrapMode.Once; mode = Mode.Animation; } } } } else if (node.HasValue("activeColor") && node.HasValue("passiveColor") && node.HasValue("coloredObject")) { string colorNameString = "_EmissiveColor"; if (node.HasValue("colorName")) { colorNameString = node.GetValue("colorName"); } colorName = Shader.PropertyToID(colorNameString); if (reverse) { activeColor = JUtil.ParseColor32(node.GetValue("passiveColor"), thisProp.part, ref rpmComp); passiveColor = JUtil.ParseColor32(node.GetValue("activeColor"), thisProp.part, ref rpmComp); } else { passiveColor = JUtil.ParseColor32(node.GetValue("passiveColor"), thisProp.part, ref rpmComp); activeColor = JUtil.ParseColor32(node.GetValue("activeColor"), thisProp.part, ref rpmComp); } Renderer colorShiftRenderer = thisProp.FindModelComponent<Renderer>(node.GetValue("coloredObject")); affectedMaterial = colorShiftRenderer.material; affectedMaterial.SetColor(colorName, passiveColor); mode = Mode.Color; } else if (node.HasValue("controlledTransform") && node.HasValue("localRotationStart") && node.HasValue("localRotationEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialRotation = controlledTransform.localRotation; if (node.HasValue("longPath")) { longPath = true; if (reverse) { vectorEnd = ConfigNode.ParseVector3(node.GetValue("localRotationStart")); vectorStart = ConfigNode.ParseVector3(node.GetValue("localRotationEnd")); } else { vectorStart = ConfigNode.ParseVector3(node.GetValue("localRotationStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localRotationEnd")); } } else { if (reverse) { rotationEnd = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationStart"))); rotationStart = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationEnd"))); } else { rotationStart = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationStart"))); rotationEnd = Quaternion.Euler(ConfigNode.ParseVector3(node.GetValue("localRotationEnd"))); } } mode = Mode.Rotation; } else if (node.HasValue("controlledTransform") && node.HasValue("localTranslationStart") && node.HasValue("localTranslationEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialPosition = controlledTransform.localPosition; if (reverse) { vectorEnd = ConfigNode.ParseVector3(node.GetValue("localTranslationStart")); vectorStart = ConfigNode.ParseVector3(node.GetValue("localTranslationEnd")); } else { vectorStart = ConfigNode.ParseVector3(node.GetValue("localTranslationStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localTranslationEnd")); } mode = Mode.Translation; } else if (node.HasValue("controlledTransform") && node.HasValue("localScaleStart") && node.HasValue("localScaleEnd")) { controlledTransform = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()); initialScale = controlledTransform.localScale; if (reverse) { vectorEnd = ConfigNode.ParseVector3(node.GetValue("localScaleStart")); vectorStart = ConfigNode.ParseVector3(node.GetValue("localScaleEnd")); } else { vectorStart = ConfigNode.ParseVector3(node.GetValue("localScaleStart")); vectorEnd = ConfigNode.ParseVector3(node.GetValue("localScaleEnd")); } mode = Mode.Scale; } else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureShiftStart") && node.HasValue("textureShiftEnd")) { affectedMaterial = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()).GetComponent<Renderer>().material; var textureLayers = node.GetValue("textureLayers").Split(','); for (int i = 0; i < textureLayers.Length; ++i) { textureLayer.Add(textureLayers[i].Trim()); } if (reverse) { textureShiftEnd = ConfigNode.ParseVector2(node.GetValue("textureShiftStart")); textureShiftStart = ConfigNode.ParseVector2(node.GetValue("textureShiftEnd")); } else { textureShiftStart = ConfigNode.ParseVector2(node.GetValue("textureShiftStart")); textureShiftEnd = ConfigNode.ParseVector2(node.GetValue("textureShiftEnd")); } mode = Mode.TextureShift; } else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureScaleStart") && node.HasValue("textureScaleEnd")) { affectedMaterial = thisProp.FindModelTransform(node.GetValue("controlledTransform").Trim()).GetComponent<Renderer>().material; var textureLayers = node.GetValue("textureLayers").Split(','); for (int i = 0; i < textureLayers.Length; ++i) { textureLayer.Add(textureLayers[i].Trim()); } if (reverse) { textureScaleEnd = ConfigNode.ParseVector2(node.GetValue("textureScaleStart")); textureScaleStart = ConfigNode.ParseVector2(node.GetValue("textureScaleEnd")); } else { textureScaleStart = ConfigNode.ParseVector2(node.GetValue("textureScaleStart")); textureScaleEnd = ConfigNode.ParseVector2(node.GetValue("textureScaleEnd")); } mode = Mode.TextureScale; } else { throw new ArgumentException("Cannot initiate any of the possible action modes."); } if (!(node.HasValue("maxRateChange") && float.TryParse(node.GetValue("maxRateChange"), out maxRateChange))) { maxRateChange = 0.0f; } if (maxRateChange >= 60.0f) { // Animation rate is too fast to even notice @60Hz maxRateChange = 0.0f; } else { lastAnimUpdate = Planetarium.GetUniversalTime(); } if (node.HasValue("threshold")) { threshold = ConfigNode.ParseVector2(node.GetValue("threshold")); } resourceAmount = 0.0f; if (threshold != Vector2.zero) { thresholdMode = true; float min = Mathf.Min(threshold.x, threshold.y); float max = Mathf.Max(threshold.x, threshold.y); threshold.x = min; threshold.y = max; if (node.HasValue("flashingDelay")) { flashingDelay = double.Parse(node.GetValue("flashingDelay")); } if (node.HasValue("alarmSound")) { alarmSoundVolume = 0.5f; if (node.HasValue("alarmSoundVolume")) { alarmSoundVolume = float.Parse(node.GetValue("alarmSoundVolume")); } audioOutput = JUtil.SetupIVASound(thisProp, node.GetValue("alarmSound"), alarmSoundVolume, false); if (node.HasValue("alarmMustPlayOnce")) { if (!bool.TryParse(node.GetValue("alarmMustPlayOnce"), out alarmMustPlayOnce)) { throw new ArgumentException("So is 'alarmMustPlayOnce' true or false?"); } } if (node.HasValue("alarmShutdownButton")) { SmarterButton.CreateButton(thisProp, node.GetValue("alarmShutdownButton"), AlarmShutdown); } if (node.HasValue("alarmSoundLooping")) { if (!bool.TryParse(node.GetValue("alarmSoundLooping"), out alarmSoundLooping)) { throw new ArgumentException("So is 'alarmSoundLooping' true or false?"); } audioOutput.audio.loop = alarmSoundLooping; } inIVA = (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA); GameEvents.OnCameraChange.Add(OnCameraChange); } if (node.HasValue("resourceAmount")) { resourceAmount = float.Parse(node.GetValue("resourceAmount")); if (node.HasValue("resourceName")) { resourceName = node.GetValue("resourceName"); } else { resourceName = "ElectricCharge"; } } TurnOff(Planetarium.GetUniversalTime()); } rpmComp.RegisterVariableCallback(variable.variableName, onChangeDelegate); }
public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent<DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent<DragManager>(); DragManager.SetPart(part); } gearHandler.Start(ID,part); anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) s.layer = i++; } part.PhysicsSignificance = 1; Transform bounds = part.FindModelTransform("Bounds"); if (bounds != null) UnityEngine.Object.DestroyImmediate(bounds.gameObject); gearState = Deployed ? ModuleLandingGear.GearStates.DEPLOYED : ModuleLandingGear.GearStates.RETRACTED; animState.normalizedTime = Deployed ? 1 : 0; animState.speed = Deployed ? Mathf.Abs(animState.speed) : -Mathf.Abs(animState.speed); UpdateDrag(); anim.Play(AnimationName); HashSet<WheelCollider> tmp = new HashSet<WheelCollider>(); part.transform.FindWheelColliders(ref tmp); foreach (WheelCollider w in tmp) w.enabled = true; }