跳转到内容

BattleUnitWorldBar

BattleUnitWorldBar

世界空间中的单位外框 — 分段 HP、AP 圆点、友军 / 敌军配色,可选预伤害威胁提示,工具提示身份信息。

SusGame · HUD(商业)

在 Playground 中打开

SusGame · HUD

属性

名称类型默认值
UnitNameProp<string>""v-model
RankProp<string>""v-model
DescriptionProp<string>""v-model
PositionLabelProp<string>""v-model
TipExtraProp<string>""v-model
CurrentHpProp<int>10v-model
MaxHpProp<int>10v-model
CurrentApProp<int>2v-model
MaxApProp<int>2v-model
PredamageMinProp<int>0v-model
PredamageAccuracyProp<int>0v-model
PredamageProp<bool>falsev-model
AllyProp<bool>truev-model
BarActiveProp<bool>truev-model
EntityIdProp<int>-1v-model
DisplayNameProp<string>""
HpTextProp<string>"0"

插槽

没有插槽。

事件

没有公开事件。

样式钩子

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

  • battle-unit-world-bar
  • battle-unit-world-bar__ap-pip
  • battle-unit-world-bar__ap-pip--active
  • battle-unit-world-bar__ap-pip--hidden
  • battle-unit-world-bar__ap-pip--spent
  • battle-unit-world-bar__ap-row
  • battle-unit-world-bar__ap-spacer
  • battle-unit-world-bar__content
  • battle-unit-world-bar__counter
  • battle-unit-world-bar__counter-label
  • battle-unit-world-bar__hp-row
  • battle-unit-world-bar__hp-seg
  • battle-unit-world-bar__hp-seg--empty
  • battle-unit-world-bar__hp-seg--filled
  • battle-unit-world-bar__hp-seg--hidden
  • battle-unit-world-bar__hp-seg--spent
  • battle-unit-world-bar__hp-seg--threat
  • battle-unit-world-bar__hp-seg-fill
  • battle-unit-world-bar__main
  • battle-unit-world-bar__name
  • battle-unit-world-bar__row
  • battle-unit-world-bar__statuses
  • battle-unit-world-bar__statuses--hidden
  • battle-unit-world-bar__tip
  • battle-unit-world-bar--ally
  • battle-unit-world-bar--enemy
  • battle-unit-world-bar--inactive
  • battle-unit-world-bar--predamage
  • sus-icon
  • sus-status-effect
  • sus-status-effect__icon

用法

csharp
var bar = new BattleUnitWorldBar();
bar.UnitName.Value = "Ranger";
bar.Rank.Value = "Sgt";
bar.Ally.Value = true;
bar.CurrentHp.Value = 7;
bar.MaxHp.Value = 10;
bar.CurrentAp.Value = 2;
bar.MaxAp.Value = 3;
bar.BarActive.Value = true;
bar.Init(wounds: 10, actionPoints: 3);
bar.ShowPredamage(minDamage: 2, accuracy: 75);
xml
<template>
  <sus:BattleUnitWorldBar :UnitName="Name.Value"
                          :Rank="Rank.Value"
                          :Description="Desc.Value"
                          :PositionLabel="Pos.Value"
                          :CurrentHp="Hp.Value"
                          :MaxHp="HpMax.Value"
                          :CurrentAp="Ap.Value"
                          :MaxAp="ApMax.Value"
                          :Ally="Ally.Value"
                          :BarActive="Active.Value"
                          :Predamage="Threat.Value"
                          :PredamageMin="ThreatMin.Value"
                          :PredamageAccuracy="ThreatAcc.Value"
                          :EntityId="Entity.Value" />
</template>

<script>
public Prop<string> Name = new("Ranger");
public Prop<string> Rank = new("Sgt");
public Prop<string> Desc = new("Scout · medium armor");
public Prop<string> Pos = new("A3");
public Prop<int> Hp = new(7);
public Prop<int> HpMax = new(10);
public Prop<int> Ap = new(2);
public Prop<int> ApMax = new(3);
public Prop<bool> Ally = new(true);
public Prop<bool> Active = new(true);
public Prop<bool> Threat = new(false);
public Prop<int> ThreatMin = new(0);
public Prop<int> ThreatAcc = new(0);
public Prop<int> Entity = new(-1);
</script>
Prop / API作用
UnitName · Rank · Description身份信息 / 提示框
PositionLabel · TipExtra额外的提示框文字行
CurrentHp / MaxHp伤口分段(1:1)
CurrentAp / MaxApAP 圆点(≤8
Ally友军 / 敌军配色
BarActive未激活 / 变暗
Predamage*HP 上的威胁覆盖层
EntityId宿主 / ECS 桥接 id
Init / ResolveDamage / SpendAction战斗辅助方法
ShowPredamage / ResetHealthVisual威胁提示 + 视觉重置

备注

  • DisplayNameHpText 是派生值 —— 请绑定上面列出的源属性,而不是这两个。
  • 每个伤口点对应一段 HP(当 MaxHp 不同时,并非固定填充的 10 段条)。
  • 对于更简单的世界空间标签,优先使用 kit 中的 SusHealthBar / SusUnitNameplate;本组件是战术分段变体。