5 [
Attribute(
"0", UIWidgets.EditComboBox,
"Defines which spawner uses this Spawn Point",
"", ParamEnumArray.FromEnum(
EPrefabSpawnType))]
8 [
Attribute(
"0", uiwidget: UIWidgets.Flags,
"Game Flags required to spawn contained prefabs.",
"", ParamEnumArray.FromEnum(
EGameFlags))]
11 [
Attribute(
"50", UIWidgets.Slider,
"Percentage of how many prefabs to spawn based on how many SCR_PrefabSpawnPoints(with defined type) exists in Mission.",
"0 100")]
12 protected int m_iTotalPrefabs;
14 [
Attribute(
"", UIWidgets.Object,
"Add categories of prefabs and/or specific prefabs to spawn.")]
15 protected ref array<ref SCR_BasePrefabCategory> m_aPrefabsCategories;
18 protected ref array<SCR_PrefabSpawnPoint> m_aPrefabSpawnPoints;
30 void Spawn(array<SCR_PrefabSpawnPoint> prefabSpawnPoints)
35 if (prefabSpawnPoints ==
null)
37 Debug.Error(
"Can't spawn items of type: " +
m_eType.ToString() +
" because no spawn points are available.");
41 m_aPrefabSpawnPoints = prefabSpawnPoints;
43 int numberOfPrefabsToSpawn = m_aPrefabSpawnPoints.Count() * m_iTotalPrefabs * 0.01;
44 SpawnPrefabsCategories(numberOfPrefabsToSpawn, m_aPrefabsCategories);
51 void SpawnPrefabsCategories(
int numberOfPrefabsToSpawn, array<ref SCR_BasePrefabCategory> prefabsCategories)
53 int totalRatio = GetTotalRatio(prefabsCategories);
60 prefabCategory.Spawn(numberOfPrefabsToSpawn * prefabCategory.GetRatio() / totalRatio,
this);
68 void SpawnPrefabCategory(
int totalprefabs, ResourceName prefab)
70 if (totalprefabs <= 0 || m_aPrefabSpawnPoints ==
null)
73 for (
int i = 0; i < totalprefabs; i++)
76 m_aPrefabSpawnPoints.RemoveItem(prefabSpawnPoint);
79 prefabSpawnPoint.GetWorldTransform(mat);
81 if (prefabSpawnPoint.ShouldSnapToGround())
88 EntitySpawnParams spawnParams =
new EntitySpawnParams();
89 spawnParams.TransformMode = ETransformMode.WORLD;
90 spawnParams.Transform = mat;
92 Resource resource = Resource.Load(prefab);
93 if (resource.IsValid())
94 GetGame().SpawnEntityPrefab(resource,
null, spawnParams);
102 protected int GetTotalRatio(array<ref SCR_BasePrefabCategory> prefabsCategories)
107 totalWeight += prefabCategory.GetRatio();