Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/scriptimprovements/src/world_entities/script_triggers/space_trigger.cc @ 10607

Last change on this file since 10607 was 10607, checked in by snellen, 17 years ago

Introduced new scripttrigger: space trigger

File size: 4.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 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: Silvan Nellen
13   co-programmer: ...
14*/
15
16
17#include "space_trigger.h"
18#include "debug.h"
19
20ObjectListDefinition(SpaceTrigger);
21
22// CREATE_SCRIPTABLE_CLASS(SpaceTrigger,
23//             // Coordinates
24//                         addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
25//                             ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
26//                             ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
27//                             ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
28//             //Properties
29//                             ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName))
30//                             ->addMethod("setTarget", Executor1<SpaceTrigger, lua_State*, const std::string&>(&SpaceTrigger::setTarget))
31//                             ->addMethod("setTriggerParent", Executor1<SpaceTrigger, lua_State*, const std::string&>(&SpaceTrigger::setTriggerParent))
32//                             ->addMethod("setTriggerRemains", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setTriggerRemains))
33//                             ->addMethod("setActiveOnCreation", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setActiveOnCreation))
34//                             ->addMethod("setInvert", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setInvert))
35//                             ->addMethod("setRadius", Executor1<SpaceTrigger, lua_State*, float>(&SpaceTrigger::setRadius))
36//                             ->addMethod("setScript", Executor1<SpaceTrigger, lua_State*, const std::string&>(&SpaceTrigger::setScript))
37//                             ->addMethod("setFunction", Executor1<SpaceTrigger, lua_State*, const std::string&>(&SpaceTrigger::setFunction))
38//                             ->addMethod("setDebugDraw", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setDebugDraw))
39//                             ->addMethod("setAddToScript", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setAddToScript))
40//                        );
41
42
43/**
44 * Constructs a new SpaceTrigger.
45 * @param root the xml element to load the parameters from.
46 *
47 */
48SpaceTrigger::SpaceTrigger(const TiXmlElement* root)
49{
50  this->registerObject(this, SpaceTrigger::_objectList);
51  this->toList(OM_COMMON);
52
53  radius = 10;
54  invert = false;
55  triggerRemains = true;
56 
57
58
59}
60
61/**
62 * Deletes the SpaceTrigger.
63 *
64 */
65SpaceTrigger::~SpaceTrigger()
66{
67
68}
69
70/**
71 * Reads the values from the tml element and sets them.
72 * @param root the xml element to load the parameters from.
73 *
74 */
75void SpaceTrigger::loadParams(const TiXmlElement* root)
76{
77
78  ScriptTrigger ::loadParams(root);
79
80 
81  LoadParam(root, "radius", this, SpaceTrigger, setRadius)
82      .describe("the fileName of the script, that should be triggered by this script trigger")
83      .defaultValues(0);
84  LoadParam(root, "worldentity", this, SpaceTrigger, setTarget)
85      .describe("The name of the target as it is in the *.oxw file")
86      .defaultValues("");
87  LoadParam(root, "invert", this, SpaceTrigger, setInvert)
88      .describe("")
89      .defaultValues(false);
90  LoadParam(root, "triggerRemains", this, SpaceTrigger, setTriggerRemains)
91      .describe("")
92      .defaultValues(true);
93 
94}
95
96
97/**
98 * Sets the target(a world entity) of the SpaceTrigger. If the distance between the target and this trigger is smaller than the radius, the script gets triggered.
99 * @param target The worldentity that the script supervises.
100 */
101void SpaceTrigger::setTarget(const std::string& target)
102{
103
104  WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);
105  if (targetEntity != NULL)
106  {
107    this->setTarget(targetEntity);
108  }
109  else
110  {
111    PRINTF(2)("ERROR SCRTIPTTRIGGER : Target %s for %s::%s does not Exist\n", target.c_str(), this->getClassCName(), this->getCName());
112  }
113}
114
115
116void SpaceTrigger::tick(float timestep)
117{
118
119}
120
121
122
Note: See TracBrowser for help on using the repository browser.