示例#1
0
        public async Task<TimedActionListOrEntries> GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            TimedActionListOrEntries timedActionListOrEntries = new TimedActionListOrEntries();
            timedActionListOrEntries.entries = new List<string>();
            timedActionListOrEntries.sourceTypeOfEntry = SourceTypes.SourceTypeScriptedActionlist;

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List<SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                            case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                            case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                                if (_smartScript.action_param1 == smartScript.entryorguid ||
                                    _smartScript.action_param2 == smartScript.entryorguid ||
                                    _smartScript.action_param3 == smartScript.entryorguid ||
                                    _smartScript.action_param4 == smartScript.entryorguid ||
                                    _smartScript.action_param5 == smartScript.entryorguid ||
                                    _smartScript.action_param6 == smartScript.entryorguid)
                                {
                                    timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                    timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                }

                                break;
                            case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                                for (int i = _smartScript.action_param1; i <= _smartScript.action_param2; ++i)
                                {
                                    if (i == smartScript.entryorguid && !timedActionListOrEntries.entries.Contains(i.ToString()))
                                    {
                                        timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                        timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                        break;
                                    }
                                }
                                break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                    case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        timedActionListOrEntries.entries.Add(smartScript.action_param2.ToString());

                        if (smartScript.action_param3 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param3.ToString());

                        if (smartScript.action_param4 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param4.ToString());

                        if (smartScript.action_param5 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param5.ToString());

                        if (smartScript.action_param6 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param6.ToString());

                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                        for (int i = smartScript.action_param1; i <= smartScript.action_param2; ++i)
                            timedActionListOrEntries.entries.Add(i.ToString());
                        break;
                }
            }

            return timedActionListOrEntries;
        }
示例#2
0
        public async Task <TimedActionListOrEntries> GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            TimedActionListOrEntries timedActionListOrEntries = new TimedActionListOrEntries();

            timedActionListOrEntries.entries           = new List <string>();
            timedActionListOrEntries.sourceTypeOfEntry = SourceTypes.SourceTypeScriptedActionlist;

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List <SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                        case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                            if (_smartScript.action_param1 == smartScript.entryorguid ||
                                _smartScript.action_param2 == smartScript.entryorguid ||
                                _smartScript.action_param3 == smartScript.entryorguid ||
                                _smartScript.action_param4 == smartScript.entryorguid ||
                                _smartScript.action_param5 == smartScript.entryorguid ||
                                _smartScript.action_param6 == smartScript.entryorguid)
                            {
                                timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                            }

                            break;

                        case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                            for (int i = _smartScript.action_param1; i <= _smartScript.action_param2; ++i)
                            {
                                if (i == smartScript.entryorguid && !timedActionListOrEntries.entries.Contains(i.ToString()))
                                {
                                    timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                    timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                    timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                    break;

                case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                    timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                    timedActionListOrEntries.entries.Add(smartScript.action_param2.ToString());

                    if (smartScript.action_param3 > 0)
                    {
                        timedActionListOrEntries.entries.Add(smartScript.action_param3.ToString());
                    }

                    if (smartScript.action_param4 > 0)
                    {
                        timedActionListOrEntries.entries.Add(smartScript.action_param4.ToString());
                    }

                    if (smartScript.action_param5 > 0)
                    {
                        timedActionListOrEntries.entries.Add(smartScript.action_param5.ToString());
                    }

                    if (smartScript.action_param6 > 0)
                    {
                        timedActionListOrEntries.entries.Add(smartScript.action_param6.ToString());
                    }

                    break;

                case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                    for (int i = smartScript.action_param1; i <= smartScript.action_param2; ++i)
                    {
                        timedActionListOrEntries.entries.Add(i.ToString());
                    }
                    break;
                }
            }

            return(timedActionListOrEntries);
        }