This commit is contained in:
Tourswen
2025-11-20 22:57:25 +08:00
parent 6dc949158a
commit 22f03e2e05
19 changed files with 491 additions and 158 deletions

View File

@@ -4,13 +4,14 @@ using Verse;
namespace WulaFallenEmpire
{
// Gizmo 类保持不变...
[StaticConstructorOnStartup]
public class Gizmo_AreaShieldStatus : Gizmo
{
public ThingComp_AreaShield shield;
private static readonly Texture2D FullShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.8f, 0.85f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D;
private static readonly Texture2D EmptyShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.2f, 0.24f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D;
// 新增:移动状态的颜色
private static readonly Texture2D MovingShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.5f, 0.5f, 0.5f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D;
public override float GetWidth(float maxWidth) => 140f;
@@ -28,14 +29,33 @@ namespace WulaFallenEmpire
Rect barRect = rect2;
barRect.yMin = rect2.y + rect2.height / 2f;
float fillPercent = (float)shield.currentHitPoints / shield.HitPointsMax;
Widgets.FillableBar(barRect, fillPercent, FullShieldBarTex, EmptyShieldBarTex, false);
// 修改:根据状态选择不同的状态条
Texture2D barTex;
TaggedString statusText;
if (shield.IsOnCooldown)
{
barTex = EmptyShieldBarTex;
statusText = "ShieldOnCooldown".Translate();
}
else if (shield.IsWearerMoving)
{
// 移动时显示灰色状态条和"移动中"文本
barTex = MovingShieldBarTex;
statusText = "ShieldOfflineByMoving".Translate(); // 你可以根据需要修改这个文本
}
else
{
barTex = FullShieldBarTex;
statusText = new TaggedString(shield.currentHitPoints + " / " + shield.HitPointsMax);
}
Widgets.FillableBar(barRect, fillPercent, barTex, EmptyShieldBarTex, false);
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleCenter;
TaggedString statusText = shield.IsOnCooldown ? "ShieldOnCooldown".Translate() : new TaggedString(shield.currentHitPoints + " / " + shield.HitPointsMax);
Widgets.Label(barRect, statusText);
Text.Anchor = TextAnchor.UpperLeft;
return new GizmoResult(GizmoState.Clear);