public static void Postfix(Turret __instance, ref Text __result, VisibilityLevel visLevel) { if (__instance == null) { return; } /* * Turret.UnitName = return (this.TurretDef == null) ? "UNDEFINED" : this.TurretDef.Chassis.Description.Name -> * Turret.NickName = (this.TurretDef == null) ? "UNDEFINED" : this.TurretDef.Description.Name -> */ if (__instance.Combat.HostilityMatrix.IsLocalPlayerEnemy(__instance.team.GUID)) { string chassisName = __instance.UnitName; string fullName = __instance.Nickname; SensorScanType scanType = SensorLockHelper.CalculateSharedLock(__instance, null); if (scanType < SensorScanType.ArmorAndWeaponType) { bool hasVisualScan = VisualLockHelper.CanSpotTargetUsingCurrentPositions(ModState.LastPlayerActorActivated, __instance); if (hasVisualScan) { scanType = SensorScanType.ArmorAndWeaponType; } } Text response = CombatNameHelper.GetTurretOrVehicleDetectionLabel(visLevel, scanType, fullName, chassisName, false); __result = response; } }
public static void Postfix(Vehicle __instance, ref Text __result, VisibilityLevel visLevel) { if (__instance == null) { return; } ; /* * Vehicle.UnitName = VehicleDef.Chassis.Description.Name -> * Alacorn Mk.VI-P / vehicledef_ARES_CLAN / Demolisher II / Galleon GAL-102 * Vehicle.NickName = VehicleDef.Description.Name -> * Pirate Alacorn Gauss Carrier / Ares / Demolisher II` * VehicleDef.Description.Id -> * / / vehicledef_DEMOLISHER-II / vehicledef_GALLEON_GAL102 */ if (__instance.Combat.HostilityMatrix.IsLocalPlayerEnemy(__instance.team.GUID)) { string chassisName = __instance.UnitName; string fullName = __instance.Nickname; SensorScanType scanType = SensorLockHelper.CalculateSharedLock(__instance, null); if (scanType < SensorScanType.ArmorAndWeaponType) { bool hasVisualScan = VisualLockHelper.CanSpotTargetUsingCurrentPositions(ModState.LastPlayerActorActivated, __instance); if (hasVisualScan) { scanType = SensorScanType.ArmorAndWeaponType; } } Text response = CombatNameHelper.GetTurretOrVehicleDetectionLabel(visLevel, scanType, fullName, chassisName, true); __result = response; } }
private static void BuildCACDialogForTarget(AbstractActor source, ICombatant target, float range, bool hasVisualScan, SensorScanType scanType) { StringBuilder sb = new StringBuilder(); VisibilityLevel visLevel = source.VisibilityToTargetUnit(target); if (target is Mech mech) { string fullName = mech.Description.UIName; string chassisName = mech.UnitName; string partialName = mech.Nickname; string localName = CombatNameHelper.GetEnemyMechDetectionLabel(visLevel, scanType, fullName, partialName, chassisName).ToString(); string tonnage = "?"; if (scanType > SensorScanType.LocationAndType) { tonnage = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_WEIGHT], new object[] { (int)Math.Floor(mech.tonnage) }).ToString(); } string titleText = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_TITLE], new object[] { localName, tonnage }).ToString(); sb.Append(titleText); if (scanType > SensorScanType.StructAndWeaponID) { // Movement sb.Append(new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_MOVE_MECH], new object[] { mech.WalkSpeed, mech.RunSpeed, mech.JumpDistance }) .ToString() ); // Heat sb.Append(new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_HEAT], new object[] { mech.CurrentHeat, mech.MaxHeat }) .ToString() ); // Stability sb.Append(new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_STAB], new object[] { mech.CurrentStability, mech.MaxStability }) .ToString() ); } } else if (target is Turret turret) { string chassisName = turret.UnitName; string fullName = turret.Nickname; string localName = CombatNameHelper.GetTurretOrVehicleDetectionLabel(visLevel, scanType, fullName, chassisName, false).ToString(); string titleText = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_TITLE], new object[] { localName, "" }).ToString(); sb.Append(titleText); } else if (target is Vehicle vehicle) { string chassisName = vehicle.UnitName; string fullName = vehicle.Nickname; string localName = CombatNameHelper.GetTurretOrVehicleDetectionLabel(visLevel, scanType, fullName, chassisName, true).ToString(); string tonnage = "?"; if (scanType > SensorScanType.LocationAndType) { tonnage = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_WEIGHT], new object[] { (int)Math.Floor(vehicle.tonnage) }).ToString(); } string titleText = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_TITLE], new object[] { localName, tonnage }).ToString(); sb.Append(titleText); if (scanType > SensorScanType.StructAndWeaponID) { // Movement sb.Append(new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_MOVE_VEHICLE], new object[] { vehicle.CruiseSpeed, vehicle.FlankSpeed }) .ToString() ); } } string distance = new Text(Mod.LocalizedText.CACSidePanel[ModText.LT_CAC_SIDEPANEL_DIST], new object[] { (int)Math.Ceiling(range) }).ToString(); sb.Append(distance); Text panelText = new Text(sb.ToString(), new object[] { }); CustAmmoCategories.CombatHUDInfoSidePanelHelper.SetTargetInfo(source, target, panelText); }