mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:35:42 +00:00
Show sworn hero faction in Free Heroes panel (#6926)
This commit is contained in:
+32
-8
@@ -22,9 +22,13 @@ namespace eagle {
|
||||
public RawImage fireImage;
|
||||
|
||||
private DynamicHeroTextUpdater textUpdater = new DynamicHeroTextUpdater();
|
||||
private DynamicFactionTextUpdater factionTextUpdater = new DynamicFactionTextUpdater();
|
||||
private GeneratedTextListener questTextListener;
|
||||
|
||||
public void SetUnaffiliatedHero(UnaffiliatedHeroBasics uh, IGameModel model) {
|
||||
ClearQuestTextListener();
|
||||
factionTextUpdater.Dispose();
|
||||
|
||||
professionImage.texture = EagleCommonTextures.Instance.Profession(uh.Profession);
|
||||
if (professionImage.texture == null) {
|
||||
professionImage.color = Color.clear;
|
||||
@@ -39,6 +43,7 @@ namespace eagle {
|
||||
case RecruitmentStatus.HasQuest:
|
||||
SetQuestText(uh.RecruitmentInfo.Quest, model);
|
||||
break;
|
||||
case RecruitmentStatus.Sworn: SetSwornRecruitmentStatusText(uh, model); break;
|
||||
default:
|
||||
questLabel.text = DisplayNames.ShortRecruitmentStatusString(uh.RecruitmentInfo);
|
||||
break;
|
||||
@@ -68,14 +73,36 @@ namespace eagle {
|
||||
|
||||
public void Dispose() {
|
||||
textUpdater?.Dispose();
|
||||
if (questTextListener != null) {
|
||||
ClientTextProvider.Provider.RemoveListener(questTextListener);
|
||||
questTextListener = null;
|
||||
}
|
||||
factionTextUpdater?.Dispose();
|
||||
ClearQuestTextListener();
|
||||
}
|
||||
|
||||
private void OnDestroy() { Dispose(); }
|
||||
|
||||
private void ClearQuestTextListener() {
|
||||
if (questTextListener == null) { return; }
|
||||
|
||||
ClientTextProvider.Provider.RemoveListener(questTextListener);
|
||||
questTextListener = null;
|
||||
}
|
||||
|
||||
private void SetSwornRecruitmentStatusText(UnaffiliatedHeroBasics uh, IGameModel model) {
|
||||
if (!model.Heroes.TryGetValue(uh.HeroId, out var hero) ||
|
||||
!(hero.FactionId is int factionId)) {
|
||||
questLabel.text = DisplayNames.ShortRecruitmentStatusString(uh.RecruitmentInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
var factionNamePlaceholder = DynamicTextTemplate.Placeholder(
|
||||
DisplayNames.FactionTextPlaceholders.FactionName);
|
||||
factionTextUpdater.SetFactionTextWithCustomFormat(
|
||||
questLabel,
|
||||
model.MaybeDestroyedFaction(factionId),
|
||||
model,
|
||||
$"Dedicated to {factionNamePlaceholder}",
|
||||
DisplayNames.ShortRecruitmentStatusString(uh.RecruitmentInfo));
|
||||
}
|
||||
|
||||
private void SetQuestText(Quest quest, IGameModel model) {
|
||||
if (quest == null) {
|
||||
questLabel.text = "There is nothing you can do";
|
||||
@@ -190,10 +217,7 @@ namespace eagle {
|
||||
// Set fallback text and create listener for dynamic updates
|
||||
questLabel.text = fallbackText;
|
||||
|
||||
// Clean up any existing listener
|
||||
if (questTextListener != null) {
|
||||
ClientTextProvider.Provider.RemoveListener(questTextListener);
|
||||
}
|
||||
ClearQuestTextListener();
|
||||
|
||||
// Create new listener for dynamic updates
|
||||
questTextListener =
|
||||
|
||||
Reference in New Issue
Block a user