Skip to content

Commit

Permalink
Added get and has Strategy methods to Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
ctmbl committed Jan 26, 2022
1 parent e4e12ac commit 80450b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
23 changes: 5 additions & 18 deletions include/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,17 @@ class Entity //maybe virtual class ? let's see if this is useful or not later
std::vector<Strategy*> strategies; //basic attribute of an Entity

public:
const static int PHYSICAL = 0;
const static int DRAWABLE = 1;
enum StrategiesID{
DRAWABLE = 0, PHYSICAL = 1, DAMAGEABLE = 2
};

const bool hasStrategy(int strategy);
bool Entity::hasStrategy(StrategiesID);
Strategy* Entity::getStrategy(StrategiesID);

Entity(std::vector<Strategy*> strategies); //basic constructor
~Entity();
};

//in .cpp :

Entity::hasStrategy(int strategy){
//if 'strategy' in strategies return true
}

Entity::Entity(std::vector<Strategy*> strategies){
//this->strategies = strategies;
}

Entity::~Entity()
{
}




#endif
4 changes: 2 additions & 2 deletions include/entity/strategies/physical_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define PHYSICAL_ENTITY
#include "strategy.h"
#include <SFML/Graphics/Transformable.hpp>
#include "lib.h"
#include "lib/lib.h"

class Hitbox{};

Expand All @@ -23,7 +23,7 @@ or damageHitbox != physicalHitbox (like i can touch with my legs) but they can't
PhxParam phxParam;

public:
static void correction(Vector<PhysicalEntity> phxEtts, Vector<Vector<double,double>> correctionMatrix);
static void correction(std::vector<PhysicalEntity> phxEtts, std::vector<std::vector<double,double>> correctionMatrix);

Hitbox getHitbox();
void setHitbox(Hitbox newHitbox);
Expand Down
18 changes: 18 additions & 0 deletions src/entity/entity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "entity/entity.h"


bool Entity::hasStrategy(StrategiesID strategy){
return (strategies.at(strategy) != NULL);
}

Strategy* Entity::getStrategy(StrategiesID strategy){
return strategies.at(strategy);
}

Entity::Entity(std::vector<Strategy*> strategies){
//this->strategies = strategies;
}

Entity::~Entity()
{
}

0 comments on commit 80450b9

Please sign in to comment.