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

Method onAdd

Engine/source/forest/forest.cpp:145–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145bool 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
197void Forest::onRemove()
198{

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