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
37 [Obsolete(
"The delay type is unsupported.")]
41 private readonly DelayTypes delayType;
42 private readonly
float delay;
45 : base(element, parentDebugName)
47 delayType = element.GetAttributeEnum(
"delaytype", DelayTypes.Timer);
48 if (delayType == DelayTypes.ReachCursor)
50 DebugConsole.AddWarning($
"Potential error in {parentDebugName}: the delay type {DelayTypes.ReachCursor} is not supported.", contentPackage: element.
ContentPackage);
52 if (delayType is DelayTypes.Timer)
65 if (existingEffect.Parent ==
this && existingEffect.Targets.FirstOrDefault() == target) {
return; }
76 case DelayTypes.Timer:
79 case DelayTypes.ReachCursor:
80 Projectile projectile = (entity as
Item)?.GetComponent<Projectile>();
81 if (projectile ==
null)
83 DebugConsole.LogError(
"Non-projectile using a delaytype of reachcursor");
94 DebugConsole.LogError($
"Projectile \"{projectile.Item.Prefab.Identifier}\" missing user");
104 public override void Apply(
ActionType type,
float deltaTime,
Entity entity, IReadOnlyList<ISerializableEntity> targets, Vector2? worldPosition =
null)
106 if (this.type !=
type) {
return; }
112 foreach (var existingEffect
in DelayList)
114 if (existingEffect.Parent ==
this && existingEffect.Targets.SequenceEqual(targets)) {
return; }
129 case DelayTypes.Timer:
132 case DelayTypes.ReachCursor:
133 Projectile projectile = (entity as
Item)?.GetComponent<Projectile>();
134 if (projectile ==
null)
137 DebugConsole.LogError(
"Non-projectile using a delaytype of reachcursor");
149 DebugConsole.LogError($
"Projectile \"{projectile.Item.Prefab.Identifier}\" missing user");
159 public static void Update(
float deltaTime)
161 for (
int i =
DelayList.Count - 1; i >= 0; i--)
170 switch (element.
Parent.delayType)
172 case DelayTypes.Timer:
173 element.
Delay -= deltaTime;
174 if (element.
Delay > 0.0f) {
continue; }
176 case DelayTypes.ReachCursor:
Vector2? CursorWorldPosition
static Character? Controlled
float GetAttributeFloat(string key, float def)
ContentPackage? ContentPackage
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
Entity GetRootInventoryOwner()
Item Launcher
The item that launched this projectile (if any)
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.