| 140 | } |
| 141 | |
| 142 | bool Forest::onAdd() |
| 143 | { |
| 144 | if (!Parent::onAdd()) |
| 145 | return false; |
| 146 | |
| 147 | const char *name = getName(); |
| 148 | if(name && name[0] && getClassRep()) |
| 149 | { |
| 150 | Namespace *parent = getClassRep()->getNameSpace(); |
| 151 | Con::linkNamespaces(parent->mName, name); |
| 152 | mNameSpace = Con::lookupNamespace(name); |
| 153 | } |
| 154 | |
| 155 | setGlobalBounds(); |
| 156 | resetWorldBox(); |
| 157 | |
| 158 | // TODO: Make sure this calls the script "onAdd" which will |
| 159 | // populate the object with forest entries before creation. |
| 160 | addToScene(); |
| 161 | |
| 162 | // If we don't have a file name and the editor is |
| 163 | // enabled then create an empty forest data file. |
| 164 | if ( isServerObject() && ( !mDataFileName || !mDataFileName[0] ) ) |
| 165 | createNewFile(); |
| 166 | else |
| 167 | { |
| 168 | // Try to load the forest file. |
| 169 | mData = ResourceManager::get().load( mDataFileName ); |
| 170 | if ( !mData ) |
| 171 | { |
| 172 | if ( isClientObject() ) |
| 173 | NetConnection::setLastError( "You are missing a file needed to play this mission: %s", mDataFileName ); |
| 174 | |
| 175 | return false; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | updateCollision(); |
| 180 | |
| 181 | smCreatedSignal.trigger( this ); |
| 182 | |
| 183 | if ( isClientObject() ) |
| 184 | { |
| 185 | mZoningDirty = true; |
| 186 | SceneZoneSpaceManager::getZoningChangedSignal().notify( this, &Forest::_onZoningChanged ); |
| 187 | |
| 188 | ForestWindMgr::getAdvanceSignal().notify( this, &Forest::getLocalWindTrees ); |
| 189 | } |
| 190 | |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | void Forest::onRemove() |
| 195 | { |
nothing calls this directly
no test coverage detected