Core/SAI: Implemented new source type SMART_SCRIPT_TYPE_EVENT (3)
Port From (https://github.com/TrinityCore/TrinityCore/commit/d015711fbb7a8bf57f7bb64ba8113c942d5125de)
This commit is contained in:
@@ -425,7 +425,7 @@ namespace Game.Scripting
|
||||
|
||||
public virtual BattleField GetBattlefield(Map map) { return null; }
|
||||
}
|
||||
|
||||
|
||||
public class BattlegroundScript : ScriptObject
|
||||
{
|
||||
public BattlegroundScript(string name) : base(name)
|
||||
@@ -572,7 +572,7 @@ namespace Game.Scripting
|
||||
// Called when an achievement is completed.
|
||||
public virtual void OnCompleted(Player player, AchievementRecord achievement) { }
|
||||
}
|
||||
|
||||
|
||||
public class AchievementCriteriaScript : ScriptObject
|
||||
{
|
||||
public AchievementCriteriaScript(string name) : base(name)
|
||||
@@ -842,4 +842,17 @@ namespace Game.Scripting
|
||||
// Called when worldstate changes value, map is optional
|
||||
public virtual void OnValueChange(int worldStateId, int oldValue, int newValue, Map map) { }
|
||||
}
|
||||
|
||||
public class EventScript : ScriptObject
|
||||
{
|
||||
public EventScript(string name) : base(name)
|
||||
{
|
||||
Global.ScriptMgr.AddScript(this);
|
||||
}
|
||||
|
||||
public override bool IsDatabaseBound() { return true; }
|
||||
|
||||
// Called when a game event is triggered
|
||||
public virtual void OnTrigger(WorldObject obj, WorldObject invoker, uint eventId) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,15 @@ namespace Game.Scripting
|
||||
|
||||
RunScript<WorldStateScript>(script => script.OnValueChange(worldStateTemplate.Id, oldValue, newValue, map), worldStateTemplate.ScriptId);
|
||||
}
|
||||
|
||||
|
||||
// EventScript
|
||||
public void OnEventTrigger(WorldObject obj, WorldObject invoker, uint eventId)
|
||||
{
|
||||
Cypher.Assert(invoker != null);
|
||||
|
||||
RunScript<EventScript>(script => script.OnTrigger(obj, invoker, eventId), Global.ObjectMgr.GetEventScriptId(eventId));
|
||||
}
|
||||
|
||||
public void ForEach<T>(Action<T> a) where T : ScriptObject
|
||||
{
|
||||
var reg = GetScriptRegistry<T>();
|
||||
|
||||
Reference in New Issue
Block a user