浏览代码

Added Instigator Game Objects passing to Messager.Send()

/main
Thomas ICHÉ 5 年前
当前提交
1c2cba79
共有 6 个文件被更改,包括 18 次插入9 次删除
  1. 7
      CHANGELOG.md
  2. 2
      Runtime/LevelScripting/Actions/SendMessageAction.cs
  3. 4
      Runtime/LevelScripting/Events/OnGameManagerLevelStart.cs
  4. 5
      Runtime/LevelScripting/Events/OnMessageEvent.cs
  5. 6
      Runtime/Managers/Messager/Messager.cs
  6. 3
      Runtime/Managers/Messager/Playables/SendMessage/SendMessageBehaviour.cs

7
CHANGELOG.md


## 2019.3.1
#### Changed
* **Messager** is now able to pass instigator Game Object through message broadcast.
* **OnMessageEvent** now passes the optional instigator instead of itself as instigator to the Calls. In order to pass itself use an intermediate **SetInstigatorLogic** that targets the OnMessageEvent owner to replicate the former behaviour.
* **SendMessageAction** now passes its instigator game object to the **Messager**
* **SendMessageBehaviour** (Timeline Send Message Tracks/Clips) now displays an instigator game object field in the inspector to be attached to the sent message.
#### Fixed

2
Runtime/LevelScripting/Actions/SendMessageAction.cs


public override void Execute(GameObject instigator = null)
{
Messager.Send(MessageToSend);
Messager.Send(MessageToSend, instigator);
}
}
}

4
Runtime/LevelScripting/Events/OnGameManagerLevelStart.cs


}
}
void Execute()
void Execute(GameObject instigator = null)
Callable.Call(OnMessageRecieved, gameObject);
Callable.Call(OnMessageRecieved, instigator);
}
catch (System.Exception e)
{

5
Runtime/LevelScripting/Events/OnMessageEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{

Messager.RemoveMessage(MessageName, Execute);
}
void Execute()
void Execute(GameObject instigator)
Callable.Call(OnMessageRecieved, gameObject);
Callable.Call(OnMessageRecieved, instigator);
}
catch(System.Exception e)
{

6
Runtime/Managers/Messager/Messager.cs


{
public static class Messager
{
public delegate void Message();
public delegate void Message(GameObject instigator = null);
private static Dictionary<string, List<Message>> m_RegisteredMessages;

m_RegisteredMessages.Remove(messageName);
}
public static void Send(string eventName)
public static void Send(string eventName, GameObject instigator = null)
{
if(GameplayIngredientsSettings.currentSettings.verboseCalls)
Debug.Log(string.Format("[MessageManager] Broadcast: {0}", eventName));

{
foreach (var message in m_RegisteredMessages[eventName])
{
message.Invoke();
message.Invoke(instigator);
}
}
catch (Exception e)

3
Runtime/Managers/Messager/Playables/SendMessage/SendMessageBehaviour.cs


public class SendMessageBehaviour : PlayableBehaviour
{
public string StartMessage;
public GameObject Instigator;
public override void OnBehaviourPlay(Playable playable, FrameData info)
{

if (Application.isPlaying)
Messager.Send(StartMessage);
Messager.Send(StartMessage, Instigator);
else
Debug.Log("[SendMessageBehaviour] Would have sent broadcast message : '" + StartMessage + "'");
}

正在加载...
取消
保存