Species free innate skill (#1277)

* innate free job skills

* returns species magic buff + unlock all skill

* Update tiefling.yml

* fix
This commit is contained in:
Ed
2025-05-18 00:37:04 +03:00
committed by GitHub
parent 5cd70ae1e9
commit 0274826e32
19 changed files with 127 additions and 125 deletions

View File

@@ -17,16 +17,40 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem
_skillStorageQuery = GetEntityQuery<CP14SkillStorageComponent>();
SubscribeLocalEvent<CP14SkillStorageComponent, MapInitEvent>(OnMapInit);
InitializeAdmin();
InitializeChecks();
}
private void OnMapInit(Entity<CP14SkillStorageComponent> ent, ref MapInitEvent args)
{
//If at initialization we have any skill records, we automatically give them to this entity
var free = ent.Comp.FreeLearnedSkills.ToList();
var learned = ent.Comp.LearnedSkills.ToList();
ent.Comp.FreeLearnedSkills.Clear();
ent.Comp.LearnedSkills.Clear();
foreach (var skill in free)
{
TryAddSkill(ent.Owner, skill, ent.Comp, true);
}
foreach (var skill in learned)
{
TryAddSkill(ent.Owner, skill, ent.Comp);
}
}
/// <summary>
/// Directly adds the skill to the player, bypassing any checks.
/// </summary>
public bool TryAddSkill(EntityUid target,
ProtoId<CP14SkillPrototype> skill,
CP14SkillStorageComponent? component = null)
CP14SkillStorageComponent? component = null,
bool free = false)
{
if (!Resolve(target, ref component, false))
return false;
@@ -42,7 +66,10 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem
effect.AddSkill(EntityManager, target);
}
component.SkillsSumExperience += indexedSkill.LearnCost;
if (free)
component.FreeLearnedSkills.Add(skill);
else
component.SkillsSumExperience += indexedSkill.LearnCost;
component.LearnedSkills.Add(skill);
Dirty(target, component);
@@ -74,7 +101,8 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem
effect.RemoveSkill(EntityManager, target);
}
component.SkillsSumExperience -= indexedSkill.LearnCost;
if (!component.FreeLearnedSkills.Remove(skill))
component.SkillsSumExperience -= indexedSkill.LearnCost;
Dirty(target, component);
return true;
@@ -93,6 +121,16 @@ public abstract partial class CP14SharedSkillSystem : EntitySystem
return component.LearnedSkills.Contains(skill);
}
public bool HaveFreeSkill(EntityUid target,
ProtoId<CP14SkillPrototype> skill,
CP14SkillStorageComponent? component = null)
{
if (!Resolve(target, ref component, false))
return false;
return component.FreeLearnedSkills.Contains(skill);
}
/// <summary>
/// Checks if the player can learn the specified skill.
/// </summary>