public static List <AnimatedCastEvent> CreateCastEvents(Dictionary <ulong, List <CombatItem> > castEventsBySrcAgent, AgentData agentData, SkillData skillData)
        {
            var res = new List <AnimatedCastEvent>();

            foreach (KeyValuePair <ulong, List <CombatItem> > pair in castEventsBySrcAgent)
            {
#if DEBUG
                AgentItem a = agentData.GetAgent(pair.Key);
#endif
                CombatItem startItem = null;
                foreach (CombatItem c in pair.Value)
                {
                    if (c.IsActivation.StartCasting())
                    {
                        // missing end
                        if (startItem != null)
                        {
                            res.Add(new AnimatedCastEvent(startItem, agentData, skillData, c.Time));
                        }
                        startItem = c;
                    }
                    else if (c.IsActivation.EndCasting())
                    {
                        if (startItem != null && startItem.SkillID == c.SkillID)
                        {
                            res.Add(new AnimatedCastEvent(startItem, agentData, skillData, c));
                            startItem = null;
                        }
                        // missing start
                        else
                        {
                            var toCheck = new AnimatedCastEvent(agentData, skillData, c);
                            // only keep if list is empty as we are only interested in animations started before log starts
                            if (!res.Any())
                            {
                                res.Add(toCheck);
                            }
                        }
                    }
                }
                // missing end
                if (startItem != null)
                {
                    res.Add(new AnimatedCastEvent(startItem, agentData, skillData, long.MaxValue));
                }
            }
            res.Sort((x, y) => x.Time.CompareTo(y.Time));
            return(res);
        }
示例#2
0
        public static List <AnimatedCastEvent> CreateCastEvents(Dictionary <ulong, List <CombatItem> > castEventsBySrcAgent, AgentData agentData, SkillData skillData, FightData fightData)
        {
            var res = new List <AnimatedCastEvent>();

            foreach (KeyValuePair <ulong, List <CombatItem> > pairBySrcAgent in castEventsBySrcAgent)
            {
                var resBySrcAgent = new List <AnimatedCastEvent>();
                var castEventsBySrcAgentBySkillID = pairBySrcAgent.Value.GroupBy(x => x.SkillID).ToDictionary(x => x.Key, x => x.ToList());
                foreach (KeyValuePair <uint, List <CombatItem> > pairBySrcAgentBySkillID in castEventsBySrcAgentBySkillID)
                {
                    var        resBySrcAgentBySkillID = new List <AnimatedCastEvent>();
                    CombatItem startItem = null;
                    foreach (CombatItem c in pairBySrcAgentBySkillID.Value)
                    {
                        if (c.StartCasting())
                        {
                            // missing end
                            if (startItem != null)
                            {
                                resBySrcAgentBySkillID.Add(new AnimatedCastEvent(startItem, agentData, skillData, fightData.LogEnd));
                            }
                            startItem = c;
                        }
                        else if (c.EndCasting())
                        {
                            if (startItem != null && startItem.SkillID == c.SkillID)
                            {
                                resBySrcAgentBySkillID.Add(new AnimatedCastEvent(startItem, agentData, skillData, c));
                                startItem = null;
                            }
                            // missing start
                            else
                            {
                                var toCheck = new AnimatedCastEvent(agentData, skillData, c);
                                // we are only interested in animations started before log starts
                                if (toCheck.Time < fightData.LogStart)
                                {
                                    resBySrcAgentBySkillID.Add(toCheck);
                                }
                            }
                        }
                    }
                    // missing end
                    if (startItem != null)
                    {
                        resBySrcAgentBySkillID.Add(new AnimatedCastEvent(startItem, agentData, skillData, fightData.LogEnd));
                    }
                    resBySrcAgentBySkillID.RemoveAll(x => x.ActualDuration <= 1);
                    resBySrcAgent.AddRange(resBySrcAgentBySkillID);
                }
                resBySrcAgent = resBySrcAgent.OrderBy(x => x.Time).ToList();
                // sanitize
                for (int i = 0; i < resBySrcAgent.Count - 1; i++)
                {
                    resBySrcAgent[i].CutAt(resBySrcAgent[i + 1].Time + ParserHelper.ServerDelayConstant);
                }
                res.AddRange(resBySrcAgent);
            }
            res = res.OrderBy(x => x.Time).ToList();
            return(res);
        }