Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PrefabStructureFillingPlugin_Car.c
Go to the documentation of this file.
1class SCR_PrefabStructureFillingPlugin_Car : SCR_PrefabStructureFillingPlugin_TypeBase
2{
3 [Attribute(defvalue: "0", desc: "Number Of Lights Wanted", params: "0 inf")]
4 int m_iDesiredTotalNumberOfLights;
5
6 //------------------------------------------------------------------------------------------------
7 override bool Process(notnull IEntitySource prefab)
8 {
9 if (!super.Process(prefab))
10 return false;
11
12 if (!CreateLights(prefab, m_iDesiredTotalNumberOfLights))
13 return false;
14
15 return true;
16 }
17
18 //------------------------------------------------------------------------------------------------
23 protected bool CreateLights(notnull IEntitySource prefab, int desiredTotalNumberOfLights)
24 {
25 if (desiredTotalNumberOfLights < 1)
26 {
27 Print("No lights requested", LogLevel.NORMAL);
28 return true;
29 }
30
31 int componentIndex = SCR_BaseContainerTools.FindComponentIndex(prefab, BaseLightManagerComponent);
32 if (componentIndex < 0)
33 {
34 Print("No " + BaseLightManagerComponent + " on Prefab", LogLevel.WARNING);
35 return false;
36 }
37
38 IEntityComponentSource componentSource = prefab.GetComponent(componentIndex);
39 if (!componentSource)
40 {
41 Print("[SCR_PrefabStructureFillingPlugin_Car.CreateLights] wat (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.FATAL);
42 return false;
43 }
44
45 BaseContainerList lightSlots = componentSource.GetObjectArray("LightSlots");
46 if (!lightSlots)
47 {
48 Print("[SCR_PrefabStructureFillingPlugin_Car.CreateLights] wat (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.FATAL);
49 return false;
50 }
51
52 int lightSlotsCount = lightSlots.Count();
53 if (desiredTotalNumberOfLights <= lightSlotsCount)
54 {
55 PrintFormat("Requested %1 lights, %2 existing", desiredTotalNumberOfLights, lightSlotsCount, level: LogLevel.NORMAL);
56 return true;
57 }
58
59 array<ref ContainerIdPathEntry> path = { new ContainerIdPathEntry("components", componentIndex) };
60 bool isEditing = m_WorldEditorAPI.IsDoingEditAction();
61 if (!isEditing)
62 m_WorldEditorAPI.BeginEntityAction();
63
64 for (int i = lightSlotsCount; i < desiredTotalNumberOfLights; ++i)
65 {
66 if (!m_WorldEditorAPI.CreateObjectArrayVariableMember(prefab, path, "LightSlots", "SCR_LightSlot", i))
67 {
68 Print("Error creating SCR_LightSlot", LogLevel.ERROR);
69 return false;
70 }
71 }
72
73 if (!isEditing)
74 m_WorldEditorAPI.EndEntityAction();
75
76 Print("Successfully created " + (desiredTotalNumberOfLights - lightSlotsCount) + " lights", LogLevel.NORMAL);
77 return true;
78 }
79}
string path
void ContainerIdPathEntry(string propertyName, int index=-1)
Definition worldEditor.c:30
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
bool CreateLights(notnull IEntitySource prefab, int desiredTotalNumberOfLights)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute