Changeset 1671 for code/branches/script_trigger/src/orxonox
- Timestamp:
- Aug 26, 2008, 5:03:24 PM (16 years ago)
- Location:
- code/branches/script_trigger/src/orxonox/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/script_trigger/src/orxonox/objects/Trigger.cc
r1550 r1671 30 30 31 31 #include "core/Debug.h" 32 #include <OgreBillboard.h> 32 33 33 34 #include "core/CoreIncludes.h" 35 #include "core/ConsoleCommand.h" 34 36 35 37 namespace orxonox 36 38 { 39 40 ConsoleCommand(Trigger, setVisibility, AccessLevel::Debug, false).setDefaultValues(0); 41 37 42 CreateFactory(Trigger); 38 43 … … 43 48 targetMask_.exclude(Class(BaseObject)); 44 49 45 if (getSoftDebugLevel() >= ORX_DEBUG) 46 { 47 debugBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); 48 this->getNode()->attachObject(debugBillboard_.getBillboardSet()); 49 } 50 //testing 51 mode_ = TM_EventTriggerAND; 52 bActive_ = true; 53 triggingTime_ = 100; 54 55 debugBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); 56 this->getNode()->attachObject(debugBillboard_.getBillboardSet()); 50 57 } 51 58 … … 59 66 } 60 67 68 void Trigger::setVisibility(int bVisible) 69 { 70 if(bVisible) 71 this->setScale(2,2,2); 72 else 73 this->setScale(0,0,0); 74 } 75 76 void Trigger::tick(float dt) 77 { 78 //COUT(0) << "Scale: " << this->getScale() << std::endl; 79 if(bActive_) 80 { 81 //this->actualTime_ += dt; 82 if(this->isTriggered()) 83 { 84 this->debugBillboard_.getBillboardSet()->getBillboard(0)->setColour(ColourValue(0.0, 1.0, 0.0)); 85 } 86 } 87 } 88 61 89 bool Trigger::isTriggered(TriggerMode mode) 62 90 { 63 switch(mode) 64 { 65 case TM_EventTriggerAnd: 66 return checkAnd(); 67 break; 68 case TM_EventTriggerOr: 69 return checkOr(); 70 break; 71 case TM_DelayTrigger: 72 return checkDelay(); 73 break; 74 case TM_DistanceTrigger: 75 return checkDistance(); 76 break; 77 case TM_DistanceEventTriggerAnd: 78 if (checkDistance() && checkAnd()) 79 return true; 80 else 91 if( children_.size() != 0 ) 92 { 93 switch(mode) 94 { 95 case TM_EventTriggerAND: 96 return checkAnd(); 97 break; 98 case TM_EventTriggerOR: 99 return checkOr(); 100 break; 101 case TM_EventTriggerXOR: 102 return checkXor(); 103 break; 104 case TM_EventTriggerNOT: 105 return checkNot(); 106 break; 107 default: 81 108 return false; 82 break; 83 case TM_DistanceEventTriggerOr: 84 if (checkDistance() && checkOr()) 85 return true; 86 else 87 return false; 88 break; 89 default: 90 return false; 91 break; 92 } 109 break; 110 } 111 } 112 return true; 93 113 } 94 114 … … 101 121 { 102 122 if (this != trig) 103 this-> subTriggers_.insert(trig);123 this->children_.insert(trig); 104 124 } 105 125 … … 121 141 { 122 142 std::set<Trigger*>::iterator it; 123 for(it = this-> subTriggers_.begin(); it != this->subTriggers_.end(); it++)143 for(it = this->children_.begin(); it != this->children_.end(); it++) 124 144 { 125 145 if(!((*it)->isTriggered())) … … 132 152 { 133 153 std::set<Trigger*>::iterator it; 134 for(it = this-> subTriggers_.begin(); it != this->subTriggers_.end(); it++)154 for(it = this->children_.begin(); it != this->children_.end(); it++) 135 155 { 136 156 if((*it)->isTriggered()) … … 140 160 } 141 161 142 bool Trigger::checkDelay() 162 bool Trigger::checkNot() 163 { 164 std::set<Trigger*>::iterator it; 165 for(it = this->children_.begin(); it != this->children_.end(); it++) 166 { 167 if((*it)->isTriggered()) 168 return false; 169 } 170 return true; 171 } 172 173 bool Trigger::checkXor() 174 { 175 std::set<Trigger*>::iterator it; 176 bool test = false; 177 for(it = this->children_.begin(); it != this->children_.end(); it++) 178 { 179 if(test && (*it)->isTriggered()) 180 return false; 181 if((*it)->isTriggered()) 182 test = true; 183 } 184 return test; 185 } 186 187 /*bool Trigger::checkDelay() 143 188 { 144 189 if (triggingTime_ < actualTime_) … … 159 204 return false; 160 205 161 } 206 }*/ 162 207 163 208 } -
code/branches/script_trigger/src/orxonox/objects/Trigger.h
r1550 r1671 43 43 enum TriggerMode 44 44 { 45 TM_EventTriggerAnd, 46 TM_EventTriggerOr, 47 TM_DelayTrigger, 48 TM_DistanceTrigger, 49 TM_DistanceEventTriggerAnd, 50 TM_DistanceEventTriggerOr, 45 TM_EventTriggerAND, 46 TM_EventTriggerOR, 47 TM_EventTriggerXOR, 48 TM_EventTriggerNOT 51 49 }; 52 50 … … 55 53 public: 56 54 Trigger(); 57 Trigger(bool active) { bActive_ = active; }58 55 ~Trigger(); 59 56 … … 63 60 void addTargets(std::string targets); 64 61 void removeTargets(std::string targets); 62 void setVisibility(int bVisible); 65 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 66 64 inline TriggerMode getMode() { return mode_; } 67 65 inline void setMode(TriggerMode mode) { this->mode_ = mode; } 68 inline void tick(float dt) { if(bActive_) this->actualTime_ += dt; }66 void tick(float dt); 69 67 inline void reset(float time) { this->actualTime_ = 0; this->triggingTime_ = time; } 70 68 inline void reset() { reset(triggingTime_); } … … 73 71 bool checkAnd(); 74 72 bool checkOr(); 75 bool check Delay();76 bool check Distance();73 bool checkXor(); 74 bool checkNot(); 77 75 78 76 private: 79 std::set<Trigger*> subTriggers_;77 std::set<Trigger*> children_; 80 78 TriggerMode mode_; 81 79 float triggingTime_;
Note: See TracChangeset
for help on using the changeset viewer.