129 Print(
"GridSpawner: Error, no objects specified!",
LogLevel.ERROR);
135 int objectsCount = m_aObjects.Count();
148 if (
object ==
string.Empty)
152 int type = GetObjectType(
object);
156 Print(
"GridSpawnerEntity: Trying to spawn an invalid object. You must specify a valid template (.et) or mesh (.xob).",
LogLevel.ERROR);
162 if (m_aSpawnedEntities)
165 if (!m_aSpawnedEntities)
166 m_aSpawnedEntities =
new array<IEntity>();
170 int countPerAxis =
Math.Floor(
Math.Sqrt(m_iObjectsCount));
175 float spacing = m_fSpacing;
179 if (!m_bUseAbsoluteSpacing)
183 Math3D.MatrixIdentity4(dummyMatrix);
187 const float dummyOffset = -999;
188 for (
int i = 0; i < 3; i++)
189 dummyMatrix[3][i] = dummyOffset;
192 spawnParams.TransformMode = ETransformMode.WORLD;
193 for (
int comp = 0; comp < 4; comp++)
195 spawnParams.Transform[comp] = dummyMatrix[comp];
203 dummyObject =
GetGame().SpawnEntityPrefab(resource, baseWorld, spawnParams);
207 VObject obj = resource.GetResource().ToVObject();
209 dummyObject.SetObject(obj,
"");
221 float boundsSpan =
vector.Distance(min, max);
222 spacing += boundsSpan;
233 for (
int i = 0; i < countPerAxis; i++)
235 for (
int j = 0; j < countPerAxis; j++)
239 Math3D.MatrixIdentity4(mat);
242 if (m_iRandomizationSeed != 0)
245 Math3D.AnglesToMatrix(yawPitchRoll, mat);
249 vector newPos = currentPosition;
250 newPos[0] = newPos[0] + i * spacing;
251 newPos[2] = newPos[2] + j * spacing;
258 spawnParams.TransformMode = ETransformMode.WORLD;
259 for (
int comp = 0; comp < 4; comp++)
261 spawnParams.Transform[comp] = mat[comp];
269 spawnedObject =
GetGame().SpawnEntityPrefab(resource, baseWorld, spawnParams);
273 VObject obj = resource.GetResource().ToVObject();
275 spawnedObject.SetObject(obj,
"");
281 m_aSpawnedEntities.Insert(spawnedObject);
286 centerPoint[0] = 0.5 * (
float)countPerAxis * spacing;
287 centerPoint[2] = 0.5 * (
float)countPerAxis * spacing;
294 if (m_aSpawnedEntities)
296 int count = m_aSpawnedEntities.Count();
299 for (
int i = count-1; i >= 0; i--)
301 if (m_aSpawnedEntities[i])
305 delete m_aSpawnedEntities[i];
306 m_aSpawnedEntities[i] = null;
310 m_aSpawnedEntities.Clear();
311 m_aSpawnedEntities = null;