コード例 #1
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(target.ToEnumerable()))
            {
                return;
            }

            switch (delayType)
            {
            case DelayTypes.Timer:
                DelayList.Add(new DelayedListElement(this, entity, target.ToEnumerable(), delay, worldPosition, null));
                break;

            case DelayTypes.ReachCursor:
                Projectile projectile = (entity as Item)?.GetComponent <Projectile>();
                if (projectile == null)
                {
                    DebugConsole.NewMessage("Non-projectile using a delaytype of reachcursor", Color.Red, false, true);
                    return;
                }

                if (projectile.User == null)
                {
                    DebugConsole.NewMessage("Projectile: '" + projectile.Name + "' missing user to determine distance", Color.Red, false, true);
                    return;
                }

                DelayList.Add(new DelayedListElement(this, entity, target.ToEnumerable(), Vector2.Distance(entity.WorldPosition, projectile.User.CursorWorldPosition), worldPosition, entity.WorldPosition));
                break;
            }
        }
コード例 #2
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(target.ToEnumerable()))
            {
                return;
            }

            DelayList.Add(new DelayedListElement(this, entity, target.ToEnumerable(), delay, worldPosition));
        }