-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreature_Knowledge.cpp
More file actions
78 lines (63 loc) · 1.36 KB
/
Creature_Knowledge.cpp
File metadata and controls
78 lines (63 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#ifndef WORLDSIM_CREATURE_KNOWLEDGE_CPP
#define WORLDSIM_CREATURE_KNOWLEDGE_CPP
/* WorldSim: Creature_Knowledge
#include "Creature_Knowledge.cpp"
Implementation of Creature_Knowledge.hpp
*/
#include "Creature_Knowledge.hpp"
Creature_Knowledge::Creature_Knowledge()
{
pathIndex=0;
}
void Creature_Knowledge::init()
{
currentGoal.set(-1,-1);
threatLocation.set(-1,-1);
}
// Adds the tile to the Character's knowledge.
void Creature_Knowledge::addTile( World_Local* _map, int _x, int _y)
{
if ( _map == 0 || _map->isSafe(_x,_y) == false ) { return; }
vVisibleTiles.push((*_map)(_x,_y));
}
void Creature_Knowledge::updateThreat(short int _x, short int _y)
{
threatLocation.set(_x,_y);
}
//returns true if the Character has seen this tile.
char Creature_Knowledge::hasSeen( World_Local* _map, int _x, int _y)
{
if ( _map == 0 || _map->isSafe(_x,_y) == false )
{
return false;
}
LocalTile* lt = (*_map)(_x,_y);
if( vVisibleTiles.contains(lt) )
{
return 1;
}
return 0;
}
void Creature_Knowledge::updateLOS()
{
//for now just clear everything
clear();
}
void Creature_Knowledge::clear()
{
//if ( vVisibleTiles!=0)
{ vVisibleTiles.clear();
}
}
char Creature_Knowledge::nextStep()
{
if ( p.vPath.isSafe(pathIndex) )
{
return p.vPath(pathIndex++);
}
pathIndex=0;
p.vPath.clear();
return 0;
}
#endif