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
{
public abstract void RaiseEvent(EntityUid target, IEntityEffectRaiser raiser, float scale, EntityUid? user);
[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;
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;
[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);
}
}