2025-10-03 00:02:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
2025-10-27 07:04:34 -04:00
|
|
|
|
using System.Linq;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using SLSFramework.General;
|
2025-11-08 09:50:55 -05:00
|
|
|
|
using UniRx;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Card
|
|
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public class ContentSubmodule : SubmoduleBase<CardInstance>
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
public List<string> keywords;
|
|
|
|
|
|
|
|
|
|
|
|
public string cardName;
|
|
|
|
|
|
public Sprite cardSprite;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public Rarity cardRarity;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public CardType cardType;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public string originalFunctionText;
|
|
|
|
|
|
public string interpretedFunctionText;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
2025-11-08 09:50:55 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 标记:内容已更改,需要刷新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool dirtyMark;
|
|
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 标记:hint shadow 颜色需要刷新,不触发文本重解析
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool hintDirtyMark;
|
|
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public ContentSubmodule(CardInstance card) : base(card)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-27 07:04:34 -04:00
|
|
|
|
keywords = card.cardData.keywords;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
cardName = card.cardData.displayName.Localize();
|
2026-04-01 12:23:27 -04:00
|
|
|
|
cardSprite = card.cardData.cardSprite ?? MainGameManager.Instance.basePrefabs.defaultCardImage;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
originalFunctionText = card.cardData.functionText.Localize();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
cardRarity = card.cardData.cardRarity;
|
|
|
|
|
|
cardType = card.cardData.cardType;
|
2025-11-08 09:50:55 -05:00
|
|
|
|
dirtyMark = false;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
hintDirtyMark = false;
|
2025-11-08 09:50:55 -05:00
|
|
|
|
|
|
|
|
|
|
Observable.EveryLateUpdate().Subscribe(_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dirtyMark)
|
|
|
|
|
|
{
|
|
|
|
|
|
RefreshContent();
|
|
|
|
|
|
dirtyMark = false;
|
|
|
|
|
|
}
|
2026-04-01 12:23:27 -04:00
|
|
|
|
if (hintDirtyMark)
|
|
|
|
|
|
{
|
|
|
|
|
|
RefreshHintShadow();
|
|
|
|
|
|
hintDirtyMark = false;
|
|
|
|
|
|
}
|
2025-11-08 09:50:55 -05:00
|
|
|
|
}).AddTo(card.disposables);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-11-08 09:50:55 -05:00
|
|
|
|
|
|
|
|
|
|
public void RefreshContent()
|
|
|
|
|
|
{
|
|
|
|
|
|
CardTextInterpreter.InterpretText(owner);
|
|
|
|
|
|
owner.handCardView?.Setup();
|
|
|
|
|
|
owner.intentionCardView?.Setup();
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
// 文本刷新后,hint 也需要同步更新
|
|
|
|
|
|
hintDirtyMark = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 仅刷新 hint shadow 颜色,不触发文本重解析。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void RefreshHintShadow()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (owner.handCardView == null || owner.handCardView.isSelecting) return;
|
|
|
|
|
|
Color? hintColor = owner.cardLogic?.GetHintColor();
|
|
|
|
|
|
owner.handCardView.UpdateHintShadow(hintColor);
|
2025-11-08 09:50:55 -05:00
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|