Ejemplo n.º 1
0
        public CollisionItemEvent(IList <string> conditionSet, IList <string> actionSet)
            : base(conditionSet, actionSet)
        {
            var isTypeCondition = Conditions.FirstOrDefault(func => IsTypeFunctionName.Equals(func.FunctionName));

            if (isTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find {IsTypeFunctionName} function.");
            }

            ThingIdOfCollision = Convert.ToUInt16(isTypeCondition.Parameters[1]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollisionEventRule"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="scriptFactory">A reference to the script factory in use.</param>
        /// <param name="conditionSet">The conditions for this event.</param>
        /// <param name="actionSet">The actions of this event.</param>
        public CollisionEventRule(ILogger logger, IScriptApi scriptFactory, IList <string> conditionSet, IList <string> actionSet)
            : base(logger, scriptFactory, conditionSet, actionSet)
        {
            var isTypeCondition = this.Conditions.FirstOrDefault(func => IsTypeFunctionName.Equals(func.FunctionName));

            if (isTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find {IsTypeFunctionName} function.");
            }

            this.ThingIdOfCollision = Convert.ToUInt16(isTypeCondition.Parameters[1]);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UseItemOnEventRule"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="scriptFactory">A reference to the script factory in use.</param>
        /// <param name="conditionSet">The conditions for this event.</param>
        /// <param name="actionSet">The actions of this event.</param>
        public UseItemOnEventRule(ILogger logger, IScriptApi scriptFactory, IList <string> conditionSet, IList <string> actionSet)
            : base(logger, scriptFactory, conditionSet, actionSet)
        {
            // Look for a IsType condition.
            var isTypeConditions = this.Conditions.Where(func => IsTypeFunctionName.Equals(func.FunctionName));

            var typeConditionsList  = isTypeConditions as IList <IEventRuleFunction> ?? isTypeConditions.ToList();
            var firstTypeCondition  = typeConditionsList.FirstOrDefault();
            var secondTypeCondition = typeConditionsList.Skip(1).FirstOrDefault();

            if (firstTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find first {IsTypeFunctionName} function.");
            }

            if (secondTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find second {IsTypeFunctionName} function.");
            }

            this.ItemToUseId    = Convert.ToUInt16(firstTypeCondition.Parameters[1]);
            this.ThingToUseOnId = Convert.ToUInt16(secondTypeCondition.Parameters[1]);
        }
Ejemplo n.º 4
0
        public MultiUseItemEvent(IList <string> conditionSet, IList <string> actionSet)
            : base(conditionSet, actionSet)
        {
            // Look for a IsType condition.
            var isTypeConditions = Conditions.Where(func => IsTypeFunctionName.Equals(func.FunctionName));

            var typeConditionsList  = isTypeConditions as IList <IItemEventFunction> ?? isTypeConditions.ToList();
            var firstTypeCondition  = typeConditionsList.FirstOrDefault();
            var secondTypeCondition = typeConditionsList.Skip(1).FirstOrDefault();

            if (firstTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find first {IsTypeFunctionName} function.");
            }

            if (secondTypeCondition == null)
            {
                throw new ArgumentNullException($"Unable to find second {IsTypeFunctionName} function.");
            }

            ItemToUseId   = Convert.ToUInt16(firstTypeCondition.Parameters[1]);
            ItemToUseOnId = Convert.ToUInt16(secondTypeCondition.Parameters[1]);
        }