home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 06 Rabin / msg.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-10  |  1.9 KB  |  64 lines

  1. /* Copyright (C) Steve Rabin, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Steve Rabin, 2001"
  9.  */
  10.  
  11. #ifndef __MSG_H__
  12. #define __MSG_H__
  13.  
  14. #include "global.h"
  15.  
  16.  
  17. //Add new messages here
  18. typedef enum { MSG_NULL,
  19.                MSG_Randomize,
  20.                MSG_Timeout,
  21.                MSG_ChangeState
  22. } MSG_Name;
  23.  
  24.  
  25. class MSG_Object
  26. {
  27. public:
  28.  
  29.     MSG_Object( void );
  30.     MSG_Object( float deliveryTime, MSG_Name name, objectID sender, objectID receiver, int state = -1 );
  31.     ~MSG_Object( void ) {}
  32.  
  33.     MSG_Name GetMsgName( void )                    { return( m_Name ); }
  34.     void SetMsgName( MSG_Name name )            { m_Name = name; }
  35.  
  36.     objectID GetSender( void )                    { return( m_Sender ); }
  37.     void SetSender( objectID sender )            { m_Sender = sender; }
  38.  
  39.     objectID GetReceiver( void )                { return( m_Receiver ); }
  40.     void SetReceiver( objectID receiver )        { m_Receiver = receiver; }
  41.  
  42.     int GetMsgState( void )                        { return( m_State ); }
  43.     void SetMsgState( int state )                { m_State = state; }
  44.  
  45.     float GetDeliveryTime( void )                { return( m_DeliveryTime ); }
  46.     void SetDeliveryTime( float time )            { m_DeliveryTime = time; }
  47.  
  48.     bool IsDelivered( void )                    { return( m_Delivered ); }
  49.     void SetDelivered( bool value )                { m_Delivered = value; }
  50.  
  51. private:
  52.  
  53.     MSG_Name m_Name;        //Message name
  54.     objectID m_Sender;        //Object that sent the message
  55.     objectID m_Receiver;    //Object that will get the message
  56.     int m_State;            //State in which the receiver is allowed get the message (-1 means any state)
  57.  
  58.     float m_DeliveryTime;    //Time at which to send the message
  59.     bool m_Delivered;        //Whether the message has been delivered
  60.  
  61. };
  62.  
  63.  
  64. #endif    // __MSG_H__