This commit is contained in:
Ed
2025-03-30 20:31:37 +03:00
committed by GitHub
parent 8a479c4e5e
commit 987f00a493
14 changed files with 113 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared._CP14.Skill.Components;
using Content.Shared._CP14.Skill.Prototypes;
using Content.Shared.Administration;
using Content.Shared.Administration.Managers;
using Content.Shared.FixedPoint;
using Content.Shared.Verbs;
using Robust.Shared.Prototypes;
@@ -14,6 +15,7 @@ public abstract partial class CP14SharedSkillSystem
[Dependency] private readonly IPrototypeManager _proto = default!;
private IEnumerable<CP14SkillPrototype>? _allSkills;
private IEnumerable<CP14SkillTreePrototype>? _allTrees;
private void InitializeAdmin()
{
SubscribeLocalEvent<CP14SkillStorageComponent, GetVerbsEvent<Verb>>(OnGetAdminVerbs);
@@ -33,7 +35,8 @@ public abstract partial class CP14SharedSkillSystem
private void UpdateCachedSkill()
{
_allSkills = _proto.EnumeratePrototypes<CP14SkillPrototype>().ToList().OrderBy(skill => skill.Tree.Id).ThenBy(skill => skill.Name);
_allSkills = _proto.EnumeratePrototypes<CP14SkillPrototype>();
_allTrees = _proto.EnumeratePrototypes<CP14SkillTreePrototype>();
}
@@ -42,11 +45,32 @@ public abstract partial class CP14SharedSkillSystem
if (!_admin.HasAdminFlag(args.User, AdminFlags.Admin))
return;
if (_allSkills is null)
if (_allSkills is null || _allTrees is null)
return;
var target = args.Target;
//Add skill points
foreach (var tree in _allTrees)
{
FixedPoint2 current = 0;
ent.Comp.Progress.TryGetValue(tree, out current);
var name = Loc.GetString(tree.Name);
args.Verbs.Add(new Verb
{
Text = name,
Message = $"{name} EXP {current} -> {current + 1}",
Category = VerbCategory.CP14AdminSkillAdd,
Icon = tree.Icon,
Act = () =>
{
TryAddExperience(target, tree.ID, 1);
},
Priority = 2,
});
}
//Add Skill
foreach (var skill in _allSkills)
{
@@ -67,6 +91,30 @@ public abstract partial class CP14SharedSkillSystem
});
}
//Remove skill points
foreach (var tree in _allTrees)
{
FixedPoint2 current = 0;
ent.Comp.Progress.TryGetValue(tree, out current);
if (current < 1)
continue;
var name = Loc.GetString(tree.Name);
args.Verbs.Add(new Verb
{
Text = name,
Message = $"{name} EXP {current} -> {current - 1}",
Category = VerbCategory.CP14AdminSkillRemove,
Icon = tree.Icon,
Act = () =>
{
TryRemoveExperience(target, tree.ID, 1);
},
Priority = 2,
});
}
//Remove Skill
foreach (var skill in ent.Comp.LearnedSkills)
{