Core/Conversation: Implemented OnConversationStart and OnConversationUpdate hooks
Port From (https://github.com/TrinityCore/TrinityCore/commit/7f14b64e093de23abb322b843b92260d9fe51123)
This commit is contained in:
@@ -48,6 +48,8 @@ namespace Game.Entities
|
||||
|
||||
public override void Update(uint diff)
|
||||
{
|
||||
Global.ScriptMgr.OnConversationUpdate(this, diff);
|
||||
|
||||
if (GetDuration() > TimeSpan.FromMilliseconds(diff))
|
||||
{
|
||||
_duration -= TimeSpan.FromMilliseconds(diff);
|
||||
@@ -177,6 +179,7 @@ namespace Game.Entities
|
||||
if (!GetMap().AddToMap(this))
|
||||
return false;
|
||||
|
||||
Global.ScriptMgr.OnConversationStart(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -779,8 +779,14 @@ namespace Game.Scripting
|
||||
// Called when Conversation is created but not added to Map yet.
|
||||
public virtual void OnConversationCreate(Conversation conversation, Unit creator) { }
|
||||
|
||||
// Called when Conversation is started
|
||||
public virtual void OnConversationStart(Conversation conversation) { }
|
||||
|
||||
// Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid
|
||||
public virtual void OnConversationLineStarted(Conversation conversation, uint lineId, Player sender) { }
|
||||
|
||||
// Called for each update tick
|
||||
public virtual void OnConversationUpdate(Conversation conversation, uint diff) { }
|
||||
}
|
||||
|
||||
public class SceneScript : ScriptObject
|
||||
|
||||
@@ -1028,6 +1028,13 @@ namespace Game.Scripting
|
||||
RunScript<ConversationScript>(script => script.OnConversationCreate(conversation, creator), conversation.GetScriptId());
|
||||
}
|
||||
|
||||
public void OnConversationStart(Conversation conversation)
|
||||
{
|
||||
Cypher.Assert(conversation != null);
|
||||
|
||||
RunScript<ConversationScript>(script => script.OnConversationStart(conversation), conversation.GetScriptId());
|
||||
}
|
||||
|
||||
public void OnConversationLineStarted(Conversation conversation, uint lineId, Player sender)
|
||||
{
|
||||
Cypher.Assert(conversation != null);
|
||||
@@ -1036,6 +1043,13 @@ namespace Game.Scripting
|
||||
RunScript<ConversationScript>(script => script.OnConversationLineStarted(conversation, lineId, sender), conversation.GetScriptId());
|
||||
}
|
||||
|
||||
public void OnConversationUpdate(Conversation conversation, uint diff)
|
||||
{
|
||||
Cypher.Assert(conversation != null);
|
||||
|
||||
RunScript<ConversationScript>(script => script.OnConversationUpdate(conversation, diff), conversation.GetScriptId());
|
||||
}
|
||||
|
||||
//SceneScript
|
||||
public void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user