/// <summary> /// Gets the radar equipment with the highest power level from a LastSeen. /// </summary> /// <param name="gridLastSeen">LastSeen for the detected grid.</param> /// <param name="strongestEquipment">The equipment with the highest power level.</param> /// <param name="powerLevel">The power level of the equipment.</param> /// <returns>True iff a radar equipment was found.</returns> public static bool GetRadarEquipment(LastSeen gridLastSeen, out IMyCubeBlock strongestEquipment, out float powerLevel) { strongestEquipment = null; powerLevel = 0f; IMyCubeBlock strongest_in = null; float powerLevel_in = 0f; bool recentRadar = gridLastSeen.isRecent_Radar(); bool recentJammer = gridLastSeen.isRecent_Jam(); Registrar.ForEach((RadarEquipment re) => { if (re.CubeBlock.CubeGrid == gridLastSeen.Entity) { if (!re.IsWorking) { return; } float reStr = 0f; if (recentRadar && re.myDefinition.Radar) // PowerLevel_Radar can be > 0 even if it is not a radar { reStr = re.PowerLevel_Radar; } if (recentJammer && re.PowerLevel_Jammer > reStr) { reStr = re.PowerLevel_Jammer; } if (reStr > powerLevel_in) { powerLevel_in = reStr; strongest_in = re.CubeBlock; } } }); strongestEquipment = strongest_in; powerLevel = powerLevel_in; return(strongestEquipment != null); }
public void TextForPlayer(StringBuilder builder, int count) { string time = (seconds / 60).ToString("00") + separator + (seconds % 60).ToString("00"); bool friendly = relations.HasAnyFlag(ExtensionsRelations.Relations.Faction) || relations.HasAnyFlag(ExtensionsRelations.Relations.Owner); string bestName = friendly ? seen.Entity.getBestName() : seen.HostileName(); builder.Append(relations); builder.Append(tab); builder.Append(seen.Type); builder.Append(tab); //if (friendly) //{ builder.Append(bestName); builder.Append(tab); //} if (!friendly) { if (seen.isRecent_Radar()) { builder.Append("Has Radar"); builder.Append(tab); } if (seen.isRecent_Jam()) { builder.Append("Has Jammer"); builder.Append(tab); } } builder.AppendLine(); builder.Append(tab); builder.Append(tab); builder.Append(PrettySI.makePretty(distance)); builder.Append('m'); builder.Append(tab); builder.Append(time); if (seen.RadarInfoIsRecent()) { builder.Append(tab); builder.Append(seen.Info.Pretty_Volume()); } builder.AppendLine(); // GPS tag if ((options & Option.GPS) != 0) { builder.Append(GPStag1); if (friendly) { builder.Append(bestName); } else { builder.Append(relations); builder.Append(seen.Type); builder.Append('#'); builder.Append(count); } builder.Append(separator); builder.Append((int)predictedPos.X); builder.Append(separator); builder.Append((int)predictedPos.Y); builder.Append(separator); builder.Append((int)predictedPos.Z); builder.Append(separator); builder.AppendLine(); } // Entity id if ((options & Option.EntityId) != 0) { builder.Append(tab); builder.Append(tab); builder.Append("ID: "); builder.Append(seen.Entity.EntityId); builder.AppendLine(); } }