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;
            }
        }
        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(Mech __instance, ref Text __result, VisibilityLevel visLevel)
        {
            if (__instance == null)
            {
                return;
            }

            /*
             *  Mech.UnitName = MechDef.Chassis.Description.Name -> Shadow Hawk / Atlas / Marauder
             *  Mech.Nickname = Mech.Description.Name -> Shadow Hawk SHD-2D / Atlas AS7-D / Marauder ANU-O
             *  Mech.Description.UIName -> Shadow Hawk SHD-2D / Atlas AS7-D Danielle / Anand ANU-O
             */
            string fullName = __instance.Description.UIName;

            if (__instance.Combat.HostilityMatrix.IsLocalPlayerEnemy(__instance.team.GUID))
            {
                string chassisName = __instance.UnitName;
                string partialName = __instance.Nickname;

                SensorScanType scanType = SensorLockHelper.CalculateSharedLock(__instance, null);
                if (scanType < SensorScanType.ArmorAndWeaponType)
                {
                    bool hasVisualScan = VisualLockHelper.CanSpotTargetUsingCurrentPositions(ModState.LastPlayerActorActivated, __instance);
                    if (hasVisualScan)
                    {
                        scanType = SensorScanType.ArmorAndWeaponType;
                    }
                }

                __result = CombatNameHelper.GetEnemyMechDetectionLabel(visLevel, scanType, fullName, partialName, chassisName);
            }
            else
            {
                string displayName = __instance.DisplayName;

                __result = CombatNameHelper.GetNonHostileMechDetectionLabel(__instance, fullName, displayName);
            }
        }
Beispiel #4
0
        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);
        }