2 class SCR_WallGroupContainer
6 float m_fMiddleObjectLength;
7 float m_fSmallestWall =
float.MAX;
10 protected ref array<float> m_aLengths = {};
12 protected ref array<ref SCR_WallGroup> m_aWallGroups = {};
13 protected WallGeneratorEntity m_WallGenerator;
18 return m_aWallGroups.IsEmpty();
22 SCR_WallPair GetRandomWall(
float biggestSmallerThan = -1)
24 for (
int i = m_aLengths.Count() - 1; i >= 0; i--)
26 if (m_aLengths[i] < biggestSmallerThan)
27 return m_aWallGroups[i].GetRandomWall();
35 void PrepareWallGroups(notnull array<ref WallLengthGroup> groups,
bool forward,
string middleObj, WorldEditorAPI api)
37 m_aWallGroups.Clear();
39 array<ref SCR_WallGroup> wallGroupsTmp = {};
45 if (!middleObj.IsEmpty())
46 m_fMiddleObjectLength = WallGeneratorEntity.MeasureEntity(middleObj, forwardAxis, api);
59 wallPair.m_sWallAsset = pair.m_sWallAsset;
60 wallPair.m_fPostPadding = pair.m_fPostPadding;
61 wallPair.m_fPrePadding = pair.m_fPrePadding;
62 wallGroup.m_aWeights.Insert(pair.m_fWeight);
64 wallLength = WallGeneratorEntity.MeasureEntity(wallPair.m_sWallAsset, forwardAxis, api);
66 wallPair.m_fWallLength = wallLength;
68 if (wallLength > wallGroup.m_fWallLength)
69 wallGroup.m_fWallLength = wallLength;
71 if (!wallPair.m_sWallAsset.IsEmpty())
72 wallGroup.m_aWallPairs.Insert(wallPair);
75 if (!wallGroup.m_aWallPairs.IsEmpty())
77 wallGroupsTmp.Insert(wallGroup);
86 while (!wallGroupsTmp.IsEmpty())
88 smallestSize =
float.MAX;
92 if (g.m_fWallLength < smallestSize)
94 smallestSize = g.m_fWallLength;
95 if (smallestSize < m_fSmallestWall)
96 m_fSmallestWall = smallestSize;
102 m_aWallGroups.Insert(wallGroupsTmp[smallestIndex]);
103 m_aLengths.Insert(wallGroupsTmp[smallestIndex].m_fWallLength);
104 wallGroupsTmp.Remove(smallestIndex);
107 if (m_WallGenerator && m_WallGenerator.m_bDebug)
111 Print(group.m_fWallLength, LogLevel.NORMAL);
114 Print(pair.m_sWallAsset, LogLevel.NORMAL);
115 Print(pair.m_fWallWeight, LogLevel.NORMAL);
123 void SCR_WallGroupContainer(WorldEditorAPI api, array<ref WallLengthGroup> items,
bool forward,
string middleObj, WallGeneratorEntity ent)
125 m_WallGenerator = ent;
126 PrepareWallGroups(items, forward, middleObj, api);