/// <summary> /// posts a message to all agents /// </summary> public void SendToAllAgents(AgentMessage msg) { for (int i = 0; i < agentRegister.Count; i++) agentRegister[i].SendMessage(agentRegister[i], msg); }
/// <summary> /// used for sending messages to other agents /// </summary> public void SendMessage(Agent a, AgentMessage msg) { msg.sender = this; a.ReceiveMessage(msg); }
protected override void ReceiveMessage(AgentMessage msg) { BotAgentMessage bam = msg as BotAgentMessage; if (bam == null) return; //always ignore Dummy messages if (bam.msgType == BotAgentMessages.Dummy) return; //always insert messages from GamePlay level at the beginning BlockMessageReceivingStart(); if ((bam.msgType == BotAgentMessages.GameStarted) || (bam.msgType == BotAgentMessages.GameFinished) || (bam.msgType == BotAgentMessages.PauseForControlApplying) || (bam.msgType == BotAgentMessages.ControlsApplied)) messageList.Insert(0, bam); //ordinary message processing - insert at the end messageList.Add(bam); BlockMessageReceivingEnd(); }
/// <summary> /// used to put incoming message into own message list. May be overridden to implement some filtering or special message queueing. base.ReceiveMessage(msg) inserts at the end of message queue /// </summary> protected virtual void ReceiveMessage(AgentMessage msg) { BlockMessageReceivingStart(); messageList.Add(msg); BlockMessageReceivingEnd(); }