mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
extractors can only be built on unoccupied deposits
This commit is contained in:
@@ -23,6 +23,7 @@ namespace battleship{
|
||||
for(ResourceDeposit *dep : deposits)
|
||||
if(dep->getPos().getDistanceFrom(pos) < .001){
|
||||
deposit = dep;
|
||||
deposit->setExtractor(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +34,9 @@ namespace battleship{
|
||||
}
|
||||
|
||||
Extractor::~Extractor(){
|
||||
if(deposit)
|
||||
deposit->setExtractor(nullptr);
|
||||
|
||||
removeBar(ammountForeground);
|
||||
removeBar(ammountBackground);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace battleship{
|
||||
for(ResourceDeposit *dep : deposits){
|
||||
Vector3 depPos = dep->getPos();
|
||||
|
||||
if(s.getPos().getDistanceFrom(depPos) < maxDist){
|
||||
if(!dep->getExtractor() && s.getPos().getDistanceFrom(depPos) < maxDist){
|
||||
s.status = GameObjectFrame::PLACEABLE;
|
||||
s.placeAt(depPos);
|
||||
break;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "gameObject.h"
|
||||
|
||||
namespace battleship{
|
||||
class Extractor;
|
||||
|
||||
class ResourceDeposit : public GameObject{
|
||||
public:
|
||||
ResourceDeposit(Player*, int, vb01::Vector3, vb01::Quaternion, int);
|
||||
@@ -11,8 +13,11 @@ namespace battleship{
|
||||
inline int getAmmount(){return ammount;}
|
||||
inline int getInitAmmount(){return initAmmount;}
|
||||
inline void decreaseAmmount(int amnt){ammount -= amnt;}
|
||||
inline Extractor* getExtractor(){return extractor;}
|
||||
inline void setExtractor(Extractor *e){this->extractor = e;}
|
||||
private:
|
||||
int ammount, initAmmount;
|
||||
Extractor *extractor = nullptr;
|
||||
|
||||
void reinit();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user