Пример #1
0
        public override void LoadValuesFromUpdateFields()
        {
            Id = (uint)ObjectData.EntryID;
            LastLineEndTime = (uint)ConversationData.LastLineEndTime;

            var actorTemplates = new List <ConversationActorTemplate>();
            var actors         = ConversationData.Actors;

            for (var i = 0; i < actors.Count; ++i)
            {
                var actor = new ConversationActorTemplate
                {
                    Type = actors[i].Type
                };

                if (actor.Type == (uint)ActorType.WorldObjectActor)
                {
                    actor.Guid = actors[i].ActorGUID;
                }
                else if (actor.Type == (uint)ActorType.CreatureActor)
                {
                    actor.Id              = actors[i].CreatureID;
                    actor.CreatureId      = actors[i].CreatureID;
                    actor.CreatureModelId = actors[i].CreatureDisplayInfoID;

                    Storage.ConversationActorTemplates.Add(actor);
                }

                actorTemplates.Add(actor);
            }

            var lines = ConversationData.Lines;

            for (var i = 0; i < lines.Length; ++i)
            {
                var line = new ConversationLineTemplate
                {
                    Id         = (uint)lines[i].ConversationLineID,
                    StartTime  = lines[i].StartTime,
                    UiCameraID = (uint)lines[i].UiCameraID,
                    ActorIdx   = lines[i].ActorIndex,
                    Flags      = lines[i].Flags
                };

                if (i == 0)
                {
                    FirstLineID = line.Id;
                }

                var actorTemplate = actorTemplates[line.ActorIdx.Value];
                var actor         = new ConversationActor
                {
                    ConversationId      = Id,
                    ConversationActorId = actorTemplate.Id,
                    Guid = actorTemplate.Guid,
                    Idx  = line.ActorIdx
                };

                Storage.ConversationLineTemplates.Add(line);
                Storage.ConversationActors.Add(actor);
            }
        }
        public override void LoadValuesFromUpdateFields()
        {
            Id = UpdateFields.GetValue <ObjectField, uint>(ObjectField.OBJECT_FIELD_ENTRY);
            LastLineEndTime = UpdateFields.GetValue <ConversationField, uint>(ConversationField.CONVERSATION_LAST_LINE_END_TIME);

            var actorTemplates = new List <ConversationActorTemplate>();
            var actors         = new List <UpdateField>();

            if (DynamicUpdateFields.TryGetValue(WowPacketParser.Enums.Version.UpdateFields.GetUpdateField(ConversationDynamicField.CONVERSATION_DYNAMIC_FIELD_ACTORS), out actors))
            {
                var ActorSize = 6;
                for (var i = 0; i + ActorSize <= actors.Count; i += ActorSize)
                {
                    var actor = new ConversationActorTemplate();
                    actor.Type = actors[i + 4].UInt32Value;

                    if (actor.Type == (uint)ActorType.WorldObjectActor)
                    {
                        ulong lowPart  = Utilities.MAKE_PAIR64(actors[i + 0].UInt32Value, actors[i + 1].UInt32Value);
                        ulong highPart = Utilities.MAKE_PAIR64(actors[i + 2].UInt32Value, actors[i + 3].UInt32Value);
                        actor.Guid = new WowGuid128(lowPart, highPart);
                    }
                    if (actor.Type == (uint)ActorType.CreatureActor)
                    {
                        actor.Id              = actors[i + 0].UInt32Value;
                        actor.CreatureId      = actors[i + 1].UInt32Value;
                        actor.CreatureModelId = actors[i + 2].UInt32Value;

                        Storage.ConversationActorTemplates.Add(actor);
                    }

                    actorTemplates.Add(actor);
                }
            }

            var lines = new List <UpdateField>();

            if (DynamicUpdateFields.TryGetValue(WowPacketParser.Enums.Version.UpdateFields.GetUpdateField(ConversationDynamicField.CONVERSATION_DYNAMIC_FIELD_LINES), out lines))
            {
                var LineSize = 4;
                for (var i = 0; i + LineSize <= lines.Count; i += LineSize)
                {
                    var line = new ConversationLineTemplate();
                    line.Id         = lines[i + 0].UInt32Value;
                    line.StartTime  = lines[i + 1].UInt32Value;
                    line.UiCameraID = lines[i + 2].UInt32Value;
                    var part     = lines[i + 3].UInt32Value;
                    var actorIdx = (ushort)(part & 0xFFFF);
                    line.ActorIdx = actorIdx;
                    line.Unk      = (ushort)((part >> 16) & 0xFFFF);

                    if (i == 0)
                    {
                        FirstLineID = line.Id;
                    }

                    var actor = new ConversationActor();
                    actor.ConversationId = Id;
                    var actorTemplate = actorTemplates[actorIdx & 0xFF]; /// @workaround: structure is incorrect
                    actor.ConversationActorId = actorTemplate.Id;
                    actor.Guid = actorTemplate.Guid;
                    actor.Idx  = actorIdx;

                    Storage.ConversationLineTemplates.Add(line);
                    Storage.ConversationActors.Add(actor);
                }
            }
        }