abstractphysicsproperty.cc
Go to the documentation of this file.00001 //------------------------------------------------------------------------------ 00002 // properties/abstractphysicsproperty.cc 00003 // (C) 2005 Radon Labs GmbH 00004 //------------------------------------------------------------------------------ 00005 #include "properties/abstractphysicsproperty.h" 00006 #include "game/entity.h" 00007 00008 namespace Properties 00009 { 00010 ImplementRtti(Properties::AbstractPhysicsProperty, TransformableProperty); 00011 ImplementFactory(Properties::AbstractPhysicsProperty); 00012 00013 //------------------------------------------------------------------------------ 00016 AbstractPhysicsProperty::AbstractPhysicsProperty() : 00017 enabled(false) 00018 { 00019 // empty 00020 } 00021 00022 //------------------------------------------------------------------------------ 00025 AbstractPhysicsProperty::~AbstractPhysicsProperty() 00026 { 00027 if (this->IsActive()) 00028 { 00029 this->DisablePhysics(); 00030 } 00031 } 00032 00033 //------------------------------------------------------------------------------ 00038 int 00039 AbstractPhysicsProperty::GetActiveEntityPools() const 00040 { 00041 return Game::Entity::LivePool; 00042 } 00043 00044 //------------------------------------------------------------------------------ 00049 void 00050 AbstractPhysicsProperty::OnActivate() 00051 { 00052 TransformableProperty::OnActivate(); 00053 00054 // activate physics by default 00055 this->EnablePhysics(); 00056 } 00057 00058 //------------------------------------------------------------------------------ 00063 void 00064 AbstractPhysicsProperty::OnDeactivate() 00065 { 00066 if (this->IsEnabled()) 00067 { 00068 this->DisablePhysics(); 00069 } 00070 00071 TransformableProperty::OnDeactivate(); 00072 } 00073 00074 //------------------------------------------------------------------------------ 00077 void 00078 AbstractPhysicsProperty::SetEnabled(bool setEnabled) 00079 { 00080 if (this->enabled != setEnabled) 00081 { 00082 if (setEnabled) 00083 { 00084 this->EnablePhysics(); 00085 } 00086 else 00087 { 00088 this->DisablePhysics(); 00089 } 00090 } 00091 } 00092 00093 //------------------------------------------------------------------------------ 00096 void 00097 AbstractPhysicsProperty::EnablePhysics() 00098 { 00099 n_assert(!this->IsEnabled()); 00100 this->enabled = true; 00101 } 00102 00103 //------------------------------------------------------------------------------ 00106 void 00107 AbstractPhysicsProperty::DisablePhysics() 00108 { 00109 n_assert(this->IsEnabled()); 00110 this->enabled = false; 00111 } 00112 00113 //------------------------------------------------------------------------------ 00116 Physics::Entity* 00117 AbstractPhysicsProperty::GetPhysicsEntity() const 00118 { 00119 return 0; 00120 } 00121 00122 }; // namespace Properties