Add supports for different skillpoints types (#1581)

* Refactor skill points to support multiple types

Reworked the skill point system to support multiple types (e.g., Memory, Blood) instead of a single experience cap. Added CP14SkillPointPrototype, updated skill storage and UI to handle per-type points, and adjusted related logic and prototypes. Updated localization and assets to reflect these changes.

* oopsie

* Update human.yml

* Update CP14SkillUIController.cs

* Refactor skill storage to use skillPoints config

Replaced 'experienceMaxCap: 0' with 'skillPoints: Memory: max: 0' in Skeletons T1, T2, and undead mob prototypes. This change standardizes skill storage configuration and improves clarity.
This commit is contained in:
Red
2025-07-27 13:47:05 +03:00
committed by GitHub
parent d9b3ceac7c
commit 5020be8ec6
27 changed files with 213 additions and 109 deletions

View File

@@ -155,27 +155,36 @@ public sealed class CP14SkillUIController : UIController, IOnStateEntered<Gamepl
private void SelectNode(CP14SkillPrototype? skill)
{
if (skill is null)
{
DeselectNode();
UpdateGraphControl();
return;
}
if (_window is null)
return;
if (_targetPlayer == null)
return;
if (!_proto.TryIndex(skill.Tree, out var indexedTree))
return;
if (!_proto.TryIndex(indexedTree.SkillType, out var indexedSkillType))
return;
_selectedSkill = skill;
if (skill == null)
{
DeselectNode();
}
else
{
_window.SkillName.Text = _skill.GetSkillName(skill);
_window.SkillDescription.SetMessage(GetSkillDescription(skill));
_window.SkillFree.Visible = _skill.HaveFreeSkill(_targetPlayer.Value, skill);
_window.SkillView.Texture = skill.Icon.Frame0();
_window.LearnButton.Disabled = !_skill.CanLearnSkill(_targetPlayer.Value, skill);
_window.SkillCost.Text = skill.LearnCost.ToString();
}
_window.SkillName.Text = _skill.GetSkillName(skill);
_window.SkillDescription.SetMessage(GetSkillDescription(skill));
_window.SkillFree.Visible = _skill.HaveFreeSkill(_targetPlayer.Value, skill);
_window.SkillView.Texture = skill.Icon.Frame0();
_window.LearnButton.Disabled = !_skill.CanLearnSkill(_targetPlayer.Value, skill);
_window.SkillPointText.Text =
Loc.GetString("cp14-skill-menu-learncost", ("type", Loc.GetString(indexedSkillType.Name)));
_window.SkillCost.Text = skill.LearnCost.ToString();
_window.SkillPointIcon.Texture = indexedSkillType.Icon?.Frame0();
UpdateGraphControl();
}
@@ -231,6 +240,19 @@ public sealed class CP14SkillUIController : UIController, IOnStateEntered<Gamepl
if (!EntityManager.TryGetComponent<CP14SkillStorageComponent>(_targetPlayer, out var storage))
return;
if (!_proto.TryIndex(_selectedSkillTree.SkillType, out var indexedSkillType))
return;
var skillPointsMap = storage.SkillPoints;
if (skillPointsMap.TryGetValue(_selectedSkillTree.SkillType, out var skillContainer))
_window.LevelLabel.Text =
$"{Loc.GetString(indexedSkillType.Name)}: {skillContainer.Sum}/{skillContainer.Max}";
else
_window.LevelLabel.Text = $"{Loc.GetString(indexedSkillType.Name)}: 0/0";
_window.LevelTexture.Texture = indexedSkillType.Icon?.Frame0();
HashSet<CP14NodeTreeElement> nodeTreeElements = new();
HashSet<(string, string)> nodeTreeEdges = new();
@@ -303,14 +325,15 @@ public sealed class CP14SkillUIController : UIController, IOnStateEntered<Gamepl
SelectNode(_selectedSkill);
UpdateGraphControl();
_window.LevelLabel.Text = $"{storage.SkillsSumExperience}/{storage.ExperienceMaxCap}";
_window.TreeTabsContainer.RemoveAllChildren();
foreach (var tree in storage.AvailableSkillTrees)
{
if (!_proto.TryIndex(tree, out var indexedTree))
return;
if (!_proto.TryIndex(indexedTree.SkillType, out var indexedSkillType))
return;
float learnedPoints = 0;
foreach (var skillId in storage.LearnedSkills)
{
@@ -323,7 +346,10 @@ public sealed class CP14SkillUIController : UIController, IOnStateEntered<Gamepl
}
}
var treeButton2 = new CP14SkillTreeButtonControl(indexedTree.Color, Loc.GetString(indexedTree.Name), learnedPoints);
var treeButton2 = new CP14SkillTreeButtonControl(indexedTree.Color,
Loc.GetString(indexedTree.Name),
learnedPoints,
indexedSkillType.Icon?.Frame0());
treeButton2.ToolTip = Loc.GetString(indexedTree.Desc ?? string.Empty);
treeButton2.OnPressed += () =>
{

View File

@@ -37,8 +37,8 @@
</BoxContainer>
<!-- Skill Cost -->
<BoxContainer HorizontalExpand="True">
<RichTextLabel HorizontalExpand="True" Access="Public" Text="{Loc 'cp14-skill-menu-learncost'}" Margin="0 10 0 10" />
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Left" TextureScale="2, 2" TexturePath="/Textures/_CP14/Interface/Misc/skillpoint.png"/>
<RichTextLabel Name="SkillPointText" HorizontalExpand="True" Access="Public" Margin="0 10 0 10" />
<TextureRect Name="SkillPointIcon" VerticalAlignment="Center" HorizontalAlignment="Left" TextureScale="2, 2" Access="Public" />
<RichTextLabel Name="SkillCost" Access="Public" Text="0"/>
</BoxContainer>
<!-- Skill Description -->
@@ -78,9 +78,8 @@
</BoxContainer>
<!-- Experience Data -->
<BoxContainer Margin="10 10 10 10" VerticalAlignment="Bottom" HorizontalAlignment="Center" Orientation="Horizontal" VerticalExpand="True">
<RichTextLabel VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Loc 'cp14-skill-menu-level'}" StyleClasses="LabelKeyText"/>
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2, 2" TexturePath="/Textures/_CP14/Interface/Misc/skillpoint.png"/>
<RichTextLabel Margin="0 0 0 0" Name="LevelLabel" VerticalAlignment="Center" HorizontalAlignment="Left" Text="0" StyleClasses="LabelKeyText" Access="Public"/>
<TextureRect Name="LevelTexture" VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2, 2" Access="Public"/>
</BoxContainer>
</PanelContainer>
</BoxContainer>