MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / onAdd

Method onAdd

Engine/source/forest/forest.cpp:142–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142bool 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
194void Forest::onRemove()
195{

Callers

nothing calls this directly

Calls 8

linkNamespacesFunction · 0.85
lookupNamespaceFunction · 0.85
getNameSpaceMethod · 0.80
getNameFunction · 0.50
getFunction · 0.50
loadMethod · 0.45
triggerMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected