Sample() public method

public Sample ( ) : void
return void
 static public int Sample(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
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         self.Sample();
         pushValue(l, true);
         return(1);
     }
     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
 }
 static public int Sample(IntPtr l)
 {
     try {
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         self.Sample();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Sample(IntPtr l)
 {
     try{
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         self.Sample();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static int QPYX_Sample_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation));
         QPYX_obj_YXQP.Sample();
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Exemplo n.º 5
0
 public static int Sample_wrap(long L)
 {
     try
     {
         long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Animation obj = get_obj(nThisPtr);
         obj.Sample();
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
 static int Sample(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
         obj.Sample();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 7
0
    static int Sample(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Animation.Sample");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 1);
            UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
            obj.Sample();
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 8
0
        public float AdvanceAnimationTo(Animation anim, string clip, float to, float dt, float last = -1)
        {
            float ret = to;

            AnimationState st = anim[clip];
            st.enabled = true;
            st.weight = 1;
            if (last < 0)
            {
                last = st.normalizedTime;
            }
            ret = st.normalizedTime = Mathf.MoveTowards(last, to, dt * st.length);
            anim.Sample();
            st.enabled = false;

            return ret;
        }
Exemplo n.º 9
0
        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;
            }
        }
Exemplo n.º 10
0
		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) {
                if (hasTechsRequiredToUpgrade()) {
                    isupgraded = true;
                    hasrequiredupgrade = true;
                }
                return;
            }
			

			FNRadiator.list_of_radiators.Add (this);

			anim = part.FindModelAnimators (animName).FirstOrDefault ();
			//orig_emissive_colour = part.renderer.material.GetTexture (emissive_property_name);
			if (anim != null) {
				anim [animName].layer = 1;

				if (radiatorIsEnabled) {
					anim[animName].normalizedTime = 1.0f;
					anim[animName].enabled = true;
					anim.Sample();
				} else {
					//anim.Blend (animName, 0, 0);
				}
				//anim.Play ();
			}

			if (isDeployable) {
				pivot = part.FindModelTransform ("suntransform");
				original_eulers = pivot.transform.localEulerAngles;
			} else {
				radiatorIsEnabled = true;
			}

			if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER) {
				if(PluginHelper.hasTech(upgradeTechReq)) {
					hasrequiredupgrade = true;
				}
			}else{
				hasrequiredupgrade = true;
			}

			if (radiatorInit == false) {
				radiatorInit = true;
			}

			if (!isupgraded) {
				radiatorType = originalName;
			} else {
				radiatorType = upgradedName;
				radiatorTemp = upgradedRadiatorTemp;
			}


			radiatorTempStr = radiatorTemp + "K";
			maxQStr = maxQ + " Pa";
            this.part.force_activate();
		}
Exemplo n.º 11
0
        public override void Seek(float time)
        {
            base.Seek(time);
            if (_LayerKeys == null)
            {
                _LayerKeys = new CrossFadeAnimationKey[10];                     // maximum 10 layer support
            }
            for (int i = 0; i < _LayerKeys.Length; i++)
            {
                _LayerKeys[i] = null;
            }

            if (_Animation != null && _Animation.enabled)
            {
                ResetAnimations();// reset weight of all used animations

                if (Keys != null && Keys.Length > 0 && Index >= 0)
                {
                    for (int i = 0; i <= Index; i++)
                    {
                        CrossFadeAnimationKey cfak = Keys[i] as CrossFadeAnimationKey;
                        if (cfak != null)
                        {
                            if (!string.IsNullOrEmpty(cfak._Animation))
                            {
                                AnimationState newState = _Animation[cfak._Animation];
                                if (newState != null)
                                {
                                    float stateWeight = 1.0f;
                                    if (cfak._Layer < _LayerKeys.Length)
                                    {
                                        if (_LayerKeys[cfak._Layer] != null)
                                        {
                                            AnimationState preState = _Animation[_LayerKeys[cfak._Layer]._Animation];
                                            if (preState != null)
                                            {
                                                if (time >= cfak.FireTime + cfak.FadeLenght)
                                                {
                                                    preState.weight = 0.0f;
                                                    preState.time   = 0.0f;
                                                }
                                                else if (time >= cfak.FireTime)
                                                {
                                                    stateWeight     = (time - cfak.FireTime) / cfak.FadeLenght;
                                                    preState.weight = 1.0f - stateWeight;
                                                    preState.time   = time - _LayerKeys[cfak._Layer].FireTime;
                                                }
                                            }
                                        }
                                        _LayerKeys[cfak._Layer] = cfak;
                                    }

                                    cfak.ApplyStateParameters(newState);
                                    _Animation.CrossFade(newState.name, 0, cfak.Mode);
                                    newState.weight = stateWeight;
                                    newState.time   = time - cfak.FireTime;
                                }
                            }
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(_DefaultAnimation))
                {
                    AnimationState state = _Animation[_DefaultAnimation];

                    if (state != null)
                    {
                        _Animation.CrossFade(state.name, 0, PlayMode.StopAll);
                        state.time   = time;
                        state.weight = 1.0f;
                    }
                }

                _Animation.Sample();
                // this is a stupid code to make unity update animation completely in SceneView
                if (!Application.isPlaying)
                {
                    _Animation.enabled = false;
                    _Animation.enabled = true;
                }
            }
        }
Exemplo n.º 12
0
 public static void SampleAnimationFadeIn(Animation anim, string clipName, WrapMode wrap, float fadeDelay, float time)
 {
     AnimationState animState = anim[clipName];
     animState.enabled = true;
     animState.wrapMode = wrap;
     animState.weight = time < fadeDelay ? time/fadeDelay : 1.0f;
     animState.time = time;
     anim.Sample();
     animState.enabled = false;
 }
Exemplo n.º 13
0
    public static void SampleAnimationCrossFade(Animation anim, float fadeDelay, string prevClipName, WrapMode prevWrap, float prevTime, string clipName, WrapMode wrap, float time)
    {
        float weight = time < fadeDelay ? time / fadeDelay : 1.0f;

        if(weight < 1.0f) {
            AnimationState animPrevState = anim[prevClipName];
            AnimationState animState = anim[clipName];

            animPrevState.enabled = true;
            animPrevState.wrapMode = prevWrap;
            animPrevState.weight = 1.0f - weight;
            animPrevState.time = prevTime;

            animState.enabled = true;
            animState.wrapMode = wrap;
            animState.weight = weight;
            animState.time = time;

            anim.Sample();

            animPrevState.enabled = false;
            animState.enabled = false;
        }
        else {
            AnimationState animState = anim[clipName];
            animState.enabled = true;
            animState.wrapMode = wrap;
            animState.weight = weight;
            animState.time = time;
            anim.Sample();
            animState.enabled = false;
        }
    }
Exemplo n.º 14
0
 public static void SampleAnimation(Animation anim, string clipName, WrapMode wrap, float weight, float time)
 {
     AnimationState animState = anim[clipName];
     animState.enabled = true;
     animState.wrapMode = wrap;
     animState.weight = weight;
     animState.time = time;
     anim.Sample();
     animState.enabled = false;
 }
        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();
        }
Exemplo n.º 16
0
        /// <summary>
        /// 播放动画片段
        /// </summary>
        /// <param name="anim"></param>
        /// <param name="name"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static AnimationState PlayAnimation(Animation anim, string name, AnimationDirection dir)
        {
            if (string.IsNullOrEmpty(name)) name = anim.clip.name;
            var state = anim[name];
            if (state)
            {
                float speed = state.speed;
                if (dir == AnimationDirection.Toggle)
                {
                    if (speed > 0 && state.time == 0 )
                        dir = AnimationDirection.Reverse;
                    else
                        dir = AnimationDirection.Forward;
                }

                if (dir == AnimationDirection.Reverse && state.time == 0f)
                {
                    state.time = state.length;
                }
                else if (dir == AnimationDirection.Forward && state.time == state.length)
                {
                    state.time = 0f;
                }

                state.speed = Mathf.Abs(speed) * (int)dir;

                anim.Play(name);
                anim.Sample();
            }
            return state;
        }
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_THERMALPOWER };

            wasteheatResource = part.Resources[FNResourceManager.FNRESOURCE_WASTEHEAT];

            this.resources_to_supply = resources_to_supply;
            base.OnStart(state);
            if (state == StartState.Editor) { return; }

            // calculate WasteHeat Capacity
            partBaseWasteheat = part.mass * 1.0e+5 * wasteHeatMultiplier + (StableMaximumReactorPower * 100);
            if (wasteheatResource != null)
            {
                var ratio = wasteheatResource.amount / wasteheatResource.maxAmount;
                wasteheatResource.maxAmount = partBaseWasteheat;
                wasteheatResource.amount = wasteheatResource.maxAmount * ratio;
            }

            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].enabled = true;
                    animT[animTName].layer = 1;
                    animT[animTName].normalizedTime = 0f;
                    animT[animTName].speed = 0.001f;
                    animT.Sample();
                }
            }

            if (animName != null)
                anim = part.FindModelAnimators(animName).FirstOrDefault();

            penaltyFreeDistance = Math.Sqrt(1 / ((microwaveAngleTan * microwaveAngleTan) / collectorArea));

            this.part.force_activate();
        }
Exemplo n.º 18
0
        private void BakeSkinnedMesh(Animation animation, SkinnedMeshRenderer skinnedMeshRenderer)
        {
            int clipIndex = 0;

            foreach (AnimationState clipState in animation)
            {
                //Prep animation clip for sampling
                var curClip = this.AnimationClipsToBake[clipIndex] = animation.GetClip(clipState.name);
                animation.Play(clipState.name, PlayMode.StopAll);
                clipState.time = 0;
                clipState.wrapMode = WrapMode.Clamp;

                //Calculate number of meshes to bake in this clip sequence based on the clip's sampling framerate
                uint numberOfFrames = (uint)Mathf.RoundToInt(curClip.frameRate * curClip.length);
                var curBakedMeshSequence = this.BakedClips[clipIndex] = new MeshSequence(numberOfFrames);

                for (uint frameIndex = 0; frameIndex < numberOfFrames; frameIndex++)
                {
                    //Bake sequence of meshes
                    var curMeshFrame = curBakedMeshSequence[frameIndex] = new Mesh();
                    curMeshFrame.name = string.Format(@"{0}_Baked_{1}_{2}", this.name, clipIndex, frameIndex);
                    animation.Sample();
                    skinnedMeshRenderer.BakeMesh(curMeshFrame);

                    clipState.time += (1.0f / curClip.frameRate);
                }

                animation.Stop();
                clipIndex++;
            }
        }
Exemplo n.º 19
0
        public override void OnStart(StartState state)
        {
            radiatedThermalPower = 0;
            convectedThermalPower = 0;
            current_rad_temp = 0;
            directionrotate = 1;
            //oldangle = 0;
            last_draw_update = 0;
            update_count = 0;
            hasrequiredupgrade = false;
            explode_counter = 0;
            UpdateEnableAutomation();

            if (upgradedRadiatorArea == 1)
                upgradedRadiatorArea = radiatorArea * 1.7f;

            Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = "Deploy Radiator";
            Actions["RetractRadiatorAction"].guiName = Events["RetractRadiator"].guiName = "Retract Radiator";
            Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");

            var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
            // calculate WasteHeat Capacity
            if (wasteheatPowerResource != null)
            {
                var ratio =  Math.Min(1, Math.Max(0, wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount));
                wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
                wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
            }

            var myAttachedEngine = this.part.FindModuleImplementing<ModuleEngines>();
            if (myAttachedEngine == null)
            {
                Fields["partMass"].guiActiveEditor = true;
                Fields["upgradeTechReq"].guiActiveEditor = true;
                Fields["convectiveBonus"].guiActiveEditor = true;
                Fields["upgradedRadiatorTemp"].guiActiveEditor = true;
            }

            if (state == StartState.Editor)
            {
                if (hasTechsRequiredToUpgrade())
                {
                    isupgraded = true;
                    hasrequiredupgrade = true;
                }
                return;
            }

            list_of_thermal_sources = vessel.FindPartModulesImplementing<IThermalSource>();

            if (ResearchAndDevelopment.Instance != null)
                upgradeCostStr = ResearchAndDevelopment.Instance.Science + "/" + upgradeCost.ToString("0") + " Science";

            if (state == PartModule.StartState.Docked)
            {
                base.OnStart(state);
                return;
            }

            // add to static list of all radiators
            FNRadiator.list_of_all_radiators.Add(this);

            moduleDeployableRadiator = part.FindModuleImplementing<ModuleDeployableRadiator>();
            array = part.FindModelComponents<Renderer>();

            deployAnim = part.FindModelAnimators (animName).FirstOrDefault ();
            if (deployAnim != null)
            {
                deployAnim [animName].layer = 1;

                if (radiatorIsEnabled)
                {
                    deployAnim[animName].normalizedTime = 1.0f;
                    deployAnim[animName].enabled = true;
                    deployAnim.Sample();
                }

            }

            if (!String.IsNullOrEmpty(thermalAnim))
                heatStates = SetUpAnimation(thermalAnim, this.part);

            if (isDeployable)
            {
                pivot = part.FindModelTransform ("suntransform");
                original_eulers = pivot.transform.localEulerAngles;
            }
            else
                radiatorIsEnabled = true;

            if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                if(PluginHelper.hasTech(upgradeTechReq))
                    hasrequiredupgrade = true;
            }
            else
                hasrequiredupgrade = true;

            if (radiatorInit == false)
                radiatorInit = true;

            if (!isupgraded)
                radiatorType = originalName;
            else
            {
                radiatorType = upgradedName;
                radiatorTemp = upgradedRadiatorTemp;
            }

            radiatorTempStr = radiatorTemp + "K";
        }
Exemplo n.º 20
0
 private void sample(Animation anim, AnimationState clip, float time)
 {
     bool en = clip.enabled;
     clip.enabled = true;
     clip.normalizedTime = time;
     clip.weight = 1;
     anim.Sample();
     clip.enabled = en;//restore previous enabled state...
 }
Exemplo n.º 21
0
		public override void OnStart(PartModule.StartState state) 
        {
            _moduleDeployableRadiator = part.FindModuleImplementing<ModuleDeployableRadiator>();

            radiatedThermalPower = 0;
		    convectedThermalPower = 0;
		    current_rad_temp = 0;
		    directionrotate = 1;
		    oldangle = 0;
		    last_draw_update = 0;
            update_count = 0;
		    hasrequiredupgrade = false;
		    explode_counter = 0;

            if (upgradedRadiatorArea == 1)
                upgradedRadiatorArea = radiatorArea * 1.7f;

    		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");

            var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
            // calculate WasteHeat Capacity
            if (wasteheatPowerResource != null)
            {
                var ratio =  Math.Min(1, Math.Max(0, wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount));
                wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
                wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
            }

            if (state == StartState.Editor) 
            {
                if (hasTechsRequiredToUpgrade()) 
                {
                    isupgraded = true;
                    hasrequiredupgrade = true;
                }
                return;
            }

			FNRadiator.list_of_radiators.Add (this);

			anim = part.FindModelAnimators (animName).FirstOrDefault ();
			//orig_emissive_colour = part.renderer.material.GetTexture (emissive_property_name);
			if (anim != null) 
            {
				anim [animName].layer = 1;

				if (radiatorIsEnabled) 
                {
					anim[animName].normalizedTime = 1.0f;
					anim[animName].enabled = true;
					anim.Sample();
				} 
                else 
                {
					//anim.Blend (animName, 0, 0);
				}
				//anim.Play ();
			}

			if (isDeployable) 
            {
				pivot = part.FindModelTransform ("suntransform");
				original_eulers = pivot.transform.localEulerAngles;
			} 
            else 
				radiatorIsEnabled = true;
			

			if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER) 
            {
				if(PluginHelper.hasTech(upgradeTechReq)) 
					hasrequiredupgrade = true;
			}
            else
				hasrequiredupgrade = true;
			

			if (radiatorInit == false) 
				radiatorInit = true;
			

			if (!isupgraded) 
				radiatorType = originalName;
			else 
            {
				radiatorType = upgradedName;
				radiatorTemp = upgradedRadiatorTemp;
			}


			radiatorTempStr = radiatorTemp + "K";
            this.part.force_activate();
		}
        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].enabled = true;
                    animT[animTName].layer = 1;
                    animT[animTName].normalizedTime = 0f;
                    animT[animTName].speed = 0.001f;
                    animT.Sample();
                }
            }

            if (animName != null)
            {
                anim = part.FindModelAnimators(animName).FirstOrDefault();
            }

            penaltyFreeDistance = Math.Sqrt(1 / ((microwaveAngleTan * microwaveAngleTan) / collectorArea));

            this.part.force_activate();
        }
Exemplo n.º 23
0
 /// <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;
 }
        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].enabled = true;
					anim.Sample();
                }
            }

            this.part.force_activate();
        }