コード例 #1
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;
                    isupgraded = 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.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 (!isupgraded) {
				radiatorType = originalName;
			} else {
				radiatorType = upgradedName;
				radiatorTemp = upgradedRadiatorTemp;
			}


			radiatorTempStr = radiatorTemp + "K";
            this.part.force_activate();
		}
コード例 #2
0
 public bool hasTechsRequiredToUpgrade() {
     if (HighLogic.CurrentGame != null) {
         if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) {
             if (upgradeTechReq != null) {
                 if (PluginHelper.hasTech(upgradeTechReq)) {
                     return true;
                 }
             }
         } else {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
 public static bool upgradeAvailable(string techid)
 {
     if (HighLogic.CurrentGame != null)
     {
         if (PluginHelper.TechnologyIsInUse)
         {
             if (techid != null && PluginHelper.hasTech(techid))
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
ファイル: FNRadiator.cs プロジェクト: droric/KSPInterstellar
        public bool hasTechsRequiredToUpgrade()
        {
            if (HighLogic.CurrentGame == null)
            {
                return(false);
            }

            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                return(true);
            }

            if (upgradeTechReq != null && PluginHelper.hasTech(upgradeTechReq))
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
 public AntimatterFactory(Part part)
 {
     this.part = part;
     vessel    = part.vessel;
     if (HighLogic.CurrentGame != null && HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
     {
         if (PluginHelper.hasTech("ultraHighEnergyPhysics"))
         {
             efficiency = efficiency / 100;
         }
         else if (PluginHelper.hasTech("highEnergyScience"))
         {
             efficiency = efficiency / 1000;
         }
         else
         {
             efficiency = efficiency / 10000;
         }
     }
 }
コード例 #6
0
 public static bool upgradeAvailable(string techid)
 {
     if (HighLogic.CurrentGame != null)
     {
         if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
         {
             if (techid != null)
             {
                 if (PluginHelper.hasTech(techid))
                 {
                     return(true);
                 }
             }
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
 public AntimatterFactory(Part part)
 {
     this.part = part;
     vessel    = part.vessel;
     if (HighLogic.CurrentGame != null)
     {
         if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
         {
             if (PluginHelper.hasTech("interstellarTechAntimatterPower"))
             {
             }
             else if (PluginHelper.hasTech("interstellarTechAccelerator"))
             {
                 efficiency = efficiency / 100;
             }
             else
             {
                 efficiency = efficiency / 10000;
             }
         }
     }
 }
コード例 #8
0
        public override string GetInfo()
        {
            bool upgraded = false;

            if (HighLogic.CurrentGame != null)
            {
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
                {
                    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 = 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);
        }
コード例 #9
0
ファイル: FNRadiator.cs プロジェクト: droric/KSPInterstellar
        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";
        }
コード例 #10
0
        public override void OnStart(PartModule.StartState state)
        {
            exoticResourceDefinition = PartResourceLibrary.Instance.GetDefinition(InterstellarResourcesConfiguration.Instance.ExoticMatter);
            var exoticMatterResource = part.Resources[InterstellarResourcesConfiguration.Instance.ExoticMatter];

            // reset Exotic Matter Capacity
            if (exoticMatterResource != null)
            {
                part.mass = partMass;
                var ratio = Math.Min(1, Math.Max(0, exoticMatterResource.amount / exoticMatterResource.maxAmount));
                exoticMatterResource.maxAmount = 0.001;
                exoticMatterResource.amount    = exoticMatterResource.maxAmount * ratio;
            }

            InstanceID = GetInstanceID();

            if (IsSlave)
            {
                UnityEngine.Debug.Log("KSPI - AlcubierreDrive Slave " + InstanceID + " Started");
            }
            else
            {
                UnityEngine.Debug.Log("KSPI - AlcubierreDrive Master " + InstanceID + " Started");
            }

            if (!String.IsNullOrEmpty(AnimationName))
            {
                animationState = SetUpAnimation(AnimationName, this.part);
            }

            try
            {
                Events["StartCharging"].active       = !IsSlave;
                Events["StopCharging"].active        = !IsSlave;
                Events["ActivateWarpDrive"].active   = !IsSlave;
                Events["DeactivateWarpDrive"].active = !IsSlave;
                Events["ToggleWarpSpeedUp"].active   = !IsSlave;
                Events["ToggleWarpSpeedDown"].active = !IsSlave;
                Events["ReduceWarpPower"].active     = !IsSlave;

                Fields["exotic_power_required"].guiActive     = !IsSlave;
                Fields["WarpEngineThrottle"].guiActive        = !IsSlave;
                Fields["maximumAllowedWarpThrotle"].guiActive = !IsSlave;
                Fields["warpToMassRatio"].guiActive           = !IsSlave;
                Fields["vesselTotalMass"].guiActive           = !IsSlave;
                Fields["DriveStatus"].guiActive = !IsSlave;
                Fields["minPowerRequirementForLightSpeed"].guiActive            = !IsSlave;
                Fields["currentPowerRequirementForWarp"].guiActive              = !IsSlave;
                Fields["sumOfAlcubierreDrives"].guiActive                       = !IsSlave;
                Fields["PowerRequirementForMaximumAllowedLightSpeed"].guiActive = !IsSlave;

                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["ToggleWarpSpeedUpAction"].guiName   = Events["ToggleWarpSpeedUp"].guiName = String.Format("Warp Speed (+)");
                Actions["ToggleWarpSpeedDownAction"].guiName = Events["ToggleWarpSpeedDown"].guiName = String.Format("Warp Speed (-)");

                minimum_selected_factor = engine_throtle.ToList().IndexOf(engine_throtle.First(w => w == 1f));
                if (selected_factor == -1)
                {
                    selected_factor = minimum_selected_factor;
                }

                if (state == StartState.Editor)
                {
                    return;
                }

                if (!IsSlave)
                {
                    UnityEngine.Debug.Log("KSPI - AlcubierreDrive Create Slaves");
                    alcubierreDrives = part.vessel.FindPartModulesImplementing <AlcubierreDrive>();
                    foreach (var drive in alcubierreDrives)
                    {
                        var driveId = drive.GetInstanceID();
                        if (driveId != InstanceID)
                        {
                            drive.IsSlave = true;
                            UnityEngine.Debug.Log("KSPI - AlcubierreDrive " + driveId + " != " + InstanceID);
                        }
                    }
                }

                UnityEngine.Debug.Log("KSPI - AlcubierreDrive OnStart step C ");

                this.part.force_activate();
                if (serialisedwarpvector != null)
                {
                    heading_act = ConfigNode.ParseVector3D(serialisedwarpvector);
                }

                warp_effect  = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                warp_effect2 = GameObject.CreatePrimitive(PrimitiveType.Cylinder);

                warp_effect1_renderer = warp_effect.GetComponent <Renderer>();
                warp_effect2_renderer = warp_effect2.GetComponent <Renderer>();

                warp_effect1_collider = warp_effect.GetComponent <Collider>();
                warp_effect2_collider = warp_effect2.GetComponent <Collider>();

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

                warp_effect1_renderer.material.shader = Shader.Find("Unlit/Transparent");
                warp_effect2_renderer.material.shader = Shader.Find("Unlit/Transparent");

                warp_textures = new Texture[33];

                const string warp_tecture_path = "WarpPlugin/ParticleFX/warp";
                for (int i = 0; i < 11; i++)
                {
                    warp_textures[i] = GameDatabase.Instance.GetTexture((i > 0)
                        ? warp_tecture_path + (i + 1).ToString()
                        : warp_tecture_path, false);
                }

                warp_textures[11] = GameDatabase.Instance.GetTexture("WarpPlugin/ParticleFX/warp10", false);
                for (int i = 12; i < 33; i++)
                {
                    int j = i > 17 ? 34 - i : i;
                    warp_textures[i] = GameDatabase.Instance.GetTexture(j > 1 ?
                                                                        warp_tecture_path + (j + 1).ToString() : warp_tecture_path, false);
                }

                warp_textures2 = new Texture[33];

                const string warpr_tecture_path = "WarpPlugin/ParticleFX/warpr";
                for (int i = 0; i < 11; i++)
                {
                    warp_textures2[i] = GameDatabase.Instance.GetTexture((i > 0)
                        ? warpr_tecture_path + (i + 1).ToString()
                        : warpr_tecture_path, false);
                }

                warp_textures2[11] = GameDatabase.Instance.GetTexture("WarpPlugin/ParticleFX/warpr10", false);
                for (int i = 12; i < 33; i++)
                {
                    int j = i > 17 ? 34 - i : i;
                    warp_textures2[i] = GameDatabase.Instance.GetTexture(j > 1 ?
                                                                         warpr_tecture_path + (j + 1).ToString() : warpr_tecture_path, false);
                }

                warp_effect1_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_effect1_renderer.material.mainTexture = warp_textures[0];
                warp_effect1_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_effect1_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("WarpPlugin/Sounds/warp_sound");
                warp_sound.volume = GameSettings.SHIP_VOLUME;

                //warp_sound.panLevel = 0;
                warp_sound.panStereo   = 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)
                {
                    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;
                }
                else
                {
                    warpdriveType = originalName;
                }

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

                // disable charging at startup
                //IsCharging = false;
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("[KSPI] - AlcubierreDrive OnStart 1 Exception " + e.Message);
            }

            warpdriveType = originalName;
        }
コード例 #11
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];

            const string warp_tecture_path = "WarpPlugin/ParticleFX/warp";

            for (int i = 0; i < 11; i++)
            {
                warp_textures[i] = GameDatabase.Instance.GetTexture((i > 0) ?
                                                                    warp_tecture_path + (i + 1).ToString() : warp_tecture_path, false);
            }
            warp_textures[11] = GameDatabase.Instance.GetTexture("WarpPlugin/ParticleFX/warp10", false);
            for (int i = 12; i < 33; i++)
            {
                int j = i > 17 ? 34 - i : i;
                warp_textures[i] = GameDatabase.Instance.GetTexture(j > 1 ?
                                                                    warp_tecture_path + (j + 1).ToString() : warp_tecture_path, false);
            }

            warp_textures2 = new Texture[33];

            const string warpr_tecture_path = "WarpPlugin/ParticleFX/warpr";

            for (int i = 0; i < 11; i++)
            {
                warp_textures2[i] = GameDatabase.Instance.GetTexture((i > 0) ?
                                                                     warpr_tecture_path + (i + 1).ToString() : warpr_tecture_path, false);
            }
            warp_textures2[11] = GameDatabase.Instance.GetTexture("WarpPlugin/ParticleFX/warpr10", false);
            for (int i = 12; i < 33; i++)
            {
                int j = i > 17 ? 34 - i : i;
                warp_textures2[i] = GameDatabase.Instance.GetTexture(j > 1 ?
                                                                     warpr_tecture_path + (j + 1).ToString() : warpr_tecture_path, 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("WarpPlugin/Sounds/warp_sound");
            warp_sound.volume      = GameSettings.SHIP_VOLUME;
            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)
            {
                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;
        }
コード例 #12
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                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();
        }
コード例 #13
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)
            {
                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();
        }