Blend() public method

public Blend ( string animation ) : void
animation string
return void
コード例 #1
0
ファイル: AnimationQueue.cs プロジェクト: MrBek/Poker
        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);
                }
            }
        }
コード例 #2
0
 static public int Blend__String(IntPtr l)
 {
     try {
         UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
         System.String         a1;
         checkType(l, 2, out a1);
         self.Blend(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #3
0
 public static int Blend2_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);
         obj.Blend(arg0);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #4
0
 static public int Blend(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 5)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 3, out a1);
             System.Single a2;
             checkType(l, 4, out a2);
             System.Single a3;
             checkType(l, 5, out a3);
             self.Blend(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 3, out a1);
             System.Single a2;
             checkType(l, 4, out a2);
             self.Blend(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 3, out a1);
             self.Blend(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #5
0
    static int Blend(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Animation.Register");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
                string arg0 = ToLua.CheckString(L, 2);
                obj.Blend(arg0);
                return(0);
            }
            else if (count == 3)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
                string arg0 = ToLua.CheckString(L, 2);
                float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                obj.Blend(arg0, arg1);
                return(0);
            }
            else if (count == 4)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation));
                string arg0 = ToLua.CheckString(L, 2);
                float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                float  arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                obj.Blend(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.Blend"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #6
0
 static public int Blend(IntPtr l)
 {
     try{
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 4)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             self.Blend(a1, a2, a3);
             return(0);
         }
         else if (argc == 3)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             self.Blend(a1, a2);
             return(0);
         }
         else if (argc == 2)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             self.Blend(a1);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #7
0
    static int Blend(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                obj.Blend(arg0);
                return(0);
            }
            else if (count == 3)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                obj.Blend(arg0, arg1);
                return(0);
            }
            else if (count == 4)
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                float  arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                obj.Blend(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.Blend"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #8
0
    static int Blend(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string)))
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                obj.Blend(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string), typeof(float)))
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                float  arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                obj.Blend(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string), typeof(float), typeof(float)))
            {
                UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                float  arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                float  arg2 = (float)LuaDLL.lua_tonumber(L, 4);
                obj.Blend(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.Blend"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #9
0
 static int QPYX_Blend_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2)
         {
             UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation));
             string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2);
             QPYX_obj_YXQP.Blend(QPYX_arg0_YXQP);
             return(0);
         }
         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);
             float  QPYX_arg1_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 3);
             QPYX_obj_YXQP.Blend(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 4)
         {
             UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation));
             string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2);
             float  QPYX_arg1_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 3);
             float  QPYX_arg2_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 4);
             QPYX_obj_YXQP.Blend(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP);
             return(0);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Animation.Blend"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #10
0
        public override void OnStart(PartModule.StartState state) {
            if (state == StartState.Editor) { return; }
            reprocessor = new NuclearFuelReprocessor(part);
            anti_factory = new AntimatterFactory(part);
            ConfigNode config = PluginHelper.getPluginSaveFile();

            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 = 1f;
                    //anim2 [animName2].normalizedTime = 1f;
                    //anim [animName1].speed = -1f;
                    //anim2 [animName2].speed = -1f;
                    anim.Blend(animName1, 1, 0);
                    anim2.Blend(animName2, 1, 0);
                } else {
                    //anim [animName1].normalizedTime = 0f;
                    //anim2 [animName2].normalizedTime = 0f;
                    //anim [animName1].speed = 1f;
                    //anim2 [animName2].speed = 1f;
                    //anim.Blend (animName1, 0, 0);
                    //anim2.Blend (animName2, 0, 0);
                    play_down = false;
                }
                //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_increment = GameConstants.baseScienceRate * time_diff / 86400 * electrical_power_ratio * stupidity * global_rate_multipliers * PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed) / ((float)Math.Sqrt(altitude_multiplier));
                    science_to_increment = (double.IsNaN(science_to_increment) || double.IsInfinity(science_to_increment)) ? 0 : science_to_increment;
                    science_to_add += (float)science_to_increment;

                } else if (active_mode == 2) { // Antimatter persistence
                    double now = Planetarium.GetUniversalTime();
                    double time_diff = now - last_active_time;

                    List<PartResource> antimatter_resources = part.GetConnectedResources(InterstellarResourcesConfiguration.Instance.Antimatter).ToList();
                    float currentAntimatter_missing = (float) antimatter_resources.Sum(ar => ar.maxAmount-ar.amount);

                    float total_electrical_power_provided = (float)(electrical_power_ratio * (GameConstants.baseAMFPowerConsumption + GameConstants.basePowerConsumption) * 1E6);
                    double antimatter_mass = total_electrical_power_provided / GameConstants.warpspeed / GameConstants.warpspeed * 1E6 / 20000.0;
                    float antimatter_peristence_to_add = (float)-Math.Min(currentAntimatter_missing, antimatter_mass * time_diff);
                    part.RequestResource("Antimatter", antimatter_peristence_to_add);
                }
            }
        }
コード例 #11
0
ファイル: PlayerAnimation.cs プロジェクト: rbtk/photon-test
 private void blendAnimation(Animation animation, AnimationClip clip)
 {
     if(!animation.IsPlaying(clip.name)) {
         animation.Blend(clip.name, 4f);
     }
 }
コード例 #12
0
 private void lightAnimator(Animation a, string name, bool stop)
 {
     if (!a.IsPlaying(name) && !stop)
     {
         a[name].speed = 1f;
         a[name].normalizedTime = 0f;
         a[name].wrapMode = WrapMode.Loop;
         a.Blend(name);
     }
     else if (stop)
     {
         a[name].normalizedTime = a[name].normalizedTime % 1;
         a[name].wrapMode = WrapMode.Clamp;
     }
 }
コード例 #13
0
 static public int Blend(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 == 2)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             self.Blend(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             self.Blend(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             self.Blend(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function Blend 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
 }
コード例 #14
0
 private bool PlayAnimation(Animation animation, string name)
 {
     bool b = false;
     if(animation != null && name != "" && animation[name] != null)
     {
         if(this.show) animation[name].layer = this.min;
         if(this.playOptions[this.number] == "Play")
         {
             animation.Play(name, this.playMode);
         }
         else if(this.playOptions[this.number] == "CrossFade")
         {
             animation.CrossFade(name, this.time, this.playMode);
         }
         else if(this.playOptions[this.number] == "Blend")
         {
             animation.Blend(name, this.speed, this.time);
         }
         else if(this.playOptions[this.number] == "PlayQueued")
         {
             animation.PlayQueued(name, this.queueMode, this.playMode);
         }
         else if(this.playOptions[this.number] == "CrossFadeQueued")
         {
             animation.CrossFadeQueued(name, this.time, this.queueMode, this.playMode);
         }
         b = true;
     }
     return b;
 }
コード例 #15
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) { 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.Blend (animName, 1, 0);
                } 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(hasrequiredupgrade) {
                    isupgraded = true;
                }
            }

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

            radiatorTempStr = radiatorTemp + "K";
            this.part.force_activate();
        }
コード例 #16
0
 protected void primaryAnimator(float speed, float time, WrapMode wrap, string name, Animation a)
 {
     if (a != null)
     {
         a[name].speed = speed;
         if (!a.IsPlaying(name))
         {
             a[name].wrapMode = wrap;
             a[name].normalizedTime = time;
             a.Blend(name, 1f);
         }
     }
 }
コード例 #17
0
ファイル: FNRadiator.cs プロジェクト: Joeppie/KSPInterstellar
        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;
                //    isupgraded = true;
                //}
                //return;
            }


            FNRadiator.list_of_radiators.Add(this);

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

                if (radiatorIsEnabled)
                {
                    anim.Blend(animName, 1, 0);
                }
                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 | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            //{
            //    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();
        }
コード例 #18
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                return;
            }

            if (isupgraded)
                upgradePartModule();
            else
            {
                if (this.HasTechsRequiredToUpgrade())
                    hasrequiredupgrade = true;
            }

            // update gui names
            Events["BeginResearch"].guiName = beginResearchName;

            reprocessor = new NuclearFuelReprocessor(part);
            anti_factory = new AntimatterFactory(part);
            ConfigNode config = PluginHelper.getPluginSaveFile();

            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 = 1f;
                    //anim2 [animName2].normalizedTime = 1f;
                    //anim [animName1].speed = -1f;
                    //anim2 [animName2].speed = -1f;
                    anim.Blend(animName1, 1, 0);
                    anim2.Blend(animName2, 1, 0);
                }
                else
                {
                    //anim [animName1].normalizedTime = 0f;
                    //anim2 [animName2].normalizedTime = 0f;
                    //anim [animName1].speed = 1f;
                    //anim2 [animName2].speed = 1f;
                    //anim.Blend (animName1, 0, 0);global_rate_multipliers
                    //anim2.Blend (animName2, 0, 0);
                    play_down = false;
                }
                //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 time_diff = Planetarium.GetUniversalTime() - last_active_time;
                    float altitude_multiplier = Math.Max((float)(vessel.altitude / (vessel.mainBody.Radius)), 1);
                    float kerbalResearchSkillFactor = part.protoModuleCrew.Sum(proto_crew_member => GetKerbalScienceFactor(proto_crew_member) / 2f);

                    double science_to_increment = kerbalResearchSkillFactor * GameConstants.baseScienceRate * time_diff
                        / GameConstants.EARH_DAY_SECONDS * electrical_power_ratio * global_rate_multipliers * PluginHelper.getScienceMultiplier(vessel)   //PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed)
                        / ((float)Math.Sqrt(altitude_multiplier));

                    science_to_increment = (double.IsNaN(science_to_increment) || double.IsInfinity(science_to_increment)) ? 0 : science_to_increment;
                    science_to_add += (float)science_to_increment;

                }
                else if (active_mode == 2) // Antimatter persistence
                {
                    double time_diff = Planetarium.GetUniversalTime() - last_active_time;

                    List<PartResource> antimatter_resources = part.GetConnectedResources(InterstellarResourcesConfiguration.Instance.Antimatter).ToList();
                    float currentAntimatter_missing = (float) antimatter_resources.Sum(ar => ar.maxAmount-ar.amount);

                    float total_electrical_power_provided = (float)(electrical_power_ratio * (PluginHelper.BaseAMFPowerConsumption + PluginHelper.BasePowerConsumption) * 1E6);
                    double antimatter_mass = total_electrical_power_provided / GameConstants.warpspeed / GameConstants.warpspeed * 1E6 / 20000.0;
                    float antimatter_peristence_to_add = (float)-Math.Min(currentAntimatter_missing, antimatter_mass * time_diff);
                    part.RequestResource("Antimatter", antimatter_peristence_to_add);
                }
            }
        }
コード例 #19
0
ファイル: FNRefinery.cs プロジェクト: Neouni/KSPInterstellar
        public override void OnStart(PartModule.StartState state) {
            if (state == StartState.Editor) { return; }
            part.force_activate();
            reprocessor = new NuclearFuelReprocessor(part);

            if (part.airlock != null && part.airlock.transform != null) {
                if (part.airlock.transform.gameObject != null) {
                    Destroy(part.airlock.transform.gameObject);
                }
            }

            anim = part.FindModelAnimators(animName).FirstOrDefault();
            if (anim != null) {
                anim[animName].layer = 1;
                if (IsEnabled) {
                    anim.Blend(animName, 2, 0);
                } else {
                    play_down = false;
                    anim[animName].speed = -1f;
                    anim[animName].normalizedTime = 0f;
                    anim.Blend(animName, 0, 1);
                }
            }
        }
コード例 #20
0
 //Controls the main, door-opening animation
 private void animator(float speed, float time, Animation a, string name)
 {
     if (a != null)
     {
         a[name].speed = speed;
         if (!a.IsPlaying(name))
         {
             a[name].normalizedTime = time;
             a.Blend(name, 1f);
         }
     }
 }