Fix showvalue Ui for melee weapons (#38703)

Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
This commit is contained in:
Nemanja
2025-08-06 18:01:49 -04:00
committed by GitHub
parent dc3eb188cd
commit 66daa1e6db
4 changed files with 46 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
<ScrollContainer HorizontalExpand="True" <ScrollContainer HorizontalExpand="True"
VerticalExpand="True" VerticalExpand="True"
SizeFlagsStretchRatio="6"> SizeFlagsStretchRatio="6">
<GridContainer Name="Values"/> <GridContainer Name="Values" HSeparationOverride="0" VSeparationOverride="15"/>
</ScrollContainer> </ScrollContainer>
</BoxContainer> </BoxContainer>
</DefaultWindow> </DefaultWindow>

View File

@@ -6,10 +6,12 @@ using Content.Server.EUI;
using Content.Server.Item; using Content.Server.Item;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Research.Prototypes; using Content.Shared.Research.Prototypes;
using Content.Shared.UserInterface; using Content.Shared.UserInterface;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using Content.Shared.Wieldable.Components;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -170,10 +172,13 @@ public sealed class StatValuesCommand : IConsoleCommand
return state; return state;
} }
private static readonly ProtoId<DamageTypePrototype> StructuralDamageType = "Structural";
private StatValuesEuiMessage GetMelee() private StatValuesEuiMessage GetMelee()
{ {
var values = new List<string[]>(); var values = new List<string[]>();
var meleeName = _entManager.ComponentFactory.GetComponentName<MeleeWeaponComponent>(); var meleeName = _entManager.ComponentFactory.GetComponentName<MeleeWeaponComponent>();
var increaseDamageName = _entManager.ComponentFactory.GetComponentName<IncreaseDamageOnWieldComponent>();
foreach (var proto in _proto.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in _proto.EnumeratePrototypes<EntityPrototype>())
{ {
@@ -186,26 +191,45 @@ public sealed class StatValuesCommand : IConsoleCommand
var comp = (MeleeWeaponComponent) meleeComp.Component; var comp = (MeleeWeaponComponent) meleeComp.Component;
// TODO: Wielded damage
// TODO: Esword damage // TODO: Esword damage
var structuralDamage = comp.Damage.DamageDict.GetValueOrDefault(StructuralDamageType);
var baseDamage = comp.Damage.GetTotal() - comp.Damage.DamageDict.GetValueOrDefault(StructuralDamageType);
var wieldedStructuralDamage = "-";
var wieldedDamage = "-";
if (proto.Components.TryGetValue(increaseDamageName, out var increaseDamageComp))
{
var comp2 = (IncreaseDamageOnWieldComponent) increaseDamageComp.Component;
wieldedStructuralDamage = (structuralDamage + comp2.BonusDamage.DamageDict.GetValueOrDefault(StructuralDamageType)).ToString();
wieldedDamage = (baseDamage + comp2.BonusDamage.GetTotal() - comp2.BonusDamage.DamageDict.GetValueOrDefault(StructuralDamageType)).ToString();
}
values.Add(new[] values.Add(new[]
{ {
proto.ID, proto.ID,
(comp.Damage.GetTotal() * comp.AttackRate).ToString(), baseDamage.ToString(),
comp.AttackRate.ToString(CultureInfo.CurrentCulture), wieldedDamage,
comp.Damage.GetTotal().ToString(), comp.AttackRate.ToString("0.00", CultureInfo.CurrentCulture),
comp.Range.ToString(CultureInfo.CurrentCulture), (comp.AttackRate * baseDamage).Float().ToString("0.00", CultureInfo.CurrentCulture),
structuralDamage.ToString(),
wieldedStructuralDamage,
}); });
} }
var state = new StatValuesEuiMessage() var state = new StatValuesEuiMessage
{ {
Title = "Cargo sell prices", Title = Loc.GetString("stat-melee-values"),
Headers = new List<string>() Headers = new List<string>
{ {
"ID", Loc.GetString("stat-melee-id"),
"Price", Loc.GetString("stat-melee-base-damage"),
Loc.GetString("stat-melee-wield-damage"),
Loc.GetString("stat-melee-attack-rate"),
Loc.GetString("stat-melee-dps"),
Loc.GetString("stat-melee-structural-damage"),
Loc.GetString("stat-melee-structural-wield-damage"),
}, },
Values = values, Values = values,
}; };

View File

@@ -6,5 +6,6 @@ namespace Content.Shared.Wieldable.Components;
public sealed partial class IncreaseDamageOnWieldComponent : Component public sealed partial class IncreaseDamageOnWieldComponent : Component
{ {
[DataField("damage", required: true)] [DataField("damage", required: true)]
[Access(Other = AccessPermissions.ReadExecute)]
public DamageSpecifier BonusDamage = default!; public DamageSpecifier BonusDamage = default!;
} }

View File

@@ -8,6 +8,16 @@ stat-cargo-values = Cargo sell prices
stat-cargo-id = ID stat-cargo-id = ID
stat-cargo-price = Price stat-cargo-price = Price
# Melee
stat-melee-values = Melee weapon damage
stat-melee-id = ID
stat-melee-base-damage = Base damage
stat-melee-wield-damage = Wielded damage
stat-melee-attack-rate = Attack rate
stat-melee-dps = DPS
stat-melee-structural-damage = Structure damage
stat-melee-structural-wield-damage = Wielded structure damage
# Lathe # Lathe
stat-lathe-values = Lathe sell prices stat-lathe-values = Lathe sell prices
stat-lathe-id = ID stat-lathe-id = ID