public override void OnStart(StartState state) { Personaliser personaliser = Personaliser.instance; if (!isInitialised) { if (!personaliser.isAtmSuitEnabled) { Events.First().active = false; hasEvaSuit = true; } isInitialised = true; } if (!personaliser.personaliseEva(part, hasEvaSuit)) { hasEvaSuit = true; } if (Reflections.instance.isVisorReflectionEnabled && Reflections.instance.reflectionType == Reflections.Type.REAL) { reflectionScript = new Reflections.Script(part, 1); reflectionScript.setActive(hasEvaSuit); } }
public override void OnStart(StartState state) { var reflections = Reflections.Instance; Shader reflectiveShader = shader.Length == 0 ? null : Shader.Find(shader); Color reflectionColour = Color.white; int updateInterval = 1; Util.Parse(colour, ref reflectionColour); Util.Parse(interval, ref updateInterval); updateInterval = Math.Max(updateInterval, 1); List <string> meshNames = Util.SplitConfigValue(meshes).ToList(); if (reflections.LogReflectiveMeshes) { log.Print("Part \"{0}\"", part.name); } if (reflections.ReflectionType == Reflections.Type.None) { return; } script = new Reflections.Script(part, updateInterval); bool success = false; foreach (MeshFilter meshFilter in part.FindModelComponents <MeshFilter>()) { var renderer = meshFilter.GetComponent <Renderer>(); if (renderer == null) { continue; } Material material = renderer.material; if (reflections.LogReflectiveMeshes) { log.Print("+ {0} [{1}]", meshFilter.name, material.shader.name); } if (meshNames.Count == 0 || meshNames.Contains(meshFilter.name)) { success |= script.Apply(material, reflectiveShader, reflectionColour); } } if (!success) { script?.Destroy(); script = null; log.Print("Failed to replace any shader on \"{0}\" with its reflective counterpart", part.name); } }
public override void OnStart(StartState state) { bool useEvaSuit = false; ProtoCrewMember kerbal = part.protoModuleCrew.FirstOrDefault(); if (kerbal != null) { var kerbalEva = GetComponent <KerbalEVA>(); useEvaSuit = kerbal.hasHelmetOn || !kerbalEva.CanEVAWithoutHelmet(); Personaliser.Instance.PersonaliseEva(part, kerbal, useEvaSuit); } if (Reflections.Instance.ReflectionType == Reflections.Type.Real) { reflectionScript = new Reflections.Script(part, 1); reflectionScript.SetActive(useEvaSuit); } }
public override void OnStart(StartState state) { Personaliser personaliser = Personaliser.instance; if (!isInitialised) { if (!personaliser.isAtmSuitEnabled) { Events.First().active = false; hasEvaSuit = true; } isInitialised = true; } if (!personaliser.personaliseEva(part, hasEvaSuit)) hasEvaSuit = true; if (Reflections.instance.isVisorReflectionEnabled && Reflections.instance.reflectionType == Reflections.Type.REAL) { reflectionScript = new Reflections.Script(part, 1); reflectionScript.setActive(hasEvaSuit); } }
public override void OnStart(StartState state) { Reflections reflections = Reflections.instance; Shader reflectiveShader = shader.Length == 0 ? null : Shader.Find(shader); Color reflectionColour = new Color(0.5f, 0.5f, 0.5f); int updateInterval = 1; Util.parse(ReflectionColor, ref reflectionColour); Util.parse(colour, ref reflectionColour); Util.parse(interval, ref updateInterval); updateInterval = Math.Max(updateInterval, 1); List <string> meshNames = Util.splitConfigValue(meshes).ToList(); if (MeshesToChange != "all") { meshNames.AddUniqueRange(Util.splitConfigValue(MeshesToChange)); } if (reflections.reflectionType == Reflections.Type.NONE) { return; } if (reflections.reflectionType == Reflections.Type.REAL) { script = new Reflections.Script(part, updateInterval); } if (reflections.logReflectiveMeshes) { Util.log("Part \"{0}\"", part.name); } bool success = false; foreach (MeshFilter meshFilter in part.FindModelComponents <MeshFilter>()) { if (meshFilter.renderer == null) { continue; } Material material = meshFilter.renderer.material; if (reflections.logReflectiveMeshes) { Util.log("+ {0} [{1}]", meshFilter.name, material.shader.name); } if (meshNames.Count == 0 || meshNames.Contains(meshFilter.name)) { success |= script == null? reflections.applyStatic(material, reflectiveShader, reflectionColour) : script.apply(material, reflectiveShader, reflectionColour); } } if (!success) { if (script != null) { script.destroy(); script = null; } Util.log("Failed to replace any shader on \"{0}\" with its reflective counterpart", part.name); } }
public override void OnStart(StartState state) { Reflections reflections = Reflections.instance; Shader reflectiveShader = shader.Length == 0 ? null : Shader.Find(shader); Color reflectionColour = new Color(0.5f, 0.5f, 0.5f); int updateInterval = 1; Util.parse(ReflectionColor, ref reflectionColour); Util.parse(colour, ref reflectionColour); Util.parse(interval, ref updateInterval); updateInterval = Math.Max(updateInterval, 1); List<string> meshNames = Util.splitConfigValue(meshes).ToList(); if (MeshesToChange != "all") meshNames.AddUniqueRange(Util.splitConfigValue(MeshesToChange)); if (reflections.reflectionType == Reflections.Type.NONE) return; if (reflections.reflectionType == Reflections.Type.REAL) script = new Reflections.Script(part, updateInterval); if (reflections.logReflectiveMeshes) Util.log("Part \"{0}\"", part.name); bool success = false; foreach (MeshFilter meshFilter in part.FindModelComponents<MeshFilter>()) { if (meshFilter.renderer == null) continue; Material material = meshFilter.renderer.material; if (reflections.logReflectiveMeshes) Util.log("+ {0} [{1}]", meshFilter.name, material.shader.name); if (meshNames.Count == 0 || meshNames.Contains(meshFilter.name)) { success |= script == null ? reflections.applyStatic(material, reflectiveShader, reflectionColour) : script.apply(material, reflectiveShader, reflectionColour); } } if (!success) { if (script != null) { script.destroy(); script = null; } Util.log("Failed to replace any shader on \"{0}\" with its reflective counterpart", part.name); } }