/// <summary> /// The main interface for communicating between behaviours. Using polymorphism, we /// define a bunch of different messages deriving from BehaviourMessage. Each behaviour /// can then check for particular upcasted messahe types, and either grab some data /// from it (set message) or store some data in it (get message). /// </summary> /// <param name="msg">The message being communicated to the behaviour.</param> public override void OnMessage(ref BehaviourMessage msg) { base.OnMessage(ref msg); if (msg is Health.OnZeroHealthMessage) { AdvanceToState("Dead"); } else if (msg is ExtractionPoint.OnExtractionPointActivatedMessage) { // Store the next extraction point. ExtractionPoint.OnExtractionPointActivatedMessage temp = (ExtractionPoint.OnExtractionPointActivatedMessage)msg; mExtractionPoint = msg.pSender; FSMState curState = GetCurrentState(); // If anyone is in the Safe House, they should make a run for the Extraction point now. if (curState is States.Common.FSMStateGoToStandingPosition || curState is States.Common.FSMStateWaitAtStandingPosition || curState is FSMStatePatrol || curState is FSMStatePauseAtPatrolPoint) { AdvanceToState("GoToExtraction"); } } else if (msg is FSMCivilian.GetExtractionPointMessage) { FSMCivilian.GetExtractionPointMessage temp = (FSMCivilian.GetExtractionPointMessage)msg; temp.mExtractionPoint_Out = mExtractionPoint; } else if (msg is FSMCivilian.GetSafeHouseScoreMessage) { FSMCivilian.GetSafeHouseScoreMessage temp = (FSMCivilian.GetSafeHouseScoreMessage)msg; temp.mSafeHouseScore_Out = mSafeHouseScore; } else if (msg is StrandedPopup.GetIsScoutableMessage) { // Currently the only thing required for a Stranded to be Scoutable, is that // they are currently in the Cower state. This can later be expanded to include // things like distance from the sender. if (GetCurrentState() is States.Common.FSMStateCower) { StrandedPopup.GetIsScoutableMessage temp = (StrandedPopup.GetIsScoutableMessage)msg; temp.mIsScoutable_Out = true; } } }
/// <summary> /// The main interface for communicating between behaviours. Using polymorphism, we /// define a bunch of different messages deriving from BehaviourMessage. Each behaviour /// can then check for particular upcasted messahe types, and either grab some data /// from it (set message) or store some data in it (get message). /// </summary> /// <param name="msg">The message being communicated to the behaviour.</param> public override void OnMessage(ref BehaviourMessage msg) { base.OnMessage(ref msg); if (msg is Health.OnZeroHealthMessage) { AdvanceToState("Dead"); } else if (msg is ExtractionPoint.OnExtractionPointActivatedMessage) { // Store the next extraction point. ExtractionPoint.OnExtractionPointActivatedMessage temp = (ExtractionPoint.OnExtractionPointActivatedMessage)msg; mExtractionPoint = msg.pSender; FSMState curState = GetCurrentState(); // If anyone is in the Safe House, they should make a run for the Extraction point now. if (curState is States.Common.FSMStateGoToStandingPosition || curState is States.Common.FSMStateWaitAtStandingPosition || curState is States.Engineer.FSMStateDoRepair || curState is States.Engineer.FSMStateRepair || curState is States.Engineer.FSMStateWaitForRepairChance) { AdvanceToState("GoToExtraction"); } } else if (msg is FSMCivilian.GetExtractionPointMessage) { FSMCivilian.GetExtractionPointMessage temp = (FSMCivilian.GetExtractionPointMessage)msg; temp.mExtractionPoint_Out = mExtractionPoint; } else if (msg is FSMCivilian.GetSafeHouseScoreMessage) { FSMCivilian.GetSafeHouseScoreMessage temp = (FSMCivilian.GetSafeHouseScoreMessage)msg; temp.mSafeHouseScore_Out = mSafeHouseScore; } else if (msg is StrandedPopup.GetIsScoutableMessage) { // Currently the only thing required for a Civilian to be Scoutable, is that // they are currently in the Cower state. This can later be expanded to include // things like distance from the sender. if (GetCurrentState() is States.Common.FSMStateCower) { StrandedPopup.GetIsScoutableMessage temp = (StrandedPopup.GetIsScoutableMessage)msg; temp.mIsScoutable_Out = true; } } else if (msg is SetTileToRepairMessage) { SetTileToRepairMessage temp = (SetTileToRepairMessage)msg; mTileToRepair = temp.mTile_In; } else if (msg is GetTileToRepairMessage) { System.Diagnostics.Debug.Assert(mTileToRepair != null, "Getting mTileToRepair when it has not yet been set."); GetTileToRepairMessage temp = (GetTileToRepairMessage)msg; temp.mTile_Out = mTileToRepair; } }