using Content.Shared.Database; using Content.Shared.EntityConditions; using Robust.Shared.Prototypes; namespace Content.Shared.EntityEffects; /// /// A basic instantaneous effect which can be applied to an entity via events. /// [ImplicitDataDefinitionForInheritors] public abstract partial class EntityEffect { /// /// Applies this effect to a target. /// /// Target we're applying an effect to. /// The type of effect raising the event. /// Optional scale multiplier for the effect. /// The entity causing the effect. public abstract void RaiseEvent(EntityUid target, IEntityEffectRaiser raiser, float scale, EntityUid? user); /// /// Conditions for this effect to happen. /// [DataField] public EntityCondition[]? Conditions; /// /// If our scale is less than this value, the effect fails. /// [DataField] public virtual float MinScale { get; private set; } /// /// If true, then it allows the scale multiplier to go above 1. /// [DataField] public virtual bool Scaling { get; private set; } = true; // TODO: This should be an entity condition but guidebook relies on it heavily for formatting... /// /// Probability of the effect occuring. /// [DataField] public float Probability = 1.0f; /// /// Generates the guidebook text for this effect. /// /// Prototype manager, to resolve prototype calls. /// EntitySystem manager, to resolve system calls. /// The guidebook text string, if generated. Null otherwise. public virtual string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => null; /// /// If this effect is logged, how important is the log? /// [ViewVariables] public virtual LogImpact? Impact => null; /// /// The type of log this effect should cause. /// [ViewVariables] public virtual LogType LogType => LogType.EntityEffect; } /// /// Used to store an so it can be raised without losing the type of the condition. /// /// The Condition wer are raising. public abstract partial class EntityEffectBase : EntityEffect where T : EntityEffectBase { public override void RaiseEvent(EntityUid target, IEntityEffectRaiser raiser, float scale, EntityUid? user) { if (this is not T type) return; raiser.RaiseEffectEvent(target, type, scale, user); } }