2024-11-06 08:44:03 +03:00
|
|
|
using Content.Shared._CP14.MagicRitual.Prototypes;
|
2024-11-09 17:55:16 +03:00
|
|
|
using Content.Shared._CP14.MagicSpell.Components;
|
2024-11-06 08:44:03 +03:00
|
|
|
using Content.Shared.FixedPoint;
|
|
|
|
|
using Content.Shared.Inventory;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
2024-08-01 11:52:27 +03:00
|
|
|
namespace Content.Shared._CP14.MagicSpell.Events;
|
2024-07-28 17:26:47 +03:00
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Called first to verify that all conditions are met and the spell can be performed.
|
|
|
|
|
/// </summary>
|
2024-07-28 17:26:47 +03:00
|
|
|
[ByRefEvent]
|
2024-11-07 16:04:49 +03:00
|
|
|
public sealed class CP14CastMagicEffectAttemptEvent : CancellableEntityEventArgs
|
2024-07-28 17:26:47 +03:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Performer of the event, to check if they meet the requirements.
|
|
|
|
|
/// </summary>
|
2024-11-07 16:04:49 +03:00
|
|
|
public EntityUid Performer { get; init; }
|
2024-07-28 17:26:47 +03:00
|
|
|
|
|
|
|
|
public string Reason = string.Empty;
|
|
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
public CP14CastMagicEffectAttemptEvent(EntityUid performer)
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
Performer = performer;
|
2024-11-06 08:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
2024-07-28 17:26:47 +03:00
|
|
|
public void PushReason(string reason)
|
|
|
|
|
{
|
|
|
|
|
Reason += $"{reason}\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// An event that checks all sorts of conditions, and calculates the total cost of casting a spell. Called before the spell is cast.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>TODO: This call is duplicated at the beginning of the cast for checks, and at the end of the cast for mana subtraction.</remarks>
|
|
|
|
|
public sealed class CP14CalculateManacostEvent : EntityEventArgs, IInventoryRelayEvent
|
2024-07-28 17:26:47 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
public FixedPoint2 Manacost = 0f;
|
|
|
|
|
|
|
|
|
|
public float Multiplier = 1f;
|
2024-11-10 16:15:08 +03:00
|
|
|
public EntityUid? Performer;
|
2024-11-07 16:04:49 +03:00
|
|
|
public ProtoId<CP14MagicTypePrototype>? MagicType;
|
|
|
|
|
|
2024-11-10 16:15:08 +03:00
|
|
|
public CP14CalculateManacostEvent(EntityUid? performer, FixedPoint2 initialManacost, ProtoId<CP14MagicTypePrototype>? magicType)
|
2024-11-07 16:04:49 +03:00
|
|
|
{
|
|
|
|
|
Performer = performer;
|
|
|
|
|
Manacost = initialManacost;
|
|
|
|
|
MagicType = magicType;
|
|
|
|
|
}
|
2024-11-06 08:44:03 +03:00
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
public float GetManacost()
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
return (float)Manacost * Multiplier;
|
2024-11-06 08:44:03 +03:00
|
|
|
}
|
2024-11-07 16:04:49 +03:00
|
|
|
|
|
|
|
|
public SlotFlags TargetSlots { get; } = SlotFlags.All;
|
2024-07-28 17:26:47 +03:00
|
|
|
}
|
2024-11-07 16:04:49 +03:00
|
|
|
|
2024-07-28 17:26:47 +03:00
|
|
|
/// <summary>
|
2024-11-07 16:04:49 +03:00
|
|
|
/// is invoked if all conditions are met and the spell has begun to be cast (doAfter start moment)
|
2024-07-28 17:26:47 +03:00
|
|
|
/// </summary>
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
public sealed class CP14StartCastMagicEffectEvent : EntityEventArgs
|
|
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
public EntityUid Performer { get; init; }
|
2024-11-06 08:44:03 +03:00
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
public CP14StartCastMagicEffectEvent(EntityUid performer)
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
Performer = performer;
|
2024-11-06 08:44:03 +03:00
|
|
|
}
|
2024-07-28 17:26:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-11-07 16:04:49 +03:00
|
|
|
/// is invoked on the spell itself when the spell process has been completed or interrupted (doAfter end moment)
|
2024-07-28 17:26:47 +03:00
|
|
|
/// </summary>
|
|
|
|
|
[ByRefEvent]
|
2024-08-02 13:51:54 +03:00
|
|
|
public sealed class CP14EndCastMagicEffectEvent : EntityEventArgs
|
2024-07-28 17:26:47 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
public EntityUid Performer { get; init; }
|
2024-11-06 08:44:03 +03:00
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
public CP14EndCastMagicEffectEvent(EntityUid performer)
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
Performer = performer;
|
2024-11-06 08:44:03 +03:00
|
|
|
}
|
2024-07-28 17:26:47 +03:00
|
|
|
}
|
|
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// is invoked only if the spell has been successfully cast
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
public sealed class CP14AfterCastMagicEffectEvent : EntityEventArgs
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
public EntityUid? Performer { get; init; }
|
2024-11-06 08:44:03 +03:00
|
|
|
|
2024-11-07 16:04:49 +03:00
|
|
|
public CP14AfterCastMagicEffectEvent(EntityUid? performer)
|
2024-11-06 08:44:03 +03:00
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
Performer = performer;
|
2024-11-06 08:44:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-09 17:55:16 +03:00
|
|
|
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
public sealed class CP14SpellFromSpellStorageUsedEvent : EntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public EntityUid? Performer { get; init; }
|
|
|
|
|
public Entity<CP14MagicEffectComponent> Action { get; init; }
|
|
|
|
|
public FixedPoint2 Manacost { get; init; }
|
|
|
|
|
|
|
|
|
|
public CP14SpellFromSpellStorageUsedEvent(EntityUid? performer, Entity<CP14MagicEffectComponent> action, FixedPoint2 manacost)
|
|
|
|
|
{
|
|
|
|
|
Performer = performer;
|
|
|
|
|
Action = action;
|
|
|
|
|
Manacost = manacost;
|
|
|
|
|
}
|
|
|
|
|
}
|