/// <summary> /// Unity calls this hook during the KSP initial startup screen: /// </summary> /// <param name="state"></param> public override void OnAwake() { moduleName = "LaserDistModule"; relLaserOrigin = new Vector3d(0.0, -0.3, 0.0); pqsTool = new LaserPQSUtil(part); pqsTool.tickPortionAllowed = (double)(CPUGreedyPercent / 100.0); mask = (1 << maskBitDefault) + (1 << maskBitWater) + (1 << maskBitPartsList) // + (1 << maskBitScaledScenery) // seems to be the map scenery and it finds hits when not on mapview. + (1 << maskBitLocalScenery) + (1 << maskBitKerbals) + (1 << maskBitDisconnectedParts) + (1 << maskBitPartTriggers) + (1 << maskBitWheelColliders) + (1 << maskBitTerrainColliders); }
/// <summary> /// Unity calls this hook during the activation of the partmodule on a part. /// </summary> /// <param name="state"></param> public override void OnAwake() { moduleName = "LaserDistModule"; relLaserOrigin = new Vector3d(0.0, 0.0, 0.0); pqsTool = new LaserPQSUtil(part); pqsTool.tickPortionAllowed = (double)(CPUGreedyPercent / 100.0); SetGuiFieldsFromSettings(); bool debugShowAllMaskNames = false; // turn on to print the following after a KSP update: if (debugShowAllMaskNames) { for (int i = 0; i < 32; i++) { System.Console.WriteLine("A layer called \"" + LayerMask.LayerToName(i) + "\" exists at bit position " + i); } } // WARNING TO ANY FUTURE MAINTAINERS ABOUT THE FOLLOWING LAYERMASK SETTING: // // SQUAD does not put the layer mask values into any sort of an Enum I could find. // There isn't any guarantee that they'll keep the same names. Therefore always // test this again after every KSP update to see if these values have // been changed or if more have been added. LaserDist has been broken by // KSP updates in the past due to this being changed. You can use the debug // printout in the lines above to see the new layer mask names after an update. // // This is a bit-mask, but we don't have to do our own bit shifting to make it because // Unity provides the following string-name based way to build the mask. // The commented-out lines are present as a form of documentation. It shows // what we're masking off - otherwise that would be unclear because those names // aren't mentioned elsewhere. mask = LayerMask.GetMask( "Default", // layer number 0, which contains most physical objects that are not "scenery" // "TransparentFX", // layer number 1 // "Ignore Raycast", // layer number 2 // "", // layer number 3 (no name - don't know what it is) "Water", // layer number 4 // "UI", // layer number 5 // "", // layer number 6 (no name - don't know what it is) // "", // layer number 7 (no name - don't know what it is) // "PartsList_Icons", // layer number 8 // "Atmosphere", // layer number 9 // "Scaled Scenery", // layer number 10 (this is the map view planets, I think) // "UIDialog", // layer number 11 // "UIVectors", // layer number 12 (i.e. lines for orbits and comm connections maybe?) // "UI_Mask", // layer number 13 // "Screens", // layer number 14 "Local Scenery", // layer number 15 // "kerbals", // layer number 16 (presumably the hovering faces in the UI, not the 3-D in-game kerbals) "EVA", // layer number 17 // "SkySphere", // layer number 18 "PhysicalObjects", // layer number 19 (don't know - maybe rocks?) // "Internal Space", // layer number 20 (objects inside the cockpit in IVA view) // "Part Triggers", // layer number 21 (don't know what this is) // "KerbalInstructors", // layer number 22 (presumably the people's faces on screen? // "AeroFXIgnore", // layer number 23 (well, it says "ignore" so I will) // "MapFX", // layer number 24 // "UIAdditional". // layer number 25 // "WheelCollidersIgnore", // layer number 26 "WheelColliders", // layer number 27 "TerrainColliders" // layer number 28 // "DragRender" // layer number 29 // "SurfaceFX" // layer number 30 // "Vectors" // layer number 31 (UI overlay for things like lift and drag display, maybe?). ); laserFlightDrawLayer = LayerMask.NameToLayer("TransparentFX"); laserMapDrawLayer = LayerMask.NameToLayer("Scaled Scenery"); laserEditorDrawLayer = LayerMask.NameToLayer("Default"); }