Files
wwdpublic/Content.Shared/Psionics/PsionicPowerPrototype.cs
VMSolidus a3747166d8 Psionic Refactor Version 3 Part 1 (#1383)
# Description

They say Rome wasn't built in a day, well this entire PR was coded in a
single 6 hour Adderall binge. This PR represents the next big leap in
code capability for the PsionicSystem, completely reworking how Psionic
Powers are added and removed, such that like the TraitSystem, they
utilize modular functions governing how they work. Instead of there
being only 5 different hardcoded things that Psi Powers can do, there is
now a library containing 21 different modular functions, which are
slotted as desired into the power prototypes.

Additionally, a significant improvement in the logical flow of this is
that since each power is responsible for its own "removal codepath",
it's now possible to remove individual powers from a character, as
opposed to always needing to wipe the slate clean entirely.

I'm not going to add any new powers in this PR, nor am I touching the
code for the Psionic Actions themselves, that'll come in Part 2, in
which I refactor the Psionic-Actions so that they also operate on
similar stacks of modular functions.

This PR also makes extensive refactors to the PsionicPowerPrototype, as
well as PsionicAbilitiesSystem, so that it has all new hooks and
datafields for other systems to be able to modify a psion. It is now
entirely feasible to create unique "Types" of Psions, with their own
distinct power lists. It's also now possible to create "Tech Trees" of
powers, by setting up powers such that they write to and modify the
personalized pool of available powers to generate. For example,
Xenoglossy and Psychognomy are now dependent on Telepathy, and simply
won't appear in the list of available powers if a Psion doesn't first
have Telepathy.

# Changelog

🆑
- add: Psionic Refactor V3 is here! No new powers are added in this
update, but the options for creating new powers has been SIGNIFICANTLY
EXPANDED.
- add: Xenoglossy and Psychognomy now can only be rolled if you first
have the Telepathy power.
- add: Breath of Life can now only be rolled if you first have the
Healing Word power
- add: Pyrokinesis and Summon Imp now require the Pyroknetic Flare power
- add: All new Psychognomy descriptors for many pre-existing powers.
Have fun being unintentionally screamed at telepathically by someone
with the POWER OVERWHELMING trait.

(cherry picked from commit eb27db61dc42c00ea18198c094633692bf5baf0a)
2025-01-13 23:02:35 +03:00

64 lines
2.0 KiB
C#

using Content.Shared.Abilities.Psionics;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;
namespace Content.Shared.Psionics;
[Prototype]
public sealed partial class PsionicPowerPrototype : IPrototype
{
/// <summary>
/// The ID of the psionic power to use.
/// </summary>
[IdDataField]
public string ID { get; } = default!;
/// <summary>
/// The name of the psionic power.
/// </summary>
[DataField(required: true)]
public string Name = default!;
/// <summary>
/// What category of psionics does this power come from.
/// EG: Mentalics, Anomalists, Blood Cults, Heretics, etc.
/// </summary>
[DataField]
public List<string> PowerCategories = new();
/// <summary>
/// These functions are called when a Psionic Power is added to a Psion.
/// </summary>
[DataField(serverOnly: true)]
public PsionicPowerFunction[] InitializeFunctions { get; private set; } = Array.Empty<PsionicPowerFunction>();
/// <summary>
/// These functions are called when a Psionic Power is removed from a Psion,
/// as a rule of thumb these should do the exact opposite of most of a power's init functions.
/// </summary>
[DataField(serverOnly: true)]
public PsionicPowerFunction[] RemovalFunctions { get; private set; } = Array.Empty<PsionicPowerFunction>();
/// <summary>
/// How many "Power Slots" this power occupies.
/// </summary>
[DataField]
public int PowerSlotCost = 1;
}
/// This serves as a hook for psionic powers to modify the psionic component.
[ImplicitDataDefinitionForInheritors]
public abstract partial class PsionicPowerFunction
{
public abstract void OnAddPsionic(
EntityUid mob,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager,
ISharedPlayerManager playerManager,
ILocalizationManager loc,
PsionicComponent psionicComponent,
PsionicPowerPrototype proto);
}