예제 #1
0
 // return true if the helmet is visible
 public static bool HasHelmet(KerbalEVA kerbal)
 {
   foreach(var comp in kerbal.GetComponentsInChildren<Renderer>())
   {
     if (comp.name == "helmet") return comp.enabled;
   }
   return false;
 }
예제 #2
0
 // set helmet of a kerbal
 public static void SetHelmet(KerbalEVA kerbal, bool b)
 {
   foreach (var comp in kerbal.GetComponentsInChildren<Renderer>())
   {
     if (comp.name == "helmet" || comp.name == "visor" || comp.name == "flare1" || comp.name == "flare2")
     {
       comp.enabled = b;
     }
   }
 }
예제 #3
0
 // set helmet flares of a kerbal
 public static void SetFlares(KerbalEVA kerbal, bool b)
 {
   foreach(var comp in kerbal.GetComponentsInChildren<UnityEngine.Renderer>())
   {
     if (comp.name == "flare1" || comp.name == "flare2")
     {
       comp.enabled = b;
     }
   }
 }
예제 #4
0
  // set helmet of a kerbal
  public static void SetHelmet(KerbalEVA kerbal, bool b)
  {
    // do not touch the helmet if the user has KIS installed
    if (Kerbalism.detected_mods.KIS) return;

    foreach (var comp in kerbal.GetComponentsInChildren<Renderer>())
    {
      if (comp.name == "helmet" || comp.name == "visor" || comp.name == "flare1" || comp.name == "flare2")
      {
        comp.enabled = b;
      }
    }
  }
예제 #5
0
		// set headlamps on/off
		public static void HeadLamps(KerbalEVA kerbal, bool b)
		{
			// set the lights intensity
			kerbal.headLamp.GetComponent<Light>().intensity = b ? 1.0f : 0.0f;

			// set the flare effects
			foreach (var comp in kerbal.GetComponentsInChildren<Renderer>())
			{
				if (comp.name == "flare1" || comp.name == "flare2")
				{
					comp.enabled = b;
				}
			}
		}
예제 #6
0
        /// <summary>
        /// Enable you to remove the helmet.
        /// </summary>
        /// <param name="eva"></param>
        /// <param name="showHelmet"></param>
        public static void ShowHelmet(this KerbalEVA eva, bool showHelmet)
        {
            foreach (Renderer renderer in eva.GetComponentsInChildren <Renderer>())
            {
                var smr = renderer as SkinnedMeshRenderer;

                if (smr != null)
                {
                    switch (smr.name)
                    {
                    case "helmet":
                    {
                        if (helmetMesh == null)
                        {
                            helmetMesh = smr.sharedMesh;
                        }

                        smr.sharedMesh = showHelmet ? helmetMesh : null;
                    }
                    break;

                    case "visor":
                    {
                        if (visorMesh == null)
                        {
                            visorMesh = smr.sharedMesh;
                        }

                        smr.sharedMesh = showHelmet ? visorMesh : null;
                    }
                    break;
                    }
                }
            }

            if (!showHelmet)
            {
                eva.TurnLamp(false);
            }
        }