File: BehaviorVisitor.cpp

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (46 lines) | stat: -rw-r--r-- 1,316 bytes parent folder | download | duplicates (2)
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
/***************************************************************************
                          BehaviorVisitor.cpp  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/
#include "Private.h"
#include "BehaviorVisitor.h"
#include "Behavior.h"
#include "Group.h"

#include <cassert>
#include <cstdio>
#include <cstddef>

BehaviorVisitor * BehaviorVisitor::p_BehaviorVisitor = NULL;

BehaviorVisitor::BehaviorVisitor() {
}

BehaviorVisitor::~BehaviorVisitor() {
  p_BehaviorVisitor = NULL;
}

BehaviorVisitor * BehaviorVisitor::getInstance() {
  if (p_BehaviorVisitor == NULL) {
    p_BehaviorVisitor = new BehaviorVisitor();
  }
  return p_BehaviorVisitor;
}

void BehaviorVisitor::visit(Group* g) {
  // Check properties before applying behavior
  if (g->m_iProperties & EM_GROUP_NO_BEHAVIOR) return;
#ifdef PINBALL_TODO
  vector<Behavior*>::iterator iter = g->m_vBehavior.begin();
  vector<Behavior*>::iterator end = g->m_vBehavior.end();
  for(; iter != end; iter++) {
    (*iter)->onTick();
  }
#endif
  if (g->getBehavior() != NULL) {
    g->getBehavior()->onTick();
  }
}