Core/Conversations: Replace _participants with generic personal object implementation

Port From (https://github.com/TrinityCore/TrinityCore/commit/3fe9b0a2961b60509d11dd38a90e7b7657b68084)
This commit is contained in:
hondacrx
2021-10-10 09:55:16 -04:00
parent c73060fde0
commit a1459617e6
4 changed files with 8 additions and 22 deletions
+1 -1
View File
@@ -2405,7 +2405,7 @@ namespace Game.AI
if (playerTarget != null) if (playerTarget != null)
{ {
Conversation conversation = Conversation.CreateConversation(e.Action.conversation.id, playerTarget, Conversation conversation = Conversation.CreateConversation(e.Action.conversation.id, playerTarget,
playerTarget, new List<ObjectGuid>() { playerTarget.GetGUID() }, null); playerTarget, playerTarget.GetGUID(), null);
if (!conversation) if (!conversation)
Log.outWarn(LogFilter.ScriptsAi, $"SmartScript.ProcessAction: SMART_ACTION_CREATE_CONVERSATION: id {e.Action.conversation.id}, baseObject {baseObject?.GetName()}, target {playerTarget.GetName()} - failed to create"); Log.outWarn(LogFilter.ScriptsAi, $"SmartScript.ProcessAction: SMART_ACTION_CREATE_CONVERSATION: id {e.Action.conversation.id}, baseObject {baseObject?.GetName()}, target {playerTarget.GetName()} - failed to create");
} }
+1 -1
View File
@@ -123,7 +123,7 @@ namespace Game.Chat
return false; return false;
} }
return Conversation.CreateConversation(conversationEntry, target, target, new List<ObjectGuid>() { target.GetGUID() }) != null; return Conversation.CreateConversation(conversationEntry, target, target, target.GetGUID()) != null;
} }
[Command("entervehicle", RBACPermissions.CommandDebugEntervehicle)] [Command("entervehicle", RBACPermissions.CommandDebugEntervehicle)]
+4 -18
View File
@@ -59,14 +59,6 @@ namespace Game.Entities
} }
} }
public override bool IsNeverVisibleFor(WorldObject seer)
{
if (!_participants.Contains(seer.GetGUID()))
return true;
return base.IsNeverVisibleFor(seer);
}
public override void Update(uint diff) public override void Update(uint diff)
{ {
if (GetDuration() > diff) if (GetDuration() > diff)
@@ -96,7 +88,7 @@ namespace Game.Entities
} }
} }
public static Conversation CreateConversation(uint conversationEntry, Unit creator, Position pos, List<ObjectGuid> participants, SpellInfo spellInfo = null) public static Conversation CreateConversation(uint conversationEntry, Unit creator, Position pos, ObjectGuid privateObjectOwner, SpellInfo spellInfo = null)
{ {
ConversationTemplate conversationTemplate = Global.ConversationDataStorage.GetConversationTemplate(conversationEntry); ConversationTemplate conversationTemplate = Global.ConversationDataStorage.GetConversationTemplate(conversationEntry);
if (conversationTemplate == null) if (conversationTemplate == null)
@@ -105,19 +97,19 @@ namespace Game.Entities
ulong lowGuid = creator.GetMap().GenerateLowGuid(HighGuid.Conversation); ulong lowGuid = creator.GetMap().GenerateLowGuid(HighGuid.Conversation);
Conversation conversation = new(); Conversation conversation = new();
if (!conversation.Create(lowGuid, conversationEntry, creator.GetMap(), creator, pos, participants, spellInfo)) if (!conversation.Create(lowGuid, conversationEntry, creator.GetMap(), creator, pos, privateObjectOwner, spellInfo))
return null; return null;
return conversation; return conversation;
} }
bool Create(ulong lowGuid, uint conversationEntry, Map map, Unit creator, Position pos, List<ObjectGuid> participants, SpellInfo spellInfo = null) bool Create(ulong lowGuid, uint conversationEntry, Map map, Unit creator, Position pos, ObjectGuid privateObjectOwner, SpellInfo spellInfo = null)
{ {
ConversationTemplate conversationTemplate = Global.ConversationDataStorage.GetConversationTemplate(conversationEntry); ConversationTemplate conversationTemplate = Global.ConversationDataStorage.GetConversationTemplate(conversationEntry);
//ASSERT(conversationTemplate); //ASSERT(conversationTemplate);
_creatorGuid = creator.GetGUID(); _creatorGuid = creator.GetGUID();
_participants = participants; SetPrivateObjectOwner(privateObjectOwner);
SetMap(map); SetMap(map);
Relocate(pos); Relocate(pos);
@@ -212,11 +204,6 @@ namespace Game.Entities
SetUpdateFieldValue(ref actorField.Type, ConversationActorType.WorldObjectActor); SetUpdateFieldValue(ref actorField.Type, ConversationActorType.WorldObjectActor);
} }
void AddParticipant(ObjectGuid participantGuid)
{
_participants.Add(participantGuid);
}
public uint GetScriptId() public uint GetScriptId()
{ {
return Global.ConversationDataStorage.GetConversationTemplate(GetEntry()).ScriptId; return Global.ConversationDataStorage.GetConversationTemplate(GetEntry()).ScriptId;
@@ -303,6 +290,5 @@ namespace Game.Entities
ObjectGuid _creatorGuid; ObjectGuid _creatorGuid;
uint _duration; uint _duration;
uint _textureKitId; uint _textureKitId;
List<ObjectGuid> _participants = new();
} }
} }
+2 -2
View File
@@ -5333,7 +5333,7 @@ namespace Game.Spells
if (unitCaster == null || !m_targets.HasDst()) if (unitCaster == null || !m_targets.HasDst())
return; return;
Conversation.CreateConversation((uint)effectInfo.MiscValue, unitCaster, destTarget.GetPosition(), new List<ObjectGuid>() { GetCaster().GetGUID() }, GetSpellInfo()); Conversation.CreateConversation((uint)effectInfo.MiscValue, unitCaster, destTarget.GetPosition(), ObjectGuid.Empty, GetSpellInfo());
} }
[SpellEffectHandler(SpellEffectName.AddGarrisonFollower)] [SpellEffectHandler(SpellEffectName.AddGarrisonFollower)]
@@ -5681,7 +5681,7 @@ namespace Game.Spells
if (unitCaster == null || unitTarget == null || !unitTarget.IsPlayer()) if (unitCaster == null || unitTarget == null || !unitTarget.IsPlayer())
return; return;
Conversation.CreateConversation((uint)effectInfo.MiscValue, unitCaster, unitTarget.GetPosition(), new List<ObjectGuid>() { unitTarget.GetGUID() }, GetSpellInfo()); Conversation.CreateConversation((uint)effectInfo.MiscValue, unitCaster, unitTarget.GetPosition(), unitTarget.GetGUID(), GetSpellInfo());
} }
[SpellEffectHandler(SpellEffectName.SendChatMessage)] [SpellEffectHandler(SpellEffectName.SendChatMessage)]