Guest User

activateWithAirspeed_ModSettings.cs

a guest
Jun 6th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using SPModSettings;
  5.  
  6. public class ActivateWithAirspeed_ModSettings : MonoBehaviour
  7.  
  8. {
  9.     private bool FXON; //if the game object (FX for reentry) is enabled or not
  10.     public GameObject EnableDisableObj; //the empty or whatever you what to toggle
  11.     public float ActivationSpeed = 1000; //speed in m/s of activation
  12.  
  13.     //MOD SETTINGS
  14.     IModSettingsPage ReEntrySettings;
  15.     IModSetting ActivationSpeedMS;
  16.     // Start is called before the first frame update
  17.     void Start()
  18.     {
  19.  
  20.     }
  21.  
  22.     // Update is called once per frame
  23.     void Update()
  24.     {
  25.  
  26.  
  27.         //check the plane's speed and see if its enough to activate the particles
  28.         if (ServiceProvider.Instance.PlayerAircraft.Airspeed >= ActivationSpeed)
  29.         {
  30.             FXON = true; //if it is, turn on FX
  31.         }
  32.         else
  33.         {
  34.             FXON = false; //if it isn't make sure FX is off
  35.         }
  36.  
  37.         //if the FX bool is on, activate the particles or whatever
  38.         if (FXON == true)
  39.         {
  40.             EnableDisableObj.SetActive(true);
  41.         }
  42.         //if the FX bool is off, make sure particles aren't on or whatver
  43.         if (FXON == false)
  44.         {
  45.             EnableDisableObj.SetActive(false);
  46.         }
  47.  
  48.         //From AntiGravity ModSettings docs, by HellFireKoder
  49.         //Mod settings- waits until settings load
  50.         if (!ModSettingsHandler.ModSettingsReady)
  51.         {   // if the mod settings aren't ready to generate settings, wait
  52.             return;
  53.         }
  54.        
  55.         if (ReEntrySettings == null || ReEntrySettings.Equals(null))
  56.         {   // if we have no settings page\
  57.  
  58.             ReEntrySettings = ModSettingsHandler.AddSettingsPage("ReEntrySettings", "ReEntry Settings", "Setting for Re-Entry FX activation speed"); // generate page
  59.             ActivationSpeedMS = ModSettingsHandler.AddSettingToPage(ReEntrySettings, "ActivationSpeed", "ActivationSpeed", ModSettingTypes.Numeric, 1000.ToString());// and settings
  60.             SPModSettings.ModSettingsHandler.LoadSettingsForPage(ReEntrySettings); // load saved settings (if they've been saved before, otherwise defaults)
  61.        
  62.            
  63.         }
  64.         ReEntrySettings.GenerateSettingsXML();
  65.        
  66.         ActivationSpeed = float.Parse(ActivationSpeedMS.Value); //give the setting value to the variable as a float
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment