Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/contentcreation/pps/FabianLandau/mover/environments/mover_trigger_event.cc @ 5468

Last change on this file since 5468 was 4844, checked in by landauf, 18 years ago
File size: 1.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2007 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Fabian 'x3n' Landau
13   co-programmer:
14*/
15
16#include "util/loading/load_param.h"
17#include "util/loading/factory.h"
18#include "mover_trigger_event.h"
19#include "debug.h"
20
21ObjectListDefinition(EventTrigger);
22CREATE_FACTORY(EventTrigger);
23
24
25EventTrigger::EventTrigger(const TiXmlElement* root)
26{
27    PRINTF(0)("15_1 EventTrigger %p created\n", this);
28    this->registerObject(this, EventTrigger::_objectList);
29    this->toList(OM_ENVIRON);
30
31    this->eventName = "";
32    this->eventTriggers = 0;
33    this->bIsChecking = false;
34   
35    if (root != NULL)
36        this->loadParams(root);
37
38    this->init_post_params();
39}
40
41EventTrigger::~EventTrigger()
42{
43    delete this->eventTriggers;
44}
45
46void EventTrigger::loadParams(const TiXmlElement* root)
47{
48    MoverTrigger::loadParams(root);
49
50    LoadParam(root, "event", this, EventTrigger, setEvent)
51        .describe("The event that releases the trigger")
52        .defaultValues("");
53}
54
55bool EventTrigger::checkIsTriggered()
56{
57    if (this->bIsChecking)
58        return this->bIsTriggered; // to avoid event-loops
59       
60    if (!this->eventTriggers)
61    {
62        if (MoverTrigger::events)
63            this->eventTriggers = MoverTrigger::events->getPointerList(this->eventName);
64
65        if (!this->eventTriggers)
66            this->eventTriggers = new MoverTriggerPointerList();
67    }
68
69    this->bIsChecking = true;
70    bool isTriggered = this->eventTriggers->isTriggered();
71    this->bIsChecking = false;
72   
73    return isTriggered;
74}
75
Note: See TracBrowser for help on using the repository browser.