1 using System.Collections.Generic;
10 private readonly List<StatusEffect> effects =
new List<StatusEffect>();
12 private readonly
int actionIndex;
20 foreach (var subElement
in parentEvent.Prefab.ConfigElement.Descendants())
22 if (subElement == element) {
break; }
26 foreach (var subElement
in element.Elements())
28 switch (subElement.Name.ToString().ToLowerInvariant())
31 effects.Add(
StatusEffect.
Load(subElement, $
"{nameof(StatusEffectAction)} ({parentEvent.Prefab.Identifier})"));
37 private bool isFinished =
false;
48 public override void Update(
float deltaTime)
50 if (isFinished) {
return; }
54 foreach (var target
in eventTargets)
58 List<ISerializableEntity> nearbyTargets =
new List<ISerializableEntity>();
60 foreach (var nearbyTarget
in nearbyTargets)
62 ApplyOnTarget(nearbyTarget as
Entity, effect);
66 ApplyOnTarget(target, effect);
70 ServerWrite(eventTargets);
76 if (target is
Item targetItem)
78 effect.
Apply(effect.
type, deltaTime, target, targetItem.AllPropertyObjects);
89 return $
"{ToolBox.GetDebugSymbol(isFinished)} {nameof(StatusEffectAction)} -> (TargetTag: {TargetTag.ColorizeObject()}";
readonly ScriptedEvent ParentEvent
IEnumerable< Entity > GetTargets(Identifier tag)
Executes all the StatusEffects defined as child elements of the action.
override string ToDebugString()
Rich test to display in debugdraw
override void Update(float deltaTime)
StatusEffectAction(ScriptedEvent parentEvent, ContentXElement element)
override bool IsFinished(ref string goTo)
Has the action finished.
StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in ...
bool HasTargetType(TargetType targetType)
static StatusEffect Load(ContentXElement element, string parentDebugName)
void AddNearbyTargets(Vector2 worldPosition, List< ISerializableEntity > targets)
virtual void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Vector2? worldPosition=null)