public CubemapWrapper(string value, Texture2D[] textures, TextureTypeEnum cubeType, bool mipmaps, bool readable) { this.name = value; type = cubeType == TextureTypeEnum.RGB2_CubeMap? TextureTypeEnum.RGB2_CubeMap : TextureTypeEnum.CubeMap; KSPLog.print("[EVE] Creating " + name + " Cubemap"); foreach (Texture2D tex in textures) { tex.wrapMode = TextureWrapMode.Clamp; } if (type == TextureTypeEnum.RGB2_CubeMap) { texPositive = textures[0]; texNegative = textures[1]; } else { /* * cubeTex = new Cubemap(textures[0].width, TextureFormat.RGBA32, mipmaps); * * foreach (CubemapFace face in Enum.GetValues(typeof(CubemapFace))) * { * Texture2D tex = textures[(int)face]; * cubeTex.SetPixels(tex.GetPixels(), face); * } * cubeTex.Apply(mipmaps, !readable); * cubeTex.SmoothEdges(); */ texList = textures; } }
public void ShipRolloutEvent(ShipConstruct construct) { KSPLog.print("ES: ShipRolloutEvent"); foreach (Part part in construct.parts) { if (part.Resources.Contains(Constants.EEDefinition.name)) { PartResource exoticEnergies = part.Resources[Constants.EEDefinition.name]; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { if (exoticEnergies.amount > storedExoticMatter) { exoticEnergies.amount = (float)storedExoticMatter; } storedExoticMatter -= exoticEnergies.amount; } KSPLog.print("Spent " + exoticEnergies.amount + " EM"); } if (part.Resources.Contains(Constants.EMDefinition.name)) { PartResource exoticMaterials = part.Resources[Constants.EMDefinition.name]; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { if (exoticMaterials.amount > storedExoticMatter) { exoticMaterials.amount = (float)storedExoticMatter; } storedExoticMatter -= exoticMaterials.amount; } KSPLog.print("Spent " + exoticMaterials.amount + " EM"); } } KSPLog.print("Stored EM: " + storedExoticMatter); }
public void Remove() { KSPLog.print("Removing PQS Material Manager!"); RemoveFromPQSCities(); if (this.sphere != null && this.sphere.quads != null) { foreach (PQ pq in this.sphere.quads) { RemoveFromQuads(pq); } ChildUpdater[] cuArray = this.sphere.transform.GetComponentsInChildren <ChildUpdater>(true).Where(cu => cu.Material == material).ToArray(); foreach (ChildUpdater cu in cuArray) { GameObject.DestroyImmediate(cu); } DeferredRenderer[] drArray = (DeferredRenderer[])this.sphere.transform.GetComponentsInChildren <DeferredRenderer>(true).Where(cu => cu.Material == material).ToArray(); foreach (DeferredRenderer dr in drArray) { GameObject.DestroyImmediate(dr); } } this.sphere = null; this.enabled = false; this.transform.parent = null; GameEvents.OnPQSCityLoaded.Remove(PQSLoaded); }
public static void visualizeTransform(Transform transform, Color color) { if (transform == null) { return; } KSPLog.print("TRANSFORM: " + transform.position); GameObject gameObject = transform.gameObject; Vector3 origin = transform.position; LineRenderer lineRenderer = gameObject.GetComponent <LineRenderer>(); if (lineRenderer == null) { lineRenderer = gameObject.AddComponent <LineRenderer>(); lineRenderer.material = new Material(Shader.Find("Particles/Additive")); lineRenderer.SetVertexCount(6); } lineRenderer.SetWidth(0.05f, 0.01f); lineRenderer.SetColors(color, Color.white); lineRenderer.SetPosition(0, origin); lineRenderer.SetPosition(1, transform.TransformPoint(Vector3.right)); lineRenderer.SetPosition(2, origin); lineRenderer.SetPosition(3, transform.TransformPoint(Vector3.up)); lineRenderer.SetPosition(4, origin); lineRenderer.SetPosition(5, transform.TransformPoint(Vector3.forward)); }
internal void ApplyCubeMap(Material mat, string name, int index) { if (type == TextureTypeEnum.RGB2_CubeMap) { mat.SetTexture("cube" + name + "POS", texPositive); mat.SetTexture("cube" + name + "NEG", texNegative); mat.EnableKeyword("MAP_TYPE_CUBE2_" + index.ToString()); KSPLog.print("[EVE] Applying " + name + " Cubemap"); } else { /* * KSPLog.print("[EVE] Setting cube" + name); * mat.SetTexture("cube" + name, cubeTex); * mat.EnableKeyword("MAP_TYPE_CUBE_" + index.ToString()); */ mat.SetTexture("cube" + name + "xn", texList[(int)CubemapFace.NegativeX]); mat.SetTexture("cube" + name + "yn", texList[(int)CubemapFace.NegativeY]); mat.SetTexture("cube" + name + "zn", texList[(int)CubemapFace.NegativeZ]); mat.SetTexture("cube" + name + "xp", texList[(int)CubemapFace.PositiveX]); mat.SetTexture("cube" + name + "yp", texList[(int)CubemapFace.PositiveY]); mat.SetTexture("cube" + name + "zp", texList[(int)CubemapFace.PositiveZ]); mat.EnableKeyword("MAP_TYPE_CUBE6_" + index.ToString()); } }
private Dictionary <int, Part> soundIDToPartIVA = new Dictionary <int, Part>(); //using a separate storage for internal model audio sources as they have completely different reference system public void rebuildCache(AudioSource[] audioSources) { Stopwatch performanceWatch = Stopwatch.StartNew(); soundIDToPart.Clear(); soundIDToPartIVA.Clear(); for (int i = 0; i < audioSources.Length; i++) { AudioSource audioSource = audioSources[i]; for (int p = 0; p < FlightGlobals.ActiveVessel.Parts.Count; p++) { Part part = FlightGlobals.ActiveVessel.Parts[p]; if (part.internalModel && audioSource.transform.IsChildOf(part.internalModel.transform)) { soundIDToPartIVA.Add(audioSource.GetInstanceID(), part); break; } else if (audioSource.transform.IsChildOf(part.transform)) { soundIDToPart.Add(audioSource.GetInstanceID(), part); break; } } } /*foreach (KeyValuePair<int, Part> entry in soundIDToPart) { * UnityEngine.Debug.Log("ENTRY: " + entry.Key + " " + entry.Value.name); * }*/ performanceWatch.Stop(); KSPLog.print("AudioMuffler: VesselSoundsCache rebuild time = " + performanceWatch.ElapsedMilliseconds); }
static void WarnOnNotFound() { System.Reflection.MemberInfo[] mi = typeof(ReflectedMembers).FindMembers(System.Reflection.MemberTypes.Field, System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public, null, null); foreach (System.Reflection.MemberInfo m in mi) { System.Reflection.FieldInfo tf = m as System.Reflection.FieldInfo; if (tf == null) { continue; } if (typeof(System.Reflection.MemberInfo).IsAssignableFrom(tf.FieldType)) { System.Reflection.MemberInfo val = tf.GetValue(null) as System.Reflection.MemberInfo; if (val == null) { KSPLog.print("WARNING: REFLECTEDMEMBERS cannot find member: '" + tf.Name + "'"); } else { //KSPLog.print ("RM found " + tf.Name); } } } }
public override void OnStart(StartState state) { base.OnStart(state); KSPLog.print("Core: OnStart(" + state.ToString() + ")"); if (vessel) { //KSPLog.print(vessel.situation.ToString()); if ((vessel.situation | Vessel.Situations.PRELAUNCH) == Vessel.Situations.PRELAUNCH) { //KSPLog.print(exoticEnergy.amount.ToString() + "/" + exoticEnergy.maxAmount.ToString()); //Perform prelaunch conversion //if ((vessel.situation & Vessel.Situations.PRELAUNCH) == Vessel.Situations.PRELAUNCH) //generateEE(exoticEnergy.maxAmount - exoticEnergy.amount); } //KSPLog.print(Planetarium.GetUniversalTime()); //KSPLog.print(saveTime); //KSPLog.print(Planetarium.GetUniversalTime() - saveTime); if (saveTime != 0) { generateEE(EEGeneration * (Planetarium.GetUniversalTime() - saveTime)); } } if (active) { Events["CoreToggle"].guiName = "Deactivate Core"; } }
private void writeDebug(string message) { if (config.Debug && !Planetarium.Pause) { KSPLog.print("[Audio Muffler] " + message); } }
public void deactivateOtherCores() { List <Part> partlist; if (vessel) { partlist = vessel.parts; } else if (EditorLogic.fetch != null && EditorLogic.fetch.ship != null) { partlist = EditorLogic.fetch.ship.parts; } else { partlist = null; KSPLog.print("ERROR: deactivateOtherCores called... but can't figure out how!"); } foreach (Part part in partlist) { ModuleExoticsCore otherModule = part.FindModuleImplementing <ModuleExoticsCore>(); if (otherModule != null && otherModule != this) { otherModule.DeactivateCore(); } } }
public override void FixedUpdate() { if (vessel && vessel.situation != Vessel.Situations.ORBITING && IsActivated) { KSPLog.print("Shutting down Orbital Converter. Not in orbit."); StopResourceConverter(); } base.FixedUpdate(); }
public static void PostDebugMessage(string Msg) { if (HighLogic.LoadedScene > GameScenes.SPACECENTER) { debugmsg.message = Msg; //ScreenMessages.PostScreenMessage(debugmsg, true); } KSPLog.print(Msg); }
public void WriteToLog() { KSPLog.print("====================================================================="); KSPLog.print(activeNote.note); KSPLog.print("====================================================================="); UnityEngine.Debug.Log("====================================================================="); UnityEngine.Debug.Log(activeNote.note); UnityEngine.Debug.Log("====================================================================="); }
public void Start() { Constants.exoticSolutionScenario = this; GameEvents.OnVesselRollout.Add(ShipRolloutEvent); GameEvents.onVesselRecovered.Add(VesselRecoveredEvent); GameEvents.onVesselRecoveryProcessing.Add(VesselRecoveryProcessingEvent); GameEvents.onVesselRecoveryProcessingComplete.Add(VesselRecoveryProcessingCompleteEvent); GameEvents.OnVesselRecoveryRequested.Add(VesselRecoveryRequestedEvent); GameEvents.onVesselCreate.Add(VesselCreateEvent); KSPLog.print("ES: ScenarioStart"); }
public void OnDisable() { Constants.exoticSolutionScenario = null; GameEvents.OnVesselRollout.Remove(ShipRolloutEvent); GameEvents.onVesselRecovered.Remove(VesselRecoveredEvent); GameEvents.onVesselRecoveryProcessing.Remove(VesselRecoveryProcessingEvent); GameEvents.onVesselRecoveryProcessingComplete.Remove(VesselRecoveryProcessingCompleteEvent); GameEvents.OnVesselRecoveryRequested.Remove(VesselRecoveryRequestedEvent); GameEvents.onVesselCreate.Remove(VesselCreateEvent); KSPLog.print("ES: ScenarioDisable"); }
private void onSceneLoadRequested(GameScenes scene) { //This is needed to avoid fighting stock camera during "Revert to launch" as that causes NullRefences in Unity breaking the revert process stopTouchingCamera = true; if (fpCameraManager != null && fpCameraManager.isFirstPerson) { KSPLog.print("TTE: Resetting because of scene change."); fpCameraManager.resetCamera(fpCameraManager.currentfpeva.vessel); } KeyDisabler.instance.restoreAllKeys(KeyDisabler.eDisableLockSource.FirstPersonEVA); }
private void SaveSettings() { KSPLog.print("[kalculator.dll] Saving Config..."); KSP.IO.PluginConfiguration _configfile = KSP.IO.PluginConfiguration.CreateForType <Kalculator>(); _configfile.SetValue("windowpos", _calcsize); _configfile.SetValue("keybind", _keybind); _configfile.SetValue("version", _version); _configfile.SetValue("KSPSkin", _useKspSkin); _configfile.save(); print("[kalculator.dll] Config Saved "); }
private void LoadSettings() { KSPLog.print("[kalculator.dll] Loading Config..."); KSP.IO.PluginConfiguration _configfile = KSP.IO.PluginConfiguration.CreateForType <Kalculator>(); _configfile.load(); _calcsize = _configfile.GetValue("windowpos", new Rect(360, 20, 308, 365)); _keybind = _configfile.GetValue("keybind", "k"); _versionlastrun = _configfile.GetValue <string>("version"); _useKspSkin = _configfile.GetValue <bool>("KSPSkin", false); KSPLog.print("[kalculator.dll] Config Loaded Successfully"); }
public void RebuildCache() { Stopwatch performanceWatch = Stopwatch.StartNew(); partMeshes.Clear(); Vector3 min = Vector3.zero; Vector3 max = Vector3.zero; //vesselTransform = FlightGlobals.ActiveVessel.vesselTransform; /*if (FlightGlobals.ActiveVessel.isEVA) { * vesselBounds = EVA_BOUNDS; * }*/ for (int i = 0; i < FlightGlobals.ActiveVessel.Parts.Count; i++) { Part part = FlightGlobals.ActiveVessel.Parts[i]; List <MeshFilter> filters = part.FindModelComponents <MeshFilter>(); partMeshes.Add(part, filters); if (FlightGlobals.ActiveVessel.isEVA) { continue; } //this optimzation causes huge lags when part count / vessel changes //Determining vessel bounds: /*for (int j = 0; j < filters.Count; j++) { * MeshFilter filter = filters[j]; * for (int v = 0; v < filter.mesh.vertices.Length; v++) { * Vector3 vertice = vesselTransform.InverseTransformPoint( * filter.transform.TransformPoint(filter.mesh.vertices[v])); * min.x = Mathf.Min(min.x, vertice.x); * min.y = Mathf.Min(min.y, vertice.y); * min.z = Mathf.Min(min.z, vertice.z); * max.x = Mathf.Max(max.x, vertice.x); * max.y = Mathf.Max(max.y, vertice.y); * max.z = Mathf.Max(max.z, vertice.z); * } * * }*/ } /*if (!FlightGlobals.ActiveVessel.isEVA) { * vesselBounds.SetMinMax(min, max); * }*/ performanceWatch.Stop(); KSPLog.print("AudioMuffler: VesselGeometryCache rebuild time = " + performanceWatch.ElapsedMilliseconds); }
public static Shader FindShader(string name) { if (shaderDictionary == null) { KSPLog.print("[EVE] Trying to find shader before assets loaded"); return(null); } if (shaderDictionary.ContainsKey(name)) { return(shaderDictionary[name]); } KSPLog.print("[EVE] Could not find shader " + name); return(null); }
private void logVersion() { Assembly buildManager = Assembly.GetExecutingAssembly(); String location = Path.GetDirectoryName(buildManager.Location); List <AssemblyName> assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => Path.GetDirectoryName(x.Location) == location).Select(x => x.GetName()).ToList(); String versionInfo = "[BLACKRACK_EVE_REDUX] Version Info:\n"; foreach (AssemblyName assembly in assemblies) { versionInfo += assembly.Name + ", " + assembly.Version.ToString() + "\n"; } KSPLog.print(versionInfo); }
public override void OnSphereActive() { sphere.maxLevel = 0; sphere.minLevel = 0; KSPLog.print(sphere.transform.childCount); for (int i = 0; i < sphere.transform.childCount; i++) { Transform t = sphere.transform.GetChild(i); if (Regex.IsMatch(t.name, "[A-z][np]")) { t.gameObject.SetActive(false); } } sphere.maxLevel = 0; sphere.minLevel = 0; }
void DEBUG_DeltaHdg(KerbalEVA eva, string nn) { float dotproduct = Vector3.Dot(eva.transform.forward, (Vector3)ReflectedMembers.eva_tgtFwd.GetValue(eva)); float dheading = Mathf.Acos(Vector3.Dot(eva.transform.forward, (Vector3)ReflectedMembers.eva_tgtFwd.GetValue(eva))) * 57.29578f; float num = Mathf.Sign((Quaternion.Inverse(eva.transform.rotation) * (Vector3)ReflectedMembers.eva_tgtFwd.GetValue(eva)).x); KSPLog.print(nn + "LastDH: " + ReflectedMembers.eva_lastDeltaHdg.GetValue(eva).ToString() + ", DH: " + ReflectedMembers.eva_deltaHdg.GetValue(eva).ToString() + ", TgtF: " + ReflectedMembers.eva_tgtFwd.GetValue(eva).ToString() + ", TrnsF: " + eva.transform.forward.ToString() + ", dot: " + dotproduct.ToString() + ", dh: " + dheading.ToString() + ", num: " + num.ToString() + ", rpos: " + ReflectedMembers.eva_tgtRpos.GetValue(eva).ToString() //+ ", myTgtF: " + target_fwd.ToString() ); }
public void VesselRecoveredEvent(ProtoVessel protoVessel, bool somethin) { KSPLog.print("ES: VesselRecoveredEvent"); foreach (ProtoPartSnapshot partSnapshot in protoVessel.protoPartSnapshots) { foreach (ProtoPartResourceSnapshot resourceSnapshot in partSnapshot.resources) { if (resourceSnapshot.resourceName == Constants.EMDefinition.name || resourceSnapshot.resourceName == Constants.EEDefinition.name) { storedExoticMatter += resourceSnapshot.amount; KSPLog.print("Storing " + resourceSnapshot.amount + " EM"); resourceSnapshot.amount = 0; } } } KSPLog.print("Stored EM: " + storedExoticMatter); }
public override void OnSphereActive() { sphere.maxLevel = 0; sphere.minLevel = 0; KSPLog.print(sphere.transform.childCount); for (int i = 0; i < sphere.transform.childCount; i++) { Transform t = sphere.transform.GetChild(i); if (Regex.IsMatch(t.name, "[A-z][np]")) { t.gameObject.SetActive(false); } } //these two lines are responsible for the flying tiles bug since 1.3, no idea what changed sphere.maxLevel = 0; sphere.minLevel = 0; }
public static Shader FindShader(string name, bool search = true) { if (shaderDictionary.ContainsKey(name)) { return(shaderDictionary[name]); } else if (search) { Shader[] shaders = (Shader[])Resources.FindObjectsOfTypeAll(typeof(Shader)); foreach (Shader shader in shaders) { KSPLog.print("Adding shader " + shader.name); shaderDictionary[shader.name] = shader; } return(FindShader(name, false)); } else { KSPLog.print("Could not find shader " + name); return(null); } }
private void Awake() { String shaderFolder = KSPUtil.ApplicationRootPath + "GameData/EnvironmentalVisualEnhancements/Shaders/"; foreach (string shader in Directory.GetFiles(shaderFolder)) { StreamReader shaderStream = new StreamReader(shader); String shaderString = shaderStream.ReadToEnd(); if (SystemInfo.graphicsDeviceVersion.Contains("OpenGL")) { shaderString = shaderString.Replace("Offset 0, 0", "Offset -.25, -.25"); } Material shaderMat = new Material(shaderString); KSPLog.print("Loading shader " + shaderMat.shader.name); } Shader[] shaders = (Shader[])Resources.FindObjectsOfTypeAll(typeof(Shader)); foreach (Shader shader in shaders) { KSPLog.print("Adding shader " + shader.name); shaderDictionary[shader.name] = shader; } }
private void LoadShaders() { if (shaderDictionary == null) { shaderDictionary = new Dictionary <string, Shader>(); // Add all other shaders Shader[] shaders = Resources.FindObjectsOfTypeAll <Shader>(); foreach (Shader shader in shaders) { shaderDictionary[shader.name] = shader; } using (WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath + "GameData/EnvironmentalVisualEnhancements/eveshaders.bundle")) { if (www.error != null) { KSPLog.print("[EVE] eveshaders.bundle not found!"); return; } AssetBundle bundle = www.assetBundle; shaders = bundle.LoadAllAssets <Shader>(); foreach (Shader shader in shaders) { KSPLog.print("[EVE] Shader " + shader.name + " loaded"); shaderDictionary.Add(shader.name, shader); } bundle.Unload(false); www.Dispose(); } loaded = true; } }
public static void PostLogMessage(LogChannel channel, string Msg) { switch (channel) { case LogChannel.Log: #if DEBUG Debug.Log(Msg); #else KSPLog.print(Msg); #endif break; case LogChannel.Warning: Debug.LogWarning(Msg); break; case LogChannel.Error: Debug.LogError(Msg); break; default: throw new NotImplementedException("Invalid channel, must pick one of Log, Warning, or Error."); } }
/// <summary> /// Print a log warning. /// </summary> /// <param name="message"></param> public static void Warn(string message) { KSPLog.print("SimpleSurvival: WARN " + message); }