Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/contentcreation/pps/FabianLandau/mover/environments/mover_trigger_list.cc @ 12373

Last change on this file since 12373 was 4844, checked in by landauf, 18 years ago
File size: 3.0 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 "mover_trigger_list.h"
17#include "debug.h"
18
19
20MoverTriggerList::MoverTriggerList()
21{
22    PRINTF(0)("10_1 MoverTriggerList %p created\n", this);
23    this->first = 0;
24    PRINTF(0)("10_2 first element: %p\n", this->first);
25}
26
27MoverTriggerList::~MoverTriggerList()
28{
29    PRINTF(0)("13_1 MoverTriggerList %p destroyed\n", this);
30    MoverTriggerListElement *temp1 = this->first;
31    MoverTriggerListElement *temp2;
32    while (temp1 != 0)
33    {
34        temp2 = temp1->next;
35        delete temp1;
36        temp1 = temp2;
37    }
38}
39
40void MoverTriggerList::addTrigger(MoverTrigger *trigger)
41{
42    PRINTF(0)("11_1 added trigger %p to list %p\n", trigger, this);
43    if (trigger)
44    {
45        if (this->first == 0)
46        {
47            PRINTF(0)("11_2\n");
48            this->first = new MoverTriggerListElement(trigger);
49        }
50        else
51        {
52            PRINTF(0)("11_3\n");
53            MoverTriggerListElement *temp = this->first;
54            while (temp->next != 0)
55                temp = temp->next;
56
57            temp->next = new MoverTriggerListElement(trigger);
58            PRINTF(0)("11_4\n");
59        }
60    }
61    PRINTF(0)("11_5\n");
62}
63
64bool MoverTriggerList::isTriggered()
65{
66//    PRINTF(0)("16_1\n");
67    if (this->first == 0)
68    {
69//        PRINTF(0)("16_2\n");
70        return true;
71    }
72    else
73    {
74//        PRINTF(0)("16_3\n");
75        bool isTriggered = false;
76        MoverTriggerListElement *temp = this->first;
77
78        while (temp != 0)
79        {
80            if (temp->trigger->isTriggered())
81            {
82                isTriggered = true;
83            }
84            else
85            {
86                if (temp->trigger->isObligatory())
87                    return false;
88            }
89                   
90            temp = temp->next;
91        }
92
93//        PRINTF(0)("16_4\n");
94        return isTriggered;
95    }
96}
97
98void MoverTriggerList::setBaseCoor(Vector baseCoor)
99{
100//    PRINTF(0)("12_1 set base coor in %p\n", this);
101//    PRINTF(0)("12_2 first element: %p\n", this->first);
102    MoverTriggerListElement *temp = this->first;
103    while (temp != 0)
104    {
105//        PRINTF(0)("12_3\n");
106        temp->trigger->setBaseCoor(baseCoor);
107        temp = temp->next;
108    }
109//    PRINTF(0)("12_4\n");
110}
111
112
113////////////////////////////////////////////////////////
114
115
116MoverTriggerListElement::MoverTriggerListElement(MoverTrigger *trigger)
117{
118    this->trigger = trigger;
119    this->next = 0;
120}
121
122MoverTriggerListElement::~MoverTriggerListElement()
123{
124    if (this->trigger)
125        delete this->trigger;
126}
Note: See TracBrowser for help on using the repository browser.