Files
crystall-punk-14/Content.Server/_CP14/Chemistry/ReagentEffect/CP14ManaChange.cs
Ed 16a0b99daf Magic crystal lanterns + Aftertest balance (#532)
* lamp visual update

* deleete ice floor spell

* mana gift spell

* magic lantern

* wallmount crystal lamps

* QoL

* crafting

* Update StyleNano.cs

* examining simplify

* rings name

* remove snakes modifier

* trinkets update

* remove snakes, add boars and rabbits to demiplans

* Update flashlight.yml

* fix

* Update test.yml

* Update migration.yml

* ыы
2024-11-04 00:55:15 +03:00

47 lines
1.5 KiB
C#

using Content.Server._CP14.MagicEnergy;
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared.EntityEffects;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.Chemistry.ReagentEffect;
[UsedImplicitly]
[DataDefinition]
public sealed partial class CP14ManaChange : EntityEffect
{
[DataField(required: true)]
public float ManaDelta = 1;
[DataField]
public bool Safe = false;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Loc.GetString(ManaDelta >= 0 ? "cp14-reagent-effect-guidebook-mana-add" : "cp14-reagent-effect-guidebook-mana-remove",
("chance", Probability),
("amount", Math.Abs(ManaDelta)));
}
public override void Effect(EntityEffectBaseArgs args)
{
var scale = FixedPoint2.New(1);
if (args is EntityEffectReagentArgs reagentArgs)
{
scale = reagentArgs.Quantity * reagentArgs.Scale;
}
var magicSystem = args.EntityManager.System<CP14MagicEnergySystem>();
magicSystem.ChangeEnergy(args.TargetEntity, ManaDelta * scale, Safe);
if (args.EntityManager.TryGetComponent<CP14MagicEnergyCrystalSlotComponent>(args.TargetEntity,
out var crystalSlot))
{
var slotSystem = args.EntityManager.System<CP14MagicEnergyCrystalSlotSystem>();
slotSystem.TryChangeEnergy(args.TargetEntity, ManaDelta * scale, crystalSlot);
}
}
}