Esempio n. 1
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target)
        {
            if (this.type != type || !HasRequiredItems(entity))
            {
                return;
            }
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.Count == 1 && d.Targets[0] == target))
            {
                return;
            }

            if (targetNames != null && !targetNames.Contains(target.Name))
            {
                return;
            }

            DelayedListElement element = new DelayedListElement
            {
                Parent     = this,
                StartTimer = delay,
                Entity     = entity,
                Targets    = new List <ISerializableEntity>()
                {
                    target
                }
            };

            DelayList.Add(element);
        }
Esempio n. 2
0
        public static void Update(float deltaTime)
        {
            for (int i = DelayList.Count - 1; i >= 0; i--)
            {
                DelayedListElement element = DelayList[i];
                if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets))
                {
                    DelayList.Remove(element);
                    continue;
                }

                switch (element.Parent.delayType)
                {
                case DelayTypes.Timer:
                    element.Delay -= deltaTime;
                    if (element.Delay > 0.0f)
                    {
                        continue;
                    }
                    break;

                case DelayTypes.ReachCursor:
                    if (Vector2.Distance(element.Entity.WorldPosition, element.StartPosition.Value) < element.Delay)
                    {
                        continue;
                    }
                    break;
                }

                element.Parent.Apply(deltaTime, element.Entity, element.Targets, element.WorldPosition);
                DelayList.Remove(element);
            }
        }
Esempio n. 3
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, List <ISerializableEntity> targets)
        {
            if (this.type != type || !HasRequiredItems(entity))
            {
                return;
            }
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.SequenceEqual(targets)))
            {
                return;
            }

            //remove invalid targets
            if (targetNames != null)
            {
                targets.RemoveAll(t => !targetNames.Contains(t.Name));
                if (targets.Count == 0)
                {
                    return;
                }
            }

            DelayedListElement element = new DelayedListElement
            {
                Parent     = this,
                StartTimer = delay,
                Entity     = entity,
                Targets    = targets
            };

            DelayList.Add(element);
        }
Esempio n. 4
0
        public static void Update(float deltaTime)
        {
            for (int i = DelayList.Count - 1; i >= 0; i--)
            {
                DelayedListElement element = DelayList[i];
                if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets))
                {
                    DelayList.Remove(element);
                    continue;
                }

                element.Targets.RemoveAll(t => t is Entity entity && entity.Removed);
                if (element.Targets.Count == 0)
                {
                    DelayList.RemoveAt(i);
                    continue;
                }

                element.StartTimer -= deltaTime;

                if (element.StartTimer > 0.0f) continue;

                element.Parent.Apply(1.0f, element.Entity, element.Targets, element.CancelledEffects, element.causecharacter, element.identifier);
                DelayList.RemoveAt(i);
            }
        }
Esempio n. 5
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, List<ISerializableEntity> targets, Character causecharacter = null, string identifier = "")
        {
            if (this.type != type || !HasRequiredItems(entity)) return;
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.SequenceEqual(targets))) return;

            //remove invalid targets
            if (targetNames != null)
            {
                targets.RemoveAll(t => !targetNames.Contains(t.Name));
                if (targets.Count == 0) return;
            }

            if (identifier == "") identifier = "statuseffect";

            DelayedListElement element = new DelayedListElement
            {
                Parent = this,
                StartTimer = delay,
                Entity = entity,
                Targets = targets,
                causecharacter = causecharacter,
                identifier = identifier
            };

            DelayList.Add(element);
        }
Esempio n. 6
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, IEnumerable <ISerializableEntity> targets, Vector2?worldPosition = null)
        {
            if (this.type != type || !HasRequiredItems(entity))
            {
                return;
            }
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.SequenceEqual(targets)))
            {
                return;
            }

            currentTargets.Clear();
            foreach (ISerializableEntity target in targets)
            {
                if (targetIdentifiers != null)
                {
                    //ignore invalid targets
                    if (!IsValidTarget(target))
                    {
                        continue;
                    }
                }
                currentTargets.Add(target);
            }

            if (!HasRequiredConditions(currentTargets))
            {
                return;
            }

            DelayedListElement element = new DelayedListElement
            {
                Parent        = this,
                StartTimer    = delay,
                Entity        = entity,
                WorldPosition = worldPosition,
                Targets       = currentTargets
            };

            DelayList.Add(element);
        }
Esempio n. 7
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Character causecharacter = null, string identifier = "")
        {
            if (this.type != type || !HasRequiredItems(entity)) return;
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.Count == 1 && d.Targets[0] == target)) return;

            if (targetNames != null && !targetNames.Contains(target.Name)) return;

            if (identifier == "") identifier = "statuseffect";

            DelayedListElement element = new DelayedListElement
            {
                Parent = this,
                StartTimer = delay,
                Entity = entity,
                Targets = new List<ISerializableEntity>() { target },
                causecharacter = causecharacter,
                identifier = identifier
            };

            DelayList.Add(element);
        }
Esempio n. 8
0
        public static void Update(float deltaTime)
        {
            for (int i = DelayList.Count - 1; i >= 0; i--)
            {
                DelayedListElement element = DelayList[i];
                if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets))
                {
                    DelayList.Remove(element);
                    continue;
                }

                element.StartTimer -= deltaTime;

                if (element.StartTimer > 0.0f)
                {
                    continue;
                }

                element.Parent.Apply(1.0f, element.Entity, element.Targets);
                DelayList.Remove(element);
            }
        }
Esempio n. 9
0
        public override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target, Vector2?worldPosition = null)
        {
            if (this.type != type || !HasRequiredItems(entity))
            {
                return;
            }
            if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.FirstOrDefault() == target))
            {
                return;
            }

            if (targetIdentifiers != null && !IsValidTarget(target))
            {
                return;
            }
            if (!HasRequiredConditions(new List <ISerializableEntity>()
            {
                target
            }))
            {
                return;
            }

            DelayedListElement element = new DelayedListElement
            {
                Parent        = this,
                StartTimer    = delay,
                Entity        = entity,
                WorldPosition = worldPosition,
                Targets       = new List <ISerializableEntity>()
                {
                    target
                }
            };

            DelayList.Add(element);
        }