Fixed movement of multiple entities.
Changed std::unique_ptr<Entity> to std::shared_ptr<Entity>. Fixed pathfinding away from targets TODO : - Fix oscillation around destination - Fix fleeing from adjacent target - Win conditions - GUI
This commit is contained in:
parent
293a564a29
commit
5ccd7d0c13
6 changed files with 33 additions and 21 deletions
10
src/Rule.h
10
src/Rule.h
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
|
@ -18,7 +18,8 @@ class Rule : public Entity
|
|||
{
|
||||
public:
|
||||
// The Rule object takes ownership of the Entity*
|
||||
Rule(Entity* entity, State targetState, EntityType targetType, std::vector<std::unique_ptr<Entity>>& entities,
|
||||
Rule(std::shared_ptr<Entity> entity, State targetState, EntityType targetType,
|
||||
const std::vector<std::shared_ptr<Entity>>& entities,
|
||||
const std::vector<pro_maat::GridPos>& occupiedSquares, const pro_maat::GridPos& mapSize);
|
||||
|
||||
/// Update according to the targetState and targetType
|
||||
|
@ -40,13 +41,12 @@ private:
|
|||
/// \return Suitable target square or current position if none was found.
|
||||
pro_maat::GridPos findTarget();
|
||||
|
||||
std::unique_ptr<Entity> entity;
|
||||
std::shared_ptr<Entity> entity;
|
||||
|
||||
State targetState;
|
||||
EntityType targetType;
|
||||
|
||||
// TOOD : dropped const-qualifier. Consider using shared_ptr ?
|
||||
std::vector<std::unique_ptr<Entity>>& entities;
|
||||
const std::vector<std::shared_ptr<Entity>>& entities;
|
||||
const std::vector<pro_maat::GridPos>& occupiedSquares;
|
||||
|
||||
const pro_maat::GridPos& mapSize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue