跳转到内容

SusHudUnitCard

SusHudUnitCard

战术单位头像——图片或图标回退,名字 / 军衔覆层,状态效果行;点击可选中。

SusGame · HUD(商业)

在 Playground 中打开

SusGame · HUD

属性

名称类型默认值
UnitIdProp<string>""
UnitNameProp<string>""
RankProp<string>""
ImageSrcProp<string>""
IconProp<string>""
ActiveProp<bool>false
AllyProp<bool>true
HpProp<float>0f
MaxHpProp<float>0f

插槽

没有插槽。

事件

名称字段载荷
SelectedOnSelectedSusHudUnitCard

样式钩子

USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:

  • breakpoint-sm
  • sus-hud-unit-card
  • sus-hud-unit-card__effects
  • sus-hud-unit-card__fallback
  • sus-hud-unit-card__img
  • sus-hud-unit-card__name
  • sus-hud-unit-card__overlay
  • sus-hud-unit-card__portrait
  • sus-hud-unit-card__rank
  • sus-hud-unit-card--active
  • sus-hud-unit-card--ally
  • sus-hud-unit-card--enemy

用法

通过 props 驱动,或用 ApplyData / SetEffects 填充(rail 使用的是数据路径)。

csharp
var card = new SusHudUnitCard();
card.ApplyData(new SusHudUnitCardData
{
    Id = "u1",
    Name = "Mara",
    Rank = "Sergeant",
    ImageSrc = "portraits/mara",
    Icon = "",
    Active = true,
    Ally = true,
    Hp = 42f,
    MaxHp = 50f,
    Effects = new List<SusStatusEffectData>
    {
        new() { Id = "regen", Icon = "heart", Title = "Regen", Stacks = 2, TurnsLeft = 3 },
    },
});
card.OnSelected += c => { /* focus unit */ };
xml
<template>
  <sus:SusHudUnitCard :UnitId="Id.Value"
                      :UnitName="Name.Value"
                      :Rank="Rank.Value"
                      :ImageSrc="Img.Value"
                      :Icon="Icon.Value"
                      :Active="Active.Value"
                      :Ally="Ally.Value"
                      :Hp="Hp.Value"
                      :MaxHp="MaxHp.Value"
                      @selected="OnSelected" />
</template>

<script>
public Prop<string> Id = new("u1");
public Prop<string> Name = new("Mara");
public Prop<string> Rank = new("Sergeant");
public Prop<string> Img = new("portraits/mara");
public Prop<string> Icon = new("");
public Prop<bool> Active = new(true);
public Prop<bool> Ally = new(true);
public Prop<float> Hp = new(42f);
public Prop<float> MaxHp = new(50f);
void OnSelected(SusHudUnitCard card) { /* … */ }
// Prefer ApplyData + SetEffects when syncing from combat state.
</script>
Prop / APIRole
UnitId稳定 id(rail 对账用的 key)
UnitName · Rank覆层文本
ImageSrc头像目录 key(SusGameMedia
Icon图片为空时的回退图标 key
Active放大的 --active 外框;effect 尺寸切换 normal / mini
Ally友军 / 敌军边框样式
Hp · MaxHp仅用于 tooltip(MaxHp ≤ 0 时隐藏 HP 行)
ApplyData(SusHudUnitCardData)完整同步 + effects
SetEffects / ClearEffects状态行(SusStatusEffect
OnSelected载荷 = 当前卡片

备注

  • 没有 Phosphor 骷髅/用户占位图——只有目录中的 ImageSrc / Icon key。
  • 需要友军/敌军列表时,优先通过 SusHudUnitRail 承载。
  • 相关的分子组件 SusUnitCard 是另一个组件(名册 / 商店),不是这张 HUD 卡片。