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