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]

View File

@@ -6,6 +6,7 @@ using Content.Shared.Administration.Managers;
using Content.Shared.FixedPoint;
using Content.Shared.Verbs;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared._CP14.Skill;
@@ -89,5 +90,19 @@ public abstract partial class CP14SharedSkillSystem
},
});
}
//Reset/Remove All Skills
args.Verbs.Add(new Verb
{
Text = "Reset skills",
Message = "Remove all learned skills",
Category = VerbCategory.CP14AdminSkillRemove,
Icon = new SpriteSpecifier.Rsi(new("/Textures/_CP14/Interface/Misc/reroll.rsi"), "reroll"),
Act = () =>
{
TryResetSkills(target);
},
});
}
}