public bool hasTechsRequiredToUpgrade()
 {
     if (HighLogic.CurrentGame != null)
     {
         if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
         {
             if (upgradeTechReq != null)
             {
                 if (PluginHelper.hasTech(upgradeTechReq))
                 {
                     return(true);
                 }
             }
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
 public AntimatterFactory(Part part)
 {
     this.part = part;
     vessel    = part.vessel;
     if (HighLogic.CurrentGame != null)
     {
         if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
         {
             if (PluginHelper.hasTech("interstellarTechAntimatterPower"))
             {
             }
             else if (PluginHelper.hasTech("interstellarTechAccelerator"))
             {
                 efficiency = efficiency / 100;
             }
             else
             {
                 efficiency = efficiency / 10000;
             }
         }
     }
 }
예제 #3
0
        public override string GetInfo()
        {
            bool upgraded = false;

            if (HighLogic.CurrentGame != null)
            {
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
                {
                    if (PluginHelper.hasTech(upgradeTechReq))
                    {
                        upgraded = true;
                    }
                }
                else
                {
                    upgraded = true;
                }
            }
            else
            {
                upgraded = false;
            }
            ConfigNode[] prop_nodes    = getPropellants(upgraded);
            string       return_str    = "Max Power Consumption: " + maxPower.ToString("") + " MW\n";
            float        thrust_per_mw = isThrusterElectrothermal ? 0.051425f : 0.013089f;

            foreach (ConfigNode propellant_node in prop_nodes)
            {
                float  ispMultiplier = float.Parse(propellant_node.GetValue("ispMultiplier"));
                float  ispProp       = initialIsp * ispMultiplier;
                float  thrustProp    = thrust_per_mw / ispMultiplier;
                string guiname       = propellant_node.GetValue("guiName");
                return_str = return_str + "--" + guiname + "--\n" + "Thrust: " + thrustProp.ToString("0.0000") + " kN per MW\n" + "ISP: " + ispProp.ToString("0.0") + "s\n";
            }
            return(return_str);
        }
예제 #4
0
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;

            base.OnStart(state);

            Actions["TogglePropellantAction"].guiName = Events["TogglePropellant"].guiName = String.Format("Toggle Propellant");

            if (state == StartState.Editor)
            {
                return;
            }
            //this.part.force_activate();

            fuel_gauge = part.stackIcon.DisplayInfo();


            var curEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;

            if (curEngine != null)
            {
                initial_thrust = curEngine.maxThrust;
                initialIsp     = curEngine.atmosphereCurve.Evaluate(0);
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                if (upgradeTechReq != null)
                {
                    if (PluginHelper.hasTech(upgradeTechReq))
                    {
                        hasrequiredupgrade = true;
                    }
                    else if (upgradeTechReq == "none")
                    {
                        manual_upgrade = true;
                    }
                }
                else
                {
                    manual_upgrade = true;
                }
            }
            else
            {
                hasrequiredupgrade = true;
            }

            if (engineInit == false)
            {
                engineInit = true;
                if (hasrequiredupgrade && upgradeCost > 0)
                {
                    isupgraded = true;
                    ConfigNode node = new ConfigNode("RESOURCE");
                    node.AddValue("name", "VacuumPlasma");
                    node.AddValue("maxAmount", 10);
                    node.AddValue("amount", 10);
                    part.AddResource(node);
                    fuel_mode = 0;
                }
            }

            propellants = getPropellants(isupgraded);

            if (manual_upgrade)
            {
                hasrequiredupgrade = true;
            }

            if (isupgraded)
            {
                engineType = upgradedName;
            }
            else
            {
                engineType = originalName;
            }


            evaluateMaxThrust();
        }
예제 #5
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                if (upgradeTechReq != null)
                {
                    if (PluginHelper.hasTech(upgradeTechReq))
                    {
                        hasrequiredupgrade = true;
                    }
                    else if (upgradeTechReq == "none")
                    {
                        manual_upgrade = true;
                    }
                }
                else
                {
                    manual_upgrade = true;
                }
            }
            else
            {
                hasrequiredupgrade = true;
            }

            if (coreInit == false)
            {
                coreInit = true;
                if (hasrequiredupgrade)
                {
                    isupgraded = true;
                }
            }

            if (manual_upgrade)
            {
                hasrequiredupgrade = true;
            }

            if (isupgraded)
            {
                computercoreType = upgradedName;
                if (nameStr == "")
                {
                    ConfigNode[] namelist = ComputerCore.getNames();
                    Random       rands    = new Random();
                    ConfigNode   myName   = namelist[rands.Next(0, namelist.Length)];
                    nameStr = myName.GetValue("name");
                }

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

                double science_to_add = baseScienceRate * time_diff / 86400 * electrical_power_ratio * PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed) / ((float)Math.Sqrt(altitude_multiplier));
                science_awaiting_addition = science_to_add;

                var curReaction = this.part.Modules["ModuleReactionWheel"] as ModuleReactionWheel;
                curReaction.PitchTorque = 5;
                curReaction.RollTorque  = 5;
                curReaction.YawTorque   = 5;
            }
            else
            {
                computercoreType = originalName;
            }


            this.part.force_activate();
        }
예제 #6
0
        public override void OnStart(PartModule.StartState state)
        {
            Actions["StartChargingAction"].guiName       = Events["StartCharging"].guiName = String.Format("Start Charging");
            Actions["StopChargingAction"].guiName        = Events["StopCharging"].guiName = String.Format("Stop Charging");
            Actions["ToggleChargingAction"].guiName      = String.Format("Toggle Charging");
            Actions["ActivateWarpDriveAction"].guiName   = Events["ActivateWarpDrive"].guiName = String.Format("Activate Warp Drive");
            Actions["DeactivateWarpDriveAction"].guiName = Events["DeactivateWarpDrive"].guiName = String.Format("Deactivate Warp Drive");
            Actions["ToggleWarpSpeedAction"].guiName     = Events["ToggleWarpSpeed"].guiName = String.Format("Warp Speed (+)");
            Actions["ToggleWarpSpeedDownAction"].guiName = Events["ToggleWarpSpeedDown"].guiName = String.Format("Warp Speed (-)");
            if (state == StartState.Editor)
            {
                return;
            }
            this.part.force_activate();
            if (serialisedwarpvector != null)
            {
                heading_act = ConfigNode.ParseVector3D(serialisedwarpvector);
            }


            warp_effect2 = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            warp_effect  = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            warp_effect.collider.enabled  = false;
            warp_effect2.collider.enabled = false;
            Vector3 ship_pos     = new Vector3(part.transform.position.x, part.transform.position.y, part.transform.position.z);
            Vector3 end_beam_pos = ship_pos + transform.up * warp_size;
            Vector3 mid_pos      = (ship_pos - end_beam_pos) / 2.0f;

            warp_effect.transform.localScale  = new Vector3(effectSize1, mid_pos.magnitude, effectSize1);
            warp_effect.transform.position    = new Vector3(mid_pos.x, ship_pos.y + mid_pos.y, mid_pos.z);
            warp_effect.transform.rotation    = part.transform.rotation;
            warp_effect2.transform.localScale = new Vector3(effectSize2, mid_pos.magnitude, effectSize2);
            warp_effect2.transform.position   = new Vector3(mid_pos.x, ship_pos.y + mid_pos.y, mid_pos.z);
            warp_effect2.transform.rotation   = part.transform.rotation;
            //warp_effect.layer = LayerMask.NameToLayer("Ignore Raycast");
            //warp_effect.renderer.material = new Material(KSP.IO.File.ReadAllText<AlcubierreDrive>("AlphaSelfIllum.shader"));
            //KSP.IO.File.
            warp_effect.renderer.material.shader  = Shader.Find("Unlit/Transparent");
            warp_effect2.renderer.material.shader = Shader.Find("Unlit/Transparent");

            warp_textures     = new Texture[33];
            warp_textures[0]  = GameDatabase.Instance.GetTexture("Interstellar/warp", false);
            warp_textures[1]  = GameDatabase.Instance.GetTexture("Interstellar/warp2", false);
            warp_textures[2]  = GameDatabase.Instance.GetTexture("Interstellar/warp3", false);
            warp_textures[3]  = GameDatabase.Instance.GetTexture("Interstellar/warp4", false);
            warp_textures[4]  = GameDatabase.Instance.GetTexture("Interstellar/warp5", false);
            warp_textures[5]  = GameDatabase.Instance.GetTexture("Interstellar/warp6", false);
            warp_textures[6]  = GameDatabase.Instance.GetTexture("Interstellar/warp7", false);
            warp_textures[7]  = GameDatabase.Instance.GetTexture("Interstellar/warp8", false);
            warp_textures[8]  = GameDatabase.Instance.GetTexture("Interstellar/warp9", false);
            warp_textures[9]  = GameDatabase.Instance.GetTexture("Interstellar/warp10", false);
            warp_textures[10] = GameDatabase.Instance.GetTexture("Interstellar/warp11", false);
            warp_textures[11] = GameDatabase.Instance.GetTexture("Interstellar/warp10", false);
            warp_textures[12] = GameDatabase.Instance.GetTexture("Interstellar/warp11", false);
            warp_textures[13] = GameDatabase.Instance.GetTexture("Interstellar/warp12", false);
            warp_textures[14] = GameDatabase.Instance.GetTexture("Interstellar/warp13", false);
            warp_textures[15] = GameDatabase.Instance.GetTexture("Interstellar/warp14", false);
            warp_textures[16] = GameDatabase.Instance.GetTexture("Interstellar/warp15", false);
            warp_textures[17] = GameDatabase.Instance.GetTexture("Interstellar/warp16", false);
            warp_textures[18] = GameDatabase.Instance.GetTexture("Interstellar/warp15", false);
            warp_textures[19] = GameDatabase.Instance.GetTexture("Interstellar/warp14", false);
            warp_textures[20] = GameDatabase.Instance.GetTexture("Interstellar/warp13", false);
            warp_textures[21] = GameDatabase.Instance.GetTexture("Interstellar/warp12", false);
            warp_textures[22] = GameDatabase.Instance.GetTexture("Interstellar/warp11", false);
            warp_textures[23] = GameDatabase.Instance.GetTexture("Interstellar/warp10", false);
            warp_textures[24] = GameDatabase.Instance.GetTexture("Interstellar/warp9", false);
            warp_textures[25] = GameDatabase.Instance.GetTexture("Interstellar/warp8", false);
            warp_textures[26] = GameDatabase.Instance.GetTexture("Interstellar/warp7", false);
            warp_textures[27] = GameDatabase.Instance.GetTexture("Interstellar/warp6", false);
            warp_textures[28] = GameDatabase.Instance.GetTexture("Interstellar/warp5", false);
            warp_textures[29] = GameDatabase.Instance.GetTexture("Interstellar/warp4", false);
            warp_textures[30] = GameDatabase.Instance.GetTexture("Interstellar/warp3", false);
            warp_textures[31] = GameDatabase.Instance.GetTexture("Interstellar/warp2", false);
            warp_textures[32] = GameDatabase.Instance.GetTexture("Interstellar/warp", false);

            warp_textures2     = new Texture[33];
            warp_textures2[0]  = GameDatabase.Instance.GetTexture("Interstellar/warpr", false);
            warp_textures2[1]  = GameDatabase.Instance.GetTexture("Interstellar/warpr2", false);
            warp_textures2[2]  = GameDatabase.Instance.GetTexture("Interstellar/warpr3", false);
            warp_textures2[3]  = GameDatabase.Instance.GetTexture("Interstellar/warpr4", false);
            warp_textures2[4]  = GameDatabase.Instance.GetTexture("Interstellar/warpr5", false);
            warp_textures2[5]  = GameDatabase.Instance.GetTexture("Interstellar/warpr6", false);
            warp_textures2[6]  = GameDatabase.Instance.GetTexture("Interstellar/warpr7", false);
            warp_textures2[7]  = GameDatabase.Instance.GetTexture("Interstellar/warpr8", false);
            warp_textures2[8]  = GameDatabase.Instance.GetTexture("Interstellar/warpr9", false);
            warp_textures2[9]  = GameDatabase.Instance.GetTexture("Interstellar/warpr10", false);
            warp_textures2[10] = GameDatabase.Instance.GetTexture("Interstellar/warpr11", false);
            warp_textures2[11] = GameDatabase.Instance.GetTexture("Interstellar/warpr10", false);
            warp_textures2[12] = GameDatabase.Instance.GetTexture("Interstellar/warpr11", false);
            warp_textures2[13] = GameDatabase.Instance.GetTexture("Interstellar/warpr12", false);
            warp_textures2[14] = GameDatabase.Instance.GetTexture("Interstellar/warpr13", false);
            warp_textures2[15] = GameDatabase.Instance.GetTexture("Interstellar/warpr14", false);
            warp_textures2[16] = GameDatabase.Instance.GetTexture("Interstellar/warpr15", false);
            warp_textures2[17] = GameDatabase.Instance.GetTexture("Interstellar/warpr16", false);
            warp_textures2[18] = GameDatabase.Instance.GetTexture("Interstellar/warpr15", false);
            warp_textures2[19] = GameDatabase.Instance.GetTexture("Interstellar/warpr14", false);
            warp_textures2[20] = GameDatabase.Instance.GetTexture("Interstellar/warpr13", false);
            warp_textures2[21] = GameDatabase.Instance.GetTexture("Interstellar/warpr12", false);
            warp_textures2[22] = GameDatabase.Instance.GetTexture("Interstellar/warpr11", false);
            warp_textures2[23] = GameDatabase.Instance.GetTexture("Interstellar/warpr10", false);
            warp_textures2[24] = GameDatabase.Instance.GetTexture("Interstellar/warpr9", false);
            warp_textures2[25] = GameDatabase.Instance.GetTexture("Interstellar/warpr8", false);
            warp_textures2[26] = GameDatabase.Instance.GetTexture("Interstellar/warpr7", false);
            warp_textures2[27] = GameDatabase.Instance.GetTexture("Interstellar/warpr6", false);
            warp_textures2[28] = GameDatabase.Instance.GetTexture("Interstellar/warpr5", false);
            warp_textures2[29] = GameDatabase.Instance.GetTexture("Interstellar/warpr4", false);
            warp_textures2[30] = GameDatabase.Instance.GetTexture("Interstellar/warpr3", false);
            warp_textures2[31] = GameDatabase.Instance.GetTexture("Interstellar/warpr2", false);
            warp_textures2[32] = GameDatabase.Instance.GetTexture("Interstellar/warpr", false);



            warp_effect.renderer.material.color       = new Color(Color.cyan.r, Color.cyan.g, Color.cyan.b, 0.5f);
            warp_effect2.renderer.material.color      = new Color(Color.red.r, Color.red.g, Color.red.b, 0.1f);
            warp_effect.renderer.material.mainTexture = warp_textures[0];
            warp_effect.renderer.receiveShadows       = false;
            //warp_effect.layer = LayerMask.NameToLayer ("Ignore Raycast");
            //warp_effect.collider.isTrigger = true;
            warp_effect2.renderer.material.mainTexture       = warp_textures2[0];
            warp_effect2.renderer.receiveShadows             = false;
            warp_effect2.renderer.material.mainTextureOffset = new Vector2(-0.2f, -0.2f);
            //warp_effect2.layer = LayerMask.NameToLayer ("Ignore Raycast");
            //warp_effect2.collider.isTrigger = true;
            warp_effect2.renderer.material.renderQueue = 1000;
            warp_effect.renderer.material.renderQueue  = 1001;

            /*gameObject.AddComponent<Light>();
             * gameObject.light.color = Color.cyan;
             * gameObject.light.intensity = 1f;
             * gameObject.light.range = 4000f;
             * gameObject.light.type = LightType.Spot;
             * gameObject.light.transform.position = end_beam_pos;
             * gameObject.light.cullingMask = ~0;*/

            //light.

            warp_sound             = gameObject.AddComponent <AudioSource>();
            warp_sound.clip        = GameDatabase.Instance.GetAudioClip("Interstellar/Sounds/warp_sound");
            warp_sound.volume      = 1;
            warp_sound.panLevel    = 0;
            warp_sound.rolloffMode = AudioRolloffMode.Linear;
            warp_sound.Stop();

            if (IsEnabled)
            {
                warp_sound.Play();
                warp_sound.loop = true;
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                if (upgradeTechReq != null)
                {
                    if (PluginHelper.hasTech(upgradeTechReq))
                    {
                        hasrequiredupgrade = true;
                    }
                    else if (upgradeTechReq == "none")
                    {
                        manual_upgrade = true;
                    }
                }
                else
                {
                    manual_upgrade = true;
                }
            }
            else
            {
                hasrequiredupgrade = true;
            }

            if (warpInit == false)
            {
                warpInit = true;
                if (hasrequiredupgrade)
                {
                    isupgraded = true;
                }
            }

            if (manual_upgrade)
            {
                hasrequiredupgrade = true;
            }

            if (isupgraded)
            {
                warpdriveType = upgradedName;
                mass_divisor  = 40f;
            }
            else
            {
                warpdriveType = originalName;
                mass_divisor  = 10f;
            }

            //warp_effect.transform.localScale.y = 2.5f;
            //warp_effect.transform.localScale.z = 200f;
        }