Added reset all (non-free) skills (#1343)

* Added reset all (non-free) skills

* I don't know why I didn't do this the first time

* Formatting fixes

* Removed old code and made removal function iterate in reverse order
This commit is contained in:
TheKittehJesus
2025-06-03 02:58:21 -05:00
committed by GitHub
parent 766f17e559
commit d4e9049576
2 changed files with 35 additions and 0 deletions

View File

@@ -244,6 +244,26 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem
return sb.ToString();
}
/// <summary>
/// Helper function to reset skills to only learned skills
/// </summary>
public bool TryResetSkills(EntityUid target,
CP14SkillStorageComponent? component = null)
{
if (!Resolve(target, ref component, false))
{
return false;
}
for(var i = component.LearnedSkills.Count - 1; i >= 0; i--)
{
if(HaveFreeSkill(target, component.LearnedSkills[i], component))
{
continue;
}
TryRemoveSkill(target, component.LearnedSkills[i], component);
}
return true;
}
}
[ByRefEvent]