public bool Get(out float destination) { if (value != null) { destination = value.Value; return(true); } destination = comp.ProcessVariable(variableName).MassageToFloat(); if (float.IsNaN(destination) || float.IsInfinity(destination)) { if (!warningMade) { JUtil.LogMessage(owner, "Warning, {0} can fail to produce a usable number.", variableName); warningMade = true; return(false); } } return(true); }
private JProperty GetAssessedNetworkShare(JToken netShare) { int interestLevel = 2; JObject assessedGppNetShare = new JObject { { "Name", JUtil.GetSafeString(netShare, "@name") }, { "Changed", JUtil.GetSafeString(netShare, "@changed") }, { "Action", JUtil.GetActionString(netShare["Properties"]["@action"].ToString()) } }; assessedGppNetShare.Add("Path", JUtil.GetSafeString(netShare["Properties"], "@path")); assessedGppNetShare.Add("Comment", JUtil.GetSafeString(netShare["Properties"], "@comment")); // removed InvestigatePath because it's a network share, it's literally always going to be local and therefore not super interesting. if (interestLevel >= GlobalVar.IntLevelToShow) { return(new JProperty(netShare["@uid"].ToString(), assessedGppNetShare)); } return(null); }
//[JNE] this is temporary function. public void LoadTable() { PlantList = JUtil.CSVToDicationary <PlantTableInfo> (PlantInfoTablePath); PlantGroupList = JUtil.CSVToDicationary <PlantGroupTableInfo> (PlantGroupInfoTablePath); }
public void CreateMapInfo(MapTileInfo[,] tileInfoList) { int columnCount = MapTileInfo.ColumnCount; int rowCount = MapTileInfo.RowCount; //tileInfoList = new MapTileInfo[columnCount, rowCount]; //Create Map First for (int x = 0; x < columnCount; x++) { for (int y = 0; y < rowCount; y++) { MapTileInfo info = new MapTileInfo(); //this is for temp -> almost ground MapTileInfo.Type type = JUtil.NextInt(0, 75) != 0 ? MapTileInfo.Type.Ground : MapTileInfo.Type.Water; info.Init(x, y, type); tileInfoList [x, y] = info; } } int humididyRange = 5; //Set temperature and humidity for (int x = 0; x < columnCount; x++) { for (int y = 0; y < rowCount; y++) { if (tileInfoList[x, y].TileType == MapTileInfo.Type.Water) { for (int tx = x - humididyRange; tx <= x + humididyRange; tx++) { if (tx < 0) { continue; } if (tx >= columnCount) { break; } for (int ty = y - humididyRange; ty <= y + humididyRange; ty++) { if (ty < 0) { continue; } if (ty >= rowCount) { break; } if (tileInfoList [tx, ty].TileType == MapTileInfo.Type.Water) { continue; } float temperature = 25; float humidity = 0; if (Mathf.Abs(tx - x) == 5 || Mathf.Abs(ty - y) == 5) { humidity = 0.1f; } else if (Mathf.Abs(tx - x) == 4 || Mathf.Abs(ty - y) == 4) { humidity = 0.2f; } else if (Mathf.Abs(tx - x) == 3 || Mathf.Abs(ty - y) == 3) { humidity = 0.3f; } else if (Mathf.Abs(tx - x) == 2 || Mathf.Abs(ty - y) == 2) { humidity = 0.4f; } else if (Mathf.Abs(tx - x) == 1 || Mathf.Abs(ty - y) == 1) { humidity = 0.5f; } SetHumidity(tileInfoList[tx, ty], humidity); tileInfoList [tx, ty].Temperature = temperature; } } } } } }
static JProperty AssessGppPrinter(JToken gppPrinter) { int interestLevel = 1; string gppPrinterUid = JUtil.GetSafeString(gppPrinter, "@uid"); string gppPrinterName = JUtil.GetSafeString(gppPrinter, "@name"); string gppPrinterChanged = JUtil.GetSafeString(gppPrinter, "@changed"); JToken gppPrinterProps = gppPrinter["Properties"]; string gppPrinterAction = JUtil.GetActionString(gppPrinterProps["@action"].ToString()); string gppPrinterUsername = JUtil.GetSafeString(gppPrinterProps, "@username"); string gppPrintercPassword = JUtil.GetSafeString(gppPrinterProps, "@cpassword"); string gppPrinterPassword = ""; if (gppPrintercPassword.Length > 0) { gppPrinterPassword = Util.DecryptCpassword(gppPrintercPassword); interestLevel = 10; } string gppPrinterAddress = JUtil.GetSafeString(gppPrinterProps, "@ipAddress"); string gppPrinterLocalName = JUtil.GetSafeString(gppPrinterProps, "@localName"); string gppPrinterSnmpCommString = JUtil.GetSafeString(gppPrinterProps, "@snmpCommunity"); if (gppPrinterSnmpCommString.Length > 1) { interestLevel = 7; } JToken gppPrinterPath = FileSystem.InvestigatePath(JUtil.GetSafeString(gppPrinterProps, "@path")); JToken gppPrinterComment = FileSystem.InvestigateString(JUtil.GetSafeString(gppPrinterProps, "@comment")); JToken gppPrinterLocation = FileSystem.InvestigateString(JUtil.GetSafeString(gppPrinterProps, "@location")); // check each of our potentially interesting values to see if it raises our overall interest level JToken[] valuesWithInterest = { gppPrinterPath, gppPrinterComment, gppPrinterLocation, }; foreach (JToken val in valuesWithInterest) { if ((val != null) && (val["InterestLevel"] != null)) { int valInterestLevel = int.Parse(val["InterestLevel"].ToString()); if (valInterestLevel > interestLevel) { interestLevel = valInterestLevel; } } } if (interestLevel >= GlobalVar.IntLevelToShow) { JObject assessedGppPrinter = new JObject { { "Name", gppPrinterName }, { "Changed", gppPrinterChanged }, { "Action", gppPrinterAction } }; if (gppPrintercPassword.Length > 0) { assessedGppPrinter.Add("Username", gppPrinterUsername); assessedGppPrinter.Add("cPassword", gppPrintercPassword); assessedGppPrinter.Add("Decrypted Password", gppPrinterPassword); } assessedGppPrinter.Add("Local Name", gppPrinterLocalName); assessedGppPrinter.Add("Address", gppPrinterAddress); assessedGppPrinter.Add("Path", gppPrinterPath); assessedGppPrinter.Add("SNMP Community String", gppPrinterSnmpCommString); assessedGppPrinter.Add("Comment", gppPrinterComment); assessedGppPrinter.Add("Location", gppPrinterLocation); return(new JProperty(gppPrinterUid, assessedGppPrinter)); } return(null); }
public void ButtonProcessor(int buttonID) { if (buttonID == buttonUp) { CurrentMenu.PreviousItem(); } if (buttonID == buttonDown) { CurrentMenu.NextItem(); } if (buttonID == buttonEnter) { CurrentMenu.SelectItem(); } if (buttonID == buttonEsc) { CloseSubMenu(); } if (buttonID == buttonHome) { menuStack.RemoveRange(1, menuStack.Count - 1); } if (buttonID == buttonRight) { JUtil.LogInfo(null, "dumping experiment"); DumpObject(experimentModules[experimentsMenu.GetCurrentIndex()]); } if (buttonID == buttonLeft) { DumpObject(containerModules[containersMenu.GetCurrentIndex()]); } if (buttonID == buttonNext) { var experiment = experimentModules[experimentsMenu.GetCurrentIndex()]; var scienceData = experiment.GetData(); DumpObject(experiment); JUtil.LogInfo(null, "{0} science data", scienceData.Length); foreach (var data in scienceData) { JUtil.LogInfo(null, "science data"); DumpObject(data); var subject = ResearchAndDevelopment.GetSubjectByID(data.subjectID); JUtil.LogInfo(null, "subject"); DumpObject(subject); } JUtil.LogInfo(null, "experiment"); DumpObject(experiment.experiment); JUtil.LogInfo(null, "actions"); foreach (var action in experiment.Actions) { DumpObject(action); } } }
/// <summary> /// Provides a simple boolean true/false for whether the named /// variable is in range. /// </summary> /// <param name="comp"></param> /// <param name="persistence"></param> /// <returns></returns> public bool IsInRange(RPMVesselComputer comp, PersistenceAccessor persistence) { float value; float low, high; if (stateFunction != null) { bool state = stateFunction(); value = state.GetHashCode(); } else if (!string.IsNullOrEmpty(sourceValueName)) { value = comp.ProcessVariable(sourceValueName, persistence).MassageToFloat(); } else { value = sourceValue; } if (float.IsNaN(value) || float.IsInfinity(value)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", sourceValueName); warningMade = true; } return(false); } if (!string.IsNullOrEmpty(lowerBoundName)) { low = comp.ProcessVariable(lowerBoundName, persistence).MassageToFloat(); if (float.IsNaN(low) || float.IsInfinity(low)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", lowerBoundName); warningMade = true; } return(false); } } else { low = lowerBound; } if (!string.IsNullOrEmpty(upperBoundName)) { high = comp.ProcessVariable(upperBoundName, persistence).MassageToFloat(); if (float.IsNaN(high) || float.IsInfinity(high)) { if (!warningMade) { JUtil.LogMessage(this, "Warning: {0} can fail to produce a usable number.", upperBoundName); warningMade = true; } return(false); } } else { high = upperBound; } if (high < low) { return(value >= high && value <= low); } else { return(value >= low && value <= high); } }
static JProperty AssessGppDrive(JToken gppDrive) { int interestLevel = 1; string gppDriveUid = JUtil.GetSafeString(gppDrive, "@uid"); string gppDriveName = JUtil.GetSafeString(gppDrive, "@name"); string gppDriveChanged = JUtil.GetSafeString(gppDrive, "@changed"); string gppDriveAction = JUtil.GetActionString(gppDrive["Properties"]["@action"].ToString()); string gppDriveUserName = JUtil.GetSafeString(gppDrive["Properties"], "@userName"); string gppDrivecPassword = JUtil.GetSafeString(gppDrive["Properties"], "@cpassword"); string gppDrivePassword = ""; if (gppDrivecPassword.Length > 0) { gppDrivePassword = Util.DecryptCpassword(gppDrivecPassword); interestLevel = 10; } string gppDriveLetter = ""; if (gppDrive["Properties"]["@useLetter"] != null) { if (gppDrive["Properties"]["@useLetter"].ToString() == "1") { gppDriveLetter = JUtil.GetSafeString(gppDrive["Properties"], "@letter"); } else if (gppDrive["Properties"]["@useLetter"].ToString() == "0") { gppDriveLetter = "First letter available, starting at " + JUtil.GetSafeString(gppDrive["Properties"], "@letter"); } } string gppDriveLabel = JUtil.GetSafeString(gppDrive["Properties"], "@label"); JObject gppDrivePath = FileSystem.InvestigatePath(gppDrive["Properties"]["@path"].ToString()); if (gppDrivePath != null) { if (gppDrivePath["InterestLevel"] != null) { int pathInterestLevel = int.Parse(gppDrivePath["InterestLevel"].ToString()); if (pathInterestLevel > interestLevel) { interestLevel = pathInterestLevel; } } } if (interestLevel >= GlobalVar.IntLevelToShow) { JObject assessedGppDrive = new JObject { { "Name", gppDriveName }, { "Action", gppDriveAction }, { "Changed", gppDriveChanged }, { "Drive Letter", gppDriveLetter }, { "Label", gppDriveLabel } }; if (gppDrivecPassword.Length > 0) { assessedGppDrive.Add("Username", gppDriveUserName); assessedGppDrive.Add("cPassword", gppDrivecPassword); assessedGppDrive.Add("Decrypted Password", gppDrivePassword); } if (gppDrivePath != null) { assessedGppDrive.Add("Path", gppDrivePath); } return(new JProperty(gppDriveUid, assessedGppDrive)); } return(null); }
static JProperty AssessGppNTService(JToken gppNtService) { int interestLevel = 1; string gppNtServiceUid = JUtil.GetSafeString(gppNtService, "@uid"); string gppNtServiceChanged = JUtil.GetSafeString(gppNtService, "@changed"); string gppNtServiceName = JUtil.GetSafeString(gppNtService, "@name"); string gppNtServiceUserName = JUtil.GetSafeString(gppNtService["Properties"], "@accountName"); string gppNtServicecPassword = JUtil.GetSafeString(gppNtService["Properties"], "@cpassword"); string gppNtServicePassword = ""; if (gppNtServicecPassword.Length > 0) { gppNtServicePassword = Util.DecryptCpassword(gppNtServicecPassword); interestLevel = 10; } string gppNtServiceTimeout = JUtil.GetSafeString(gppNtService["Properties"], "@timeout"); string gppNtServiceStartup = JUtil.GetSafeString(gppNtService["Properties"], "@startupType"); string gppNtServiceAction = JUtil.GetSafeString(gppNtService["Properties"], "@serviceAction"); string gppNtServiceServiceName = JUtil.GetSafeString(gppNtService["Properties"], "@serviceName"); string gppNtServiceFirstFailure = JUtil.GetSafeString(gppNtService["Properties"], "@firstFailure"); string gppNtServiceSecondFailure = JUtil.GetSafeString(gppNtService["Properties"], "@secondFailure"); string gppNtServiceThirdFailure = JUtil.GetSafeString(gppNtService["Properties"], "@thirdFailure"); JObject gppNtServiceProgram = FileSystem.InvestigatePath(JUtil.GetSafeString(gppNtService["Properties"], "@program")); JObject gppNtServiceArgs = FileSystem.InvestigateString(JUtil.GetSafeString(gppNtService["Properties"], "@args")); if ((gppNtServiceProgram != null) && (gppNtServiceProgram["InterestLevel"] != null)) { int progInterestLevelInt = int.Parse(gppNtServiceProgram["InterestLevel"].ToString()); if (progInterestLevelInt > interestLevel) { interestLevel = progInterestLevelInt; } } if (gppNtServiceArgs["InterestLevel"] != null) { int argsInterestLevelInt = int.Parse(gppNtServiceArgs["InterestLevel"].ToString()); if (argsInterestLevelInt > interestLevel) { interestLevel = argsInterestLevelInt; } } if (interestLevel >= GlobalVar.IntLevelToShow) { JObject assessedGppNtService = new JObject { { "Name", gppNtServiceName }, { "Changed", gppNtServiceChanged } }; if (gppNtServiceServiceName.Length > 0) { assessedGppNtService.Add("Service Name", gppNtServiceName); } if (gppNtServicecPassword.Length > 0) { assessedGppNtService.Add("Username", gppNtServiceUserName); assessedGppNtService.Add("cPassword", gppNtServicecPassword); assessedGppNtService.Add("Decrypted Password", gppNtServicePassword); } if (gppNtServiceTimeout.Length > 0) { assessedGppNtService.Add("Timeout", gppNtServiceTimeout); } if (gppNtServiceStartup.Length > 0) { assessedGppNtService.Add("Startup Type", gppNtServiceStartup); } if (gppNtServiceAction.Length > 0) { assessedGppNtService.Add("Action", gppNtServiceAction); } if (gppNtServiceFirstFailure.Length > 0) { assessedGppNtService.Add("Action on first failure", gppNtServiceFirstFailure); } if (gppNtServiceSecondFailure.Length > 0) { assessedGppNtService.Add("Action on second failure", gppNtServiceSecondFailure); } if (gppNtServiceThirdFailure.Length > 0) { assessedGppNtService.Add("Action on third failure", gppNtServiceThirdFailure); } if (gppNtServiceProgram.HasValues) { assessedGppNtService.Add("Program", gppNtServiceProgram); } if (gppNtServiceArgs.HasValues) { assessedGppNtService.Add("Args", gppNtServiceArgs); } return(new JProperty(gppNtServiceUid, assessedGppNtService)); } return(null); }
private void Start() { // Referencing the parent project should work, shouldn't it. persistentVarName = "scansat" + internalProp.propID; try { sat = part.FindModulesImplementing <SCANsat>().First(); } catch { Debug.LogWarning("[SCANsatRPM] SCANsat module not attached to this IVA, check for Module Manager problems and make sure the RPMMapTraq.cfg file is in the SCANsat/MMconfigs folder"); sat = null; } if (sat != null) { satModuleFound = true; if (sat.RPMList.Count > 0) { foreach (RPMPersistence RPMProp in sat.RPMList) { if (RPMProp.RPMID == persistentVarName) { persist = RPMProp; break; } } } if (persist == null) { persist = new RPMPersistence(persistentVarName); sat.RPMList.Add(persist); } showLines = persist.RPMLines; } else { satModuleFound = false; } // Arrrgh. if (!string.IsNullOrEmpty(iconColorSelf)) { iconColorSelfValue = ConfigNode.ParseColor32(iconColorSelf); } if (!string.IsNullOrEmpty(iconColorTarget)) { iconColorTargetValue = ConfigNode.ParseColor32(iconColorTarget); } if (!string.IsNullOrEmpty(iconColorUnvisitedAnomaly)) { iconColorUnvisitedAnomalyValue = ConfigNode.ParseColor32(iconColorUnvisitedAnomaly); } if (!string.IsNullOrEmpty(iconColorVisitedAnomaly)) { iconColorVisitedAnomalyValue = ConfigNode.ParseColor32(iconColorVisitedAnomaly); } if (!string.IsNullOrEmpty(iconColorShadow)) { iconColorShadowValue = ConfigNode.ParseColor32(iconColorShadow); } if (!string.IsNullOrEmpty(iconColorAP)) { iconColorAPValue = ConfigNode.ParseColor32(iconColorAP); } if (!string.IsNullOrEmpty(iconColorPE)) { iconColorPEValue = ConfigNode.ParseColor32(iconColorPE); } if (!string.IsNullOrEmpty(iconColorANDN)) { iconColorANDNValue = ConfigNode.ParseColor32(iconColorANDN); } if (!string.IsNullOrEmpty(iconColorNode)) { iconColorNodeValue = ConfigNode.ParseColor32(iconColorNode); } if (!string.IsNullOrEmpty(trailColor)) { trailColorValue = ConfigNode.ParseColor32(trailColor); } trailMaterial = JUtil.DrawLineMaterial(); LeaveTrail(); if (!string.IsNullOrEmpty(scaleBar) && !string.IsNullOrEmpty(scaleLabels) && !string.IsNullOrEmpty(scaleLevels)) { scaleBarTexture = GameDatabase.Instance.GetTexture(scaleBar, false); scaleLabelTexture = GameDatabase.Instance.GetTexture(scaleLabels, false); var scales = new List <float>(); foreach (string scl in scaleLevels.Split(',')) { float scale; if (float.TryParse(scl.Trim(), out scale)) { scales.Add(scale / 1000); } } scaleLevelValues = scales.ToArray(); Array.Sort(scaleLevelValues); scaleLabelSpan = 1f / scaleLevelValues.Length; } // Now the fun bit: Locate all cfg files depicting map features anywhere. foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("JSISCANSATVECTORMARK")) { mapMarkup.Add(new MapMarkupLine(node)); } }
public void Start() { JUtil.LogMessage(this, "I am in prop named {0} and it has prop ID {1}", internalProp.name, internalProp.propID); // And just in case the user forgets. Destroy(this); }
// Analysis disable once UnusedParameter public bool MapRenderer(RenderTexture screen, float cameraAspect) { // Just in case. if (!HighLogic.LoadedSceneIsFlight) { return(false); } if (!TestForActiveSCANsat()) { return(false); } if (!startupComplete) { JUtil.AnnoyUser(this); } if (screenWidth == 0 || screenHeight == 0) { int?loadedMode = persistence.GetVar(persistentVarName + "mode"); mapMode = loadedMode ?? 0; int?loadedZoom = persistence.GetVar(persistentVarName + "zoom"); zoomLevel = loadedZoom ?? 0; int?loadedColors = persistence.GetVar(persistentVarName + "color"); SCANcontroller.controller.colours = loadedColors ?? 0; screenWidth = screen.width; screenHeight = screen.height; iconMaterial = new Material(Shader.Find("KSP/Alpha/Unlit Transparent")); screenSpace = new Rect(0, 0, screenWidth, screenHeight); RedrawMap(); return(false); } // In case SCANsat is present but not working, we can't run any of our code. :( if (map == null) { return(false); } start = Planetarium.GetUniversalTime(); Graphics.Blit(map.map, screen); GL.PushMatrix(); GL.LoadPixelMatrix(0, screenWidth, screenHeight, 0); // Markup lines are the lowest layer. if (showLines) { foreach (MapMarkupLine vectorLine in mapMarkup) { if (vectorLine.body == orbitingBody && vectorLine.points.Count > 0) { DrawTrail(vectorLine.points, vectorLine.color, Vector2d.zero); } } } // Trails go above markup lines if (showLines && trailLimit > 0 && trail.Count > 0) { DrawTrail(trail, trailColorValue, new Vector2d(vessel.longitude, vessel.latitude), true); } // Anomalies go above trails foreach (SCANdata.SCANanomaly anomaly in localAnomalies) { if (anomaly.known) { DrawIcon(anomaly.longitude, anomaly.latitude, anomaly.detail ? (VesselType)int.MaxValue : VesselType.Unknown, anomaly.detail ? iconColorVisitedAnomalyValue : iconColorUnvisitedAnomalyValue); } } // Target orbit and targets go above anomalies if (targetVessel != null && targetVessel.mainBody == orbitingBody) { if (showLines && JUtil.OrbitMakesSense(targetVessel)) { DrawOrbit(targetVessel, targetVessel.orbit, start, iconColorTargetValue); // Connect our orbit and the target orbit with a line at the point of closest approach... if (JUtil.OrbitMakesSense(vessel)) { double closestApproachMoment; JUtil.GetClosestApproach(vessel.orbit, targetVessel.orbit, out closestApproachMoment); Vector2d targetCoord, vesselCoord; bool targetCollision, vesselCollision; // Analysis disable once CompareOfFloatsByEqualityOperator if (closestApproachMoment != start && GetPositionAtT(targetVessel, targetVessel.orbit, start, closestApproachMoment, out targetCoord, out targetCollision) && !targetCollision && GetPositionAtT(vessel, targetVessel.orbit, start, closestApproachMoment, out vesselCoord, out vesselCollision) && !vesselCollision) { var endpoints = new List <Vector2d>(); endpoints.Add(targetCoord); endpoints.Add(vesselCoord); DrawTrail(endpoints, iconColorTargetValue, Vector2d.zero); } } } DrawIcon(targetVessel.longitude, targetVessel.latitude, targetVessel.vesselType, iconColorTargetValue); if (showLines) { DrawOrbitIcon(targetVessel, MapIcons.OtherIcon.AP, iconColorTargetValue); DrawOrbitIcon(targetVessel, MapIcons.OtherIcon.PE, iconColorTargetValue); } } // Own orbit goes above that. if (showLines && JUtil.OrbitMakesSense(vessel)) { DrawOrbit(vessel, vessel.orbit, start, iconColorSelfValue); DrawOrbitIcon(vessel, MapIcons.OtherIcon.AP, iconColorAPValue); DrawOrbitIcon(vessel, MapIcons.OtherIcon.PE, iconColorPEValue); if (targetVessel != null && JUtil.OrbitMakesSense(targetVessel)) { if (vessel.orbit.AscendingNodeExists(targetVessel.orbit)) { DrawOrbitIcon(vessel, MapIcons.OtherIcon.AN, iconColorANDNValue, vessel.orbit.TimeOfAscendingNode(targetVessel.orbit, start)); } if (vessel.orbit.DescendingNodeExists(targetVessel.orbit)) { DrawOrbitIcon(vessel, MapIcons.OtherIcon.DN, iconColorANDNValue, vessel.orbit.TimeOfDescendingNode(targetVessel.orbit, start)); } } // And the maneuver node and post-maneuver orbit: ManeuverNode node = vessel.patchedConicSolver.maneuverNodes.Count > 0 ? vessel.patchedConicSolver.maneuverNodes[0] : null; if (node != null) { DrawOrbit(vessel, node.nextPatch, node.UT, iconColorNodeValue); DrawOrbitIcon(vessel, MapIcons.OtherIcon.NODE, iconColorNodeValue, node.UT); } } // Own icon goes above that DrawIcon(vessel.longitude, vessel.latitude, vessel.vesselType, iconColorSelfValue); // And scale goes above everything. DrawScale(); GL.PopMatrix(); return(true); }
private void Start() { InstallationPathWarning.Warn("SCANsatRPM"); // Arrrgh. if (!string.IsNullOrEmpty(iconColorSelf)) { iconColorSelfValue = ConfigNode.ParseColor32(iconColorSelf); } if (!string.IsNullOrEmpty(iconColorTarget)) { iconColorTargetValue = ConfigNode.ParseColor32(iconColorTarget); } if (!string.IsNullOrEmpty(iconColorUnvisitedAnomaly)) { iconColorUnvisitedAnomalyValue = ConfigNode.ParseColor32(iconColorUnvisitedAnomaly); } if (!string.IsNullOrEmpty(iconColorVisitedAnomaly)) { iconColorVisitedAnomalyValue = ConfigNode.ParseColor32(iconColorVisitedAnomaly); } if (!string.IsNullOrEmpty(iconColorShadow)) { iconColorShadowValue = ConfigNode.ParseColor32(iconColorShadow); } if (!string.IsNullOrEmpty(iconColorAP)) { iconColorAPValue = ConfigNode.ParseColor32(iconColorAP); } if (!string.IsNullOrEmpty(iconColorPE)) { iconColorPEValue = ConfigNode.ParseColor32(iconColorPE); } if (!string.IsNullOrEmpty(iconColorANDN)) { iconColorANDNValue = ConfigNode.ParseColor32(iconColorANDN); } if (!string.IsNullOrEmpty(iconColorNode)) { iconColorNodeValue = ConfigNode.ParseColor32(iconColorNode); } if (!string.IsNullOrEmpty(trailColor)) { trailColorValue = ConfigNode.ParseColor32(trailColor); } // Referencing the parent project should work, shouldn't it. persistentVarName = "scansat" + internalProp.propID; persistence = new PersistenceAccessor(part); showLines = persistence.GetBool(persistentVarName + "lines") ?? true; trailMaterial = JUtil.DrawLineMaterial(); LeaveTrail(); if (!string.IsNullOrEmpty(scaleBar) && !string.IsNullOrEmpty(scaleLabels) && !string.IsNullOrEmpty(scaleLevels)) { scaleBarTexture = GameDatabase.Instance.GetTexture(scaleBar, false); scaleLabelTexture = GameDatabase.Instance.GetTexture(scaleLabels, false); var scales = new List <float>(); foreach (string scl in scaleLevels.Split(',')) { float scale; if (float.TryParse(scl.Trim(), out scale)) { scales.Add(scale / 1000); } } scaleLevelValues = scales.ToArray(); Array.Sort(scaleLevelValues); scaleLabelSpan = 1f / scaleLevelValues.Length; } // Now the fun bit: Locate all cfg files depicting map features anywhere. foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("JSISCANSATVECTORMARK")) { mapMarkup.Add(new MapMarkupLine(node)); } startupComplete = true; }
private JObject GetAssessedShortcut(JObject gppShortcut) { int interestLevel = 3; JObject assessedShortcut = new JObject(); JToken gppShortcutProps = gppShortcut["Properties"]; assessedShortcut.Add("Name", JUtil.GetSafeString(gppShortcut, "@name")); assessedShortcut.Add("Status", JUtil.GetSafeString(gppShortcut, "@status")); assessedShortcut.Add("Changed", JUtil.GetSafeString(gppShortcut, "@changed")); string gppShortcutAction = JUtil.GetActionString(gppShortcutProps["@action"].ToString()); assessedShortcut.Add("Action", gppShortcutAction); assessedShortcut.Add("Target Type", JUtil.GetSafeString(gppShortcutProps, "@targetType")); string arguments = JUtil.GetSafeString(gppShortcutProps, "@arguments"); if (arguments != null) { JToken investigatedArguments = FileSystem.InvestigateString(arguments); assessedShortcut.Add("Arguments", arguments); if (investigatedArguments["InterestLevel"] != null) { if ((int)investigatedArguments["InterestLevel"] > interestLevel) { interestLevel = (int)investigatedArguments["InterestLevel"]; } } } string iconPath = JUtil.GetSafeString(gppShortcutProps, "@iconPath"); JObject investigatedIconPath = FileSystem.InvestigatePath(iconPath); if ((investigatedIconPath != null) && (investigatedIconPath["InterestLevel"] != null)) { if ((int)investigatedIconPath["InterestLevel"] > interestLevel) { interestLevel = (int)investigatedIconPath["InterestLevel"]; } } assessedShortcut.Add("Icon Path", investigatedIconPath); assessedShortcut.Add("Icon Index", JUtil.GetSafeString(gppShortcutProps, "@iconIndex")); string workingDir = JUtil.GetSafeString(gppShortcutProps, "@startIn"); if (workingDir != null) { JToken assessedWorkingDir = FileSystem.InvestigatePath(workingDir); if (assessedWorkingDir != null) { assessedShortcut.Add("Working Directory", assessedWorkingDir); } } assessedShortcut.Add("Comment", JUtil.GetSafeString(gppShortcutProps, "@comment")); string shortcutPath = JUtil.GetSafeString(gppShortcutProps, "@shortcutPath"); JObject investigatedShortcutPath = FileSystem.InvestigatePath(shortcutPath); if (investigatedShortcutPath["InterestLevel"] != null) { if ((int)investigatedShortcutPath["InterestLevel"] > interestLevel) { interestLevel = (int)investigatedShortcutPath["InterestLevel"]; } } string targetPath = JUtil.GetSafeString(gppShortcutProps, "@targetPath"); JObject investigatedTargetPath = FileSystem.InvestigatePath(targetPath); if ((investigatedTargetPath != null) && (investigatedTargetPath["InterestLevel"] != null)) { if ((int)investigatedTargetPath["InterestLevel"] > interestLevel) { interestLevel = (int)investigatedTargetPath["InterestLevel"]; } } assessedShortcut.Add("Shortcut Path", investigatedShortcutPath); assessedShortcut.Add("Target Path", investigatedTargetPath); // if it's too boring to be worth showing, return an empty jobj. if (interestLevel < GlobalVar.IntLevelToShow) { return(null); } return(assessedShortcut); }
private JObject GetAssessedScheduledTask(JToken scheduledTask, string schedTaskType) { int interestLevel = 4; JObject assessedScheduledTask = new JObject { { "Name", scheduledTask["@name"].ToString() }, { "UID", scheduledTask["@uid"].ToString() }, { "Type", schedTaskType }, { "Changed", scheduledTask["@changed"].ToString() } }; if (scheduledTask["Properties"]["@runAs"] != null) { assessedScheduledTask.Add("Run As", JUtil.GetSafeString(scheduledTask["Properties"], "@runAs")); } string cPassword = JUtil.GetSafeString(scheduledTask["Properties"], "@cpassword"); if (cPassword.Length > 1) { assessedScheduledTask.Add("Encrypted Password", JUtil.GetSafeString(scheduledTask["Properties"], "@cpassword")); assessedScheduledTask.Add("Decrypted Password", Util.DecryptCpassword(cPassword)); interestLevel = 10; } if (scheduledTask["Properties"]["@logonType"] != null) { assessedScheduledTask.Add("Logon Type", JUtil.GetSafeString(scheduledTask["Properties"], "@logonType")); } // handle the entries that are specific to some task types but not others // both taskv2 and immediatetaskv2 have the same rough structure if (schedTaskType.EndsWith("V2")) { assessedScheduledTask.Add("Action", JUtil.GetActionString(scheduledTask["Properties"]["@action"].ToString())); assessedScheduledTask.Add("Description", JUtil.GetSafeString(scheduledTask, "@desc")); assessedScheduledTask.Add("Enabled", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Settings"], "Enabled")); // just adding the Triggers info raw, there are way too many options. assessedScheduledTask.Add("Triggers", scheduledTask["Properties"]["Task"]["Triggers"]); if (scheduledTask["Properties"]["Task"]["Actions"]["ShowMessage"] != null) { assessedScheduledTask.Add( new JProperty("Action - Show Message", new JObject( new JProperty("Title", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["ShowMessage"], "Title")), new JProperty("Body", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["ShowMessage"], "Body")) ) ) ); } if (scheduledTask["Properties"]["Task"]["Actions"]["Exec"] != null) { // do we have an array of Command? if (scheduledTask["Properties"]["Task"]["Actions"]["Exec"].Type == JTokenType.Array) { int i = 1; foreach (JToken item in scheduledTask["Properties"]["Task"]["Actions"]["Exec"]) { assessedScheduledTask.Add(ExtractCommandFromScheduledTask(item, ref interestLevel, i)); i++; } } else { // or just one? assessedScheduledTask.Add(ExtractCommandFromScheduledTask(scheduledTask["Properties"]["Task"]["Actions"]["Exec"], ref interestLevel)); } } if (scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"] != null) { string attachmentString = JUtil.GetSafeString( scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"]["Attachments"], "File"); JObject attachment = new JObject(new JProperty("Attachment", attachmentString)); if (GlobalVar.OnlineChecks) { attachment = FileSystem.InvestigateString(attachmentString); if (attachment["InterestLevel"] != null) { int attachmentInterest = (int)attachment["InterestLevel"]; interestLevel = interestLevel + attachmentInterest; } } assessedScheduledTask.Add( new JProperty("Action - Send Email", new JObject( new JProperty("From", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "From")), new JProperty("To", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "To")), new JProperty("Subject", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "Subject")), new JProperty("Body", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "Body")), new JProperty("Header Fields", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "HeaderFields")), new JProperty("Attachment", attachment), new JProperty("Server", JUtil.GetSafeString(scheduledTask["Properties"]["Task"]["Actions"]["SendEmail"], "Server")) ) ) ); } } if (schedTaskType == "Task") { string commandString = JUtil.GetSafeString(scheduledTask["Properties"], "@appname"); string argumentsString = JUtil.GetSafeString(scheduledTask["Properties"], "@args"); JObject command = new JObject(new JProperty("Command", commandString)); JObject arguments = new JObject(new JProperty("Arguments", argumentsString)); command = FileSystem.InvestigatePath(commandString); arguments = FileSystem.InvestigateString(argumentsString); if ((arguments != null) && (arguments["InterestLevel"] != null)) { int argumentInterest = (int)arguments["InterestLevel"]; interestLevel = interestLevel + argumentInterest; } if ((command != null) && (command["InterestLevel"] != null)) { int commandInterest = (int)command["InterestLevel"]; interestLevel = interestLevel + commandInterest; } assessedScheduledTask.Add("Action", JUtil.GetActionString(scheduledTask["Properties"]["@action"].ToString())); assessedScheduledTask.Add("Command", command); assessedScheduledTask.Add("Args", arguments); JObject assessedWorkingDir = FileSystem.InvestigatePath(JUtil.GetSafeString(scheduledTask["Properties"], "@startIn")); if ((assessedWorkingDir != null) && assessedWorkingDir.HasValues) { assessedScheduledTask.Add("Working Dir", assessedWorkingDir); } if (scheduledTask["Properties"]["Triggers"] != null) { assessedScheduledTask.Add("Triggers", scheduledTask["Properties"]["Triggers"]); } } if (schedTaskType == "ImmediateTask") { string argumentsString = JUtil.GetSafeString(scheduledTask["Properties"], "@args"); string commandString = JUtil.GetSafeString(scheduledTask["Properties"], "@appName"); JObject command = new JObject(new JProperty("Command", commandString)); JObject arguments = new JObject(new JProperty("Arguments", argumentsString)); command = FileSystem.InvestigatePath(commandString); arguments = FileSystem.InvestigateString(argumentsString); if ((arguments != null) && (arguments["InterestLevel"] != null)) { int argumentInterest = (int)arguments["InterestLevel"]; interestLevel = interestLevel + argumentInterest; } if ((command != null) && (command["InterestLevel"] != null)) { int commandInterest = (int)command["InterestLevel"]; interestLevel = interestLevel + commandInterest; } assessedScheduledTask.Add("Command", command); assessedScheduledTask.Add("Arguments", arguments); JObject assessedWorkingDir = FileSystem.InvestigatePath(JUtil.GetSafeString(scheduledTask["Properties"], "@startIn")); if ((assessedWorkingDir != null) && assessedWorkingDir.HasValues) { assessedScheduledTask.Add("Working Dir", assessedWorkingDir); } assessedScheduledTask.Add("Comment", JUtil.GetSafeString(scheduledTask["Properties"], "@comment")); } if (interestLevel < GlobalVar.IntLevelToShow) { return(null); } return(assessedScheduledTask); }
private JObject GetAssessedGroup(JObject gppGroup) { int interestLevel = 3; JToken gppGroupProps = gppGroup["Properties"]; // check what the entry is doing to the group and turn it into real word string groupAction = JUtil.GetActionString(gppGroupProps["@action"].ToString()); //TODO if the name is an interesting group, make the finding more interesting. JArray gppGroupMemberJArray = new JArray(); string membersString = ""; if (gppGroupProps["Members"] != null) { if (!(gppGroupProps["Members"] is JValue)) { if (gppGroupProps["Members"]["Member"] != null) { JToken members = gppGroupProps["Members"]["Member"]; string membersType = members.Type.ToString(); if (membersType == "Array") { foreach (JToken member in members.Children()) { gppGroupMemberJArray.Add(GetAssessedGroupMember(member)); } } else if (membersType == "Object") { gppGroupMemberJArray.Add(GetAssessedGroupMember(members)); } else { Output.DebugWrite("Something went squirrely with Group Memberships"); Output.DebugWrite(members.Type.ToString()); Output.DebugWrite(" " + membersType + " "); Output.DebugWrite(members.ToString()); } } } // munge jarray string to make it tidier. membersString = gppGroupMemberJArray.ToString(); membersString = membersString.Replace("\"", ""); membersString = membersString.Replace(",", ""); membersString = membersString.Replace("[", ""); membersString = membersString.Replace("]", ""); membersString = membersString.Replace("{", ""); membersString = membersString.Replace("}", ""); membersString = membersString.Replace(" ", ""); membersString = membersString.Replace("\r\n \r\n \r\n", "\r\n\r\n"); membersString = membersString.Trim(); } List <JToken> groupProps = new List <JToken> { JUtil.GetSafeJProp("Name", gppGroup, "@name"), JUtil.GetSafeJProp("Description", gppGroup, "@description"), JUtil.GetSafeJProp("New Name", gppGroupProps, "@newName"), JUtil.GetSafeJProp("Delete All Users", gppGroupProps, "@deleteAllUsers"), JUtil.GetSafeJProp("Delete All Groups", gppGroupProps, "@deleteAllGroups"), JUtil.GetSafeJProp("Remove Accounts", gppGroupProps, "@removeAccounts"), JUtil.GetSafeJProp("Action", groupAction), JUtil.GetSafeJProp("Members", membersString) }; JObject assessedGroup = new JObject(); foreach (JProperty groupProp in groupProps) { if (groupProp != null) { assessedGroup.Add(groupProp); } } if ((interestLevel > GlobalVar.IntLevelToShow) && (assessedGroup.HasValues)) { return(assessedGroup); } return(null); }
private JObject GetAssessedRegistrySetting(JToken gppRegSetting) { JObject jankyDb = JankyDb.Instance; // get our data about what regkeys are interesting JArray intRegKeysData = (JArray)jankyDb["regKeys"]; JObject assessedRegistrySetting = new JObject(); assessedRegistrySetting.Add("Display Name", JUtil.GetSafeString(gppRegSetting, "@name")); assessedRegistrySetting.Add("Status", JUtil.GetSafeString(gppRegSetting, "@status")); assessedRegistrySetting.Add("Changed", JUtil.GetSafeString(gppRegSetting, "@changed")); assessedRegistrySetting.Add("Action", JUtil.GetActionString(gppRegSetting["Properties"]["@action"].ToString())); assessedRegistrySetting.Add("Default", JUtil.GetSafeString(gppRegSetting["Properties"], "@default")); assessedRegistrySetting.Add("Hive", JUtil.GetSafeString(gppRegSetting["Properties"], "@hive")); string key = JUtil.GetSafeString(gppRegSetting["Properties"], "@key"); int interestLevel = 1; foreach (JToken intRegKey in intRegKeysData) { if (key.ToLower().Contains(intRegKey["regKey"].ToString().ToLower())) { // get the name string interestLevelString = intRegKey["intLevel"].ToString(); // if it matches at all it's a 1. // if we can get the interest level from it, do so, otherwise throw an error that we need to fix something. if (!int.TryParse(interestLevelString, out interestLevel)) { Utility.Output.DebugWrite(intRegKey["regKey"].ToString() + " in jankydb doesn't have an interest level assigned."); } } } JObject investigatedKey = FileSystem.InvestigateString(key); if ((int)investigatedKey["InterestLevel"] >= interestLevel) { interestLevel = (int)investigatedKey["InterestLevel"]; } assessedRegistrySetting.Add("Key", investigatedKey); string name = JUtil.GetSafeString(gppRegSetting["Properties"], "@name"); JObject investigatedName = FileSystem.InvestigateString(name); if ((int)investigatedName["InterestLevel"] >= interestLevel) { interestLevel = (int)investigatedKey["InterestLevel"]; } assessedRegistrySetting.Add("Name", investigatedName); assessedRegistrySetting.Add("Type", JUtil.GetSafeString(gppRegSetting["Properties"], "@type")); string value = JUtil.GetSafeString(gppRegSetting["Properties"], "@value"); JObject investigatedValue = FileSystem.InvestigateString(value); if ((int)investigatedValue["InterestLevel"] >= interestLevel) { interestLevel = (int)investigatedKey["InterestLevel"]; } assessedRegistrySetting.Add("Value", investigatedValue); if (interestLevel >= GlobalVar.IntLevelToShow) { return(new JObject(assessedRegistrySetting)); } else { return(null); } }
public void LateUpdate() { JUtil.LogMessage(this, "Attempting vessel recovery"); GameEvents.OnVesselRecoveryRequested.Fire(VesselToRecover); GameObject.Destroy(this.gameObject); }