Added DB-support for conversation actorGuids

This commit is contained in:
hondacrx
2017-11-05 16:55:27 -05:00
parent f6d034b7e5
commit f81a877ad3
3 changed files with 85 additions and 22 deletions
+37 -7
View File
@@ -120,23 +120,48 @@ namespace Game.Entities
SetUInt32Value(ConversationFields.LastLineEndTime, conversationTemplate.LastLineEndTime);
_duration = conversationTemplate.LastLineEndTime;
ushort actorsIndex = 0;
foreach (ConversationActorTemplate actor in conversationTemplate.Actors)
for (ushort actorIndex = 0; actorIndex < conversationTemplate.Actors.Count; ++actorIndex)
{
ConversationActorTemplate actor = conversationTemplate.Actors[actorIndex];
if (actor != null)
{
ConversationDynamicFieldActor actorField = new ConversationDynamicFieldActor();
actorField.ActorTemplate = actor;
actorField.Type = ConversationDynamicFieldActor.ActorType.CreatureActor;
SetDynamicStructuredValue(ConversationDynamicFields.Actors, actorsIndex++, actorField);
SetDynamicStructuredValue(ConversationDynamicFields.Actors, actorIndex, actorField);
}
else
++actorsIndex;
}
ushort linesIndex = 0;
for (ushort actorIndex = 0; actorIndex < conversationTemplate.ActorGuids.Count; ++actorIndex)
{
ulong actorGuid = conversationTemplate.ActorGuids[actorIndex];
if (actorGuid == 0)
continue;
foreach (var creature in map.GetCreatureBySpawnIdStore().LookupByKey(actorGuid))
{
// we just need the last one, overriding is legit
AddActor(creature.GetGUID(), actorIndex);
}
}
List<ushort> actorIndices = new List<ushort>();
foreach (ConversationLineTemplate line in conversationTemplate.Lines)
SetDynamicStructuredValue(ConversationDynamicFields.Lines, linesIndex++, line);
{
actorIndices.Add(line.ActorIdx);
AddDynamicStructuredValue(ConversationDynamicFields.Lines, line);
}
// All actors need to be set
foreach (ushort actorIndex in actorIndices)
{
ConversationDynamicFieldActor actor = GetDynamicStructuredValue<ConversationDynamicFieldActor>(ConversationDynamicFields.Actors, actorIndex);
if (actor == null || actor.IsEmpty())
{
Log.outError(LogFilter.Conversation, $"Failed to create conversation (Id: {conversationEntry}) due to missing actor (Idx: {actorIndex}).");
return false;
}
}
if (!GetMap().AddToMap(this))
return false;
@@ -181,6 +206,11 @@ namespace Game.Entities
CreatureActor = 1
}
public bool IsEmpty()
{
return ActorGuid.IsEmpty(); // this one is good enough
}
public ObjectGuid ActorGuid;
public ConversationActorTemplate ActorTemplate;