void SetFlags(int f) { flags = f; }
bool Blocking() const { return !(flags & FLAG_NONBLOCKING); }
+ bool Hostile() const {
+ // NOTE: this is a stub for testing!
+ return Blocking();
+ }
Entity *Follower() { return follower; }
const Entity *Follower() const { return follower; }
void MapState::OnGridLock() {
LockEntities();
- Trigger *trigger(map->TriggerAt(Vector<int>(controlled->Position())));
- if (trigger) {
- // TODO: run trigger
- }
- // TODO: check for adjacent monsters
- // TODO: force all entities into their grid positions?
+ CheckMonster();
+ CheckTrigger();
}
void MapState::LockEntities() {
}
}
+void MapState::CheckMonster() {
+ Vector<int> coords(map->TileCoordinates(controlled->Position()));
+ Vector<int> neighbor[4];
+ neighbor[0] = Vector<int>(coords.X() - 1, coords.Y()); // W
+ neighbor[1] = Vector<int>(coords.X(), coords.Y() + 1); // S
+ neighbor[2] = Vector<int>(coords.X() + 1, coords.Y()); // E
+ neighbor[3] = Vector<int>(coords.X(), coords.Y() - 1); // N
+
+ for (int i(0); i < 4; ++i) {
+ for (std::vector<Entity *>::iterator e(entities.begin()), end(entities.end()); e != end; ++e) {
+ if ((*e)->Hostile() && map->TileCoordinates((*e)->Position()) == neighbor[i]) {
+ // remove entity, push battle state and transition and halt all other activity
+ }
+ }
+ }
+}
+
+void MapState::CheckTrigger() {
+ Trigger *trigger(map->TriggerAt(Vector<int>(controlled->Position())));
+ if (trigger) {
+ // TODO: run trigger
+ }
+
+}
+
void MapState::OnMove(bool realMove) {
// TODO: evaluate monster movements
if (realMove) {