Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

agentrobber.cpp

00001 /***************************************************************************
00002                     agentrobber.cpp  -  description
00003                         -------------------
00004     begin                : nov 29th 2005
00005     copyright            : (C) 2005 by Duong-Khang NGUYEN
00006     email                : neoneurone @ users sourceforge net
00007     author               : Victor STINNER
00008 
00009     $Id: agentrobber.cpp 32 2006-08-06 18:59:25Z neoneurone $
00010  ***************************************************************************/
00011 
00012 /***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   any later version.                                                    *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 
00022 #include "agentrobber.h"
00023 #include "kernel.h"
00024 #include "message.h"
00025 
00026 
00027    /*=====================================================================*/
00028 AgentRobber::AgentRobber(Kernel& kernel, Environment& env, int x, int y):
00029 Agent(kernel, env, x, y, ROLE_ROBBER)
00030 {
00031     this->born();       // Warning: see superclass
00032 
00033 // OpenCity's specifics
00034     this->SetGraphicCode( OC_VEHICLE_ROBBER );
00035 }
00036 
00037 
00038    /*=====================================================================*/
00039 AgentRobber::~AgentRobber()
00040 {
00041     if (m_agent_state != AGENT_DIE)
00042         this->die();        // Warning: see superclass
00043 }
00044 
00045 
00046    /*=====================================================================*/
00047 void AgentRobber::processMessage()
00048 {
00049 }
00050 
00051 
00052    /*=====================================================================*/
00053 void AgentRobber::born()
00054 {
00055     Agent::born();
00056     m_kernel.registerRole(this, ROLE_ROBBER);
00057 }
00058 
00059 
00060    /*=====================================================================*/
00061 void AgentRobber::live()
00062 {
00063     static bool first = true;
00064     if (first)
00065     {
00066         sendMessage(
00067                 ROLE_POLICE, 
00068                 Message( Message::MSG_NEW_ROBBER ) << 10 << 5);
00069         first = false;
00070     }
00071 }
00072 
00073 
00074    /*=====================================================================*/
00075 void AgentRobber::die()
00076 {
00077     Agent::die();
00078     m_kernel.unregisterRole(this, this->getRole());
00079 }
00080 
00081 
00082    /*=====================================================================*/
00083 void AgentRobber::output (std::ostream& os) const
00084 {
00085     os << "AgentRobber " << getId();
00086 }
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2