2 using System.Collections.Generic;
7 using Microsoft.Xna.Framework;
17 public readonly List<ISerializableEntity>
Targets;
24 Targets =
new List<ISerializableEntity>(targets);
32 public static readonly List<DelayedListElement>
DelayList =
new List<DelayedListElement>();
34 private enum DelayTypes { Timer = 0, ReachCursor = 1 }
36 private readonly DelayTypes delayType;
37 private readonly
float delay;
40 : base(element, parentDebugName)
42 DelayTypes delayTypeAttr = element.GetAttributeEnum(
"delaytype", DelayTypes.Timer);
43 if (delayTypeAttr is DelayTypes.Timer)
56 if (existingEffect.Parent ==
this && existingEffect.Targets.FirstOrDefault() == target) {
return; }
67 case DelayTypes.Timer:
70 case DelayTypes.ReachCursor:
71 Projectile projectile = (entity as
Item)?.GetComponent<Projectile>();
72 if (projectile ==
null)
74 DebugConsole.LogError(
"Non-projectile using a delaytype of reachcursor");
78 if (projectile.
User ==
null)
80 DebugConsole.LogError(
"Projectile: '" + projectile.
Name +
"' missing user to determine distance");
89 public override void Apply(
ActionType type,
float deltaTime,
Entity entity, IReadOnlyList<ISerializableEntity> targets, Vector2? worldPosition =
null)
91 if (this.type !=
type) {
return; }
99 if (existingEffect.Parent ==
this && existingEffect.Targets.SequenceEqual(targets)) {
return; }
114 case DelayTypes.Timer:
117 case DelayTypes.ReachCursor:
118 Projectile projectile = (entity as
Item)?.GetComponent<Projectile>();
119 if (projectile ==
null)
122 DebugConsole.LogError(
"Non-projectile using a delaytype of reachcursor");
127 if (projectile.
User ==
null)
130 DebugConsole.LogError(
"Projectile " + projectile.
Name +
"missing user");
140 public static void Update(
float deltaTime)
142 for (
int i =
DelayList.Count - 1; i >= 0; i--)
151 switch (element.
Parent.delayType)
153 case DelayTypes.Timer:
154 element.
Delay -= deltaTime;
155 if (element.
Delay > 0.0f) {
continue; }
157 case DelayTypes.ReachCursor:
Vector2? CursorWorldPosition
static Character? Controlled
float GetAttributeFloat(string key, float def)
override void Apply(ActionType type, float deltaTime, Entity entity, IReadOnlyList< ISerializableEntity > targets, Vector2? worldPosition=null)
static void Update(float deltaTime)
override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Vector2? worldPosition=null)
DelayedEffect(ContentXElement element, string parentDebugName)
static readonly List< DelayedListElement > DelayList
readonly List< ISerializableEntity > Targets
readonly? Vector2 StartPosition
readonly? Vector2 WorldPosition
readonly DelayedEffect Parent
DelayedListElement(DelayedEffect parentEffect, Entity parentEntity, IEnumerable< ISerializableEntity > targets, float delay, Vector2? worldPosition, Vector2? startPosition)
virtual Vector2 WorldPosition
StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in ...
virtual bool HasRequiredItems(Entity entity)
bool IsValidTarget(ISerializableEntity entity)
readonly bool Stackable
Only valid if the effect has a duration or delay. Can the effect be applied on the same target(s) if ...
bool ShouldWaitForInterval(Entity entity, float deltaTime)
readonly List< ISerializableEntity > currentTargets
bool HasRequiredConditions(IReadOnlyList< ISerializableEntity > targets)
readonly bool CheckConditionalAlways
Only applicable for StatusEffects with a duration or delay. Should the conditional checks only be don...
ActionType
ActionTypes define when a StatusEffect is executed.