4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
28 * Actuator to toggle visibility/invisibility of objects
31 #include "KX_VisibilityActuator.h"
32 #include "KX_GameObject.h"
38 KX_VisibilityActuator::KX_VisibilityActuator(
43 : SCA_IActuator(gameobj,T),
46 // intentionally empty
49 KX_VisibilityActuator::~KX_VisibilityActuator(
53 // intentionally empty
57 KX_VisibilityActuator::GetReplica(
61 KX_VisibilityActuator* replica = new KX_VisibilityActuator(*this);
62 replica->ProcessReplica();
63 // this will copy properties and so on...
64 CValue::AddDataToReplica(replica);
69 KX_VisibilityActuator::Update()
71 bool bNegativeEvent = IsNegativeEvent();
74 if (bNegativeEvent) return false;
76 KX_GameObject *obj = (KX_GameObject*) GetParent();
78 obj->SetVisible(m_visible);
84 /* ------------------------------------------------------------------------- */
85 /* Python functions */
86 /* ------------------------------------------------------------------------- */
90 /* Integration hooks ------------------------------------------------------- */
92 KX_VisibilityActuator::Type = {
93 PyObject_HEAD_INIT(&PyType_Type)
95 "KX_VisibilityActuator",
96 sizeof(KX_VisibilityActuator),
104 0, //&cvalue_as_number,
112 KX_VisibilityActuator::Parents[] = {
113 &KX_VisibilityActuator::Type,
114 &SCA_IActuator::Type,
115 &SCA_ILogicBrick::Type,
121 KX_VisibilityActuator::Methods[] = {
122 {"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible,
123 METH_VARARGS, SetVisible_doc},
124 {NULL,NULL} //Sentinel
128 KX_VisibilityActuator::_getattr(
129 const STR_String& attr
132 _getattr_up(SCA_IActuator);
137 /* set visibility ---------------------------------------------------------- */
139 KX_VisibilityActuator::SetVisible_doc[] =
140 "setVisible(visible?)\n"
141 "\t - visible? : Make the object visible? (KX_TRUE, KX_FALSE)"
142 "\tSet the properties of the actuator.\n";
145 KX_VisibilityActuator::PySetVisible(PyObject* self,
150 if(!PyArg_ParseTuple(args, "i", &vis)) {
154 m_visible = PyArgToBool(vis);