Migrated the psionic reolling stuff to the new ECS system. Am I out of this hellhole yet?

This commit is contained in:
Vanessa 2025-12-23 16:25:35 -06:00
parent 3f69342eb4
commit 9cf3fb6aef
22 changed files with 216 additions and 174 deletions

View File

@ -0,0 +1,37 @@
using Content.Shared._DV.Pain;
using Content.Shared.EntityEffects;
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;
using Content.Server.Abilities.Psionics;
using Content.Server.Psionics;
using Content.Shared.Psionics.Glimmer;
namespace Content.Server._DV.EntityEffects.Effects;
// TODO: When Pain is moved to new Status, make this use StatusEffectsContainerComponent.
/// <summary>
/// Supresses pain based on how much of the pain suppressing reagent is in the system.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
public sealed partial class AffectsGlimmerEntityEffectSystem : EntityEffectSystem<MetaDataComponent, AffectsGlimmer>
{
[Dependency] private readonly GlimmerSystem _glimmer = default!;
protected override void Effect(Entity<MetaDataComponent> entity, ref EntityEffectEvent<AffectsGlimmer> args)
{
_glimmer.Glimmer += args.Effect.Amount;
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class AffectsGlimmer : EntityEffectBase<AffectsGlimmer>
{
/// <summary>
/// Amount that is added or subtracted from glimmer.
/// </summary>
[DataField]
public int Amount = 1;
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-change-glimmer-reaction-effect", ("chance", Probability),
("amount", Amount));
}

View File

@ -0,0 +1,34 @@
using Content.Shared._DV.Pain;
using Content.Shared.EntityEffects;
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;
using Content.Server.Abilities.Psionics;
using Content.Server.Psionics;
namespace Content.Server._DV.EntityEffects.Effects;
// TODO: When Pain is moved to new Status, make this use StatusEffectsContainerComponent.
/// <summary>
/// Supresses pain based on how much of the pain suppressing reagent is in the system.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
public sealed partial class RemovePsionicAbilitiesEntityEffectSystem : EntityEffectSystem<PotentialPsionicComponent, RemovePsionicAbilities>
{
[Dependency] private readonly PsionicsSystem _psionic = default!;
[Dependency] private readonly PsionicAbilitiesSystem _psionicAbilities = default!;
protected override void Effect(Entity<PotentialPsionicComponent> entity, ref EntityEffectEvent<RemovePsionicAbilities> args)
{
if (args.Scale != 1f)
return;
_psionicAbilities.RemovePsionics(entity);
_psionic.GrantNewPsionicReroll(entity);
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class RemovePsionicAbilities : EntityEffectBase<RemovePsionicAbilities>
{
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-chem-remove-psionic", ("chance", Probability));
}

View File

@ -0,0 +1,38 @@
using Content.Shared._DV.Pain;
using Content.Shared.EntityEffects;
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;
using Content.Server.Abilities.Psionics;
using Content.Server.Psionics;
namespace Content.Server._DV.EntityEffects.Effects;
// TODO: When Pain is moved to new Status, make this use StatusEffectsContainerComponent.
/// <summary>
/// Supresses pain based on how much of the pain suppressing reagent is in the system.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
public sealed partial class RerollPsionicAbilitiesEntityEffectSystem : EntityEffectSystem<PotentialPsionicComponent, RerollPsionicAbilities>
{
[Dependency] private readonly PsionicsSystem _psionic = default!;
protected override void Effect(Entity<PotentialPsionicComponent> entity, ref EntityEffectEvent<RerollPsionicAbilities> args)
{
if (args.Scale != 1f)
return;
_psionic.RerollPsionics(entity, bonusMuliplier: args.Effect.BonusMultiplier);
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class RerollPsionicAbilities : EntityEffectBase<RerollPsionicAbilities>
{
/// <summary>
/// Reroll multiplier.
/// </summary>
[DataField("bonusMultiplier")]
public float BonusMultiplier = 1f;
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-chem-reroll-psionic", ("chance", Probability));
}

View File

@ -1,9 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects;
public sealed partial class ActivateArtifact : EventEntityEffect<ActivateArtifact>
{
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Loc.GetString("reagent-effect-guidebook-activate-artifact", ("chance", Probability));
}

View File

@ -1,16 +0,0 @@
using Content.Shared.EntityEffects;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Shared.Nyanotrasen.Chemistry.Effects
{
/// <summary>
/// Rerolls psionics once.
/// </summary>
[UsedImplicitly]
public sealed partial class ChemRemovePsionic : EventEntityEffect<ChemRemovePsionic>
{
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-chem-remove-psionic", ("chance", Probability));
}
}

View File

@ -1,22 +0,0 @@
using Content.Shared.EntityEffects;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Shared.Nyanotrasen.Chemistry.Effects
{
/// <summary>
/// Rerolls psionics once.
/// </summary>
[UsedImplicitly]
public sealed partial class ChemRerollPsionic : EventEntityEffect<ChemRerollPsionic>
{
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-chem-reroll-psionic", ("chance", Probability));
/// <summary>
/// Reroll multiplier.
/// </summary>
[DataField("bonusMultiplier")]
public float BonusMuliplier = 1f;
}
}

View File

@ -1,26 +0,0 @@
using Content.Shared.EntityEffects;
using Content.Shared.Psionics.Glimmer;
using Robust.Shared.Prototypes;
namespace Content.Shared.Nyanotrasen.Chemistry.ReactionEffects;
[DataDefinition]
public sealed partial class ChangeGlimmerReactionEffect : EntityEffect
{
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-change-glimmer-reaction-effect", ("chance", Probability),
("count", Count));
/// <summary>
/// Added to glimmer when reaction occurs.
/// </summary>
[DataField("count")]
public int Count = 1;
public override void Effect(EntityEffectBaseArgs args)
{
var glimmersys = args.EntityManager.EntitySysManager.GetEntitySystem<GlimmerSystem>();
glimmersys.Glimmer += Count;
}
}

View File

@ -0,0 +1,85 @@
using System.Linq;
using Content.Shared.EntityEffects;
using Content.Shared.Body.Part;
using Content.Shared.Body.Systems;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.EntityConditions;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Localization;
namespace Content.Shared._DV.EntityConditions.Conditions;
/// <summary>
/// Reagent effect condition that depends on if the entity has a given component(s), potentially on a body part.
/// </summary>
/// <inheritdoc cref="EntityConditionSystem{T, TCondition}"/>
public sealed partial class HasComponentsConditionSystem : EntityConditionSystem<MetaDataComponent, HasComponentCondition>
{
[Dependency] private readonly EntityManager _ent = default!;
[Dependency] private readonly SharedBodySystem _body = default!;
protected override void Condition(Entity<MetaDataComponent> entity, ref EntityConditionEvent<HasComponentCondition> args)
{
var targetEntity = args.Condition.BodyPart is { } bodyPart
? _body.GetBodyChildrenOfType(entity.Owner, bodyPart, symmetry: args.Condition.BodyPartSymmetry).Select(it => it.Id).FirstOrDefault()
: entity.Owner;
if (!targetEntity.IsValid())
{
args.Result = !args.Condition.ShouldHave;
return;
}
var tested =
args.Condition.ConsiderAll
? args.Condition.Components.Values.All(c => _ent.HasComponent(entity, c.Component.GetType()))
: args.Condition.Components.Values.Any(c => _ent.HasComponent(entity, c.Component.GetType()));
args.Result = tested ^ !args.Condition.ShouldHave;
}
}
/// <inheritdoc cref="EntityCondition"/>
public sealed partial class HasComponentCondition : EntityConditionBase<HasComponentCondition>
{
/// <summary>
/// The set of components that this condition cares about
/// </summary>
[DataField(required: true)]
public ComponentRegistry Components;
/// <summary>
/// Whether or not the given components should be present
/// </summary>
[DataField]
public bool ShouldHave = true;
/// <summary>
/// Whether the check is an existential or universal check
/// </summary>
[DataField]
public bool ConsiderAll;
/// <summary>
/// The explanation displayed in the guidebook for this condition
/// </summary>
[DataField(required: true)]
public LocId Explanation;
/// <summary>
/// The body part of the entity to test for the components
/// </summary>
[DataField]
public BodyPartType? BodyPart;
/// <summary>
/// The side of the entity's body to test for the components
/// </summary>
[DataField]
public BodyPartSymmetry? BodyPartSymmetry;
public override string EntityConditionGuidebookText(IPrototypeManager prototype) => Loc.GetString(Explanation);
}

View File

@ -1,78 +0,0 @@
using System.Linq;
using Content.Shared.EntityEffects;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Shared.Prototypes;
using Robust.Shared.Localization;
using Content.Shared.Body.Part;
using Content.Shared.Body.Systems;
namespace Content.Shared._DV.EntityEffects.EffectConditions;
/// <summary>
/// Reagent effect condition that depends on if the entity has a given component(s), potentially on a body part
/// </summary>
public sealed partial class HasComponent : EntityEffectCondition
{
/// <summary>
/// The set of components that this condition cares about
/// </summary>
[DataField(required: true)]
public ComponentRegistry Components;
/// <summary>
/// Whether or not the given components should be present
/// </summary>
[DataField]
public bool ShouldHave = true;
/// <summary>
/// Whether the check is an existential or universal check
/// </summary>
[DataField]
public bool ConsiderAll;
/// <summary>
/// The explanation displayed in the guidebook for this condition
/// </summary>
[DataField(required: true)]
public LocId Explanation;
/// <summary>
/// The body part of the entity to test for the components
/// </summary>
[DataField]
public BodyPartType? BodyPart;
/// <summary>
/// The side of the entity's body to test for the components
/// </summary>
[DataField]
public BodyPartSymmetry? BodyPartSymmetry;
public override bool Condition(EntityEffectBaseArgs args)
{
var _body = args.EntityManager.System<SharedBodySystem>();
var entity =
BodyPart is {} bodyPart
? _body.GetBodyChildrenOfType(args.TargetEntity, bodyPart, symmetry: BodyPartSymmetry).Select(it => it.Id).FirstOrDefault()
: args.TargetEntity;
if (!entity.IsValid())
{
return !ShouldHave;
}
var tested =
ConsiderAll
? Components.Values.All(c => args.EntityManager.HasComponent(entity, c.Component.GetType()))
: Components.Values.Any(c => args.EntityManager.HasComponent(entity, c.Component.GetType()));
return tested ^ !ShouldHave;
}
public override string GuidebookExplanation(IPrototypeManager prototype)
{
return Loc.GetString(Explanation);
}
}

View File

@ -36,8 +36,7 @@ public partial class SharedCorticalBorerSystem : EntitySystem
public bool CanUseAbility(Entity<CorticalBorerComponent> ent, EntityUid target)
{
if (_statusEffects.HasStatusEffect(target,
"CorticalBorerProtection")) // hardcoded the status effect because...
if (_statusEffects.HasStatusEffect(target, "CorticalBorerProtection")) // hardcoded the status effect because...
{
_popup.PopupEntity(Loc.GetString("cortical-borer-sugar-block"), ent.Owner, ent.Owner, PopupType.Medium);
return false;
@ -101,8 +100,8 @@ public partial class SharedCorticalBorerSystem : EntitySystem
// close all the UIs that relate to host
if (TryComp<UserInterfaceComponent>(ent, out var uic))
{
_ui.CloseUi((ent.Owner,uic), HealthAnalyzerUiKey.Key);
_ui.CloseUi((ent.Owner,uic), CorticalBorerDispenserUiKey.Key);
_ui.CloseUi((ent.Owner, uic), HealthAnalyzerUiKey.Key);
_ui.CloseUi((ent.Owner, uic), CorticalBorerDispenserUiKey.Key);
}
RemCompDeferred<CorticalBorerInfestedComponent>(ent.Comp.Host.Value);

View File

@ -2,7 +2,7 @@ reagent-effect-guidebook-change-glimmer-reaction-effect =
{ $chance ->
[1] Modifies
*[other] modify
} the glimmer count by {$count} points
} the glimmer count by {$amount} points
reagent-effect-guidebook-chem-remove-psionic =
{ $chance ->

View File

@ -56,7 +56,7 @@
damage:
groups:
Toxin: 2
- !type:ChemRemovePsionic
- !type:RemovePsionicAbilities
conditions:
- !type:ReagentCondition
reagent: SoulbreakerToxin
@ -78,7 +78,7 @@
effectProto: StatusEffectSeeingRainbow
time: 5
type: Add
- !type:ChemRerollPsionic
- !type:RerollPsionicAbilities
bonusMultiplier: 4
conditions:
- !type:ReagentCondition

View File

@ -11,7 +11,7 @@
Cream:
amount: 5
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: FoodCurdCheese
number: 2
@ -29,7 +29,7 @@
amount: 5
catalyst: true
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: FoodMozzarella
number: 2

View File

@ -298,7 +298,7 @@
type: Add
time: 5
# DeltaV Additions
- !type:ChemRerollPsionic #Nyano - Summary: lets the imbiber become psionic.
- !type:RerollPsionicAbilities # DeltaV - Roll for psionics
conditions:
- !type:ReagentCondition
reagent: SpaceDrugs

View File

@ -375,7 +375,7 @@
- !type:AdjustReagent
reagent: LotophagoiOil # DeltaV: prevent rapid remove/reroll/remove/reroll psionic loop
amount: -100
- !type:ChemRemovePsionic #Nyano - Summary: removes psionics from the user at 20u.
- !type:RemovePsionicAbilities # DeltaV - Remove Psionics at 20u
conditions:
- !type:ReagentCondition
reagent: MindbreakerToxin

View File

@ -68,7 +68,7 @@
damage:
Brute: -1 # Not great, but will help you to tank an extra bullet or two
conditions: # This one only works for cultists
- !type:HasComponent
- !type:HasComponentCondition
explanation: reagent-condition-is-cultist
components:
- type: CosmicCult
@ -92,8 +92,8 @@
Cold: 1.5
Asphyxiation: 3
conditions:
- !type:HasComponent
- !type:HasComponentCondition
explanation: reagent-condition-is-not-cultist
components:
- type: CosmicCult
shouldHave: false
shouldHave: false

View File

@ -13,7 +13,7 @@
- !type:ReduceRotting
seconds: 10
conditions:
- !type:HasComponent
- !type:HasComponentCondition
bodyPart: Torso
explanation: reagent-explanation-netinadone-ribcage
components:

View File

@ -7,7 +7,7 @@
Quartzite:
amount: 10
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: SheetGlass1
- type: reaction
@ -25,5 +25,5 @@
Slime:
amount: 20
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: MobSlimesPet

View File

@ -30,7 +30,7 @@
amount: 5
catalyst: true
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: CrystalNormality
- !type:ChangeGlimmerReactionEffect
count: -10
- !type:AffectsGlimmer
amount: -10

View File

@ -9,5 +9,5 @@
Sugar:
amount: 15
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: FoodFrosting

View File

@ -130,7 +130,7 @@
metabolisms:
Poison:
effects:
- !type:CreateEntityReactionEffect # DeltaV - was polymorph, just have a chance to spawn a corgi instead
- !type:SpawnEntity # DeltaV - was polymorph, just have a chance to spawn a corgi instead
entity: MobCorgiPuppy
probability: 0.25
conditions:

View File

@ -130,7 +130,7 @@
Water:
amount: 5
effects:
- !type:CreateEntityReactionEffect
- !type:SpawnEntity
entity: MobCorgiPuppy
# Exotic could make mats / explode, but the former's better a diff chem and a diff PR, and latter's better for a pyrotechnics rework. Expansion's mostly meds and toxins.