Danbias/Code/Game/GameLogic/Weapon.cpp

70 lines
1.4 KiB
C++
Raw Normal View History

#include "Weapon.h"
#include "AttatchmentSocket.h"
#include "AttatchmentMassDriver.h"
using namespace GameLogic;
2013-12-05 11:50:39 +01:00
struct Weapon::PrivateData
{
2013-12-05 11:50:39 +01:00
PrivateData()
{
weaponState = WEAPON_STATE_IDLE;
SelectedAttatchment = new AttatchmentMassDriver();
2013-12-05 11:50:39 +01:00
}
~PrivateData()
{
}
WEAPON_STATE weaponState;
AttatchmentSocket **attatchmentSockets;
int nrOfAttatchmentSockets;
IAttatchment *SelectedAttatchment;
2013-12-05 11:50:39 +01:00
}myData;
Weapon::Weapon()
{
myData = new PrivateData();
}
Weapon::~Weapon(void)
{
2013-12-05 11:50:39 +01:00
delete myData;
}
/********************************************************
* Uses the weapon based on the input given and the current state of the weapon
********************************************************/
void Weapon::UseWeapon(const WEAPON_FIRE &fireInput)
{
myData->SelectedAttatchment->UseAttatchment(fireInput);
}
/********************************************************
* Specific weapon usage implementation
********************************************************/
/********************************************************
* Get functions for states
********************************************************/
bool Weapon::IsFireing()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIREING);
}
bool Weapon::IsIdle()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
}
bool Weapon::IsReloading()
{
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
}