This commit is contained in:
2026-03-11 16:48:26 +08:00
parent 113decb414
commit 9c5871b518
21 changed files with 611 additions and 47 deletions
@@ -117,7 +117,7 @@ namespace GeometryTD.CustomUtility
ConfigId = 3,
Name = "穿透枪口",
Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Purple),
Endurance = 97f,
Endurance = 1f,
IsAssembledIntoTower = false,
AttackDamage = new[] { 50, 55, 60, 80, 90 },
DamageRandomRate = 0.02f,
@@ -70,6 +70,14 @@ namespace GeometryTD.CustomUtility
sb.Append(BuildTowerDesc(tower.Stats ?? new TowerStatsData()));
float enduranceRate = ResolveTowerEnduranceRate(tower, muzzleMap, bearingMap, baseMap);
sb.AppendLine($"平均耐久: {enduranceRate * 100f:0.#}");
CombatParticipantTowerValidationFailureReason failureReason =
ResolveTowerValidationFailureReason(tower, muzzleMap, bearingMap, baseMap);
if (failureReason != CombatParticipantTowerValidationFailureReason.None)
{
sb.AppendLine("状态:已损坏");
sb.Append($"参战限制:{CombatParticipantTowerValidationText.GetFailureReasonMessage(failureReason)}");
}
return sb.ToString();
}
@@ -139,6 +147,7 @@ namespace GeometryTD.CustomUtility
sb.AppendLine($"攻击方式:{ConvertAttackMethod(muzzleData.AttackMethodType)}");
sb.AppendLine($"当前耐久:{muzzleData.Endurance}");
AppendComponentBrokenStatus(sb, muzzleData);
return sb.ToString();
}
@@ -164,6 +173,7 @@ namespace GeometryTD.CustomUtility
sb.Append('\n');
sb.AppendLine($"当前耐久:{bearingData.Endurance}");
AppendComponentBrokenStatus(sb, bearingData);
return sb.ToString();
}
@@ -183,10 +193,65 @@ namespace GeometryTD.CustomUtility
sb.AppendLine($"伤害属性:{ConvertAttackProperty(baseData.AttackPropertyType)}");
sb.AppendLine($"当前耐久:{baseData.Endurance}");
AppendComponentBrokenStatus(sb, baseData);
return sb.ToString();
}
private static void AppendComponentBrokenStatus(StringBuilder sb, TowerCompItemData component)
{
if (sb == null || component == null || component.Endurance > 0f)
{
return;
}
sb.AppendLine("状态:已损坏,无法参战。");
}
private static CombatParticipantTowerValidationFailureReason ResolveTowerValidationFailureReason(
TowerItemData tower,
IReadOnlyDictionary<long, MuzzleCompItemData> muzzleMap,
IReadOnlyDictionary<long, BearingCompItemData> bearingMap,
IReadOnlyDictionary<long, BaseCompItemData> baseMap)
{
if (tower == null)
{
return CombatParticipantTowerValidationFailureReason.TowerMissing;
}
if (muzzleMap == null || !muzzleMap.TryGetValue(tower.MuzzleComponentInstanceId, out MuzzleCompItemData muzzle))
{
return CombatParticipantTowerValidationFailureReason.MissingMuzzleComponent;
}
if (muzzle.Endurance <= 0f)
{
return CombatParticipantTowerValidationFailureReason.BrokenMuzzleComponent;
}
if (bearingMap == null || !bearingMap.TryGetValue(tower.BearingComponentInstanceId, out BearingCompItemData bearing))
{
return CombatParticipantTowerValidationFailureReason.MissingBearingComponent;
}
if (bearing.Endurance <= 0f)
{
return CombatParticipantTowerValidationFailureReason.BrokenBearingComponent;
}
if (baseMap == null || !baseMap.TryGetValue(tower.BaseComponentInstanceId, out BaseCompItemData baseComp))
{
return CombatParticipantTowerValidationFailureReason.MissingBaseComponent;
}
if (baseComp.Endurance <= 0f)
{
return CombatParticipantTowerValidationFailureReason.BrokenBaseComponent;
}
return CombatParticipantTowerValidationFailureReason.None;
}
public static string ConvertAttackMethod(AttackMethodType type)
{
return type switch
@@ -215,4 +280,3 @@ namespace GeometryTD.CustomUtility
}
}