I am developing a mini-game. The classes involved in this question are:
- PlayState
- IA
- Terrorist.
PlayState
gives a Terrorist Vector to IA
.
Intelligence = new IA(terrorists, p->getRigidBody(), _world);
The definition of the Vector and the terrorist
Terrorist *unTerrorista;
std::vector<Terrorist*> terrorists;
So, I'm creating a vector that contains a pointer to terrorists and I give it to IA
. What I want is that IA
delete terrorists and update automatically in PlayState
(to avoid working with 2 vectors)
Extra information:
IA.h
class IA {
public:
IA(std::vector<Terrorist*> &pTerrorists, RigidBody *pPlayer, OgreBulletDynamics::DynamicsWorld *pWorld);
IA(const IA& orig);
virtual ~IA();
void updateWorld(Ogre::Real pDeltaT);
private:
// int patrullando, rastreando, atacando, muerto;
bool notifyAllTerrorists;
Ogre::Real deltaT;
Ogre::Real auxT;
RigidBody *player;
std::vector<Terrorist*> &terrorists;
OgreBulletDynamics::DynamicsWorld *world;
};
IA.cpp
IA::IA(std::vector<Terrorist*> &pTerrorists, RigidBody *pPlayer, OgreBulletDynamics::DynamicsWorld *pWorld) {
terrorists = pTerrorists;
player = pPlayer;
world = pWorld;
}